Search
SailfishOS Open Build Service
>
Projects
>
home:dcthang:branches:nemo:devel:hw:ti:omap3:n900
>
kernel-adaptation-n900
> linux-2.6.37-upgrade-sgx-driver.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File linux-2.6.37-upgrade-sgx-driver.patch of Package kernel-adaptation-n900
From 1f56b5d42ea7d163f72185c49515fc7f7bad0a2b Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 03:00:35 +0200 Subject: [PATCH 01/95] gpu: pvr: remove build time ABI dependency on the EDM trace option So that we can build user / kernel space independently on the EDM tracing option being configured or not. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_sgx_bridge.c | 37 ++++++++++++++------------------- drivers/gpu/pvr/sgx_options.h | 4 --- drivers/gpu/pvr/sgxinfo.h | 4 --- drivers/gpu/pvr/sgxinfokm.h | 3 +- drivers/gpu/pvr/sgxinit.c | 5 +--- 5 files changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index b2dae37..dabcaa4 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -582,6 +582,7 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, IMG_BOOL bLookupFailed = IMG_FALSE; IMG_BOOL bReleaseFailed = IMG_FALSE; void *hDummy; + void **edm_mi; u32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DEVINITPART2); @@ -640,13 +641,12 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO); bLookupFailed |= (IMG_BOOL) (eError != PVRSRV_OK); -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, - psSGXDevInitPart2IN->sInitInfo. - hKernelEDMStatusBufferMemInfo, - PVRSRV_HANDLE_TYPE_MEM_INFO); - bLookupFailed |= (IMG_BOOL) (eError != PVRSRV_OK); -#endif + edm_mi = &psSGXDevInitPart2IN->sInitInfo.hKernelEDMStatusBufferMemInfo; + if (*edm_mi) { + eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDummy, + *edm_mi, PVRSRV_HANDLE_TYPE_MEM_INFO); + bLookupFailed |= eError != PVRSRV_OK; + } for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { void *hHandle = @@ -724,15 +724,12 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, PVRSRV_HANDLE_TYPE_MEM_INFO); bReleaseFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, - &psSGXDevInitPart2IN->sInitInfo. - hKernelEDMStatusBufferMemInfo, - psSGXDevInitPart2IN->sInitInfo. - hKernelEDMStatusBufferMemInfo, + if (*edm_mi) { + eError = PVRSRVLookupAndReleaseHandle(psPerProc->psHandleBase, + edm_mi, *edm_mi, PVRSRV_HANDLE_TYPE_MEM_INFO); - bReleaseFailed |= (IMG_BOOL)(eError != PVRSRV_OK); -#endif + bReleaseFailed |= eError != PVRSRV_OK; + } for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { void **phHandle = @@ -791,12 +788,10 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, hKernelHWPerfCBMemInfo); bDissociateFailed |= (IMG_BOOL) (eError != PVRSRV_OK); -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) - eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, - psSGXDevInitPart2IN->sInitInfo. - hKernelEDMStatusBufferMemInfo); - bDissociateFailed |= (IMG_BOOL) (eError != PVRSRV_OK); -#endif + if (*edm_mi) { + eError = PVRSRVDissociateDeviceMemKM(hDevCookieInt, *edm_mi); + bDissociateFailed |= eError != PVRSRV_OK; + } for (i = 0; i < SGX_MAX_INIT_MEM_HANDLES; i++) { void *hHandle = diff --git a/drivers/gpu/pvr/sgx_options.h b/drivers/gpu/pvr/sgx_options.h index 67402fe..858c1e9 100644 --- a/drivers/gpu/pvr/sgx_options.h +++ b/drivers/gpu/pvr/sgx_options.h @@ -38,12 +38,8 @@ #define OPTIONS_BIT1 0x0 #endif -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined(INTERNAL_TEST) #define PVRSRV_USSE_EDM_STATUS_DEBUG_SET_OFFSET OPTIONS_BIT2 #define OPTIONS_BIT2 (0x1 << 2) -#else -#define OPTIONS_BIT2 0x0 -#endif #define SUPPORT_HW_RECOVERY_SET_OFFSET OPTIONS_BIT3 #define OPTIONS_BIT3 (0x1 << 3) diff --git a/drivers/gpu/pvr/sgxinfo.h b/drivers/gpu/pvr/sgxinfo.h index 11f599f..955261a 100644 --- a/drivers/gpu/pvr/sgxinfo.h +++ b/drivers/gpu/pvr/sgxinfo.h @@ -56,9 +56,7 @@ struct SGX_BRIDGE_INIT_INFO { u32 ui32HostKickAddress; u32 ui32GetMiscInfoAddress; void *hKernelHWPerfCBMemInfo; -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) void *hKernelEDMStatusBufferMemInfo; -#endif u32 ui32EDMTaskReg0; u32 ui32EDMTaskReg1; @@ -198,10 +196,8 @@ struct SGXMKIF_HOST_CTL { u32 ui32HWPerfFlags; -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) /* !< See SGXMK_STATUS_BUFFER */ struct IMG_DEV_VIRTADDR sEDMStatusBuffer; -#endif /*< to count time wraps in the Timer task */ u32 ui32TimeWraps; diff --git a/drivers/gpu/pvr/sgxinfokm.h b/drivers/gpu/pvr/sgxinfokm.h index 6db6bb3..887ebe6 100644 --- a/drivers/gpu/pvr/sgxinfokm.h +++ b/drivers/gpu/pvr/sgxinfokm.h @@ -99,10 +99,9 @@ struct PVRSRV_SGXDEV_INFO { struct PVRSRV_SGXDEV_DIFF_INFO sDiffInfo; u32 ui32HWGroupRequested; u32 ui32HWReset; -#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + /*!< Meminfo for EDM status buffer */ struct PVRSRV_KERNEL_MEM_INFO *psKernelEDMStatusBufferMemInfo; -#endif u32 ui32ClientRefCount; diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index be7fa0f..ace786c 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -124,11 +124,8 @@ static enum PVRSRV_ERROR InitDevInfo(struct PVRSRV_PER_PROCESS_DATA *psPerProc, psDevInfo->psKernelHWPerfCBMemInfo = (struct PVRSRV_KERNEL_MEM_INFO *)psInitInfo->hKernelHWPerfCBMemInfo; -#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG psDevInfo->psKernelEDMStatusBufferMemInfo = - (struct PVRSRV_KERNEL_MEM_INFO *)psInitInfo-> - hKernelEDMStatusBufferMemInfo; -#endif + psInitInfo->hKernelEDMStatusBufferMemInfo; eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct PVRSRV_SGX_CCB_INFO), -- 1.7.5.4 From 340898a61bd0f89390f64917f8df20310edf8247 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 03:04:33 +0200 Subject: [PATCH 02/95] gpu: pvr: make the IOCTL i/f compatible for old ABI users The previous patch breaks the IOCTL i/f for current user space code. This change will notice such calls based on the IOCTL parameter size and fix up the param struct accordingly. This patch can be reverted once applications are converted to use the new ABI. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 2 +- drivers/gpu/pvr/bridged_sgx_bridge.c | 39 ++++++++++++++++++++++++++++++++- drivers/gpu/pvr/bridged_sgx_bridge.h | 6 ++-- drivers/gpu/pvr/perproc.h | 5 ++++ drivers/gpu/pvr/sgx_bridge_km.h | 3 +- drivers/gpu/pvr/sgxinit.c | 10 ++++++-- 6 files changed, 55 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 7409816..f95335f 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -3225,7 +3225,7 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = SGXGetInfoForSrvinitBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_SGX_DEVINITPART2: - err = SGXDevInitPart2BW(cmd, in, out, per_proc); + err = SGXDevInitPart2BW(cmd, in, out, in_size, per_proc); break; case PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC: diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index dabcaa4..37c2b89 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -519,7 +519,8 @@ int SGXReadDiffCountersBW(u32 ui32BridgeID, psSGXReadDiffCountersIN->ui32CountersReg, &psSGXReadDiffCountersOUT->ui32Time, &psSGXReadDiffCountersOUT->bActive, - &psSGXReadDiffCountersOUT->sDiffs); + &psSGXReadDiffCountersOUT->sDiffs, + psPerProc->edm_compat_abi); return 0; } @@ -571,9 +572,38 @@ int SGXReadHWPerfCBBW(u32 ui32BridgeID, return 0; } +static int fixup_compat_format(struct PVRSRV_PER_PROCESS_DATA *psPerProc, + struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *info, + size_t size) +{ + void **edm_buf; + + if (size == sizeof(*info)) { + psPerProc->edm_compat_abi = 0; + return 0; + } + + edm_buf = &info->sInitInfo.hKernelEDMStatusBufferMemInfo; + + if (size + sizeof(*edm_buf) != sizeof(*info)) + return -EFAULT; + + /* + * remainder of the compat struct size after the + * hKernelEDMStatusBufferMemInfo field + */ + size -= offsetof(struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2, + sInitInfo.hKernelEDMStatusBufferMemInfo); + memmove(edm_buf + 1, edm_buf, size); + *edm_buf = NULL; + psPerProc->edm_compat_abi = 1; + + return 0; +} + int SGXDevInitPart2BW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, + struct PVRSRV_BRIDGE_RETURN *psRetOUT, size_t in_size, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { void *hDevCookieInt; @@ -592,6 +622,11 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, return 0; } + if (fixup_compat_format(psPerProc, psSGXDevInitPart2IN, in_size) < 0) { + psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; + return 0; + } + psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, psSGXDevInitPart2IN->hDevCookie, diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.h b/drivers/gpu/pvr/bridged_sgx_bridge.h index c2a8c47..4806cb4 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.h +++ b/drivers/gpu/pvr/bridged_sgx_bridge.h @@ -76,9 +76,9 @@ int SGXReadHWPerfCBBW(u32 ui32BridgeID, struct PVRSRV_PER_PROCESS_DATA *psPerProc); int SGXDevInitPart2BW(u32 ui32BridgeID, - struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, - struct PVRSRV_PER_PROCESS_DATA *psPerProc); + struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, + struct PVRSRV_BRIDGE_RETURN *psRetOUT, size_t in_size, + struct PVRSRV_PER_PROCESS_DATA *psPerProc); int SGXRegisterHWRenderContextBW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_SGX_REGISTER_HW_RENDER_CONTEXT diff --git a/drivers/gpu/pvr/perproc.h b/drivers/gpu/pvr/perproc.h index a89b0e4..11b132a 100644 --- a/drivers/gpu/pvr/perproc.h +++ b/drivers/gpu/pvr/perproc.h @@ -45,6 +45,11 @@ struct PVRSRV_PER_PROCESS_DATA { IMG_BOOL bInitProcess; void *hOsPrivateData; + + int edm_compat_abi; /* + * set if old ABI is used to pass the + * EDM trace buffer address. + */ }; struct PVRSRV_PER_PROCESS_DATA *PVRSRVPerProcessData(u32 ui32PID); diff --git a/drivers/gpu/pvr/sgx_bridge_km.h b/drivers/gpu/pvr/sgx_bridge_km.h index 3389b0c..2990521 100644 --- a/drivers/gpu/pvr/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx_bridge_km.h @@ -61,7 +61,8 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, u32 *pui32Old, IMG_BOOL bNew, u32 ui32New, u32 ui32NewReset, u32 ui32CountersReg, u32 *pui32Time, IMG_BOOL *pbActive, - struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs); + struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs, + int edm_compat_abi); enum PVRSRV_ERROR SGXReadHWPerfCBKM(void *hDevHandle, u32 ui32ArraySize, struct PVRSRV_SGX_HWPERF_CB_ENTRY *psHWPerfCBData, u32 *pui32DataCount, u32 *pui32ClockSpeed, diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index ace786c..4fa29c6 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -1515,7 +1515,8 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, u32 *pui32Old, IMG_BOOL bNew, u32 ui32New, u32 ui32NewReset, u32 ui32CountersReg, u32 *pui32Time, IMG_BOOL *pbActive, - struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs) + struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs, + int edm_compat_abi) { struct SYS_DATA *psSysData; struct PVRSRV_POWER_DEV *psPowerDevice; @@ -1555,6 +1556,7 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, sNew.ui32Time[0] = OSClockus(); *pui32Time = sNew.ui32Time[0]; if (sNew.ui32Time[0] != psPrev->ui32Time[0] && bPowered) { + u32 __iomem *time_wraps; *pui32Old = OSReadHWReg(psDevInfo->pvRegsBaseKM, ui32Reg); @@ -1581,8 +1583,10 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, sNew.ui32Marker[0] = psDevInfo->ui32KickTACounter; sNew.ui32Marker[1] = psDevInfo->ui32KickTARenderCounter; - sNew.ui32Time[1] = readl( - &psDevInfo->psSGXHostCtl->ui32TimeWraps); + time_wraps = &psDevInfo->psSGXHostCtl->ui32TimeWraps; + if (edm_compat_abi) + time_wraps -= 1; + sNew.ui32Time[1] = readl(time_wraps); for (i = 0; i < PVRSRV_SGX_DIFF_NUM_COUNTERS; ++i) { psDiffs->aui32Counters[i] = -- 1.7.5.4 From 3fe128d418d7e57664a3672518f6a310a30b42d4 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 04:58:43 +0200 Subject: [PATCH 03/95] gpu: pvr: fix Kconfig description for EDM tracing We don't have a dependency on user space configuration any more, so fix the description accordingly. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Kconfig | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig index 949911c..96dc456 100644 --- a/drivers/gpu/pvr/Kconfig +++ b/drivers/gpu/pvr/Kconfig @@ -34,9 +34,9 @@ config PVR_EDM_DEBUG bool "Enable EDM trace" default n help - EDM trace helps to track down some HW recovery events. You _must_ - also enabled EDM (PVRSRV_USSE_EDM_STATUS_DEBUG) in the userland - libraries otherwise the drivers won't start + This will print the micro kernel (EDM) tracing buffer in case + of a HW recovery event. You also need a micro kernel that was + configured to generate this trace. config PVR_NO_HARDWARE bool -- 1.7.5.4 From 2d51abb3e52351b88757ef9eaed1b5cae58a8040 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 03:08:12 +0200 Subject: [PATCH 04/95] gpu: pvr: remove runtime dependency on the EDM trace option So that we can use the same kernel driver with user space having the option either configured or not. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinit.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 4fa29c6..dd05eb9 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -1199,7 +1199,8 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE *psDeviceNode) struct PVRSRV_KERNEL_MEM_INFO *psMemInfo; enum PVRSRV_ERROR eError; #if !defined(NO_HARDWARE) - u32 ui32BuildOptions, ui32BuildOptionsMismatch; + u32 opts; + u32 opt_mismatch; struct PVRSRV_SGX_MISCINFO_FEATURES *psSGXFeatures; #endif @@ -1239,24 +1240,22 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE *psDeviceNode) PVRVERSION_BUILD, psSGXFeatures->ui32DDKBuild); } - ui32BuildOptions = psSGXFeatures->ui32BuildOptions; - if (ui32BuildOptions != (SGX_BUILD_OPTIONS)) { - ui32BuildOptionsMismatch = - ui32BuildOptions ^ (SGX_BUILD_OPTIONS); - if (((SGX_BUILD_OPTIONS) & ui32BuildOptionsMismatch) != 0) + opts = psSGXFeatures->ui32BuildOptions; + opt_mismatch = opts ^ SGX_BUILD_OPTIONS; + /* we support the ABIs both with and without EDM tracing option */ + opt_mismatch &= ~PVRSRV_USSE_EDM_STATUS_DEBUG_SET_OFFSET; + if (opt_mismatch) { + if (SGX_BUILD_OPTIONS & opt_mismatch) PVR_DPF(PVR_DBG_ERROR, "SGXInit: " "Mismatch in driver and microkernel build " "options; extra options present in driver: " - "(0x%lx)", - (SGX_BUILD_OPTIONS) & - ui32BuildOptionsMismatch); + "(0x%lx)", SGX_BUILD_OPTIONS & opt_mismatch); - if ((ui32BuildOptions & ui32BuildOptionsMismatch) != 0) + if (opts & opt_mismatch) PVR_DPF(PVR_DBG_ERROR, "SGXInit: " "Mismatch in driver and microkernel build " "options; extra options present in " - "microkernel: (0x%lx)", - ui32BuildOptions & ui32BuildOptionsMismatch); + "microkernel: (0x%lx)", opts & opt_mismatch); eError = PVRSRV_ERROR_BUILD_MISMATCH; goto exit; } else { -- 1.7.5.4 From 25a47235c912ab543ca0adb1b465b82152f5731d Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 03:42:39 +0200 Subject: [PATCH 05/95] gpu: pvr: move debugfs entries under a new pvr dir Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debug.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debug.c b/drivers/gpu/pvr/pvr_debug.c index 0ac1322..e02d5dd 100644 --- a/drivers/gpu/pvr/pvr_debug.c +++ b/drivers/gpu/pvr/pvr_debug.c @@ -253,7 +253,7 @@ int PVRDebugProcGetLevel(char *page, char **start, off_t off, int count, #ifdef CONFIG_DEBUG_FS -static struct dentry *debugfs_dentry; +static struct dentry *debugfs_dir; static u32 pvr_reset; static struct PVRSRV_DEVICE_NODE *get_sgx_node(void) @@ -323,15 +323,22 @@ DEFINE_SIMPLE_ATTRIBUTE(pvr_dbg_fops, NULL, pvr_dbg_set, "%llu\n"); static int pvr_init_debugfs(void) { - debugfs_dentry = debugfs_create_file("reset_sgx", S_IWUGO, NULL, - &pvr_reset, &pvr_dbg_fops); + debugfs_dir = debugfs_create_dir("pvr", NULL); + if (!debugfs_dir) + return -ENODEV; + + if (!debugfs_create_file("reset_sgx", S_IWUGO, debugfs_dir, &pvr_reset, + &pvr_dbg_fops)) { + debugfs_remove(debugfs_dir); + return -ENODEV; + } - return debugfs_dentry ? 0 : -ENODEV; + return 0; } static void pvr_cleanup_debugfs(void) { - debugfs_remove(debugfs_dentry); + debugfs_remove_recursive(debugfs_dir); } #else /* !CONFIG_DEBUG_FS */ -- 1.7.5.4 From 6a627a09bf1704e35d5fef70856d1512bb6ab898 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Mon, 13 Dec 2010 19:40:00 +0200 Subject: [PATCH 06/95] gpu: pvr: make debugfs available in release build too Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 1 + drivers/gpu/pvr/pvr_debug.c | 6 ++++++ drivers/gpu/pvr/pvr_debug.h | 15 +++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 48e37d0..4b20e00 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -14,6 +14,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o pdump.o proc.o \ pvr_events.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o +pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o pvrsrvkm-objs += $(pvrsrvkm-objs-y) $(pvrsrvkm-objs-m) diff --git a/drivers/gpu/pvr/pvr_debug.c b/drivers/gpu/pvr/pvr_debug.c index e02d5dd..0f49175 100644 --- a/drivers/gpu/pvr/pvr_debug.c +++ b/drivers/gpu/pvr/pvr_debug.c @@ -42,6 +42,8 @@ #include "sgxutils.h" #include "pvr_bridge_km.h" +#ifdef CONFIG_PVR_DEBUG + u32 gPVRDebugLevel = DBGPRIV_WARNING; #define PVR_MAX_MSG_LEN PVR_MAX_DEBUG_MESSAGE_LEN @@ -251,6 +253,8 @@ int PVRDebugProcGetLevel(char *page, char **start, off_t off, int count, return 0; } +#endif + #ifdef CONFIG_DEBUG_FS static struct dentry *debugfs_dir; @@ -354,7 +358,9 @@ static void pvr_cleanup_debugfs(void) { } void pvr_dbg_init(void) { +#if defined(CONFIG_PVR_DEBUG) || defined(TIMING) mutex_init(&gsDebugMutexNonIRQ); +#endif pvr_init_debugfs(); } diff --git a/drivers/gpu/pvr/pvr_debug.h b/drivers/gpu/pvr/pvr_debug.h index c8c7e75..4bad9c4 100644 --- a/drivers/gpu/pvr/pvr_debug.h +++ b/drivers/gpu/pvr/pvr_debug.h @@ -77,9 +77,6 @@ int PVRDebugProcGetLevel(char *page, char **start, off_t off, int count, int *eof, void *data); void PVRDebugSetLevel(u32 uDebugLevel); -void pvr_dbg_init(void); -void pvr_dbg_cleanup(void); - #define PVR_DBG_BREAK #else @@ -101,10 +98,20 @@ void PVRSRVTrace(const char *pszFormat, ...); #define PVR_TRACE(fmt, ...) do { } while (0) #define PVR_DBG_BREAK do { } while (0) +#endif /* TIMING */ + +#endif /* CONFIG_PVR_DEBUG */ + +#if defined(CONFIG_PVR_DEBUG) || defined(TIMING) || defined(CONFIG_DEBUG_FS) + +void pvr_dbg_init(void); +void pvr_dbg_cleanup(void); + +#else + static inline void pvr_dbg_init(void) {}; static inline void pvr_dbg_cleanup(void) {}; #endif -#endif #endif -- 1.7.5.4 From 628b56c6cd53272ad76e55b7a4d2ad6838cc7d4e Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 02:48:37 +0200 Subject: [PATCH 07/95] gpu: pvr: add snprint_edm_trace Needed by an upcoming patch adding a debugfs entry to dump the trace. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinfokm.h | 16 ++++++++++ drivers/gpu/pvr/sgxinit.c | 70 ++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/pvr/sgxinfokm.h b/drivers/gpu/pvr/sgxinfokm.h index 887ebe6..83228d4 100644 --- a/drivers/gpu/pvr/sgxinfokm.h +++ b/drivers/gpu/pvr/sgxinfokm.h @@ -56,6 +56,9 @@ #define PVRSRV_USSE_MISCINFO_READY 0x1UL +#define SGXMK_TRACE_BUFFER_SIZE 512 +#define SGXMK_TRACE_BUF_STR_LEN 80 + struct PVRSRV_SGX_CCB_INFO; struct PVRSRV_SGXDEV_INFO { @@ -249,6 +252,19 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE void SysGetSGXTimingInformation(struct SGX_TIMING_INFORMATION *psSGXTimingInfo); +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined(CONFIG_DEBUG_FS) +size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *buf, + size_t buf_size); +#else +static inline size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, + char *buf, size_t buf_size) +{ + return 0; +} +#endif + + + #if defined(NO_HARDWARE) static inline void NoHardwareGenerateEvent(struct PVRSRV_SGXDEV_INFO *psDevInfo, u32 ui32StatusRegister, diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index dd05eb9..0184eea 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -586,38 +586,68 @@ static enum PVRSRV_ERROR DevDeInitSGX(void *pvDeviceNode) return PVRSRV_OK; } -#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG - -#define SGXMK_TRACE_BUFFER_SIZE 512 +#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined(CONFIG_DEBUG_FS) -static void dump_edm(struct PVRSRV_SGXDEV_INFO *psDevInfo) +static size_t __print_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, + size_t dst_len) { - u32 *trace_buffer = - psDevInfo->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; - u32 last_code, write_offset; + u32 *buf_start; + u32 *buf_end; + u32 *buf; + size_t p = 0; + size_t wr_ofs; int i; - last_code = *trace_buffer; - trace_buffer++; - write_offset = *trace_buffer; +#define _PR(fmt, ...) do { \ + if (dst) \ + p += snprintf(dst + p, dst_len - p, fmt, ## __VA_ARGS__); \ + else \ + pr_err(fmt, ## __VA_ARGS__); \ +} while (0) - pr_err("Last SGX microkernel status code: 0x%x\n", last_code); + if (!sdev->psKernelEDMStatusBufferMemInfo) + return 0; - trace_buffer++; - /* Dump the status values */ + buf = sdev->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; + + _PR("Last SGX microkernel status code: 0x%x\n", *buf); + buf++; + wr_ofs = *buf; + buf++; + + buf_start = buf; + buf_end = buf + SGXMK_TRACE_BUFFER_SIZE * 4; + buf += wr_ofs * 4; + + /* Dump the status values */ for (i = 0; i < SGXMK_TRACE_BUFFER_SIZE; i++) { - u32 *buf; - buf = trace_buffer + (((write_offset + i) % - SGXMK_TRACE_BUFFER_SIZE) * 4); - pr_err("(MKT%u) %8.8X %8.8X %8.8X %8.8X\n", i, - buf[2], buf[3], buf[1], buf[0]); + _PR("%3d %08X %08X %08X %08X\n", + i, buf[2], buf[3], buf[1], buf[0]); + buf += 4; + if (buf >= buf_end) + buf = buf_start; } + + return p > dst_len ? dst_len : p; +#undef _PR } -#else -static void dump_edm(struct PVRSRV_SGXDEV_INFO *psDevInfo) {} + +size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *buf, + size_t buf_size) +{ + return __print_edm_trace(sdev, buf, buf_size); +} + #endif +static void dump_edm(struct PVRSRV_SGXDEV_INFO *sdev) +{ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + __print_edm_trace(sdev, NULL, 0); +#endif +} + static void dump_process_info(struct PVRSRV_DEVICE_NODE *dev) { struct PVRSRV_SGXDEV_INFO *dev_info = dev->pvDevice; -- 1.7.5.4 From 3da9f911de4f3b642c6bc0d8b8855bb1bba8c72c Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 14 Dec 2010 02:54:24 +0200 Subject: [PATCH 08/95] gpu: pvr: add debugfs entry to read the EDM trace Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debug.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debug.c b/drivers/gpu/pvr/pvr_debug.c index 0f49175..1c89499 100644 --- a/drivers/gpu/pvr/pvr_debug.c +++ b/drivers/gpu/pvr/pvr_debug.c @@ -32,6 +32,8 @@ #include <linux/spinlock.h> #include <linux/tty.h> #include <linux/debugfs.h> +#include <linux/vmalloc.h> + #include <stdarg.h> #include "img_types.h" #include "servicesext.h" @@ -325,6 +327,54 @@ static int pvr_dbg_set(void *data, u64 val) DEFINE_SIMPLE_ATTRIBUTE(pvr_dbg_fops, NULL, pvr_dbg_set, "%llu\n"); +struct edm_buf_info { + size_t len; + char data[1]; +}; + +static int pvr_dbg_edm_open(struct inode *inode, struct file *file) +{ + struct PVRSRV_DEVICE_NODE *node; + struct PVRSRV_SGXDEV_INFO *sgx_info; + struct edm_buf_info *bi; + size_t size; + + /* Take a snapshot of the EDM trace buffer */ + size = SGXMK_TRACE_BUFFER_SIZE * SGXMK_TRACE_BUF_STR_LEN; + bi = vmalloc(sizeof(*bi) + size); + if (!bi) + return -ENOMEM; + + node = get_sgx_node(); + sgx_info = node->pvDevice; + bi->len = snprint_edm_trace(sgx_info, bi->data, size); + file->private_data = bi; + + return 0; +} + +static int pvr_dbg_edm_release(struct inode *inode, struct file *file) +{ + vfree(file->private_data); + + return 0; +} + +static ssize_t pvr_dbg_edm_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct edm_buf_info *bi = file->private_data; + + return simple_read_from_buffer(buffer, count, ppos, bi->data, bi->len); +} + +static const struct file_operations pvr_dbg_edm_fops = { + .owner = THIS_MODULE, + .open = pvr_dbg_edm_open, + .read = pvr_dbg_edm_read, + .release = pvr_dbg_edm_release, +}; + static int pvr_init_debugfs(void) { debugfs_dir = debugfs_create_dir("pvr", NULL); @@ -337,6 +387,12 @@ static int pvr_init_debugfs(void) return -ENODEV; } + if (!debugfs_create_file("edm_trace", S_IRUGO, debugfs_dir, NULL, + &pvr_dbg_edm_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + return 0; } -- 1.7.5.4 From 0f1e9ba80cdf06770a7162a1a0a8af62732c3a9a Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Mon, 13 Dec 2010 19:40:38 +0200 Subject: [PATCH 09/95] gpu: pvr: print some init failure messages in release mode too Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinit.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 0184eea..7f591a6 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -1247,8 +1247,7 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE *psDeviceNode) eError = SGXGetBuildInfoKM(psDevInfo, psDeviceNode); if (eError != PVRSRV_OK) { - PVR_DPF(PVR_DBG_ERROR, "SGXDevInitCompatCheck: " - "Unable to validate device DDK version"); + pr_err("pvr: unable to validate device DDK version\n"); goto exit; } psSGXFeatures = @@ -1258,9 +1257,8 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE *psDeviceNode) ((PVRVERSION_MAJ << 16) | (PVRVERSION_MIN << 8) | PVRVERSION_BRANCH)) || (psSGXFeatures->ui32DDKBuild != PVRVERSION_BUILD)) { - PVR_DPF(PVR_DBG_ERROR, "SGXDevInitCompatCheck: " - "Incompatible driver DDK revision (%ld)" - "/device DDK revision (%ld).", + pr_err("pvr: incompatible driver DDK revision (%d)" + "/device DDK revision (%d).\n", PVRVERSION_BUILD, psSGXFeatures->ui32DDKBuild); eError = PVRSRV_ERROR_DDK_VERSION_MISMATCH; goto exit; @@ -1276,16 +1274,14 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE *psDeviceNode) opt_mismatch &= ~PVRSRV_USSE_EDM_STATUS_DEBUG_SET_OFFSET; if (opt_mismatch) { if (SGX_BUILD_OPTIONS & opt_mismatch) - PVR_DPF(PVR_DBG_ERROR, "SGXInit: " - "Mismatch in driver and microkernel build " + pr_err("pvr: mismatch in driver and microkernel build " "options; extra options present in driver: " - "(0x%lx)", SGX_BUILD_OPTIONS & opt_mismatch); + "(0x%x)", SGX_BUILD_OPTIONS & opt_mismatch); if (opts & opt_mismatch) - PVR_DPF(PVR_DBG_ERROR, "SGXInit: " - "Mismatch in driver and microkernel build " + pr_err("pvr: Mismatch in driver and microkernel build " "options; extra options present in " - "microkernel: (0x%lx)", opts & opt_mismatch); + "microkernel: (0x%x)", opts & opt_mismatch); eError = PVRSRV_ERROR_BUILD_MISMATCH; goto exit; } else { -- 1.7.5.4 From 92153a85803507282f15a15f2f7bd0071b4bb195 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Thu, 10 Feb 2011 01:43:50 +0200 Subject: [PATCH 10/95] gpu: pvr: remove ABI compatibility hack from SGXInitPart2 IOCTL By now everyone should have a recent enough kernel/user space library, so this isn't needed. This reverts commit 743ccd092b08b1e033c0a95648033afa057887d8. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 2 +- drivers/gpu/pvr/bridged_sgx_bridge.c | 39 +-------------------------------- drivers/gpu/pvr/bridged_sgx_bridge.h | 2 +- drivers/gpu/pvr/perproc.h | 5 ---- drivers/gpu/pvr/sgx_bridge_km.h | 3 +- drivers/gpu/pvr/sgxinit.c | 10 ++------ 6 files changed, 8 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index f95335f..7409816 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -3225,7 +3225,7 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = SGXGetInfoForSrvinitBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_SGX_DEVINITPART2: - err = SGXDevInitPart2BW(cmd, in, out, in_size, per_proc); + err = SGXDevInitPart2BW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC: diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index 37c2b89..dabcaa4 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -519,8 +519,7 @@ int SGXReadDiffCountersBW(u32 ui32BridgeID, psSGXReadDiffCountersIN->ui32CountersReg, &psSGXReadDiffCountersOUT->ui32Time, &psSGXReadDiffCountersOUT->bActive, - &psSGXReadDiffCountersOUT->sDiffs, - psPerProc->edm_compat_abi); + &psSGXReadDiffCountersOUT->sDiffs); return 0; } @@ -572,38 +571,9 @@ int SGXReadHWPerfCBBW(u32 ui32BridgeID, return 0; } -static int fixup_compat_format(struct PVRSRV_PER_PROCESS_DATA *psPerProc, - struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *info, - size_t size) -{ - void **edm_buf; - - if (size == sizeof(*info)) { - psPerProc->edm_compat_abi = 0; - return 0; - } - - edm_buf = &info->sInitInfo.hKernelEDMStatusBufferMemInfo; - - if (size + sizeof(*edm_buf) != sizeof(*info)) - return -EFAULT; - - /* - * remainder of the compat struct size after the - * hKernelEDMStatusBufferMemInfo field - */ - size -= offsetof(struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2, - sInitInfo.hKernelEDMStatusBufferMemInfo); - memmove(edm_buf + 1, edm_buf, size); - *edm_buf = NULL; - psPerProc->edm_compat_abi = 1; - - return 0; -} - int SGXDevInitPart2BW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, size_t in_size, + struct PVRSRV_BRIDGE_RETURN *psRetOUT, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { void *hDevCookieInt; @@ -622,11 +592,6 @@ int SGXDevInitPart2BW(u32 ui32BridgeID, return 0; } - if (fixup_compat_format(psPerProc, psSGXDevInitPart2IN, in_size) < 0) { - psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; - return 0; - } - psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, psSGXDevInitPart2IN->hDevCookie, diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.h b/drivers/gpu/pvr/bridged_sgx_bridge.h index 4806cb4..91e5b67 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.h +++ b/drivers/gpu/pvr/bridged_sgx_bridge.h @@ -77,7 +77,7 @@ int SGXReadHWPerfCBBW(u32 ui32BridgeID, int SGXDevInitPart2BW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_SGXDEVINITPART2 *psSGXDevInitPart2IN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, size_t in_size, + struct PVRSRV_BRIDGE_RETURN *psRetOUT, struct PVRSRV_PER_PROCESS_DATA *psPerProc); int SGXRegisterHWRenderContextBW(u32 ui32BridgeID, diff --git a/drivers/gpu/pvr/perproc.h b/drivers/gpu/pvr/perproc.h index 11b132a..a89b0e4 100644 --- a/drivers/gpu/pvr/perproc.h +++ b/drivers/gpu/pvr/perproc.h @@ -45,11 +45,6 @@ struct PVRSRV_PER_PROCESS_DATA { IMG_BOOL bInitProcess; void *hOsPrivateData; - - int edm_compat_abi; /* - * set if old ABI is used to pass the - * EDM trace buffer address. - */ }; struct PVRSRV_PER_PROCESS_DATA *PVRSRVPerProcessData(u32 ui32PID); diff --git a/drivers/gpu/pvr/sgx_bridge_km.h b/drivers/gpu/pvr/sgx_bridge_km.h index 2990521..3389b0c 100644 --- a/drivers/gpu/pvr/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx_bridge_km.h @@ -61,8 +61,7 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, u32 *pui32Old, IMG_BOOL bNew, u32 ui32New, u32 ui32NewReset, u32 ui32CountersReg, u32 *pui32Time, IMG_BOOL *pbActive, - struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs, - int edm_compat_abi); + struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs); enum PVRSRV_ERROR SGXReadHWPerfCBKM(void *hDevHandle, u32 ui32ArraySize, struct PVRSRV_SGX_HWPERF_CB_ENTRY *psHWPerfCBData, u32 *pui32DataCount, u32 *pui32ClockSpeed, diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 7f591a6..0896c32 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -1540,8 +1540,7 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, u32 *pui32Old, IMG_BOOL bNew, u32 ui32New, u32 ui32NewReset, u32 ui32CountersReg, u32 *pui32Time, IMG_BOOL *pbActive, - struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs, - int edm_compat_abi) + struct PVRSRV_SGXDEV_DIFF_INFO *psDiffs) { struct SYS_DATA *psSysData; struct PVRSRV_POWER_DEV *psPowerDevice; @@ -1581,7 +1580,6 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, sNew.ui32Time[0] = OSClockus(); *pui32Time = sNew.ui32Time[0]; if (sNew.ui32Time[0] != psPrev->ui32Time[0] && bPowered) { - u32 __iomem *time_wraps; *pui32Old = OSReadHWReg(psDevInfo->pvRegsBaseKM, ui32Reg); @@ -1608,10 +1606,8 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, sNew.ui32Marker[0] = psDevInfo->ui32KickTACounter; sNew.ui32Marker[1] = psDevInfo->ui32KickTARenderCounter; - time_wraps = &psDevInfo->psSGXHostCtl->ui32TimeWraps; - if (edm_compat_abi) - time_wraps -= 1; - sNew.ui32Time[1] = readl(time_wraps); + sNew.ui32Time[1] = readl( + &psDevInfo->psSGXHostCtl->ui32TimeWraps); for (i = 0; i < PVRSRV_SGX_DIFF_NUM_COUNTERS; ++i) { psDiffs->aui32Counters[i] = -- 1.7.5.4 From aac744b9b626715327475509b79d48f26195fe80 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Thu, 10 Feb 2011 01:50:49 +0200 Subject: [PATCH 11/95] gpu: pvr: remove ABI compatibility hack from SGXKick IOCTL By now everyone should have a recent enough kernel/user space library, so this isn't needed. This will revert the compatibility fixup parts of the following commit: 99baad807: Increase the max number of 3D TA status vals in kick reque Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_sgx_bridge.c | 39 +-------------------------------- drivers/gpu/pvr/sgx_bridge_km.h | 4 +- drivers/gpu/pvr/sgxapi_km.h | 1 - drivers/gpu/pvr/sgxinfo.h | 4 --- drivers/gpu/pvr/sgxkick.c | 22 +++--------------- 5 files changed, 8 insertions(+), 62 deletions(-) diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index dabcaa4..f31adb6 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -129,30 +129,6 @@ int SGXGetInternalDevInfoBW(u32 ui32BridgeID, return 0; } -/* Convert the IOCTL parameter from "old" to "new" format. */ -static int kick_compat_conv(struct PVRSRV_BRIDGE_IN_DOKICK *kick, - size_t in_size) -{ - struct SGX_CCB_KICK *ccb; - size_t diff; - - ccb = &kick->sCCBKick; - - diff = sizeof(ccb->ah3DStatusSyncInfo[0]) * - (SGX_MAX_3D_STATUS_VALS - SGX_MAX_3D_STATUS_VALS_OLD); - if (sizeof(*kick) - in_size != diff) - return -EINVAL; - - /* Trailing size at the end of struct to move. */ - diff = sizeof(*kick) - offsetof(typeof(*kick), - sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS]); - memmove(&kick->sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS], - &kick->sCCBKick.ah3DStatusSyncInfo[SGX_MAX_3D_STATUS_VALS_OLD], - diff); - - return 0; -} - int SGXDoKickBW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_DOKICK *psDoKickIN, struct PVRSRV_BRIDGE_RETURN *psRetOUT, @@ -160,20 +136,10 @@ int SGXDoKickBW(u32 ui32BridgeID, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { void *hDevCookieInt; - int max_3dstat_vals; u32 i; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_SGX_DOKICK); - max_3dstat_vals = SGX_MAX_3D_STATUS_VALS; - if (unlikely(in_size != sizeof(*psDoKickIN))) { - max_3dstat_vals = SGX_MAX_3D_STATUS_VALS_OLD; - if (kick_compat_conv(psDoKickIN, in_size) != 0) { - psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; - return -EINVAL; - } - - } psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, &hDevCookieInt, psDoKickIN->hDevCookie, @@ -254,7 +220,7 @@ int SGXDoKickBW(u32 ui32BridgeID, return 0; } - if (psDoKickIN->sCCBKick.ui32Num3DStatusVals > max_3dstat_vals) { + if (psDoKickIN->sCCBKick.ui32Num3DStatusVals > SGX_MAX_3D_STATUS_VALS) { psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; return 0; } @@ -289,8 +255,7 @@ int SGXDoKickBW(u32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick, - max_3dstat_vals); + psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick); return 0; } diff --git a/drivers/gpu/pvr/sgx_bridge_km.h b/drivers/gpu/pvr/sgx_bridge_km.h index 3389b0c..2819a7e 100644 --- a/drivers/gpu/pvr/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx_bridge_km.h @@ -39,8 +39,8 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, struct PVRSRV_TRANSFER_SGX_KICK *psKick); -enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, - int max_3dstat_val); +enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, + struct SGX_CCB_KICK *psCCBKick); enum PVRSRV_ERROR SGXGetPhysPageAddrKM(void *hDevMemHeap, struct IMG_DEV_VIRTADDR sDevVAddr, diff --git a/drivers/gpu/pvr/sgxapi_km.h b/drivers/gpu/pvr/sgxapi_km.h index 8ca76ff..88d66fa 100644 --- a/drivers/gpu/pvr/sgxapi_km.h +++ b/drivers/gpu/pvr/sgxapi_km.h @@ -50,7 +50,6 @@ #define SGX_MAX_HEAP_ID 10 #define SGX_MAX_TA_STATUS_VALS 32 -#define SGX_MAX_3D_STATUS_VALS_OLD 2 #define SGX_MAX_3D_STATUS_VALS 4 #define SGX_MAX_SRC_SYNCS 4 diff --git a/drivers/gpu/pvr/sgxinfo.h b/drivers/gpu/pvr/sgxinfo.h index 955261a..eda7f34 100644 --- a/drivers/gpu/pvr/sgxinfo.h +++ b/drivers/gpu/pvr/sgxinfo.h @@ -242,10 +242,6 @@ struct SGXMKIF_CMDTA_SHARED { struct PVRSRV_DEVICE_SYNC_OBJECT asSrcSyncs[SGX_MAX_SRC_SYNCS]; struct CTL_STATUS sCtlTAStatusInfo[SGX_MAX_TA_STATUS_VALS]; - /* - * Note that the actual size of sCtl3DStatusInfo changes based - * on the IOCTL ABI version used. - */ struct CTL_STATUS sCtl3DStatusInfo[SGX_MAX_3D_STATUS_VALS]; struct PVRSRV_DEVICE_SYNC_OBJECT sTA3DDependency; diff --git a/drivers/gpu/pvr/sgxkick.c b/drivers/gpu/pvr/sgxkick.c index 045de0f..4054988 100644 --- a/drivers/gpu/pvr/sgxkick.c +++ b/drivers/gpu/pvr/sgxkick.c @@ -37,8 +37,8 @@ #include "pvr_debug.h" #include "sgxutils.h" -enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, - int max_3dstat_vals) +enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, + struct SGX_CCB_KICK *psCCBKick) { enum PVRSRV_ERROR eError; struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; @@ -67,26 +67,12 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, psCCBKick, ui32CCBOffset); if (psCCBKick->hTA3DSyncInfo) { - struct PVRSRV_DEVICE_SYNC_OBJECT *ta3d_dep; - psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; - - ta3d_dep = &psTACmd->sTA3DDependency; - /* - * Ugly hack to account for the two possible sizes of - * struct SGXMKIF_CMDTA_SHARED which is based on the - * corresponding IOCTL ABI version used. - */ - if (max_3dstat_vals != SGX_MAX_3D_STATUS_VALS) - ta3d_dep = (struct PVRSRV_DEVICE_SYNC_OBJECT *) - ((u8 *)ta3d_dep - sizeof(struct CTL_STATUS) * - (SGX_MAX_3D_STATUS_VALS - max_3dstat_vals)); - - ta3d_dep->sWriteOpsCompleteDevVAddr = + psTACmd->sTA3DDependency.sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - ta3d_dep->ui32WriteOpsPendingVal = + psTACmd->sTA3DDependency.ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; if (psCCBKick->bTADependency) -- 1.7.5.4 From 3c2441f9565d23dfd548f49ba0db1e1765cdf3ab Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 9 Feb 2011 09:58:13 +0200 Subject: [PATCH 12/95] gpu: pvr: refactor dump_process_info Split out from the function the part getting the process data based on the current SHX HW memory context. This functionality will be needed by an upcoming patch. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinit.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 0896c32..c1a15a4 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -648,24 +648,36 @@ static void dump_edm(struct PVRSRV_SGXDEV_INFO *sdev) #endif } -static void dump_process_info(struct PVRSRV_DEVICE_NODE *dev) +static struct PVRSRV_PER_PROCESS_DATA *find_cur_proc_data( + struct PVRSRV_DEVICE_NODE *dev) { struct PVRSRV_SGXDEV_INFO *dev_info = dev->pvDevice; u32 page_dir = readl(dev_info->pvRegsBaseKM + EUR_CR_BIF_DIR_LIST_BASE0); struct BM_CONTEXT *bm_ctx; struct RESMAN_CONTEXT *res_ctx = NULL; + struct PVRSRV_PER_PROCESS_DATA *proc_data = NULL; bm_ctx = bm_find_context(dev->sDevMemoryInfo.pBMContext, page_dir); if (bm_ctx) res_ctx = pvr_get_resman_ctx(bm_ctx); - if (res_ctx) { + if (res_ctx) + proc_data = pvr_get_proc_by_ctx(res_ctx); + + return proc_data; +} + +static void dump_process_info(struct PVRSRV_DEVICE_NODE *dev) +{ + struct PVRSRV_PER_PROCESS_DATA *proc; + + proc = find_cur_proc_data(dev); + + if (proc) { struct task_struct *tsk; - struct PVRSRV_PER_PROCESS_DATA *proc; int pid; - proc = pvr_get_proc_by_ctx(res_ctx); pid = proc->ui32PID; rcu_read_lock(); tsk = pid_task(find_vpid(pid), PIDTYPE_PID); -- 1.7.5.4 From f7aaf830bed5d5ec34123075dec86db7c7cdc719 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 9 Feb 2011 17:17:55 +0200 Subject: [PATCH 13/95] gpu: pvr: dump render status buffers during SGX HW recovery To aid debugging, dump any status buffers that are provided by the ogles user space library for the rendering context that was active at the time of recovery. At the moment the USSE final patched versions of vertex and fragment shaders that were bound within the frame causing the HWRec are provided, but later on more types can be added. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxapi_km.h | 18 ++++ drivers/gpu/pvr/sgxinfo.h | 4 + drivers/gpu/pvr/sgxinfokm.h | 1 + drivers/gpu/pvr/sgxinit.c | 239 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 261 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/sgxapi_km.h b/drivers/gpu/pvr/sgxapi_km.h index 88d66fa..39ec960 100644 --- a/drivers/gpu/pvr/sgxapi_km.h +++ b/drivers/gpu/pvr/sgxapi_km.h @@ -29,6 +29,7 @@ #include "sgxdefs.h" +#include "img_types.h" #if defined(__KERNEL__) #include <linux/unistd.h> @@ -178,6 +179,23 @@ struct SGX_MISC_INFO { } uData; }; +enum render_state_buf_type { + RSB_USSE_VERTEX_PROG, + RSB_USSE_FRAGMENT_PROG, +}; + +struct render_state_buf_info { + u32 buf_id; + u32 offset; + u32 size; + enum render_state_buf_type type; +}; + +struct render_state_buf_list { + u32 cnt; + struct render_state_buf_info info[20]; +}; + #define SGX_KICKTA_DUMPBITMAP_MAX_NAME_LENGTH 256 struct SGX_KICKTA_DUMPBITMAP { diff --git a/drivers/gpu/pvr/sgxinfo.h b/drivers/gpu/pvr/sgxinfo.h index eda7f34..8310244 100644 --- a/drivers/gpu/pvr/sgxinfo.h +++ b/drivers/gpu/pvr/sgxinfo.h @@ -71,6 +71,7 @@ struct SGX_BRIDGE_INIT_INFO { struct SGX_INIT_SCRIPTS sScripts; + u32 state_buf_ofs; }; struct SGXMKIF_COMMAND { @@ -201,6 +202,9 @@ struct SGXMKIF_HOST_CTL { /*< to count time wraps in the Timer task */ u32 ui32TimeWraps; + + u32 render_state_buf_ta_handle; + u32 render_state_buf_3d_handle; }; struct SGX_CLIENT_INFO { diff --git a/drivers/gpu/pvr/sgxinfokm.h b/drivers/gpu/pvr/sgxinfokm.h index 83228d4..4191842 100644 --- a/drivers/gpu/pvr/sgxinfokm.h +++ b/drivers/gpu/pvr/sgxinfokm.h @@ -152,6 +152,7 @@ struct PVRSRV_SGXDEV_INFO { u32 asSGXDevData[SGX_MAX_DEV_DATA]; + u32 state_buf_ofs; }; struct SGX_TIMING_INFORMATION { diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index c1a15a4..f75989b 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -30,6 +30,8 @@ #include <linux/io.h> #include <linux/slab.h> #include <linux/sched.h> +#include <linux/mm.h> +#include <linux/vmalloc.h> #include "sgxdefs.h" #include "sgxmmu.h" @@ -43,10 +45,12 @@ #include "pvr_bridge_km.h" #include "sgx_bridge_km.h" #include "resman.h" +#include "bridged_support.h" #include "pdump_km.h" #include "ra.h" #include "mmu.h" +#include "mm.h" #include "handle.h" #include "perproc.h" @@ -161,6 +165,8 @@ static enum PVRSRV_ERROR InitDevInfo(struct PVRSRV_PER_PROCESS_DATA *psPerProc, OSMemCopy(&psDevInfo->asSGXDevData, &psInitInfo->asInitDevData, sizeof(psDevInfo->asSGXDevData)); + psDevInfo->state_buf_ofs = psInitInfo->state_buf_ofs; + return PVRSRV_OK; failed_allockernelccb: @@ -602,7 +608,7 @@ static size_t __print_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, if (dst) \ p += snprintf(dst + p, dst_len - p, fmt, ## __VA_ARGS__); \ else \ - pr_err(fmt, ## __VA_ARGS__); \ + printk(KERN_DEBUG fmt, ## __VA_ARGS__); \ } while (0) if (!sdev->psKernelEDMStatusBufferMemInfo) @@ -704,6 +710,236 @@ static void dump_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) readl(psDevInfo->pvRegsBaseKM + EUR_CR_CLKGATECTL)); } +#define BUF_DESC_CORRUPT (1 << 31) + +static void add_uniq_items(struct render_state_buf_list *dst, + const struct render_state_buf_list *src) +{ + int i; + + for (i = 0; i < src->cnt; i++) { + const struct render_state_buf_info *sbinf = &src->info[i]; + int j; + + for (j = 0; j < dst->cnt; j++) { + if (sbinf->buf_id == dst->info[j].buf_id) { + if (memcmp(sbinf, &dst->info[j], sizeof(sbinf))) + dst->info[j].type |= BUF_DESC_CORRUPT; + break; + } + } + if (j == dst->cnt) { + /* Bound for cnt is guaranteed by the caller */ + dst->info[dst->cnt] = *sbinf; + dst->cnt++; + } + } +} + +static struct render_state_buf_list *create_merged_uniq_list( + struct render_state_buf_list **bl_set, int set_size) +{ + int i; + struct render_state_buf_list *dbl; + size_t size; + + /* + * Create a buf list big enough to contain all elements from each + * list in bl_set. + */ + size = offsetof(struct render_state_buf_list, info[0]); + for (i = 0; i < set_size; i++) { + if (!bl_set[i]) + continue; + size += bl_set[i]->cnt * sizeof(bl_set[i]->info[0]); + } + if (!size) + return NULL; + dbl = kmalloc(size, GFP_KERNEL); + if (!dbl) + return NULL; + + dbl->cnt = 0; + for (i = 0; i < set_size; i++) { + if (bl_set[i]) + add_uniq_items(dbl, bl_set[i]); + } + + return dbl; +} + +static void *vmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, off_t offset, size_t size) +{ + struct PVRSRV_KERNEL_MEM_INFO *minfo; + struct LinuxMemArea *mem_area; + enum PVRSRV_ERROR err; + unsigned start_ofs; + unsigned end_ofs; + int pg_cnt; + struct page **pages; + void *map; + int i; + + if (offset & PAGE_MASK) + return NULL; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return NULL; + if (minfo->pvLinAddrKM) + return minfo->pvLinAddrKM; + + err = PVRSRVLookupOSMemHandle(proc->psHandleBase, (void *)&mem_area, + (void *)handle); + if (err != PVRSRV_OK) + return NULL; + + start_ofs = offset & PAGE_MASK; + end_ofs = PAGE_ALIGN(offset + size); + pg_cnt = (end_ofs - start_ofs) >> PAGE_SHIFT; + pages = kmalloc(pg_cnt * sizeof(pages[0]), GFP_KERNEL); + if (!pages) + return NULL; + for (i = 0; i < pg_cnt; i++) { + unsigned pfn; + + pfn = LinuxMemAreaToCpuPFN(mem_area, start_ofs); + if (!pfn_valid(pfn)) + goto err; + pages[i] = pfn_to_page(pfn); + start_ofs += PAGE_SIZE; + } + map = vmap(pages, pg_cnt, VM_MAP, PAGE_KERNEL); + map += offset; +err: + kfree(pages); + + return map; +} + +static void vunmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, void *map) +{ + struct PVRSRV_KERNEL_MEM_INFO *minfo; + enum PVRSRV_ERROR err; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return; + if (minfo->pvLinAddrKM) + return; + vunmap((void *)(((unsigned long)map) & PAGE_MASK)); +} + +static void dump_buf(void *start, size_t size, u32 type) +{ + unsigned addr = 0; + char *corr = ""; + + if (type & BUF_DESC_CORRUPT) { + type &= ~BUF_DESC_CORRUPT; + corr = "(corrupt)"; + } + printk(KERN_DEBUG "type %d%s size %d\n", type, corr, size); + while (addr < size) { + if (!(addr % 16)) { + if (addr) + printk("\n"); + printk(KERN_DEBUG "%08x ", addr); + } + printk("%08x ", *(u32 *)(start + addr)); + addr += 4; + } + if (addr) + printk("\n"); +} + +static struct render_state_buf_list *get_state_buf_list( + struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, off_t offset) +{ + struct PVRSRV_KERNEL_MEM_INFO *container; + struct render_state_buf_list *buf; + enum PVRSRV_ERROR err; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&container, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return NULL; + if (!container->pvLinAddrKM) + return NULL; + if (offset + sizeof(*buf) > container->ui32AllocSize) + return NULL; + + buf = container->pvLinAddrKM + offset; + + if (buf->cnt > ARRAY_SIZE(buf->info)) + return NULL; + + return buf; +} + +static void dump_state_buf_list(struct PVRSRV_PER_PROCESS_DATA *proc, + struct render_state_buf_list *bl) +{ + int i; + + if (!bl->cnt) + return; + + printk(KERN_DEBUG "Dumping %d render state buffers\n", bl->cnt); + for (i = 0; i < bl->cnt; i++) { + struct render_state_buf_info *binfo; + void *map; + + binfo = &bl->info[i]; + + map = vmap_buf(proc, binfo->buf_id, binfo->offset, binfo->size); + if (!map) + continue; + dump_buf(map, binfo->size, binfo->type); + + vunmap_buf(proc, binfo->buf_id, map); + } +} + +static void dump_sgx_state_bufs(struct PVRSRV_DEVICE_NODE *dev_node) +{ + struct PVRSRV_SGXDEV_INFO *dev_info = dev_node->pvDevice; + struct SGXMKIF_HOST_CTL __iomem *hctl = dev_info->psSGXHostCtl; + struct PVRSRV_PER_PROCESS_DATA *proc; + struct render_state_buf_list *bl_set[2] = { NULL }; + struct render_state_buf_list *mbl; + u32 handle_ta; + u32 handle_3d; + + proc = find_cur_proc_data(dev_node); + if (!proc) + return; + + handle_ta = readl(&hctl->render_state_buf_ta_handle); + handle_3d = readl(&hctl->render_state_buf_3d_handle); + bl_set[0] = get_state_buf_list(proc, handle_ta, + dev_info->state_buf_ofs); + /* + * The two buf list can be the same if the TA and 3D phases used the + * same context at the time of the HWrec. In this case just ignore + * one of them. + */ + if (handle_ta != handle_3d) + bl_set[1] = get_state_buf_list(proc, handle_3d, + dev_info->state_buf_ofs); + mbl = create_merged_uniq_list(bl_set, ARRAY_SIZE(bl_set)); + if (!mbl) + return; + + dump_state_buf_list(proc, mbl); + kfree(mbl); +} + /* Should be called with pvr_lock held */ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) { @@ -726,6 +962,7 @@ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) dump_process_info(psDeviceNode); dump_sgx_registers(psDevInfo); dump_edm(psDevInfo); + dump_sgx_state_bufs(psDeviceNode); PDUMPSUSPEND(); -- 1.7.5.4 From 19e004091134f33cbc8965777f7b70935c9479ae Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Mon, 21 Feb 2011 13:07:26 +0100 Subject: [PATCH 14/95] gpu: pvr: improve per process procfs entry/dir handling When building with full debug, a lot of "Resource Arena" (ra) data is being made available in the rather painful procfs, including per process ra info, kept in process specific subdirectories. Adding and removing process specific entries from procfs took the PID of the currently running process; which sometimes failed during cleanup, when the current process might no longer be anything tracked by the driver. This then resulted in some strange behaviour, where it was impossible to cleanup a process specific procfs directory, resulting in an endless loop. Since process specific procfs entries are only created in the RA code, we now track the pid in the RA struct. When we pass this pid to both the procfs entry creation and removal functions, we now do reliably clean up the procfs entries. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/proc.c | 115 +++++++++++++++++++++++++++--------------------- drivers/gpu/pvr/proc.h | 6 +- drivers/gpu/pvr/ra.c | 64 +++++++++++++-------------- 3 files changed, 99 insertions(+), 86 deletions(-) diff --git a/drivers/gpu/pvr/proc.c b/drivers/gpu/pvr/proc.c index 613d3de..a8564f09 100644 --- a/drivers/gpu/pvr/proc.c +++ b/drivers/gpu/pvr/proc.c @@ -138,59 +138,78 @@ int CreateProcEntry(const char *name, read_proc_t rhandler, return CreateProcEntryInDir(dir, name, rhandler, whandler, data); } -int CreatePerProcessProcEntry(const char *name, read_proc_t rhandler, - write_proc_t whandler, void *data) +static struct proc_dir_entry * +ProcessProcDirCreate(u32 pid) { struct PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; - u32 ui32PID; + char dirname[16]; + int ret; - if (!dir) { - PVR_DPF(PVR_DBG_ERROR, - "CreatePerProcessProcEntries: /proc/%s doesn't exist", - PVRProcDirRoot); + psPerProc = PVRSRVPerProcessPrivateData(pid); + if (!psPerProc) { + pr_err("%s: no per process data for %d\n", __func__, pid); + return NULL; + } - return -ENOMEM; + if (psPerProc->psProcDir) + return psPerProc->psProcDir; + + ret = snprintf(dirname, sizeof(dirname), "%u", pid); + if (ret <= 0 || ret >= sizeof(dirname)) { + pr_err("%s: couldn't generate per process proc dir for %d\n", + __func__, pid); + return NULL; } - ui32PID = OSGetCurrentProcessIDKM(); + psPerProc->psProcDir = proc_mkdir(dirname, dir); + if (!psPerProc->psProcDir) + pr_err("%s: couldn't create /proc/%s/%u\n", + __func__, PVRProcDirRoot, pid); - psPerProc = PVRSRVPerProcessPrivateData(ui32PID); - if (!psPerProc) { - PVR_DPF(PVR_DBG_ERROR, - "CreatePerProcessProcEntries: no per process data"); + return psPerProc->psProcDir; +} - return -ENOMEM; +static struct proc_dir_entry * +ProcessProcDirGet(u32 pid) +{ + struct PVRSRV_ENV_PER_PROCESS_DATA *psPerProc; + + psPerProc = PVRSRVPerProcessPrivateData(pid); + if (!psPerProc) { + pr_err("%s: no per process data for %d\n", __func__, pid); + return NULL; } if (!psPerProc->psProcDir) { - char dirname[16]; - int ret; + pr_err("%s: couldn't retrieve /proc/%s/%u\n", __func__, + PVRProcDirRoot, pid); + return NULL; + } - ret = snprintf(dirname, sizeof(dirname), "%u", ui32PID); + return psPerProc->psProcDir; +} - if (ret <= 0 || ret >= sizeof(dirname)) { - PVR_DPF(PVR_DBG_ERROR, "CreatePerProcessProcEntries: " - "couldn't generate per process proc " - "directory name \"%u\"", - ui32PID); +int CreatePerProcessProcEntry(u32 pid, const char *name, read_proc_t rhandler, + void *data) +{ + if (!dir) { + PVR_DPF(PVR_DBG_ERROR, + "CreatePerProcessProcEntries: /proc/%s doesn't exist", + PVRProcDirRoot); - return -ENOMEM; - } else { - psPerProc->psProcDir = proc_mkdir(dirname, dir); - if (!psPerProc->psProcDir) { - PVR_DPF(PVR_DBG_ERROR, - "CreatePerProcessProcEntries: " - "couldn't create per process proc " - "directory /proc/%s/%u", - PVRProcDirRoot, ui32PID); - - return -ENOMEM; - } - } + return -ENOMEM; } - return CreateProcEntryInDir(psPerProc->psProcDir, name, rhandler, - whandler, data); + if (pid) { + struct proc_dir_entry *pid_dir = ProcessProcDirCreate(pid); + + if (!pid_dir) + return -ENOMEM; + + return CreateProcEntryInDir(pid_dir, name, rhandler, NULL, + data); + } else + return CreateProcEntryInDir(dir, name, rhandler, NULL, data); } int CreateProcReadEntry(const char *name, @@ -264,24 +283,20 @@ void RemoveProcEntry(const char *name) } } -void RemovePerProcessProcEntry(const char *name) +void RemovePerProcessProcEntry(u32 pid, const char *name) { - struct PVRSRV_ENV_PER_PROCESS_DATA *psPerProc = - PVRSRVFindPerProcessPrivateData(); + if (pid) { + struct proc_dir_entry *pid_dir = ProcessProcDirGet(pid); - if (!psPerProc) { - PVR_DPF(PVR_DBG_ERROR, "CreatePerProcessProcEntries: " - "can't remove %s, no per process data", - name); - return; - } + if (!pid_dir) + return; - if (psPerProc->psProcDir) { - remove_proc_entry(name, psPerProc->psProcDir); + remove_proc_entry(name, pid_dir); PVR_DPF(PVR_DBG_MESSAGE, "Removing proc entry %s from %s", - name, psPerProc->psProcDir->name); - } + name, pid_dir->name); + } else + RemoveProcEntry(name); } void RemovePerProcessProcDir(struct PVRSRV_ENV_PER_PROCESS_DATA *psPerProc) diff --git a/drivers/gpu/pvr/proc.h b/drivers/gpu/pvr/proc.h index 942b2ea..c93543c 100644 --- a/drivers/gpu/pvr/proc.h +++ b/drivers/gpu/pvr/proc.h @@ -42,12 +42,12 @@ int CreateProcReadEntry(const char *name, int CreateProcEntry(const char *name, read_proc_t rhandler, write_proc_t whandler, void *data); -int CreatePerProcessProcEntry(const char *name, read_proc_t rhandler, - write_proc_t whandler, void *data); +int CreatePerProcessProcEntry(u32 pid, const char *name, read_proc_t rhandler, + void *data); void RemoveProcEntry(const char *name); -void RemovePerProcessProcEntry(const char *name); +void RemovePerProcessProcEntry(u32 pid, const char *name); void RemoveProcEntries(void); diff --git a/drivers/gpu/pvr/ra.c b/drivers/gpu/pvr/ra.c index 4c71af1..bcd96b8 100644 --- a/drivers/gpu/pvr/ra.c +++ b/drivers/gpu/pvr/ra.c @@ -77,7 +77,7 @@ struct RA_ARENA { #define PROC_NAME_SIZE 32 char szProcInfoName[PROC_NAME_SIZE]; char szProcSegsName[PROC_NAME_SIZE]; - IMG_BOOL bInitProcEntry; + u32 ui32PID; #endif }; @@ -644,41 +644,44 @@ struct RA_ARENA *RA_Create(char *name, u32 base, size_t uSize, #if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_DEBUG_EXTRA) if (strcmp(pArena->name, "") != 0) { int ret; - int (*pfnCreateProcEntry) (const char *, read_proc_t, - write_proc_t, void *); - pArena->bInitProcEntry = - !PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL); - - pfnCreateProcEntry = pArena->bInitProcEntry ? CreateProcEntry : - CreatePerProcessProcEntry; + if (PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL)) + pArena->ui32PID = OSGetCurrentProcessIDKM(); + else + pArena->ui32PID = 0; ret = snprintf(pArena->szProcInfoName, sizeof(pArena->szProcInfoName), "ra_info_%s", pArena->name); - if (ret > 0 && ret < sizeof(pArena->szProcInfoName)) { - (void)pfnCreateProcEntry(ReplaceSpaces - (pArena->szProcInfoName), - RA_DumpInfo, NULL, pArena); - } else { + if ((ret > 0) && (ret < sizeof(pArena->szProcInfoName))) { + ReplaceSpaces(pArena->szProcInfoName); + ret = CreatePerProcessProcEntry(pArena->ui32PID, + pArena->szProcInfoName, + RA_DumpInfo, pArena); + } else + pArena->szProcInfoName[0] = 0; + + if (ret) { pArena->szProcInfoName[0] = 0; - PVR_DPF(PVR_DBG_ERROR, "RA_Create: " - "couldn't create ra_info proc entry for arena %s", - pArena->name); + pr_err("%s: couldn't create ra_info proc entry for " + "arena %s", __func__, pArena->name); } ret = snprintf(pArena->szProcSegsName, sizeof(pArena->szProcSegsName), "ra_segs_%s", pArena->name); - if (ret > 0 && ret < sizeof(pArena->szProcInfoName)) { - (void)pfnCreateProcEntry(ReplaceSpaces - (pArena->szProcSegsName), - RA_DumpSegs, NULL, pArena); - } else { + if ((ret > 0) && (ret < sizeof(pArena->szProcSegsName))) { + ReplaceSpaces(pArena->szProcSegsName); + ret = CreatePerProcessProcEntry(pArena->ui32PID, + pArena->szProcSegsName, + RA_DumpSegs, pArena); + } else + ret = -1; + + if (ret) { pArena->szProcSegsName[0] = 0; - PVR_DPF(PVR_DBG_ERROR, "RA_Create: " - "couldn't create ra_segs proc entry for arena %s", - pArena->name); + pr_err("%s: couldn't create ra_segs proc entry for " + "arena %s", __func__, pArena->name); } } #endif @@ -734,18 +737,13 @@ void RA_Delete(struct RA_ARENA *pArena) } #if defined(CONFIG_PROC_FS) && defined(CONFIG_PVR_DEBUG_EXTRA) { - void (*pfnRemoveProcEntry) (const char *); - - pfnRemoveProcEntry = - pArena-> - bInitProcEntry ? RemoveProcEntry : - RemovePerProcessProcEntry; - if (pArena->szProcInfoName[0] != 0) - pfnRemoveProcEntry(pArena->szProcInfoName); + RemovePerProcessProcEntry(pArena->ui32PID, + pArena->szProcInfoName); if (pArena->szProcSegsName[0] != 0) - pfnRemoveProcEntry(pArena->szProcSegsName); + RemovePerProcessProcEntry(pArena->ui32PID, + pArena->szProcSegsName); } #endif HASH_Delete(pArena->pSegmentHash); -- 1.7.5.4 From e9c0dcf94e7ec4fd08c551aaf7726f3c47bfabc0 Mon Sep 17 00:00:00 2001 From: Alex Crowther <alex.crowther@imgtec.com> Date: Mon, 7 Mar 2011 13:14:06 +0000 Subject: [PATCH 15/95] gpu: pvr: disable sgx active power management while pvrtune is running Disable sgx active power management while sgxPerfServer is running. This enables pvrtune to run correctly without data loss. Signed-off-by: Alex Crowther <alex.crowther@imgtec.com> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgx_bridge_km.h | 3 +++ drivers/gpu/pvr/sgxinit.c | 34 ++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/sgxutils.c | 3 +++ 3 files changed, 40 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/sgx_bridge_km.h b/drivers/gpu/pvr/sgx_bridge_km.h index 2819a7e..fbd3379 100644 --- a/drivers/gpu/pvr/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx_bridge_km.h @@ -106,4 +106,7 @@ enum PVRSRV_ERROR SGXGetInternalDevInfoKM(void *hDevCookie, int sgx_force_reset(void); +IMG_BOOL isSGXPerfServerActive(void); +void SGXPerfServerMonitor(u32 u32TimeStamp); + #endif diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index f75989b..c551039 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -1785,6 +1785,38 @@ enum PVRSRV_ERROR SGXGetMiscInfoKM(struct PVRSRV_SGXDEV_INFO *psDevInfo, } } + + +static bool sgxps_active; +static unsigned long sgxps_timeout; + +IMG_BOOL isSGXPerfServerActive(void) +{ + if (!sgxps_active) + return 0; + + if (time_before_eq((unsigned long)OSClockus(), sgxps_timeout)) + return 1; + + sgxps_active = false; + PVR_DPF(DBGPRIV_WARNING, "pvr: perf server inactive\n"); + + return 0; +} + + +void SGXPerfServerMonitor(u32 u32TimeStamp) +{ + if (!sgxps_active) { + PVR_DPF(DBGPRIV_WARNING, "pvr: perf server active\n"); + sgxps_active = true; + } + + /* turn off after 1 second of inactivity */ + sgxps_timeout = u32TimeStamp + 1000000; +} + + enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, u32 *pui32Old, IMG_BOOL bNew, u32 ui32New, u32 ui32NewReset, u32 ui32CountersReg, @@ -1830,6 +1862,8 @@ enum PVRSRV_ERROR SGXReadDiffCountersKM(void *hDevHandle, u32 ui32Reg, *pui32Time = sNew.ui32Time[0]; if (sNew.ui32Time[0] != psPrev->ui32Time[0] && bPowered) { + SGXPerfServerMonitor(*pui32Time); + *pui32Old = OSReadHWReg(psDevInfo->pvRegsBaseKM, ui32Reg); diff --git a/drivers/gpu/pvr/sgxutils.c b/drivers/gpu/pvr/sgxutils.c index b92d502..2e97811 100644 --- a/drivers/gpu/pvr/sgxutils.c +++ b/drivers/gpu/pvr/sgxutils.c @@ -70,6 +70,9 @@ void SGXTestActivePowerEvent(struct PVRSRV_DEVICE_NODE *psDeviceNode) struct SGXMKIF_HOST_CTL __iomem *psSGXHostCtl = psDevInfo->psSGXHostCtl; u32 l; + if (isSGXPerfServerActive()) + return; + l = readl(&psSGXHostCtl->ui32InterruptFlags); if (!(l & PVRSRV_USSE_EDM_INTERRUPT_ACTIVE_POWER)) return; -- 1.7.5.4 From aca4e123fd8088cbcc798a9ef72f0603d626ca2e Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Mon, 14 Mar 2011 18:12:24 +0200 Subject: [PATCH 16/95] gpu: pvr: fix error path during SGX device initialization This also fixes some coverity reports. Fixes: NB#233667 - Dereferencing possibly NULL pointer in sgxinit.c Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinit.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index c551039..8f88052 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -345,6 +345,8 @@ static enum PVRSRV_ERROR DevInitSGXPart1(void *pvDeviceNode) hKernelDevMemContext = BM_CreateContext(psDeviceNode, &sPDDevPAddr, NULL, NULL); + if (!hKernelDevMemContext) + goto err1; psDevInfo->sKernelPDDevPAddr = sPDDevPAddr; @@ -360,6 +362,9 @@ static enum PVRSRV_ERROR DevInitSGXPart1(void *pvDeviceNode) BM_CreateHeap(hKernelDevMemContext, &psDeviceMemoryHeap[i]); + if (!hDevMemHeap) + goto err2; + psDeviceMemoryHeap[i].hDevMemHeap = hDevMemHeap; break; } @@ -370,10 +375,28 @@ static enum PVRSRV_ERROR DevInitSGXPart1(void *pvDeviceNode) if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "DevInitSGX : Failed to alloc memory for BIF reset"); - return PVRSRV_ERROR_GENERIC; + goto err2; } return PVRSRV_OK; +err2: + while (i) { + int type; + + i--; + type = psDeviceMemoryHeap[i].DevMemHeapType; + if (type != DEVICE_MEMORY_HEAP_KERNEL && + type != DEVICE_MEMORY_HEAP_SHARED && + type != DEVICE_MEMORY_HEAP_SHARED_EXPORTED) + continue; + BM_DestroyHeap(psDeviceMemoryHeap[i].hDevMemHeap); + } + BM_DestroyContext(hKernelDevMemContext); +err1: + OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, + sizeof(struct PVRSRV_SGXDEV_INFO), psDevInfo, NULL); + + return PVRSRV_ERROR_GENERIC; } enum PVRSRV_ERROR SGXGetInfoForSrvinitKM(void *hDevHandle, -- 1.7.5.4 From c2bcade8f0bd1e81711fb1acb6f39ba93d119c25 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:33 +0100 Subject: [PATCH 17/95] gpu: pvr: move debugfs infrastructure to its own files pvr_debug.* originally only provided some contrived code (which needs sanitation) to do debug printing. Future HW Recovery code will also be using debugfs and it makes sense to lump all of them together in pvr_debugfs.* Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 2 +- drivers/gpu/pvr/module.c | 11 +++ drivers/gpu/pvr/pvr_debug.c | 167 +------------------------------------ drivers/gpu/pvr/pvr_debug.h | 2 +- drivers/gpu/pvr/pvr_debugfs.c | 187 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_debugfs.h | 29 +++++++ 6 files changed, 230 insertions(+), 168 deletions(-) create mode 100644 drivers/gpu/pvr/pvr_debugfs.c create mode 100644 drivers/gpu/pvr/pvr_debugfs.h diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 4b20e00..2603208 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -14,7 +14,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o pdump.o proc.o \ pvr_events.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o -pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debug.o +pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debugfs.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o pvrsrvkm-objs += $(pvrsrvkm-objs-y) $(pvrsrvkm-objs-m) diff --git a/drivers/gpu/pvr/module.c b/drivers/gpu/pvr/module.c index d94efe6..7543579 100644 --- a/drivers/gpu/pvr/module.c +++ b/drivers/gpu/pvr/module.c @@ -54,6 +54,10 @@ #include "private_data.h" #include "pvr_events.h" +#ifdef CONFIG_DEBUG_FS +#include "pvr_debugfs.h" +#endif + #define DRVNAME "pvrsrvkm" #ifdef CONFIG_PVR_DEBUG_EXTRA @@ -234,6 +238,10 @@ static int __init pvr_init(void) PVRDebugSetLevel(debug); #endif +#ifdef CONFIG_DEBUG_FS + pvr_debugfs_init(); +#endif + error = CreateProcEntries(); if (error < 0) goto err1; @@ -283,6 +291,9 @@ static void __exit pvr_cleanup(void) PVR_TRACE("pvr_cleanup: unloading"); +#ifdef CONFIG_DEBUG_FS + pvr_debugfs_cleanup(); +#endif pvr_dbg_cleanup(); } diff --git a/drivers/gpu/pvr/pvr_debug.c b/drivers/gpu/pvr/pvr_debug.c index 1c89499..116c6ea 100644 --- a/drivers/gpu/pvr/pvr_debug.c +++ b/drivers/gpu/pvr/pvr_debug.c @@ -24,25 +24,16 @@ * ******************************************************************************/ -#include <linux/io.h> #include <linux/uaccess.h> #include <linux/kernel.h> #include <linux/hardirq.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <linux/tty.h> -#include <linux/debugfs.h> -#include <linux/vmalloc.h> -#include <stdarg.h> #include "img_types.h" #include "servicesext.h" #include "pvr_debug.h" #include "proc.h" -#include "syscommon.h" -#include "sgxinfokm.h" -#include "sgxutils.h" -#include "pvr_bridge_km.h" #ifdef CONFIG_PVR_DEBUG @@ -257,171 +248,15 @@ int PVRDebugProcGetLevel(char *page, char **start, off_t off, int count, #endif -#ifdef CONFIG_DEBUG_FS - -static struct dentry *debugfs_dir; -static u32 pvr_reset; - -static struct PVRSRV_DEVICE_NODE *get_sgx_node(void) -{ - struct SYS_DATA *sysdata; - struct PVRSRV_DEVICE_NODE *node; - - if (SysAcquireData(&sysdata) != PVRSRV_OK) - return NULL; - - for (node = sysdata->psDeviceNodeList; node; node = node->psNext) - if (node->sDevId.eDeviceType == PVRSRV_DEVICE_TYPE_SGX) - break; - - return node; -} - -static int pvr_dbg_reset(void *data, u64 val) -{ - struct PVRSRV_DEVICE_NODE *node; - enum PVRSRV_ERROR err; - int r = 0; - - if (val != 1) - return 0; - - pvr_lock(); - - if (pvr_is_disabled()) { - r = -ENODEV; - goto exit; - } - - node = get_sgx_node(); - if (!node) { - r = -ENODEV; - goto exit; - } - - err = PVRSRVSetDevicePowerStateKM(node->sDevId.ui32DeviceIndex, - PVRSRV_POWER_STATE_D0); - if (err != PVRSRV_OK) { - r = -EIO; - goto exit; - } - - HWRecoveryResetSGX(node); - - SGXTestActivePowerEvent(node); -exit: - pvr_unlock(); - - return r; -} - -static int pvr_dbg_set(void *data, u64 val) -{ - u32 *var = data; - - if (var == &pvr_reset) - return pvr_dbg_reset(data, val); - - BUG(); -} - -DEFINE_SIMPLE_ATTRIBUTE(pvr_dbg_fops, NULL, pvr_dbg_set, "%llu\n"); - -struct edm_buf_info { - size_t len; - char data[1]; -}; - -static int pvr_dbg_edm_open(struct inode *inode, struct file *file) -{ - struct PVRSRV_DEVICE_NODE *node; - struct PVRSRV_SGXDEV_INFO *sgx_info; - struct edm_buf_info *bi; - size_t size; - - /* Take a snapshot of the EDM trace buffer */ - size = SGXMK_TRACE_BUFFER_SIZE * SGXMK_TRACE_BUF_STR_LEN; - bi = vmalloc(sizeof(*bi) + size); - if (!bi) - return -ENOMEM; - - node = get_sgx_node(); - sgx_info = node->pvDevice; - bi->len = snprint_edm_trace(sgx_info, bi->data, size); - file->private_data = bi; - - return 0; -} - -static int pvr_dbg_edm_release(struct inode *inode, struct file *file) -{ - vfree(file->private_data); - - return 0; -} - -static ssize_t pvr_dbg_edm_read(struct file *file, char __user *buffer, - size_t count, loff_t *ppos) -{ - struct edm_buf_info *bi = file->private_data; - - return simple_read_from_buffer(buffer, count, ppos, bi->data, bi->len); -} - -static const struct file_operations pvr_dbg_edm_fops = { - .owner = THIS_MODULE, - .open = pvr_dbg_edm_open, - .read = pvr_dbg_edm_read, - .release = pvr_dbg_edm_release, -}; - -static int pvr_init_debugfs(void) -{ - debugfs_dir = debugfs_create_dir("pvr", NULL); - if (!debugfs_dir) - return -ENODEV; - - if (!debugfs_create_file("reset_sgx", S_IWUGO, debugfs_dir, &pvr_reset, - &pvr_dbg_fops)) { - debugfs_remove(debugfs_dir); - return -ENODEV; - } - - if (!debugfs_create_file("edm_trace", S_IRUGO, debugfs_dir, NULL, - &pvr_dbg_edm_fops)) { - debugfs_remove_recursive(debugfs_dir); - return -ENODEV; - } - - return 0; -} - -static void pvr_cleanup_debugfs(void) -{ - debugfs_remove_recursive(debugfs_dir); -} - -#else /* !CONFIG_DEBUG_FS */ - -static int pvr_init_debugfs(void) -{ - return 0; -} - -static void pvr_cleanup_debugfs(void) { } - -#endif - void pvr_dbg_init(void) { #if defined(CONFIG_PVR_DEBUG) || defined(TIMING) mutex_init(&gsDebugMutexNonIRQ); #endif - pvr_init_debugfs(); } void pvr_dbg_cleanup(void) { - pvr_cleanup_debugfs(); + } diff --git a/drivers/gpu/pvr/pvr_debug.h b/drivers/gpu/pvr/pvr_debug.h index 4bad9c4..a886a8c 100644 --- a/drivers/gpu/pvr/pvr_debug.h +++ b/drivers/gpu/pvr/pvr_debug.h @@ -102,7 +102,7 @@ void PVRSRVTrace(const char *pszFormat, ...); #endif /* CONFIG_PVR_DEBUG */ -#if defined(CONFIG_PVR_DEBUG) || defined(TIMING) || defined(CONFIG_DEBUG_FS) +#if defined(CONFIG_PVR_DEBUG) || defined(TIMING) void pvr_dbg_init(void); void pvr_dbg_cleanup(void); diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c new file mode 100644 index 0000000..1dfebca --- /dev/null +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2010-2011 Imre Deak <imre.deak@nokia.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * + * Debugfs interface living in pvr/ subdirectory. + * + */ +#include <linux/kernel.h> +#include <linux/debugfs.h> +#include <linux/vmalloc.h> + +#include "img_types.h" +#include "servicesext.h" +#include "services.h" +#include "sgxinfokm.h" +#include "syscommon.h" +#include "pvr_bridge_km.h" +#include "sgxutils.h" +#include "pvr_debugfs.h" + +static struct dentry *debugfs_dir; +static u32 pvr_reset; + +/* + * + */ +static struct PVRSRV_DEVICE_NODE *get_sgx_node(void) +{ + struct SYS_DATA *sysdata; + struct PVRSRV_DEVICE_NODE *node; + + if (SysAcquireData(&sysdata) != PVRSRV_OK) + return NULL; + + for (node = sysdata->psDeviceNodeList; node; node = node->psNext) + if (node->sDevId.eDeviceType == PVRSRV_DEVICE_TYPE_SGX) + break; + + return node; +} + +static int pvr_debugfs_reset(void *data, u64 val) +{ + struct PVRSRV_DEVICE_NODE *node; + enum PVRSRV_ERROR err; + int r = 0; + + if (val != 1) + return 0; + + pvr_lock(); + + if (pvr_is_disabled()) { + r = -ENODEV; + goto exit; + } + + node = get_sgx_node(); + if (!node) { + r = -ENODEV; + goto exit; + } + + err = PVRSRVSetDevicePowerStateKM(node->sDevId.ui32DeviceIndex, + PVRSRV_POWER_STATE_D0); + if (err != PVRSRV_OK) { + r = -EIO; + goto exit; + } + + HWRecoveryResetSGX(node); + + SGXTestActivePowerEvent(node); +exit: + pvr_unlock(); + + return r; +} + +static int pvr_debugfs_set(void *data, u64 val) +{ + u32 *var = data; + + if (var == &pvr_reset) + return pvr_debugfs_reset(data, val); + + BUG(); +} + +DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_fops, NULL, pvr_debugfs_set, "%llu\n"); + +/* + * + */ +struct edm_buf_info { + size_t len; + char data[1]; +}; + +static int pvr_debugfs_edm_open(struct inode *inode, struct file *file) +{ + struct PVRSRV_DEVICE_NODE *node; + struct PVRSRV_SGXDEV_INFO *sgx_info; + struct edm_buf_info *bi; + size_t size; + + /* Take a snapshot of the EDM trace buffer */ + size = SGXMK_TRACE_BUFFER_SIZE * SGXMK_TRACE_BUF_STR_LEN; + bi = vmalloc(sizeof(*bi) + size); + if (!bi) + return -ENOMEM; + + node = get_sgx_node(); + sgx_info = node->pvDevice; + bi->len = snprint_edm_trace(sgx_info, bi->data, size); + file->private_data = bi; + + return 0; +} + +static int pvr_debugfs_edm_release(struct inode *inode, struct file *file) +{ + vfree(file->private_data); + + return 0; +} + +static ssize_t pvr_debugfs_edm_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct edm_buf_info *bi = file->private_data; + + return simple_read_from_buffer(buffer, count, ppos, bi->data, bi->len); +} + +static const struct file_operations pvr_debugfs_edm_fops = { + .owner = THIS_MODULE, + .open = pvr_debugfs_edm_open, + .read = pvr_debugfs_edm_read, + .release = pvr_debugfs_edm_release, +}; + + +/* + * + */ +int pvr_debugfs_init(void) +{ + debugfs_dir = debugfs_create_dir("pvr", NULL); + if (!debugfs_dir) + return -ENODEV; + + if (!debugfs_create_file("reset_sgx", S_IWUSR, debugfs_dir, &pvr_reset, + &pvr_debugfs_fops)) { + debugfs_remove(debugfs_dir); + return -ENODEV; + } + + if (!debugfs_create_file("edm_trace", S_IRUGO, debugfs_dir, NULL, + &pvr_debugfs_edm_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + + return 0; +} + +void pvr_debugfs_cleanup(void) +{ + debugfs_remove_recursive(debugfs_dir); +} diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h new file mode 100644 index 0000000..6adc51b --- /dev/null +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010-2011 Imre Deak <imre.deak@nokia.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _PVR_DEBUGFS_H_ +#define _PVR_DEBUGFS_H_ 1 + +#ifndef CONFIG_DEBUG_FS +#error Error: debugfs header included but CONFIG_DEBUG_FS is not defined! +#endif + +int pvr_debugfs_init(void); +void pvr_debugfs_cleanup(void); + +#endif /* _PVR_DEBUGFS_H_ */ -- 1.7.5.4 From 9732e4debaf0dcd3a83a2985dfcfd7b6d62a6c9c Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:34 +0100 Subject: [PATCH 18/95] gpu: pvr: debugfs: add initial hwrec dumping infrastructure Currently contains hwrec_event and hwrec_time. hwrec_event blocks the reader until a hwrec event happens. This allows a simple shell application to sleep until a hwrec happens. hwrec_time contains a timestamp to enable a simple shell application to create unique dumps. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 172 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_debugfs.h | 3 + drivers/gpu/pvr/sgxinit.c | 8 ++ 3 files changed, 183 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 1dfebca..d549133 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Imre Deak <imre.deak@nokia.com> + * Copyright (c) 2010-2011 Luc Verhaegen <libv@codethink.co.uk> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -24,6 +25,8 @@ #include <linux/kernel.h> #include <linux/debugfs.h> #include <linux/vmalloc.h> +#include <linux/mutex.h> +#include <linux/uaccess.h> #include "img_types.h" #include "servicesext.h" @@ -159,9 +162,166 @@ static const struct file_operations pvr_debugfs_edm_fops = { /* * + * HW Recovery dumping support. + * + */ +static struct mutex hwrec_mutex[1]; +static struct timeval hwrec_time; +static int hwrec_open_count; +static DECLARE_WAIT_QUEUE_HEAD(hwrec_wait_queue); +static int hwrec_event; + +/* add extra locking to keep us from overwriting things during dumping. */ +static int hwrec_event_open_count; +static int hwrec_event_file_lock; + +void +pvr_hwrec_dump(void) +{ + mutex_lock(hwrec_mutex); + + if (hwrec_open_count || hwrec_event_file_lock) { + pr_err("%s: previous hwrec dump is still locked!\n", __func__); + mutex_unlock(hwrec_mutex); + return; + } + + do_gettimeofday(&hwrec_time); + pr_info("HW Recovery dump generated at %010ld%06ld\n", + hwrec_time.tv_sec, hwrec_time.tv_usec); + + hwrec_event = 1; + + mutex_unlock(hwrec_mutex); + + wake_up_interruptible(&hwrec_wait_queue); +} + +/* + * helpers. + */ +static int +hwrec_file_open(struct inode *inode, struct file *filp) +{ + mutex_lock(hwrec_mutex); + + hwrec_open_count++; + + mutex_unlock(hwrec_mutex); + return 0; +} + +static int +hwrec_file_release(struct inode *inode, struct file *filp) +{ + mutex_lock(hwrec_mutex); + + hwrec_open_count--; + + mutex_unlock(hwrec_mutex); + return 0; +} + +/* + * Provides a hwrec timestamp for unique dumping. + */ +static ssize_t +hwrec_time_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + char tmp[20]; + + mutex_lock(hwrec_mutex); + snprintf(tmp, sizeof(tmp), "%010ld%06ld", + hwrec_time.tv_sec, hwrec_time.tv_usec); + mutex_unlock(hwrec_mutex); + + return simple_read_from_buffer(buf, size, f_pos, tmp, strlen(tmp)); +} + +static const struct file_operations hwrec_time_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = hwrec_time_read, + .open = hwrec_file_open, + .release = hwrec_file_release, +}; + +/* + * Blocks the reader until a HWRec happens. + */ +static int +hwrec_event_open(struct inode *inode, struct file *filp) +{ + int ret; + + mutex_lock(hwrec_mutex); + + if (hwrec_event_open_count) + ret = -EUSERS; + else { + hwrec_event_open_count++; + ret = 0; + } + + mutex_unlock(hwrec_mutex); + + return ret; +} + +static int +hwrec_event_release(struct inode *inode, struct file *filp) +{ + mutex_lock(hwrec_mutex); + + hwrec_event_open_count--; + + mutex_unlock(hwrec_mutex); + + return 0; +} + + +static ssize_t +hwrec_event_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + int ret = 0; + + mutex_lock(hwrec_mutex); + + hwrec_event_file_lock = 0; + + mutex_unlock(hwrec_mutex); + + ret = wait_event_interruptible(hwrec_wait_queue, hwrec_event); + if (!ret) { + mutex_lock(hwrec_mutex); + + hwrec_event = 0; + hwrec_event_file_lock = 1; + + mutex_unlock(hwrec_mutex); + } + + return ret; +} + +static const struct file_operations hwrec_event_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = hwrec_event_read, + .open = hwrec_event_open, + .release = hwrec_event_release, +}; + +/* + * */ int pvr_debugfs_init(void) { + mutex_init(hwrec_mutex); + debugfs_dir = debugfs_create_dir("pvr", NULL); if (!debugfs_dir) return -ENODEV; @@ -178,6 +338,18 @@ int pvr_debugfs_init(void) return -ENODEV; } + if (!debugfs_create_file("hwrec_event", S_IRUSR, debugfs_dir, NULL, + &hwrec_event_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + + if (!debugfs_create_file("hwrec_time", S_IRUSR, debugfs_dir, NULL, + &hwrec_time_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + return 0; } diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index 6adc51b..6ec216e 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2010-2011 Imre Deak <imre.deak@nokia.com> + * Copyright (c) 2010-2011 Luc Verhaegen <libv@codethink.co.uk> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -26,4 +27,6 @@ int pvr_debugfs_init(void); void pvr_debugfs_cleanup(void); +void pvr_hwrec_dump(void); + #endif /* _PVR_DEBUGFS_H_ */ diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 8f88052..8518d22 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -58,6 +58,10 @@ #include "pvrversion.h" #include "sgx_options.h" +#ifdef CONFIG_DEBUG_FS +#include "pvr_debugfs.h" +#endif + static IMG_BOOL SGX_ISRHandler(void *pvData); static u32 gui32EventStatusServicesByISR; @@ -987,6 +991,10 @@ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) dump_edm(psDevInfo); dump_sgx_state_bufs(psDeviceNode); +#ifdef CONFIG_DEBUG_FS + pvr_hwrec_dump(); +#endif + PDUMPSUSPEND(); do { -- 1.7.5.4 From 366cd20548887307d7cd049141b03d323e223417 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:35 +0100 Subject: [PATCH 19/95] gpu: pvr: debugfs: add hwrec register dump Full register dump available after hwrec event in the file hwrec_regs. The full register page is read out, except [0xA08,0xA50] as this range results in a SIGBUS. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 142 ++++++++++++++++++++++++++++++++++++++++- drivers/gpu/pvr/pvr_debugfs.h | 2 +- drivers/gpu/pvr/sgxinit.c | 2 +- 3 files changed, 143 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index d549133..54f899e 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -27,6 +27,7 @@ #include <linux/vmalloc.h> #include <linux/mutex.h> #include <linux/uaccess.h> +#include <linux/io.h> #include "img_types.h" #include "servicesext.h" @@ -175,8 +176,33 @@ static int hwrec_event; static int hwrec_event_open_count; static int hwrec_event_file_lock; +/* While these could get moved into PVRSRV_SGXDEV_INFO, the more future-proof + * way of handling hw recovery events is by providing 1 single hwrecovery dump + * at a time, and adding a hwrec_info debugfs file with: process information, + * general driver information, and the instance of the (then multicore) pvr + * where the hwrec event happened. + */ +static u32 *hwrec_registers; + +static void +hwrec_registers_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) +{ + int i; + + if (!hwrec_registers) { + hwrec_registers = (u32 *) __get_free_page(GFP_KERNEL); + if (!hwrec_registers) { + pr_err("%s: failed to get free page.\n", __func__); + return; + } + } + + for (i = 0; i < 1024; i++) + hwrec_registers[i] = readl(psDevInfo->pvRegsBaseKM + 4 * i); +} + void -pvr_hwrec_dump(void) +pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) { mutex_lock(hwrec_mutex); @@ -190,6 +216,8 @@ pvr_hwrec_dump(void) pr_info("HW Recovery dump generated at %010ld%06ld\n", hwrec_time.tv_sec, hwrec_time.tv_usec); + hwrec_registers_dump(psDevInfo); + hwrec_event = 1; mutex_unlock(hwrec_mutex); @@ -222,6 +250,43 @@ hwrec_file_release(struct inode *inode, struct file *filp) return 0; } +static loff_t +hwrec_llseek_helper(struct file *filp, loff_t offset, int whence, loff_t max) +{ + loff_t f_pos; + + switch (whence) { + case SEEK_SET: + if ((offset > max) || (offset < 0)) + f_pos = -EINVAL; + else + f_pos = offset; + break; + case SEEK_CUR: + if (((filp->f_pos + offset) > max) || + ((filp->f_pos + offset) < 0)) + f_pos = -EINVAL; + else + f_pos = filp->f_pos + offset; + break; + case SEEK_END: + if ((offset > 0) || + (offset < -max)) + f_pos = -EINVAL; + else + f_pos = max + offset; + break; + default: + f_pos = -EINVAL; + break; + } + + if (f_pos >= 0) + filp->f_pos = f_pos; + + return f_pos; +} + /* * Provides a hwrec timestamp for unique dumping. */ @@ -316,6 +381,72 @@ static const struct file_operations hwrec_event_fops = { }; /* + * Reads out all readable registers. + */ +#define HWREC_REGS_LINE_SIZE 17 + +static loff_t +hwrec_regs_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(hwrec_mutex); + + if (hwrec_registers) + f_pos = hwrec_llseek_helper(filp, offset, whence, + 1024 * HWREC_REGS_LINE_SIZE); + else + f_pos = 0; + + mutex_unlock(hwrec_mutex); + + return f_pos; +} + +static ssize_t +hwrec_regs_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + char tmp[HWREC_REGS_LINE_SIZE + 1]; + int i; + + if ((*f_pos < 0) || (size < (sizeof(tmp) - 1))) + return 0; + + i = ((int) *f_pos) / (sizeof(tmp) - 1); + if (i >= 1024) + return 0; + + mutex_lock(hwrec_mutex); + + if (!hwrec_registers) + size = 0; + else + size = snprintf(tmp, sizeof(tmp), "0x%03X 0x%08X\n", i * 4, + hwrec_registers[i]); + + mutex_unlock(hwrec_mutex); + + if (size > 0) { + if (copy_to_user(buf, tmp + *f_pos - (i * (sizeof(tmp) - 1)), + size)) + return -EFAULT; + + *f_pos += size; + return size; + } else + return 0; +} + +static const struct file_operations hwrec_regs_fops = { + .owner = THIS_MODULE, + .llseek = hwrec_regs_llseek, + .read = hwrec_regs_read, + .open = hwrec_file_open, + .release = hwrec_file_release, +}; + +/* * */ int pvr_debugfs_init(void) @@ -350,10 +481,19 @@ int pvr_debugfs_init(void) return -ENODEV; } + if (!debugfs_create_file("hwrec_regs", S_IRUSR, debugfs_dir, NULL, + &hwrec_regs_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + return 0; } void pvr_debugfs_cleanup(void) { debugfs_remove_recursive(debugfs_dir); + + if (hwrec_registers) + free_page((u32) hwrec_registers); } diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index 6ec216e..327ef0e 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -27,6 +27,6 @@ int pvr_debugfs_init(void); void pvr_debugfs_cleanup(void); -void pvr_hwrec_dump(void); +void pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo); #endif /* _PVR_DEBUGFS_H_ */ diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 8518d22..fcf4321 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -992,7 +992,7 @@ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) dump_sgx_state_bufs(psDeviceNode); #ifdef CONFIG_DEBUG_FS - pvr_hwrec_dump(); + pvr_hwrec_dump(psDevInfo); #endif PDUMPSUSPEND(); -- 1.7.5.4 From 788ae30b934aafcd296856c7e31aa561f90bcd5c Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:36 +0100 Subject: [PATCH 20/95] gpu: pvr: debugfs: add hwrec context dump A full context is now provided through hwrec_mem. This includes page directory, page tables and all mapped pages. This code is only built when debugfs is enabled, and when build type is "Debug". Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/mmu.c | 105 +++++++++++++++++++++++++ drivers/gpu/pvr/mmu.h | 5 + drivers/gpu/pvr/pvr_debugfs.c | 172 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_debugfs.h | 6 ++ 4 files changed, 288 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index 7b9f0af..2f54255 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -37,6 +37,11 @@ #include "sgxinfokm.h" #include "mmu.h" +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_PVR_DEBUG) +#include "pvr_debugfs.h" +#include <linux/io.h> +#endif + #define UINT32_MAX_VALUE 0xFFFFFFFFUL struct MMU_PT_INFO { @@ -1437,3 +1442,103 @@ u32 mmu_get_page_dir(struct MMU_CONTEXT *psMMUContext) { return psMMUContext->sPDDevPAddr.uiAddr; } + + +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_PVR_DEBUG) + +static int +hwrec_mem_dump_page(u32 dev_p_addr) +{ + void __iomem *page; + + page = ioremap_nocache(dev_p_addr, SGX_MMU_PAGE_SIZE); + if (!page) + return -EFAULT; + + /* Loop through all the pages and dump them */ + hwrec_mem_print("<PAGE PA:0x%08X>\n", dev_p_addr); + hwrec_mem_write((void __force *) page, PAGE_SIZE); + hwrec_mem_print("</PAGE>\n"); + + iounmap(page); + + return 0; +} + +static int +hwrec_mem_dump_table(u32 dev_p_addr) +{ + void __iomem *pt; + u32 i; + + pt = ioremap_nocache(dev_p_addr, SGX_MMU_PAGE_SIZE); + if (!pt) + return -EFAULT; + + /* Loop through all the page tables and dump them */ + hwrec_mem_print("<TABLE PA:0x%08X>\n", dev_p_addr); + for (i = 0 ; i < 1024 ; i++) + hwrec_mem_print("0x%08X\n", readl(pt + 4 * i)); + hwrec_mem_print("</TABLE>\n"); + + for (i = 0; i < 1024; i++) { + u32 addr = readl(pt + 4 * i); + + if (addr & SGX_MMU_PDE_VALID) + hwrec_mem_dump_page(addr & SGX_MMU_PDE_ADDR_MASK); + } + + iounmap(pt); + + return 0; +} + +static int +hwrec_mem_dump_dir(struct MMU_CONTEXT *context) +{ + void __iomem *pd = (void __force __iomem *) context->pvPDCpuVAddr; + + int i; + + hwrec_mem_print("<DIR PA:0x%08X>\n", context->sPDDevPAddr); + + for (i = 0; i < 1024; i++) + hwrec_mem_print("0x%08X\n", readl(pd + 4 * i)); + + hwrec_mem_print("</DIR>\n"); + + for (i = 0; i < 1024; i++) { + u32 addr = readl(pd + 4 * i); + + if (addr & SGX_MMU_PDE_VALID) + hwrec_mem_dump_table(addr & SGX_MMU_PDE_ADDR_MASK); + } + + return 0; +} + +int +mmu_hwrec_mem_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) +{ + struct MMU_CONTEXT *context = psDevInfo->pvMMUContextList; + u32 page_dir; + + page_dir = readl(psDevInfo->pvRegsBaseKM + EUR_CR_BIF_DIR_LIST_BASE0); + + while (context) { + if (context->sPDDevPAddr.uiAddr == page_dir) + break; + + context = context->psNext; + } + + if (!context) { + pr_err("Unable to find matching context for page directory" + " 0x%08X\n", page_dir); + return -EFAULT; + } + + return hwrec_mem_dump_dir(context); +} + +#endif /* CONFIG_DEBUG_FS && CONFIG_PVR_DEBUG */ diff --git a/drivers/gpu/pvr/mmu.h b/drivers/gpu/pvr/mmu.h index 003f0c5..229b49f 100644 --- a/drivers/gpu/pvr/mmu.h +++ b/drivers/gpu/pvr/mmu.h @@ -83,4 +83,9 @@ enum PVRSRV_ERROR MMU_BIFResetPDAlloc(struct PVRSRV_SGXDEV_INFO *psDevInfo); void MMU_BIFResetPDFree(struct PVRSRV_SGXDEV_INFO *psDevInfo); u32 mmu_get_page_dir(struct MMU_CONTEXT *pMMUContext); + +#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_PVR_DEBUG) +int mmu_hwrec_mem_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo); #endif + +#endif /* _MMU_H_ */ diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 54f899e..e5fb7a0 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -37,6 +37,7 @@ #include "pvr_bridge_km.h" #include "sgxutils.h" #include "pvr_debugfs.h" +#include "mmu.h" static struct dentry *debugfs_dir; static u32 pvr_reset; @@ -184,6 +185,12 @@ static int hwrec_event_file_lock; */ static u32 *hwrec_registers; +#ifdef CONFIG_PVR_DEBUG +static size_t hwrec_mem_size; +#define HWREC_MEM_PAGES (4 * PAGE_SIZE) +static unsigned long hwrec_mem_pages[HWREC_MEM_PAGES]; +#endif /* CONFIG_PVR_DEBUG */ + static void hwrec_registers_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) { @@ -201,6 +208,90 @@ hwrec_registers_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) hwrec_registers[i] = readl(psDevInfo->pvRegsBaseKM + 4 * i); } +static void +hwrec_pages_free(size_t *size, u32 *pages) +{ + int i; + + if (!(*size)) + return; + + for (i = 0; (i * PAGE_SIZE) < *size; i++) { + free_page(pages[i]); + pages[i] = 0; + } + + *size = 0; +} + +static int +hwrec_pages_write(u8 *buffer, size_t size, size_t *current_size, u32 *pages, + int array_size) +{ + size_t ret = 0; + + while (size) { + size_t count = size; + size_t offset = *current_size & ~PAGE_MASK; + int page = *current_size / PAGE_SIZE; + + if (!offset) { + if (((*current_size) / PAGE_SIZE) >= array_size) { + pr_err("%s: Size overrun!\n", __func__); + return -ENOMEM; + } + + pages[page] = __get_free_page(GFP_KERNEL); + if (!pages[page]) { + pr_err("%s: failed to get free page.\n", + __func__); + return -ENOMEM; + } + } + + if (count > (PAGE_SIZE - offset)) + count = PAGE_SIZE - offset; + + memcpy(((u8 *) pages[page]) + offset, buffer, count); + + buffer += count; + size -= count; + ret += count; + *current_size += count; + } + + return ret; +} + +#ifdef CONFIG_PVR_DEBUG +static void +hwrec_mem_free(void) +{ + hwrec_pages_free(&hwrec_mem_size, hwrec_mem_pages); +} + +int +hwrec_mem_write(u8 *buffer, size_t size) +{ + return hwrec_pages_write(buffer, size, &hwrec_mem_size, + hwrec_mem_pages, ARRAY_SIZE(hwrec_mem_pages)); +} + +int +hwrec_mem_print(char *format, ...) +{ + char tmp[25]; + va_list ap; + size_t size; + + va_start(ap, format); + size = vscnprintf(tmp, sizeof(tmp), format, ap); + va_end(ap); + + return hwrec_mem_write(tmp, size); +} +#endif /* CONFIG_PVR_DEBUG */ + void pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) { @@ -218,6 +309,11 @@ pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) hwrec_registers_dump(psDevInfo); +#ifdef CONFIG_PVR_DEBUG + hwrec_mem_free(); + mmu_hwrec_mem_dump(psDevInfo); +#endif /* CONFIG_PVR_DEBUG */ + hwrec_event = 1; mutex_unlock(hwrec_mutex); @@ -446,6 +542,69 @@ static const struct file_operations hwrec_regs_fops = { .release = hwrec_file_release, }; +#ifdef CONFIG_PVR_DEBUG +/* + * Provides a full context dump: page directory, page tables, and all mapped + * pages. + */ +static loff_t +hwrec_mem_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(hwrec_mutex); + + if (hwrec_mem_size) + f_pos = hwrec_llseek_helper(filp, offset, whence, + hwrec_mem_size); + else + f_pos = 0; + + mutex_unlock(hwrec_mutex); + + return f_pos; +} + +static ssize_t +hwrec_mem_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + mutex_lock(hwrec_mutex); + + if ((*f_pos >= 0) && (*f_pos < hwrec_mem_size)) { + int page, offset; + + size = min(size, (size_t) hwrec_mem_size - (size_t) *f_pos); + + page = (*f_pos) / PAGE_SIZE; + offset = (*f_pos) & ~PAGE_MASK; + + size = min(size, (size_t) PAGE_SIZE - offset); + + if (copy_to_user(buf, + ((u8 *) hwrec_mem_pages[page]) + offset, + size)) { + mutex_unlock(hwrec_mutex); + return -EFAULT; + } + } else + size = 0; + + mutex_unlock(hwrec_mutex); + + *f_pos += size; + return size; +} + +static const struct file_operations hwrec_mem_fops = { + .owner = THIS_MODULE, + .llseek = hwrec_mem_llseek, + .read = hwrec_mem_read, + .open = hwrec_file_open, + .release = hwrec_file_release, +}; +#endif /* CONFIG_PVR_DEBUG */ + /* * */ @@ -487,6 +646,14 @@ int pvr_debugfs_init(void) return -ENODEV; } +#ifdef CONFIG_PVR_DEBUG + if (!debugfs_create_file("hwrec_mem", S_IRUSR, debugfs_dir, NULL, + &hwrec_mem_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } +#endif /* CONFIG_PVR_DEBUG */ + return 0; } @@ -496,4 +663,9 @@ void pvr_debugfs_cleanup(void) if (hwrec_registers) free_page((u32) hwrec_registers); + +#ifdef CONFIG_PVR_DEBUG + hwrec_mem_free(); +#endif /* CONFIG_PVR_DEBUG */ + } diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index 327ef0e..b9d7ebb 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -29,4 +29,10 @@ void pvr_debugfs_cleanup(void); void pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo); +#ifdef CONFIG_PVR_DEBUG +/* to be used for memory dumping from mmu.c */ +int hwrec_mem_write(u8 *buffer, size_t size); +int hwrec_mem_print(char *format, ...); +#endif + #endif /* _PVR_DEBUGFS_H_ */ -- 1.7.5.4 From f53f860e93c62a45bd4fb00f53dfbaa26cf43b67 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:37 +0100 Subject: [PATCH 21/95] gpu: pvr: debugfs: add hwrec edm trace And move all edm trace printing code to pvr_debugfs.c; since now only debugfs/pvr/edm_trace and debugfs/pvr/hwrec_edm use it. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 154 ++++++++++++++++++++++++++++++++++++++--- drivers/gpu/pvr/sgxinfokm.h | 16 ---- drivers/gpu/pvr/sgxinit.c | 63 ----------------- 3 files changed, 144 insertions(+), 89 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index e5fb7a0..b9d32a3 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -110,38 +110,97 @@ static int pvr_debugfs_set(void *data, u64 val) DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_fops, NULL, pvr_debugfs_set, "%llu\n"); +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG /* * */ +#define SGXMK_TRACE_BUFFER_SIZE 512 +#define SGXMK_TRACE_BUF_STR_LEN 80 + struct edm_buf_info { size_t len; char data[1]; }; -static int pvr_debugfs_edm_open(struct inode *inode, struct file *file) +static size_t +edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) +{ + u32 *buf_start; + u32 *buf_end; + u32 *buf; + size_t p = 0; + size_t wr_ofs; + int i; + + if (!sdev->psKernelEDMStatusBufferMemInfo) + return 0; + + buf = sdev->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; + + p += snprintf(dst + p, dst_len - p, + "Last SGX microkernel status code: 0x%x\n", *buf); + buf++; + wr_ofs = *buf; + buf++; + + buf_start = buf; + buf_end = buf + SGXMK_TRACE_BUFFER_SIZE * 4; + + buf += wr_ofs * 4; + + /* Dump the status values */ + for (i = 0; i < SGXMK_TRACE_BUFFER_SIZE; i++) { + p += snprintf(dst + p, dst_len - p, "%3d %08X %08X %08X %08X\n", + i, buf[2], buf[3], buf[1], buf[0]); + buf += 4; + if (buf >= buf_end) + buf = buf_start; + } + + return p > dst_len ? dst_len : p; +} + +static struct edm_buf_info * +pvr_edm_buffer_create(struct PVRSRV_SGXDEV_INFO *sgx_info) { - struct PVRSRV_DEVICE_NODE *node; - struct PVRSRV_SGXDEV_INFO *sgx_info; struct edm_buf_info *bi; size_t size; /* Take a snapshot of the EDM trace buffer */ size = SGXMK_TRACE_BUFFER_SIZE * SGXMK_TRACE_BUF_STR_LEN; bi = vmalloc(sizeof(*bi) + size); - if (!bi) - return -ENOMEM; + if (!bi) { + pr_err("%s: vmalloc failed!\n", __func__); + return NULL; + } + + bi->len = edm_trace_print(sgx_info, bi->data, size); + + return bi; +} + +static void +pvr_edm_buffer_destroy(struct edm_buf_info *edm) +{ + vfree(edm); +} + +static int pvr_debugfs_edm_open(struct inode *inode, struct file *file) +{ + struct PVRSRV_DEVICE_NODE *node; node = get_sgx_node(); - sgx_info = node->pvDevice; - bi->len = snprint_edm_trace(sgx_info, bi->data, size); - file->private_data = bi; + + file->private_data = pvr_edm_buffer_create(node->pvDevice); + if (!file->private_data) + return -ENOMEM; return 0; } static int pvr_debugfs_edm_release(struct inode *inode, struct file *file) { - vfree(file->private_data); + pvr_edm_buffer_destroy(file->private_data); return 0; } @@ -160,7 +219,7 @@ static const struct file_operations pvr_debugfs_edm_fops = { .read = pvr_debugfs_edm_read, .release = pvr_debugfs_edm_release, }; - +#endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ /* * @@ -191,6 +250,10 @@ static size_t hwrec_mem_size; static unsigned long hwrec_mem_pages[HWREC_MEM_PAGES]; #endif /* CONFIG_PVR_DEBUG */ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG +static struct edm_buf_info *hwrec_edm_buf; +#endif + static void hwrec_registers_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) { @@ -314,6 +377,12 @@ pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) mmu_hwrec_mem_dump(psDevInfo); #endif /* CONFIG_PVR_DEBUG */ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + if (hwrec_edm_buf) + pvr_edm_buffer_destroy(hwrec_edm_buf); + hwrec_edm_buf = pvr_edm_buffer_create(psDevInfo); +#endif + hwrec_event = 1; mutex_unlock(hwrec_mutex); @@ -606,6 +675,57 @@ static const struct file_operations hwrec_mem_fops = { #endif /* CONFIG_PVR_DEBUG */ /* + * Read out edm trace created before HW recovery reset. + */ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG +static loff_t +hwrec_edm_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(hwrec_mutex); + + if (hwrec_edm_buf) + f_pos = hwrec_llseek_helper(filp, offset, whence, + hwrec_edm_buf->len); + else + f_pos = 0; + + mutex_unlock(hwrec_mutex); + + return f_pos; +} + +static ssize_t +hwrec_edm_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + ssize_t ret; + + mutex_lock(hwrec_mutex); + + if (hwrec_edm_buf) + ret = simple_read_from_buffer(buf, size, f_pos, + hwrec_edm_buf->data, + hwrec_edm_buf->len); + else + ret = 0; + + mutex_unlock(hwrec_mutex); + + return ret; +} + +static const struct file_operations hwrec_edm_fops = { + .owner = THIS_MODULE, + .llseek = hwrec_edm_llseek, + .read = hwrec_edm_read, + .open = hwrec_file_open, + .release = hwrec_file_release, +}; +#endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ + +/* * */ int pvr_debugfs_init(void) @@ -622,11 +742,13 @@ int pvr_debugfs_init(void) return -ENODEV; } +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG if (!debugfs_create_file("edm_trace", S_IRUGO, debugfs_dir, NULL, &pvr_debugfs_edm_fops)) { debugfs_remove_recursive(debugfs_dir); return -ENODEV; } +#endif if (!debugfs_create_file("hwrec_event", S_IRUSR, debugfs_dir, NULL, &hwrec_event_fops)) { @@ -654,6 +776,14 @@ int pvr_debugfs_init(void) } #endif /* CONFIG_PVR_DEBUG */ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + if (!debugfs_create_file("hwrec_edm", S_IRUSR, debugfs_dir, NULL, + &hwrec_edm_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } +#endif + return 0; } @@ -668,4 +798,8 @@ void pvr_debugfs_cleanup(void) hwrec_mem_free(); #endif /* CONFIG_PVR_DEBUG */ +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + if (hwrec_edm_buf) + pvr_edm_buffer_destroy(hwrec_edm_buf); +#endif } diff --git a/drivers/gpu/pvr/sgxinfokm.h b/drivers/gpu/pvr/sgxinfokm.h index 4191842..6722e0b 100644 --- a/drivers/gpu/pvr/sgxinfokm.h +++ b/drivers/gpu/pvr/sgxinfokm.h @@ -56,9 +56,6 @@ #define PVRSRV_USSE_MISCINFO_READY 0x1UL -#define SGXMK_TRACE_BUFFER_SIZE 512 -#define SGXMK_TRACE_BUF_STR_LEN 80 - struct PVRSRV_SGX_CCB_INFO; struct PVRSRV_SGXDEV_INFO { @@ -253,19 +250,6 @@ enum PVRSRV_ERROR SGXDevInitCompatCheck(struct PVRSRV_DEVICE_NODE void SysGetSGXTimingInformation(struct SGX_TIMING_INFORMATION *psSGXTimingInfo); -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined(CONFIG_DEBUG_FS) -size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *buf, - size_t buf_size); -#else -static inline size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, - char *buf, size_t buf_size) -{ - return 0; -} -#endif - - - #if defined(NO_HARDWARE) static inline void NoHardwareGenerateEvent(struct PVRSRV_SGXDEV_INFO *psDevInfo, u32 ui32StatusRegister, diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index fcf4321..2b5612d 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -619,68 +619,6 @@ static enum PVRSRV_ERROR DevDeInitSGX(void *pvDeviceNode) return PVRSRV_OK; } -#if defined(PVRSRV_USSE_EDM_STATUS_DEBUG) || defined(CONFIG_DEBUG_FS) - -static size_t __print_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, - size_t dst_len) -{ - u32 *buf_start; - u32 *buf_end; - u32 *buf; - size_t p = 0; - size_t wr_ofs; - int i; - -#define _PR(fmt, ...) do { \ - if (dst) \ - p += snprintf(dst + p, dst_len - p, fmt, ## __VA_ARGS__); \ - else \ - printk(KERN_DEBUG fmt, ## __VA_ARGS__); \ -} while (0) - - if (!sdev->psKernelEDMStatusBufferMemInfo) - return 0; - - buf = sdev->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; - - _PR("Last SGX microkernel status code: 0x%x\n", *buf); - buf++; - wr_ofs = *buf; - buf++; - - buf_start = buf; - buf_end = buf + SGXMK_TRACE_BUFFER_SIZE * 4; - - buf += wr_ofs * 4; - - /* Dump the status values */ - for (i = 0; i < SGXMK_TRACE_BUFFER_SIZE; i++) { - _PR("%3d %08X %08X %08X %08X\n", - i, buf[2], buf[3], buf[1], buf[0]); - buf += 4; - if (buf >= buf_end) - buf = buf_start; - } - - return p > dst_len ? dst_len : p; -#undef _PR -} - -size_t snprint_edm_trace(struct PVRSRV_SGXDEV_INFO *sdev, char *buf, - size_t buf_size) -{ - return __print_edm_trace(sdev, buf, buf_size); -} - -#endif - -static void dump_edm(struct PVRSRV_SGXDEV_INFO *sdev) -{ -#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG - __print_edm_trace(sdev, NULL, 0); -#endif -} - static struct PVRSRV_PER_PROCESS_DATA *find_cur_proc_data( struct PVRSRV_DEVICE_NODE *dev) { @@ -988,7 +926,6 @@ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) dump_process_info(psDeviceNode); dump_sgx_registers(psDevInfo); - dump_edm(psDevInfo); dump_sgx_state_bufs(psDeviceNode); #ifdef CONFIG_DEBUG_FS -- 1.7.5.4 From e6ccb44d3faa1c4b323d00400efec331c4aeab9e Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 22 Mar 2011 12:38:38 +0100 Subject: [PATCH 22/95] gpu: pvr: debugfs: add hwrec status buffer dumping Move code over from sgxinit.c, and dump status buffers in binary format to a debugfs file instead of sending it as %08X's to syslog. Shares process info from the top level now, instead of acquiring this information several times. This now also prints the caller of the HWRecovery routine. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 329 ++++++++++++++++++++++++++++++++++++++++- drivers/gpu/pvr/pvr_debugfs.h | 3 +- drivers/gpu/pvr/sgxinfokm.h | 3 +- drivers/gpu/pvr/sgxinit.c | 274 +++------------------------------- 4 files changed, 353 insertions(+), 256 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index b9d32a3..3c3b30a 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -38,6 +38,8 @@ #include "sgxutils.h" #include "pvr_debugfs.h" #include "mmu.h" +#include "bridged_support.h" +#include "mm.h" static struct dentry *debugfs_dir; static u32 pvr_reset; @@ -89,7 +91,7 @@ static int pvr_debugfs_reset(void *data, u64 val) goto exit; } - HWRecoveryResetSGX(node); + HWRecoveryResetSGX(node, __func__); SGXTestActivePowerEvent(node); exit: @@ -355,8 +357,260 @@ hwrec_mem_print(char *format, ...) } #endif /* CONFIG_PVR_DEBUG */ +/* + * Render status buffer dumping. + */ +static size_t hwrec_status_size; +static u32 hwrec_status_pages[1024]; + +static int +hwrec_status_write(char *buffer, size_t size) +{ + return hwrec_pages_write(buffer, size, &hwrec_status_size, + hwrec_status_pages, + ARRAY_SIZE(hwrec_status_pages)); +} + +static void +hwrec_status_free(void) +{ + hwrec_pages_free(&hwrec_status_size, hwrec_status_pages); +} + +static int +hwrec_status_print(char *format, ...) +{ + char tmp[25]; + va_list ap; + size_t size; + + va_start(ap, format); + size = vscnprintf(tmp, sizeof(tmp), format, ap); + va_end(ap); + + return hwrec_status_write(tmp, size); +} + +#define BUF_DESC_CORRUPT (1 << 31) + +static void add_uniq_items(struct render_state_buf_list *dst, + const struct render_state_buf_list *src) +{ + int i; + + for (i = 0; i < src->cnt; i++) { + const struct render_state_buf_info *sbinf = &src->info[i]; + int j; + + for (j = 0; j < dst->cnt; j++) { + if (sbinf->buf_id == dst->info[j].buf_id) { + if (memcmp(sbinf, &dst->info[j], sizeof(sbinf))) + dst->info[j].type |= BUF_DESC_CORRUPT; + break; + } + } + if (j == dst->cnt) { + /* Bound for cnt is guaranteed by the caller */ + dst->info[dst->cnt] = *sbinf; + dst->cnt++; + } + } +} + +static struct render_state_buf_list *create_merged_uniq_list( + struct render_state_buf_list **bl_set, int set_size) +{ + int i; + struct render_state_buf_list *dbl; + size_t size; + + /* + * Create a buf list big enough to contain all elements from each + * list in bl_set. + */ + size = offsetof(struct render_state_buf_list, info[0]); + for (i = 0; i < set_size; i++) { + if (!bl_set[i]) + continue; + size += bl_set[i]->cnt * sizeof(bl_set[i]->info[0]); + } + if (!size) + return NULL; + dbl = kmalloc(size, GFP_KERNEL); + if (!dbl) + return NULL; + + dbl->cnt = 0; + for (i = 0; i < set_size; i++) { + if (bl_set[i]) + add_uniq_items(dbl, bl_set[i]); + } + + return dbl; +} + +static void *vmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, off_t offset, size_t size) +{ + struct PVRSRV_KERNEL_MEM_INFO *minfo; + struct LinuxMemArea *mem_area; + enum PVRSRV_ERROR err; + unsigned start_ofs; + unsigned end_ofs; + int pg_cnt; + struct page **pages; + void *map = NULL; + int i; + + if (offset & PAGE_MASK) + return NULL; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return NULL; + if (minfo->pvLinAddrKM) + return minfo->pvLinAddrKM; + + err = PVRSRVLookupOSMemHandle(proc->psHandleBase, (void *)&mem_area, + (void *)handle); + if (err != PVRSRV_OK) + return NULL; + + start_ofs = offset & PAGE_MASK; + end_ofs = PAGE_ALIGN(offset + size); + pg_cnt = (end_ofs - start_ofs) >> PAGE_SHIFT; + pages = kmalloc(pg_cnt * sizeof(pages[0]), GFP_KERNEL); + if (!pages) + return NULL; + for (i = 0; i < pg_cnt; i++) { + unsigned pfn; + + pfn = LinuxMemAreaToCpuPFN(mem_area, start_ofs); + if (!pfn_valid(pfn)) + goto err; + pages[i] = pfn_to_page(pfn); + start_ofs += PAGE_SIZE; + } + map = vmap(pages, pg_cnt, VM_MAP, PAGE_KERNEL); + map += offset; +err: + kfree(pages); + + return map; +} + +static void vunmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, void *map) +{ + struct PVRSRV_KERNEL_MEM_INFO *minfo; + enum PVRSRV_ERROR err; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return; + if (minfo->pvLinAddrKM) + return; + vunmap((void *)(((unsigned long)map) & PAGE_MASK)); +} + +static void dump_buf(void *start, size_t size, u32 type) +{ + char *corr = ""; + + if (type & BUF_DESC_CORRUPT) { + type &= ~BUF_DESC_CORRUPT; + corr = "(corrupt)"; + } + hwrec_status_print("<type %d%s size %d>\n", type, corr, size); + hwrec_status_write(start, size); +} + +static struct render_state_buf_list *get_state_buf_list( + struct PVRSRV_PER_PROCESS_DATA *proc, + u32 handle, off_t offset) +{ + struct PVRSRV_KERNEL_MEM_INFO *container; + struct render_state_buf_list *buf; + enum PVRSRV_ERROR err; + + err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&container, + (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); + if (err != PVRSRV_OK) + return NULL; + if (!container->pvLinAddrKM) + return NULL; + if (offset + sizeof(*buf) > container->ui32AllocSize) + return NULL; + + buf = container->pvLinAddrKM + offset; + + if (buf->cnt > ARRAY_SIZE(buf->info)) + return NULL; + + return buf; +} + +static void dump_state_buf_list(struct PVRSRV_PER_PROCESS_DATA *proc, + struct render_state_buf_list *bl) +{ + int i; + + if (!bl->cnt) + return; + + pr_info("Dumping %d render state buffers\n", bl->cnt); + for (i = 0; i < bl->cnt; i++) { + struct render_state_buf_info *binfo; + void *map; + + binfo = &bl->info[i]; + + map = vmap_buf(proc, binfo->buf_id, binfo->offset, binfo->size); + if (!map) + continue; + dump_buf(map, binfo->size, binfo->type); + + vunmap_buf(proc, binfo->buf_id, map); + } +} + +static void dump_sgx_state_bufs(struct PVRSRV_PER_PROCESS_DATA *proc, + struct PVRSRV_SGXDEV_INFO *dev_info) +{ + struct SGXMKIF_HOST_CTL __iomem *hctl = dev_info->psSGXHostCtl; + struct render_state_buf_list *bl_set[2] = { NULL }; + struct render_state_buf_list *mbl; + u32 handle_ta; + u32 handle_3d; + + if (!proc) + return; + + handle_ta = readl(&hctl->render_state_buf_ta_handle); + handle_3d = readl(&hctl->render_state_buf_3d_handle); + bl_set[0] = get_state_buf_list(proc, handle_ta, + dev_info->state_buf_ofs); + /* + * The two buf list can be the same if the TA and 3D phases used the + * same context at the time of the HWrec. In this case just ignore + * one of them. + */ + if (handle_ta != handle_3d) + bl_set[1] = get_state_buf_list(proc, handle_3d, + dev_info->state_buf_ofs); + mbl = create_merged_uniq_list(bl_set, ARRAY_SIZE(bl_set)); + if (!mbl) + return; + + dump_state_buf_list(proc, mbl); + kfree(mbl); +} + void -pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) +pvr_hwrec_dump(struct PVRSRV_PER_PROCESS_DATA *proc_data, + struct PVRSRV_SGXDEV_INFO *psDevInfo) { mutex_lock(hwrec_mutex); @@ -383,6 +637,9 @@ pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) hwrec_edm_buf = pvr_edm_buffer_create(psDevInfo); #endif + hwrec_status_free(); + dump_sgx_state_bufs(proc_data, psDevInfo); + hwrec_event = 1; mutex_unlock(hwrec_mutex); @@ -726,6 +983,66 @@ static const struct file_operations hwrec_edm_fops = { #endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ /* + * Provides a dump of the TA and 3D status buffers. + */ +static loff_t +hwrec_status_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(hwrec_mutex); + + if (hwrec_status_size) + f_pos = hwrec_llseek_helper(filp, offset, whence, + hwrec_status_size); + else + f_pos = 0; + + mutex_unlock(hwrec_mutex); + + return f_pos; +} + +static ssize_t +hwrec_status_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + mutex_lock(hwrec_mutex); + + if ((*f_pos >= 0) && (*f_pos < hwrec_status_size)) { + int page, offset; + + size = min(size, (size_t) hwrec_status_size - (size_t) *f_pos); + + page = (*f_pos) / PAGE_SIZE; + offset = (*f_pos) & ~PAGE_MASK; + + size = min(size, (size_t) PAGE_SIZE - offset); + + if (copy_to_user(buf, + ((u8 *) hwrec_status_pages[page]) + offset, + size)) { + mutex_unlock(hwrec_mutex); + return -EFAULT; + } + } else + size = 0; + + mutex_unlock(hwrec_mutex); + + *f_pos += size; + return size; +} + +static const struct file_operations hwrec_status_fops = { + .owner = THIS_MODULE, + .llseek = hwrec_status_llseek, + .read = hwrec_status_read, + .open = hwrec_file_open, + .release = hwrec_file_release, +}; + +/* * */ int pvr_debugfs_init(void) @@ -784,6 +1101,12 @@ int pvr_debugfs_init(void) } #endif + if (!debugfs_create_file("hwrec_status", S_IRUSR, debugfs_dir, NULL, + &hwrec_status_fops)) { + debugfs_remove_recursive(debugfs_dir); + return -ENODEV; + } + return 0; } @@ -802,4 +1125,6 @@ void pvr_debugfs_cleanup(void) if (hwrec_edm_buf) pvr_edm_buffer_destroy(hwrec_edm_buf); #endif + + hwrec_status_free(); } diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index b9d7ebb..72bf34b 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -27,7 +27,8 @@ int pvr_debugfs_init(void); void pvr_debugfs_cleanup(void); -void pvr_hwrec_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo); +void pvr_hwrec_dump(struct PVRSRV_PER_PROCESS_DATA *proc_data, + struct PVRSRV_SGXDEV_INFO *psDevInfo); #ifdef CONFIG_PVR_DEBUG /* to be used for memory dumping from mmu.c */ diff --git a/drivers/gpu/pvr/sgxinfokm.h b/drivers/gpu/pvr/sgxinfokm.h index 6722e0b..2517e04 100644 --- a/drivers/gpu/pvr/sgxinfokm.h +++ b/drivers/gpu/pvr/sgxinfokm.h @@ -214,7 +214,8 @@ struct timer_work_data * SGXOSTimerInit(struct PVRSRV_DEVICE_NODE *psDeviceNode); void SGXOSTimerDeInit(struct timer_work_data *data); -void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode); +void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode, + const char *caller); void SGXReset(struct PVRSRV_SGXDEV_INFO *psDevInfo, u32 ui32PDUMPFlags); enum PVRSRV_ERROR SGXInitialise(struct PVRSRV_SGXDEV_INFO *psDevInfo, diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 2b5612d..1942ba6 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -639,25 +639,22 @@ static struct PVRSRV_PER_PROCESS_DATA *find_cur_proc_data( return proc_data; } -static void dump_process_info(struct PVRSRV_DEVICE_NODE *dev) +static void pr_err_process_info(struct PVRSRV_PER_PROCESS_DATA *proc) { - struct PVRSRV_PER_PROCESS_DATA *proc; - - proc = find_cur_proc_data(dev); + struct task_struct *tsk; + int pid; - if (proc) { - struct task_struct *tsk; - int pid; + if (!proc) + return; - pid = proc->ui32PID; - rcu_read_lock(); - tsk = pid_task(find_vpid(pid), PIDTYPE_PID); - pr_err("PID = %d, process name = %s\n", pid, tsk->comm); - rcu_read_unlock(); - } + pid = proc->ui32PID; + rcu_read_lock(); + tsk = pid_task(find_vpid(pid), PIDTYPE_PID); + pr_err("PID = %d, process name = %s\n", pid, tsk->comm); + rcu_read_unlock(); } -static void dump_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) +static void pr_err_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) { pr_err("EVENT_STATUS = 0x%08X\n" "EVENT_STATUS2 = 0x%08X\n" @@ -675,244 +672,16 @@ static void dump_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) readl(psDevInfo->pvRegsBaseKM + EUR_CR_CLKGATECTL)); } -#define BUF_DESC_CORRUPT (1 << 31) - -static void add_uniq_items(struct render_state_buf_list *dst, - const struct render_state_buf_list *src) -{ - int i; - - for (i = 0; i < src->cnt; i++) { - const struct render_state_buf_info *sbinf = &src->info[i]; - int j; - - for (j = 0; j < dst->cnt; j++) { - if (sbinf->buf_id == dst->info[j].buf_id) { - if (memcmp(sbinf, &dst->info[j], sizeof(sbinf))) - dst->info[j].type |= BUF_DESC_CORRUPT; - break; - } - } - if (j == dst->cnt) { - /* Bound for cnt is guaranteed by the caller */ - dst->info[dst->cnt] = *sbinf; - dst->cnt++; - } - } -} - -static struct render_state_buf_list *create_merged_uniq_list( - struct render_state_buf_list **bl_set, int set_size) -{ - int i; - struct render_state_buf_list *dbl; - size_t size; - - /* - * Create a buf list big enough to contain all elements from each - * list in bl_set. - */ - size = offsetof(struct render_state_buf_list, info[0]); - for (i = 0; i < set_size; i++) { - if (!bl_set[i]) - continue; - size += bl_set[i]->cnt * sizeof(bl_set[i]->info[0]); - } - if (!size) - return NULL; - dbl = kmalloc(size, GFP_KERNEL); - if (!dbl) - return NULL; - - dbl->cnt = 0; - for (i = 0; i < set_size; i++) { - if (bl_set[i]) - add_uniq_items(dbl, bl_set[i]); - } - - return dbl; -} - -static void *vmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, - u32 handle, off_t offset, size_t size) -{ - struct PVRSRV_KERNEL_MEM_INFO *minfo; - struct LinuxMemArea *mem_area; - enum PVRSRV_ERROR err; - unsigned start_ofs; - unsigned end_ofs; - int pg_cnt; - struct page **pages; - void *map; - int i; - - if (offset & PAGE_MASK) - return NULL; - - err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, - (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); - if (err != PVRSRV_OK) - return NULL; - if (minfo->pvLinAddrKM) - return minfo->pvLinAddrKM; - - err = PVRSRVLookupOSMemHandle(proc->psHandleBase, (void *)&mem_area, - (void *)handle); - if (err != PVRSRV_OK) - return NULL; - - start_ofs = offset & PAGE_MASK; - end_ofs = PAGE_ALIGN(offset + size); - pg_cnt = (end_ofs - start_ofs) >> PAGE_SHIFT; - pages = kmalloc(pg_cnt * sizeof(pages[0]), GFP_KERNEL); - if (!pages) - return NULL; - for (i = 0; i < pg_cnt; i++) { - unsigned pfn; - - pfn = LinuxMemAreaToCpuPFN(mem_area, start_ofs); - if (!pfn_valid(pfn)) - goto err; - pages[i] = pfn_to_page(pfn); - start_ofs += PAGE_SIZE; - } - map = vmap(pages, pg_cnt, VM_MAP, PAGE_KERNEL); - map += offset; -err: - kfree(pages); - - return map; -} - -static void vunmap_buf(struct PVRSRV_PER_PROCESS_DATA *proc, - u32 handle, void *map) -{ - struct PVRSRV_KERNEL_MEM_INFO *minfo; - enum PVRSRV_ERROR err; - - err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&minfo, - (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); - if (err != PVRSRV_OK) - return; - if (minfo->pvLinAddrKM) - return; - vunmap((void *)(((unsigned long)map) & PAGE_MASK)); -} - -static void dump_buf(void *start, size_t size, u32 type) -{ - unsigned addr = 0; - char *corr = ""; - - if (type & BUF_DESC_CORRUPT) { - type &= ~BUF_DESC_CORRUPT; - corr = "(corrupt)"; - } - printk(KERN_DEBUG "type %d%s size %d\n", type, corr, size); - while (addr < size) { - if (!(addr % 16)) { - if (addr) - printk("\n"); - printk(KERN_DEBUG "%08x ", addr); - } - printk("%08x ", *(u32 *)(start + addr)); - addr += 4; - } - if (addr) - printk("\n"); -} - -static struct render_state_buf_list *get_state_buf_list( - struct PVRSRV_PER_PROCESS_DATA *proc, - u32 handle, off_t offset) -{ - struct PVRSRV_KERNEL_MEM_INFO *container; - struct render_state_buf_list *buf; - enum PVRSRV_ERROR err; - - err = PVRSRVLookupHandle(proc->psHandleBase, (void **)&container, - (void *)handle, PVRSRV_HANDLE_TYPE_MEM_INFO); - if (err != PVRSRV_OK) - return NULL; - if (!container->pvLinAddrKM) - return NULL; - if (offset + sizeof(*buf) > container->ui32AllocSize) - return NULL; - - buf = container->pvLinAddrKM + offset; - - if (buf->cnt > ARRAY_SIZE(buf->info)) - return NULL; - - return buf; -} - -static void dump_state_buf_list(struct PVRSRV_PER_PROCESS_DATA *proc, - struct render_state_buf_list *bl) -{ - int i; - - if (!bl->cnt) - return; - - printk(KERN_DEBUG "Dumping %d render state buffers\n", bl->cnt); - for (i = 0; i < bl->cnt; i++) { - struct render_state_buf_info *binfo; - void *map; - - binfo = &bl->info[i]; - - map = vmap_buf(proc, binfo->buf_id, binfo->offset, binfo->size); - if (!map) - continue; - dump_buf(map, binfo->size, binfo->type); - - vunmap_buf(proc, binfo->buf_id, map); - } -} - -static void dump_sgx_state_bufs(struct PVRSRV_DEVICE_NODE *dev_node) -{ - struct PVRSRV_SGXDEV_INFO *dev_info = dev_node->pvDevice; - struct SGXMKIF_HOST_CTL __iomem *hctl = dev_info->psSGXHostCtl; - struct PVRSRV_PER_PROCESS_DATA *proc; - struct render_state_buf_list *bl_set[2] = { NULL }; - struct render_state_buf_list *mbl; - u32 handle_ta; - u32 handle_3d; - - proc = find_cur_proc_data(dev_node); - if (!proc) - return; - - handle_ta = readl(&hctl->render_state_buf_ta_handle); - handle_3d = readl(&hctl->render_state_buf_3d_handle); - bl_set[0] = get_state_buf_list(proc, handle_ta, - dev_info->state_buf_ofs); - /* - * The two buf list can be the same if the TA and 3D phases used the - * same context at the time of the HWrec. In this case just ignore - * one of them. - */ - if (handle_ta != handle_3d) - bl_set[1] = get_state_buf_list(proc, handle_3d, - dev_info->state_buf_ofs); - mbl = create_merged_uniq_list(bl_set, ARRAY_SIZE(bl_set)); - if (!mbl) - return; - - dump_state_buf_list(proc, mbl); - kfree(mbl); -} - /* Should be called with pvr_lock held */ -void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) +void +HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode, const char *caller) { enum PVRSRV_ERROR eError; struct PVRSRV_SGXDEV_INFO *psDevInfo = (struct PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; struct SGXMKIF_HOST_CTL __iomem *psSGXHostCtl = psDevInfo->psSGXHostCtl; + struct PVRSRV_PER_PROCESS_DATA *proc; u32 l; int max_retries = 10; @@ -922,14 +691,15 @@ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode) l |= PVRSRV_USSE_EDM_INTERRUPT_HWR; writel(l, &psSGXHostCtl->ui32InterruptClearFlags); - pr_err("%s: SGX Hardware Recovery triggered\n", __func__); + pr_err("SGX Hardware Recovery triggered (from %s)\n", caller); + + proc = find_cur_proc_data(psDeviceNode); - dump_process_info(psDeviceNode); - dump_sgx_registers(psDevInfo); - dump_sgx_state_bufs(psDeviceNode); + pr_err_process_info(proc); + pr_err_sgx_registers(psDevInfo); #ifdef CONFIG_DEBUG_FS - pvr_hwrec_dump(psDevInfo); + pvr_hwrec_dump(proc, psDevInfo); #endif PDUMPSUSPEND(); @@ -1029,7 +799,7 @@ static void SGXOSTimer(struct work_struct *work) l++; writel(l, &psSGXHostCtl->ui32HostDetectedLockups); - HWRecoveryResetSGX(psDeviceNode); + HWRecoveryResetSGX(psDeviceNode, __func__); pvr_dev_unlock(); } @@ -1167,7 +937,7 @@ static void SGX_MISRHandler(void *pvData) if ((l1 & PVRSRV_USSE_EDM_INTERRUPT_HWR) && !(l2 & PVRSRV_USSE_EDM_INTERRUPT_HWR)) - HWRecoveryResetSGX(psDeviceNode); + HWRecoveryResetSGX(psDeviceNode, __func__); if (psDeviceNode->bReProcessDeviceCommandComplete) SGXScheduleProcessQueues(psDeviceNode); -- 1.7.5.4 From 7a7574929524d179160774dd31c91d65edc98dbd Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:21 +0100 Subject: [PATCH 23/95] gpu: pvr: pdump: SYS_DATA::bPowerUpPDumped is unused Nothing in the graphics stack uses this. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 9 --------- drivers/gpu/pvr/pvrsrv.c | 4 ---- drivers/gpu/pvr/syscommon.h | 2 +- 3 files changed, 1 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 7409816..0c24a68 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1481,15 +1481,6 @@ static int PVRSRVConnectBW(u32 ui32BridgeID, void *psBridgeIn, psConnectServicesOUT->hKernelServices = psPerProc->hPerProcData; psConnectServicesOUT->eError = PVRSRV_OK; -#if defined(PDUMP) - - { - struct SYS_DATA *psSysData; - SysAcquireData(&psSysData); - psSysData->bPowerUpPDumped = IMG_FALSE; - } -#endif - return 0; } diff --git a/drivers/gpu/pvr/pvrsrv.c b/drivers/gpu/pvr/pvrsrv.c index 332e000..72365ea 100644 --- a/drivers/gpu/pvr/pvrsrv.c +++ b/drivers/gpu/pvr/pvrsrv.c @@ -146,10 +146,6 @@ enum PVRSRV_ERROR PVRSRVInit(struct SYS_DATA *psSysData) psSysData->eCurrentPowerState = PVRSRV_POWER_STATE_D0; psSysData->eFailedPowerState = PVRSRV_POWER_Unspecified; -#if defined(PDUMP) - psSysData->bPowerUpPDumped = IMG_FALSE; -#endif - if (OSAllocMem(PVRSRV_PAGEABLE_SELECT, sizeof(struct PVRSRV_EVENTOBJECT), (void **) &psSysData->psGlobalEventObject, diff --git a/drivers/gpu/pvr/syscommon.h b/drivers/gpu/pvr/syscommon.h index c55ac38..5201210 100644 --- a/drivers/gpu/pvr/syscommon.h +++ b/drivers/gpu/pvr/syscommon.h @@ -78,7 +78,7 @@ struct SYS_DATA { char *pszVersionString; struct PVRSRV_EVENTOBJECT *psGlobalEventObject; #if defined(PDUMP) - IMG_BOOL bPowerUpPDumped; + IMG_BOOL Unused; #endif }; -- 1.7.5.4 From ca984651633b9845cec51b34426a61f33f2f0e94 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:22 +0100 Subject: [PATCH 24/95] gpu: pvr: pdump: consolidate some code inside PDUMP defines No functional changes. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/buffer_manager.c | 36 ++++++------- drivers/gpu/pvr/mmu.c | 111 ++++++++++++++++++-------------------- drivers/gpu/pvr/pdump_km.h | 7 +-- 3 files changed, 71 insertions(+), 83 deletions(-) diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index 8f1190c..a4109b4 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1090,21 +1090,10 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, struct BM_MAPPING *pMapping, u32 uFlags, u32 dev_vaddr_alignment, struct IMG_DEV_VIRTADDR *pDevVAddr) { - struct PVRSRV_DEVICE_NODE *psDeviceNode; -#ifdef PDUMP - u32 ui32PDumpSize = pMapping->uSize; -#endif - - psDeviceNode = pBMContext->psDeviceNode; + struct PVRSRV_DEVICE_NODE *psDeviceNode = pBMContext->psDeviceNode; if (uFlags & PVRSRV_MEM_INTERLEAVED) - pMapping->uSize *= 2; -#ifdef PDUMP - if (uFlags & PVRSRV_MEM_DUMMY) - - ui32PDumpSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; -#endif if (!psDeviceNode->pfnMMUAlloc(pMapping->pBMHeap->pMMUHeap, pMapping->uSize, 0, dev_vaddr_alignment, @@ -1113,11 +1102,21 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, return IMG_FALSE; } - PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, - pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, - pMapping->hOSMemHandle, ui32PDumpSize, - pMapping->pBMHeap->sDevArena.ui32DataPageSize, - (void *)pMapping); +#ifdef PDUMP + { + u32 ui32PDumpSize = pMapping->uSize; + + if (uFlags & PVRSRV_MEM_DUMMY) + ui32PDumpSize = + pMapping->pBMHeap->sDevArena.ui32DataPageSize; + + PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, + pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, + pMapping->hOSMemHandle, ui32PDumpSize, + pMapping->pBMHeap->sDevArena.ui32DataPageSize, + (void *)pMapping); + } +#endif switch (pMapping->eCpuMemoryOrigin) { case hm_wrapped: @@ -1176,9 +1175,6 @@ static void DevMemoryFree(struct BM_MAPPING *pMapping) struct PVRSRV_DEVICE_NODE *psDeviceNode; #ifdef PDUMP u32 ui32PSize; -#endif - -#ifdef PDUMP if (pMapping->ui32Flags & PVRSRV_MEM_DUMMY) ui32PSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index 2f54255..ed7b111 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -72,13 +72,6 @@ struct MMU_HEAP { struct DEV_ARENA_DESCRIPTOR *psDevArena; }; - -#if defined(PDUMP) -static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, - struct IMG_DEV_VIRTADDR DevVAddr, size_t uSize, - IMG_BOOL bForUnmap, void *hUniqueTag); -#endif - #define PAGE_TEST 0 @@ -698,6 +691,58 @@ void MMU_InsertHeap(struct MMU_CONTEXT *psMMUContext, MMU_InvalidateDirectoryCache(psMMUContext->psDevInfo); } +#if defined(PDUMP) +static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, + struct IMG_DEV_VIRTADDR DevVAddr, + size_t uSize, IMG_BOOL bForUnmap, void *hUniqueTag) +{ + u32 ui32NumPTEntries; + u32 ui32PTIndex; + u32 *pui32PTEntry; + + struct MMU_PT_INFO **ppsPTInfoList; + u32 ui32PDIndex; + u32 ui32PTDumpCount; + + ui32NumPTEntries = + (uSize + SGX_MMU_PAGE_SIZE - 1) >> SGX_MMU_PAGE_SHIFT; + + ui32PDIndex = + DevVAddr.uiAddr >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); + + ppsPTInfoList = &pMMUHeap->psMMUContext->apsPTInfoList[ui32PDIndex]; + + ui32PTIndex = (DevVAddr.uiAddr & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; + + PDUMPCOMMENT("Page table mods (num entries == %08X) %s", + ui32NumPTEntries, bForUnmap ? "(for unmap)" : ""); + + while (ui32NumPTEntries > 0) { + struct MMU_PT_INFO *psPTInfo = *ppsPTInfoList++; + + if (ui32NumPTEntries <= 1024 - ui32PTIndex) + ui32PTDumpCount = ui32NumPTEntries; + else + ui32PTDumpCount = 1024 - ui32PTIndex; + + if (psPTInfo) { + pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; + PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, + (void *)&pui32PTEntry[ui32PTIndex], + ui32PTDumpCount * sizeof(u32), 0, + IMG_FALSE, PDUMP_PT_UNIQUETAG, hUniqueTag); + } + + ui32NumPTEntries -= ui32PTDumpCount; + + ui32PTIndex = 0; + } + + PDUMPCOMMENT("Finished page table mods %s", + bForUnmap ? "(for unmap)" : ""); +} +#endif + static void MMU_UnmapPagesAndFreePTs(struct MMU_HEAP *psMMUHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32PageCount, void *hUniqueTag) @@ -948,58 +993,6 @@ void MMU_Disable(struct MMU_HEAP *pMMUHeap) } -#if defined(PDUMP) -static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, - struct IMG_DEV_VIRTADDR DevVAddr, - size_t uSize, IMG_BOOL bForUnmap, void *hUniqueTag) -{ - u32 ui32NumPTEntries; - u32 ui32PTIndex; - u32 *pui32PTEntry; - - struct MMU_PT_INFO **ppsPTInfoList; - u32 ui32PDIndex; - u32 ui32PTDumpCount; - - ui32NumPTEntries = - (uSize + SGX_MMU_PAGE_SIZE - 1) >> SGX_MMU_PAGE_SHIFT; - - ui32PDIndex = - DevVAddr.uiAddr >> (SGX_MMU_PAGE_SHIFT + SGX_MMU_PT_SHIFT); - - ppsPTInfoList = &pMMUHeap->psMMUContext->apsPTInfoList[ui32PDIndex]; - - ui32PTIndex = (DevVAddr.uiAddr & SGX_MMU_PT_MASK) >> SGX_MMU_PAGE_SHIFT; - - PDUMPCOMMENT("Page table mods (num entries == %08X) %s", - ui32NumPTEntries, bForUnmap ? "(for unmap)" : ""); - - while (ui32NumPTEntries > 0) { - struct MMU_PT_INFO *psPTInfo = *ppsPTInfoList++; - - if (ui32NumPTEntries <= 1024 - ui32PTIndex) - ui32PTDumpCount = ui32NumPTEntries; - else - ui32PTDumpCount = 1024 - ui32PTIndex; - - if (psPTInfo) { - pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *)&pui32PTEntry[ui32PTIndex], - ui32PTDumpCount * sizeof(u32), 0, - IMG_FALSE, PDUMP_PT_UNIQUETAG, hUniqueTag); - } - - ui32NumPTEntries -= ui32PTDumpCount; - - ui32PTIndex = 0; - } - - PDUMPCOMMENT("Finished page table mods %s", - bForUnmap ? "(for unmap)" : ""); -} -#endif - static void MMU_MapPage(struct MMU_HEAP *pMMUHeap, struct IMG_DEV_VIRTADDR DevVAddr, struct IMG_DEV_PHYADDR DevPAddr, u32 ui32MemFlags) diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 958c333..1f2a498 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -37,10 +37,6 @@ #define PDUMP_PD_UNIQUETAG ((void *)0) #define PDUMP_PT_UNIQUETAG ((void *)0) -#ifndef PDUMP -#define MAKEUNIQUETAG(hMemInfo) (0) -#endif - #ifdef PDUMP #define MAKEUNIQUETAG(hMemInfo) \ @@ -222,6 +218,9 @@ void PDumpResumeKM(void); #define PDUMPRESUME PDumpResumeKM #else + +#define MAKEUNIQUETAG(hMemInfo) (0) + #define PDUMPMEMPOL(args...) #define PDUMPMEM(args...) #define PDUMPMEM2(args...) -- 1.7.5.4 From 4a20d902550845502a015b490b83f47ad642b1c7 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:23 +0100 Subject: [PATCH 25/95] gpu: pvr: pdump: remove unused bridge calls Userspace never calls _PDUMP_DRIVERINFO, _PDUMP_DUMPREADREG, _PDUMP_STARTINITPHASE, or _PDUMP_STOPINITPHASE. So remove the respective handlers and the pdump code. No functional change. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 83 +++------------------------------- drivers/gpu/pvr/pdump.c | 71 ++--------------------------- drivers/gpu/pvr/pdump_km.h | 9 ---- 3 files changed, 12 insertions(+), 151 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 0c24a68..139adb9 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1187,42 +1187,6 @@ static int PDumpBitmapBW(u32 ui32BridgeID, return 0; } -static int PDumpReadRegBW(u32 ui32BridgeID, - struct PVRSRV_BRIDGE_IN_PDUMP_READREG *psPDumpReadRegIN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, - struct PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_DUMPREADREG); - PVR_UNREFERENCED_PARAMETER(psPerProc); - - psRetOUT->eError = PDumpReadRegKM(&psPDumpReadRegIN->szFileName[0], - psPDumpReadRegIN->ui32FileOffset, - psPDumpReadRegIN->ui32Address, - psPDumpReadRegIN->ui32Size, - psPDumpReadRegIN->ui32Flags); - - return 0; -} - -static int PDumpDriverInfoBW(u32 ui32BridgeID, - struct PVRSRV_BRIDGE_IN_PDUMP_DRIVERINFO *psPDumpDriverInfoIN, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, - struct PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - u32 ui32PDumpFlags; - - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_DRIVERINFO); - PVR_UNREFERENCED_PARAMETER(psPerProc); - - ui32PDumpFlags = 0; - if (psPDumpDriverInfoIN->bContinuous) - ui32PDumpFlags |= PDUMP_FLAGS_CONTINUOUS; - psRetOUT->eError = PDumpDriverInfoKM(&psPDumpDriverInfoIN->szString[0], - ui32PDumpFlags); - - return 0; -} - static int PDumpSyncDumpBW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_PDUMP_DUMPSYNC *psPDumpSyncDumpIN, struct PVRSRV_BRIDGE_RETURN *psRetOUT, @@ -1345,34 +1309,6 @@ static int PDumpPDDevPAddrBW(u32 ui32BridgeID, return 0; } -static int PDumpStartInitPhaseBW(u32 ui32BridgeID, void *psBridgeIn, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, - struct PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, - PVRSRV_BRIDGE_PDUMP_STARTINITPHASE); - PVR_UNREFERENCED_PARAMETER(psBridgeIn); - PVR_UNREFERENCED_PARAMETER(psPerProc); - - psRetOUT->eError = PDumpStartInitPhaseKM(); - - return 0; -} - -static int PDumpStopInitPhaseBW(u32 ui32BridgeID, void *psBridgeIn, - struct PVRSRV_BRIDGE_RETURN *psRetOUT, - struct PVRSRV_PER_PROCESS_DATA *psPerProc) -{ - PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, - PVRSRV_BRIDGE_PDUMP_STOPINITPHASE); - PVR_UNREFERENCED_PARAMETER(psBridgeIn); - PVR_UNREFERENCED_PARAMETER(psPerProc); - - psRetOUT->eError = PDumpStopInitPhaseKM(); - - return 0; -} - #endif static int PVRSRVGetMiscInfoBW(u32 ui32BridgeID, @@ -2763,20 +2699,17 @@ enum PVRSRV_ERROR CommonBridgeInit(void) SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_ISCAPTURING, PDumpIsCaptureFrameBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPBITMAP, PDumpBitmapBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPREADREG, PDumpReadRegBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPREADREG, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_SYNCPOL, PDumpSyncPolBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPSYNC, PDumpSyncDumpBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DRIVERINFO, - PDumpDriverInfoBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DRIVERINFO, DummyBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_PDREG, PDumpPDRegBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR, PDumpPDDevPAddrBW); SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ, PDumpCycleCountRegReadBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STARTINITPHASE, - PDumpStartInitPhaseBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STOPINITPHASE, - PDumpStopInitPhaseBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STARTINITPHASE, DummyBW); + SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STOPINITPHASE, DummyBW); #endif SetDispatchTableEntry(PVRSRV_BRIDGE_GET_OEMJTABLE, DummyBW); @@ -3042,7 +2975,7 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = PDumpBitmapBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_PDUMP_DUMPREADREG: - err = PDumpReadRegBW(cmd, in, out, per_proc); + err = DummyBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_PDUMP_SYNCPOL: err = PDumpSyncPolBW(cmd, in, out, per_proc); @@ -3051,7 +2984,7 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = PDumpSyncDumpBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_PDUMP_DRIVERINFO: - err = PDumpDriverInfoBW(cmd, in, out, per_proc); + err = DummyBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_PDUMP_PDREG: err = PDumpPDRegBW(cmd, in, out, per_proc); @@ -3063,10 +2996,8 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = PDumpCycleCountRegReadBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_PDUMP_STARTINITPHASE: - err = PDumpStartInitPhaseBW(cmd, in, out, per_proc); - break; case PVRSRV_BRIDGE_PDUMP_STOPINITPHASE: - err = PDumpStopInitPhaseBW(cmd, in, out, per_proc); + err = DummyBW(cmd, in, out, per_proc); break; #endif diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 0dec52f..733c208 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -61,12 +61,10 @@ static struct DBGKM_SERVICE_TABLE *gpfnDbgDrv; #define PDUMP_STREAM_PARAM2 0 #define PDUMP_STREAM_SCRIPT2 1 -#define PDUMP_STREAM_DRIVERINFO 2 -#define PDUMP_NUM_STREAMS 3 +#define PDUMP_NUM_STREAMS 2 static char *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", - "ScriptStream2", - "DriverInfoStream" + "ScriptStream2" }; #define __PDBG_PDUMP_STATE_GET_MSG_STRING(ERROR) \ @@ -213,33 +211,6 @@ void PDumpDeInit(void) gpfnDbgDrv = NULL; } -enum PVRSRV_ERROR PDumpStartInitPhaseKM(void) -{ - u32 i; - - if (gpfnDbgDrv) { - PDUMPCOMMENT("Start Init Phase"); - for (i = 0; i < PDUMP_NUM_STREAMS; i++) - gpfnDbgDrv->pfnStartInitPhase(gsDBGPdumpState. - psStream[i]); - } - return PVRSRV_OK; -} - -enum PVRSRV_ERROR PDumpStopInitPhaseKM(void) -{ - u32 i; - - if (gpfnDbgDrv) { - PDUMPCOMMENT("Stop Init Phase"); - - for (i = 0; i < PDUMP_NUM_STREAMS; i++) - gpfnDbgDrv->pfnStopInitPhase(gsDBGPdumpState. - psStream[i]); - } - return PVRSRV_OK; -} - void PDumpComment(char *pszFormat, ...) { va_list ap; @@ -907,39 +878,6 @@ enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpDriverInfoKM(char *pszString, u32 ui32Flags) -{ - u32 ui32Count = 0; - __PDBG_PDUMP_STATE_GET_MSG_STRING(PVRSRV_ERROR_GENERIC); - - snprintf(pszMsg, SZ_MSG_SIZE_MAX, "%s", pszString); - - while ((pszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) - ui32Count++; - - if ((pszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { - pszMsg[ui32Count] = '\n'; - ui32Count++; - pszMsg[ui32Count] = '\0'; - } - if ((pszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { - pszMsg[ui32Count - 1] = '\r'; - pszMsg[ui32Count] = '\n'; - ui32Count++; - pszMsg[ui32Count] = '\0'; - } - - if (!PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_DRIVERINFO], - (u8 *) pszMsg, ui32Count, ui32Flags)) { - if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) - return PVRSRV_ERROR_GENERIC; - else - return PVRSRV_ERROR_CMD_NOT_PROCESSED; - } - - return PVRSRV_OK; -} - enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, struct IMG_DEV_VIRTADDR sDevBaseAddr, @@ -962,8 +900,9 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags) +static enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Address, u32 ui32Size, + u32 ui32PDumpFlags) { __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(PVRSRV_ERROR_GENERIC); diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 1f2a498..3d9b9a9 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -80,11 +80,8 @@ void PDumpInitCommon(void); void PDumpDeInitCommon(void); void PDumpInit(void); void PDumpDeInit(void); -enum PVRSRV_ERROR PDumpStartInitPhaseKM(void); -enum PVRSRV_ERROR PDumpStopInitPhaseKM(void); enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame); enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags); -enum PVRSRV_ERROR PDumpDriverInfoKM(char *pszString, u32 ui32Flags); enum PVRSRV_ERROR PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Flags); @@ -96,8 +93,6 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, u32 ui32PDumpFlags); -enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags); void PDUMP_REG_FUNC_NAME(u32 dwReg, u32 dwData); void PDumpMsvdxRegRead(const char *const pRegRegion, const u32 dwRegOffset); @@ -205,13 +200,11 @@ void PDumpResumeKM(void); #define PDUMPPDREGWITHFLAGS PDumpPDRegWithFlags #define PDUMPCBP PDumpCBP #define PDUMPMALLOCPAGESPHYS PDumpMallocPagesPhys -#define PDUMPENDINITPHASE PDumpStopInitPhaseKM #define PDUMPMSVDXREGWRITE PDumpMsvdxRegWrite #define PDUMPMSVDXREGREAD PDumpMsvdxRegRead #define PDUMPMSVDXPOL PDumpMsvdxRegPol #define PDUMPMSVDXWRITEREF PDumpMsvdxWriteRef #define PDUMPBITMAPKM PDumpBitmapKM -#define PDUMPDRIVERINFO PDumpDriverInfoKM #define PDUMPIDLWITHFLAGS PDumpIDLWithFlags #define PDUMPIDL PDumpIDL #define PDUMPSUSPEND PDumpSuspendKM @@ -249,14 +242,12 @@ void PDumpResumeKM(void); #define PDUMPCBP(args...) #define PDUMPCOMMENTWITHFLAGS(args...) #define PDUMPMALLOCPAGESPHYS(args...) -#define PDUMPENDINITPHASE(args...) #define PDUMPMSVDXREG(args...) #define PDUMPMSVDXREGWRITE(args...) #define PDUMPMSVDXREGREAD(args...) #define PDUMPMSVDXPOLEQ(args...) #define PDUMPMSVDXPOL(args...) #define PDUMPBITMAPKM(args...) -#define PDUMPDRIVERINFO(args...) #define PDUMPIDLWITHFLAGS(args...) #define PDUMPIDL(args...) #define PDUMPSUSPEND(args...) -- 1.7.5.4 From c8e6f0cdf3c4705c9e3d8b8dabe58155c236789a Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:24 +0100 Subject: [PATCH 26/95] gpu: pvr: pdump: remove unused pdump functions Checked symbols and defines in pdump_km.h, and removed them when unused. sparse then flagged the unused functions in pdump.c and pdump_common.c No functional change. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/dbgdrvif.h | 2 +- drivers/gpu/pvr/pdump.c | 39 ----------------- drivers/gpu/pvr/pdump_common.c | 93 +--------------------------------------- drivers/gpu/pvr/pdump_km.h | 71 +----------------------------- 4 files changed, 5 insertions(+), 200 deletions(-) diff --git a/drivers/gpu/pvr/dbgdrvif.h b/drivers/gpu/pvr/dbgdrvif.h index d8ace97..0e6a110 100644 --- a/drivers/gpu/pvr/dbgdrvif.h +++ b/drivers/gpu/pvr/dbgdrvif.h @@ -284,7 +284,7 @@ struct DBGKM_SERVICE_TABLE { u32 ui32DebugLevel); void (*pfnSetFrame)(struct DBG_STREAM *psStream, u32 ui32Frame); - u32 (*pfnGetFrame)(struct DBG_STREAM *psStream); + u32 (*pfnGetFrame)(struct DBG_STREAM *psStream); /* unused */ void (*pfnOverrideMode)(struct DBG_STREAM *psStream, u32 ui32Mode); void (*pfnDefaultMode)(struct DBG_STREAM *psStream); diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 733c208..5c4b5e4 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -44,13 +44,10 @@ static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags); static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, u32 ui32Flags); static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame); -static u32 DbgGetFrame(struct DBG_STREAM *psStream); static void DbgSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker); static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32BCount, u32 ui32Flags); -#define PDUMP_DATAMASTER_PIXEL 1 - #define MIN(a, b) (a > b ? b : a) #define MAX_FILE_SIZE 0x40000000 @@ -237,12 +234,6 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) PDumpCommentKM(pszMsg, ui32Flags); } -IMG_BOOL PDumpIsLastCaptureFrameKM(void) -{ - return gpfnDbgDrv->pfnIsLastCaptureFrame( - gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2]); -} - IMG_BOOL PDumpIsCaptureFrameKM(void) { if (PDumpSuspended()) @@ -834,14 +825,6 @@ enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame) return PVRSRV_OK; } -static enum PVRSRV_ERROR PDumpGetFrameKM(u32 *pui32Frame) -{ - *pui32Frame = - DbgGetFrame(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2]); - - return PVRSRV_OK; -} - enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) { u32 ui32Count = 0; @@ -975,11 +958,6 @@ static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) gpfnDbgDrv->pfnSetFrame(psStream, ui32Frame); } -static u32 DbgGetFrame(struct DBG_STREAM *psStream) -{ - return gpfnDbgDrv->pfnGetFrame(psStream); -} - static void DbgSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) { gpfnDbgDrv->pfnSetMarker(psStream, ui32Marker); @@ -1019,18 +997,6 @@ static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, return ui32BytesWritten; } -IMG_BOOL PDumpTestNextFrame(u32 ui32CurrentFrame) -{ - IMG_BOOL bFrameDumped; - - bFrameDumped = IMG_FALSE; - PDumpSetFrameKM(ui32CurrentFrame + 1); - bFrameDumped = PDumpIsCaptureFrameKM(); - PDumpSetFrameKM(ui32CurrentFrame); - - return bFrameDumped; -} - void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, IMG_BOOL bLastFrame, u32 *pui32Registers, u32 ui32NumRegisters) { @@ -1192,11 +1158,6 @@ void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) PDumpWriteString2(pszScript, ui32Flags); } -void PDumpIDL(u32 ui32Clocks) -{ - PDumpIDLWithFlags(ui32Clocks, PDUMP_FLAGS_CONTINUOUS); -} - void PDumpSuspendKM(void) { atomic_inc(&gsPDumpSuspended); diff --git a/drivers/gpu/pvr/pdump_common.c b/drivers/gpu/pvr/pdump_common.c index 4f0e6f2f..80c795a 100644 --- a/drivers/gpu/pvr/pdump_common.c +++ b/drivers/gpu/pvr/pdump_common.c @@ -36,10 +36,9 @@ #define PTR_PLUS(t, p, x) ((t *)(((char *)(p)) + (x))) #define VPTR_PLUS(p, x) PTR_PLUS(void, p, x) #define VPTR_INC(p, x) (p = VPTR_PLUS(p, x)) -#define MAX_PDUMP_MMU_CONTEXTS 10 + static void *gpvTempBuffer; static void *ghTempBufferBlockAlloc; -static u16 gui16MMUContextUsage; static void *GetTempBuffer(void) { @@ -144,94 +143,4 @@ enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psPerProc, return PVRSRV_OK; } -static enum PVRSRV_ERROR _PdumpAllocMMUContext(u32 *pui32MMUContextID) -{ - u32 i; - - for (i = 0; i < MAX_PDUMP_MMU_CONTEXTS; i++) - if ((gui16MMUContextUsage & (1UL << i)) == 0) { - gui16MMUContextUsage |= 1UL << i; - *pui32MMUContextID = i; - return PVRSRV_OK; - } - - PVR_DPF(PVR_DBG_ERROR, - "_PdumpAllocMMUContext: no free MMU context ids"); - - return PVRSRV_ERROR_GENERIC; -} - -static enum PVRSRV_ERROR _PdumpFreeMMUContext(u32 ui32MMUContextID) -{ - if (ui32MMUContextID < MAX_PDUMP_MMU_CONTEXTS) { - - gui16MMUContextUsage &= ~(1UL << ui32MMUContextID); - return PVRSRV_OK; - } - - PVR_DPF(PVR_DBG_ERROR, - "_PdumpFreeMMUContext: MMU context ids invalid"); - - return PVRSRV_ERROR_GENERIC; -} - -enum PVRSRV_ERROR PDumpSetMMUContext(enum PVRSRV_DEVICE_TYPE eDeviceType, - char *pszMemSpace, u32 *pui32MMUContextID, - u32 ui32MMUType, void *hUniqueTag1, - void *pvPDCPUAddr) -{ - u8 *pui8LinAddr = (u8 *) pvPDCPUAddr; - struct IMG_CPU_PHYADDR sCpuPAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32MMUContextID; - enum PVRSRV_ERROR eError; - - eError = _PdumpAllocMMUContext(&ui32MMUContextID); - if (eError != PVRSRV_OK) { - PVR_DPF(PVR_DBG_ERROR, - "PDumpSetMMUContext: _PdumpAllocMMUContext failed: %d", - eError); - return eError; - } - - sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - sDevPAddr.uiAddr &= ~PVRSRV_4K_PAGE_SIZE; - - PDumpComment("Set MMU Context\r\n"); - - PDumpComment("MMU :%s:v%d %d :%s:PA_%8.8lX%8.8lX\r\n", - pszMemSpace, ui32MMUContextID, ui32MMUType, pszMemSpace, - hUniqueTag1, sDevPAddr.uiAddr); - - *pui32MMUContextID = ui32MMUContextID; - - return PVRSRV_OK; -} - -enum PVRSRV_ERROR PDumpClearMMUContext(enum PVRSRV_DEVICE_TYPE eDeviceType, - char *pszMemSpace, - u32 ui32MMUContextID, u32 ui32MMUType) -{ - enum PVRSRV_ERROR eError; - - PVR_UNREFERENCED_PARAMETER(eDeviceType); - - PDumpComment("Clear MMU Context\r\n"); - - PDumpComment("MMU :%s:v%d %d\r\n", - pszMemSpace, ui32MMUContextID, ui32MMUType); - - eError = _PdumpFreeMMUContext(ui32MMUContextID); - if (eError != PVRSRV_OK) { - PVR_DPF(PVR_DBG_ERROR, - "PDumpClearMMUContext: _PdumpFreeMMUContext failed: %d", - eError); - return eError; - } - - return PVRSRV_OK; -} - #endif diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 3d9b9a9..78c6585 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -43,8 +43,6 @@ (((struct BM_BUF *)(((struct PVRSRV_KERNEL_MEM_INFO *) \ hMemInfo)->sMemBlk.hBuffer))->pMapping) -#define PDUMP_REG_FUNC_NAME PDumpReg - enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Value, u32 ui32Mask, @@ -65,11 +63,6 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag); -enum PVRSRV_ERROR PDumpMemPagesKM(enum PVRSRV_DEVICE_TYPE eDeviceType, - struct IMG_DEV_PHYADDR *pPages, u32 ui32NumPages, - struct IMG_DEV_VIRTADDR sDevAddr, u32 ui32Start, - u32 ui32Length, u32 ui32Flags, void *hUniqueTag); - enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, u32 ui32Bytes, @@ -93,20 +86,7 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, u32 ui32PDumpFlags); -void PDUMP_REG_FUNC_NAME(u32 dwReg, u32 dwData); - -void PDumpMsvdxRegRead(const char *const pRegRegion, const u32 dwRegOffset); - -void PDumpMsvdxRegWrite(const char *const pRegRegion, const u32 dwRegOffset, - const u32 dwData); - -enum PVRSRV_ERROR PDumpMsvdxRegPol(const char *const pRegRegion, - const u32 ui32Offset, const u32 ui32CheckFuncIdExt, - const u32 ui32RequValue, const u32 ui32Enable, - const u32 ui32PollCount, const u32 ui32TimeOut); - -enum PVRSRV_ERROR PDumpMsvdxWriteRef(const char *const pRegRegion, - const u32 ui32VLROffset, const u32 ui32Physical); +void PDumpReg(u32 dwReg, u32 dwData); void PDumpComment(char *pszFormat, ...); @@ -116,24 +96,13 @@ enum PVRSRV_ERROR PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask, u32 ui32Flags); -IMG_BOOL PDumpIsLastCaptureFrameKM(void); IMG_BOOL PDumpIsCaptureFrameKM(void); void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, u32 ui32PageSize, void *hUniqueTag); -void PDumpMallocPagesPhys(enum PVRSRV_DEVICE_TYPE eDeviceType, - u32 ui32DevVAddr, u32 *pui32PhysPages, u32 ui32NumPages, - void *hUniqueTag); void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); -enum PVRSRV_ERROR PDumpSetMMUContext(enum PVRSRV_DEVICE_TYPE eDeviceType, - char *pszMemSpace, u32 *pui32MMUContextID, - u32 ui32MMUType, void *hUniqueTag1, - void *pvPDCPUAddr); -enum PVRSRV_ERROR PDumpClearMMUContext(enum PVRSRV_DEVICE_TYPE eDeviceType, - char *pszMemSpace, - u32 ui32MMUContextID, u32 ui32MMUType); void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, u32 ui32PageSize, void *hUniqueTag, IMG_BOOL bInterleaved); @@ -147,8 +116,6 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, void *hUniqueTag1, void *hUniqueTag2); -IMG_BOOL PDumpTestNextFrame(u32 ui32CurrentFrame); - void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, IMG_BOOL bLastFrame, u32 *pui32Registers, u32 ui32NumRegisters); @@ -170,7 +137,6 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag); void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags); -void PDumpIDL(u32 ui32Clocks); void PDumpSuspendKM(void); void PDumpResumeKM(void); @@ -181,32 +147,19 @@ void PDumpResumeKM(void); #define PDUMPMEMUM PDumpMemUM #define PDUMPINIT PDumpInitCommon #define PDUMPDEINIT PDumpDeInitCommon -#define PDUMPISLASTFRAME PDumpIsLastCaptureFrameKM -#define PDUMPTESTFRAME PDumpIsCaptureFrameKM -#define PDUMPTESTNEXTFRAME PDumpTestNextFrame #define PDUMPREGWITHFLAGS PDumpRegWithFlagsKM -#define PDUMPREG PDUMP_REG_FUNC_NAME +#define PDUMPREG PDumpReg #define PDUMPCOMMENT PDumpComment #define PDUMPCOMMENTWITHFLAGS PDumpCommentWithFlags #define PDUMPREGPOL PDumpRegPolKM #define PDUMPREGPOLWITHFLAGS PDumpRegPolWithFlagsKM #define PDUMPMALLOCPAGES PDumpMallocPages #define PDUMPMALLOCPAGETABLE PDumpMallocPageTable -#define PDUMPSETMMUCONTEXT PDumpSetMMUContext -#define PDUMPCLEARMMUCONTEXT PDumpClearMMUContext #define PDUMPFREEPAGES PDumpFreePages #define PDUMPFREEPAGETABLE PDumpFreePageTable -#define PDUMPPDREG PDumpPDReg #define PDUMPPDREGWITHFLAGS PDumpPDRegWithFlags #define PDUMPCBP PDumpCBP -#define PDUMPMALLOCPAGESPHYS PDumpMallocPagesPhys -#define PDUMPMSVDXREGWRITE PDumpMsvdxRegWrite -#define PDUMPMSVDXREGREAD PDumpMsvdxRegRead -#define PDUMPMSVDXPOL PDumpMsvdxRegPol -#define PDUMPMSVDXWRITEREF PDumpMsvdxWriteRef -#define PDUMPBITMAPKM PDumpBitmapKM #define PDUMPIDLWITHFLAGS PDumpIDLWithFlags -#define PDUMPIDL PDumpIDL #define PDUMPSUSPEND PDumpSuspendKM #define PDUMPRESUME PDumpResumeKM @@ -220,39 +173,21 @@ void PDumpResumeKM(void); #define PDUMPMEMUM(args...) #define PDUMPINIT(args...) #define PDUMPDEINIT(args...) -#define PDUMPISLASTFRAME(args...) -#define PDUMPTESTFRAME(args...) -#define PDUMPTESTNEXTFRAME(args...) #define PDUMPREGWITHFLAGS(args...) #define PDUMPREG(args...) #define PDUMPCOMMENT(args...) +#define PDUMPCOMMENTWITHFLAGS(args...) #define PDUMPREGPOL(args...) #define PDUMPREGPOLWITHFLAGS(args...) #define PDUMPMALLOCPAGES(args...) #define PDUMPMALLOCPAGETABLE(args...) -#define PDUMPSETMMUCONTEXT(args...) -#define PDUMPCLEARMMUCONTEXT(args...) #define PDUMPFREEPAGES(args...) #define PDUMPFREEPAGETABLE(args...) -#define PDUMPPDREG(args...) #define PDUMPPDREGWITHFLAGS(args...) -#define PDUMPSYNC(args...) -#define PDUMPCOPYTOMEM(args...) -#define PDUMPWRITE(args...) #define PDUMPCBP(args...) -#define PDUMPCOMMENTWITHFLAGS(args...) -#define PDUMPMALLOCPAGESPHYS(args...) -#define PDUMPMSVDXREG(args...) -#define PDUMPMSVDXREGWRITE(args...) -#define PDUMPMSVDXREGREAD(args...) -#define PDUMPMSVDXPOLEQ(args...) -#define PDUMPMSVDXPOL(args...) -#define PDUMPBITMAPKM(args...) #define PDUMPIDLWITHFLAGS(args...) -#define PDUMPIDL(args...) #define PDUMPSUSPEND(args...) #define PDUMPRESUME(args...) -#define PDUMPMSVDXWRITEREF(args...) #endif #endif -- 1.7.5.4 From 5a82b270285a3b51838dd4888ba75d3712a10f0c Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:25 +0100 Subject: [PATCH 27/95] gpu: pvr: pdump: remove lastframe support Userspace does not use this, so no functional change. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 6 +-- drivers/gpu/pvr/bridged_sgx_bridge.c | 4 -- drivers/gpu/pvr/pdump.c | 68 ++++++++++----------------------- drivers/gpu/pvr/pdump_km.h | 17 +++----- drivers/gpu/pvr/sgxpower.c | 2 +- drivers/gpu/pvr/sgxutils.c | 5 +- 6 files changed, 32 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 139adb9..5da331e 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1132,8 +1132,6 @@ static int PDumpMemPolBW(u32 ui32BridgeID, psPDumpMemPolIN->ui32Value, psPDumpMemPolIN->ui32Mask, PDUMP_POLL_OPERATOR_EQUAL, - psPDumpMemPolIN->bLastFrame, - psPDumpMemPolIN->bOverwrite, MAKEUNIQUETAG(pvMemInfo)); return 0; @@ -1244,7 +1242,6 @@ static int PDumpSyncPolBW(u32 ui32BridgeID, psSyncDataMemInfoKM, ui32Offset, psPDumpSyncPolIN->ui32Value, psPDumpSyncPolIN->ui32Mask, PDUMP_POLL_OPERATOR_EQUAL, - IMG_FALSE, IMG_FALSE, MAKEUNIQUETAG(((struct PVRSRV_KERNEL_SYNC_INFO *) pvSyncInfo)->psSyncDataMemInfoKM)); @@ -1276,8 +1273,7 @@ static int PDumpCycleCountRegReadBW(u32 ui32BridgeID, PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ); PVR_UNREFERENCED_PARAMETER(psPerProc); - PDumpCycleCountRegRead(psPDumpCycleCountRegReadIN->ui32RegOffset, - psPDumpCycleCountRegReadIN->bLastFrame); + PDumpCycleCountRegRead(psPDumpCycleCountRegReadIN->ui32RegOffset); psRetOUT->eError = PVRSRV_OK; diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index f31adb6..3a1aaec 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -1501,7 +1501,6 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, PDUMPMEMPOL(psCtrlMemInfoKM, ui32Offset, 0, 0xFFFFFFFF, PDUMP_POLL_OPERATOR_NOTEQUAL, - IMG_FALSE, IMG_FALSE, MAKEUNIQUETAG(psCtrlMemInfoKM)); PDUMPCOMMENTWITHFLAGS(0, @@ -1615,7 +1614,6 @@ int SGXPDump3DSignatureRegistersBW(u32 ui32BridgeID, PDump3DSignatureRegisters(psPDump3DSignatureRegistersIN-> ui32DumpFrameNum, - psPDump3DSignatureRegistersIN->bLastFrame, pui32Registers, psPDump3DSignatureRegistersIN-> ui32NumRegisters); @@ -1665,7 +1663,6 @@ int SGXPDumpCounterRegistersBW(u32 ui32BridgeID, } PDumpCounterRegisters(psPDumpCounterRegistersIN->ui32DumpFrameNum, - psPDumpCounterRegistersIN->bLastFrame, pui32Registers, psPDumpCounterRegistersIN->ui32NumRegisters); @@ -1718,7 +1715,6 @@ int SGXPDumpTASignatureRegistersBW(u32 ui32BridgeID, ui32DumpFrameNum, psPDumpTASignatureRegistersIN-> ui32TAKickCount, - psPDumpTASignatureRegistersIN->bLastFrame, pui32Registers, psPDumpTASignatureRegistersIN-> ui32NumRegisters); diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 5c4b5e4..f72e344 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -474,7 +474,6 @@ void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Value, u32 ui32Mask, enum PDUMP_POLL_OPERATOR eOperator, - IMG_BOOL bLastFrame, IMG_BOOL bOverwrite, void *hUniqueTag) { #define MEMPOLL_DELAY (1000) @@ -484,7 +483,6 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; - u32 ui32Flags; __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); PVR_ASSERT((ui32Offset + sizeof(u32)) <= @@ -496,14 +494,6 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", gsDBGPdumpState.ui32ParamFileNum); - ui32Flags = 0; - - if (bLastFrame) - ui32Flags |= PDUMP_FLAGS_LASTFRAME; - - if (bOverwrite) - ui32Flags |= PDUMP_FLAGS_RESETLFBUFFER; - CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); ui32PageOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); @@ -521,7 +511,7 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, (u32)hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(pszScript, 0); return PVRSRV_OK; } @@ -978,92 +968,76 @@ static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, ui32BytesWritten = gpfnDbgDrv->pfnDBGDrivWrite2(psStream, pui8Data, ui32BCount, 1); - } else if (ui32Flags & PDUMP_FLAGS_LASTFRAME) { - u32 ui32DbgFlags; - - ui32DbgFlags = 0; - if (ui32Flags & PDUMP_FLAGS_RESETLFBUFFER) - ui32DbgFlags |= WRITELF_FLAGS_RESETBUF; - - ui32BytesWritten = - gpfnDbgDrv->pfnWriteLF(psStream, pui8Data, - ui32BCount, 1, ui32DbgFlags); } else { - ui32BytesWritten = - gpfnDbgDrv->pfnWriteBINCM(psStream, pui8Data, - ui32BCount, 1); + ui32BytesWritten = + gpfnDbgDrv->pfnWriteBINCM(psStream, pui8Data, + ui32BCount, 1); } return ui32BytesWritten; } -void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, IMG_BOOL bLastFrame, - u32 *pui32Registers, u32 ui32NumRegisters) +void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters) { - u32 ui32FileOffset, ui32Flags; + u32 ui32FileOffset; u32 i; __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); - ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; ui32FileOffset = 0; - PDUMPCOMMENTWITHFLAGS(ui32Flags, - "\r\n-- Dump 3D signature registers\r\n"); + PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump 3D signature registers\r\n"); snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", ui32DumpFrameNum); for (i = 0; i < ui32NumRegisters; i++) { PDumpReadRegKM(pszFile, ui32FileOffset, pui32Registers[i], - sizeof(u32), ui32Flags); + sizeof(u32), 0); ui32FileOffset += sizeof(u32); } } static void PDumpCountRead(char *pszFileName, u32 ui32Address, u32 ui32Size, - u32 *pui32FileOffset, IMG_BOOL bLastFrame) + u32 *pui32FileOffset) { __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, *pui32FileOffset, pszFileName); - PDumpWriteString2(pszScript, bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0); + PDumpWriteString2(pszScript, 0); *pui32FileOffset += ui32Size; } -void PDumpCounterRegisters(u32 ui32DumpFrameNum, IMG_BOOL bLastFrame, - u32 *pui32Registers, u32 ui32NumRegisters) +void PDumpCounterRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters) { u32 ui32FileOffset; u32 i; __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); - PDUMPCOMMENTWITHFLAGS(bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0, - "\r\n-- Dump counter registers\r\n"); + PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump counter registers\r\n"); snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); ui32FileOffset = 0; for (i = 0; i < ui32NumRegisters; i++) PDumpCountRead(pszFile, pui32Registers[i], sizeof(u32), - &ui32FileOffset, bLastFrame); + &ui32FileOffset); } void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, - IMG_BOOL bLastFrame, u32 *pui32Registers, - u32 ui32NumRegisters) + u32 *pui32Registers, u32 ui32NumRegisters) { - u32 ui32FileOffset, ui32Flags; + u32 ui32FileOffset; u32 i; __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); - ui32Flags = bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0; - PDUMPCOMMENTWITHFLAGS(ui32Flags, - "\r\n-- Dump TA signature registers\r\n"); + PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump TA signature registers\r\n"); snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", ui32DumpFrameNum); @@ -1071,7 +1045,7 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, for (i = 0; i < ui32NumRegisters; i++) { PDumpReadRegKM(pszFile, ui32FileOffset, pui32Registers[i], - sizeof(u32), ui32Flags); + sizeof(u32), 0); ui32FileOffset += sizeof(u32); } } @@ -1085,13 +1059,13 @@ void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) PDumpWriteString2(pszScript, ui32Flags); } -void PDumpCycleCountRegRead(const u32 ui32RegOffset, IMG_BOOL bLastFrame) +void PDumpCycleCountRegRead(const u32 ui32RegOffset) { __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); - PDumpWriteString2(pszScript, bLastFrame ? PDUMP_FLAGS_LASTFRAME : 0); + PDumpWriteString2(pszScript, 0); } void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 78c6585..5d22fb7 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -47,8 +47,6 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Value, u32 ui32Mask, enum PDUMP_POLL_OPERATOR eOperator, - IMG_BOOL bLastFrame, - IMG_BOOL bOverwrite, void *hUniqueTag); enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA @@ -116,19 +114,18 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, void *hUniqueTag1, void *hUniqueTag2); -void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, - u32 ui32TAKickCount, IMG_BOOL bLastFrame, - u32 *pui32Registers, u32 ui32NumRegisters); +void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, + u32 *pui32Registers, u32 ui32NumRegisters); -void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, IMG_BOOL bLastFrame, - u32 *pui32Registers, u32 ui32NumRegisters); +void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters); void PDumpRegRead(const u32 dwRegOffset, u32 ui32Flags); -void PDumpCycleCountRegRead(const u32 dwRegOffset, IMG_BOOL bLastFrame); +void PDumpCycleCountRegRead(const u32 dwRegOffset); -void PDumpCounterRegisters(u32 ui32DumpFrameNum, IMG_BOOL bLastFrame, - u32 *pui32Registers, u32 ui32NumRegisters); +void PDumpCounterRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters); void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, u32 ui32ROffOffset, diff --git a/drivers/gpu/pvr/sgxpower.c b/drivers/gpu/pvr/sgxpower.c index 899613f..551b1a2 100644 --- a/drivers/gpu/pvr/sgxpower.c +++ b/drivers/gpu/pvr/sgxpower.c @@ -309,7 +309,7 @@ static enum PVRSRV_ERROR SGXPrePowerState(void *hDevHandle, PDUMPMEMPOL(psDevInfo->psKernelSGXHostCtlMemInfo, offsetof(struct SGXMKIF_HOST_CTL, ui32PowerStatus), ui32CompleteStatus, ui32CompleteStatus, - PDUMP_POLL_OPERATOR_EQUAL, IMG_FALSE, IMG_FALSE, + PDUMP_POLL_OPERATOR_EQUAL, MAKEUNIQUETAG(psDevInfo-> psKernelSGXHostCtlMemInfo)); #endif diff --git a/drivers/gpu/pvr/sgxutils.c b/drivers/gpu/pvr/sgxutils.c index 2e97811..05973df 100644 --- a/drivers/gpu/pvr/sgxutils.c +++ b/drivers/gpu/pvr/sgxutils.c @@ -175,7 +175,7 @@ enum PVRSRV_ERROR SGXScheduleCCBCommand(struct PVRSRV_SGXDEV_INFO *psDevInfo, PDUMPMEMPOL(psKernelCCB->psCCBCtlMemInfo, offsetof(struct PVRSRV_SGX_CCB_CTL, ui32ReadOffset), (psKernelCCB->ui32CCBDumpWOff + 1) & 0xff, 0xff, - PDUMP_POLL_OPERATOR_NOTEQUAL, IMG_FALSE, IMG_FALSE, + PDUMP_POLL_OPERATOR_NOTEQUAL, MAKEUNIQUETAG(psKernelCCB->psCCBCtlMemInfo)); PDUMPCOMMENTWITHFLAGS(0, "Kernel CCB command\r\n"); @@ -444,8 +444,7 @@ void SGXCleanupRequest(struct PVRSRV_DEVICE_NODE *psDeviceNode, offsetof(struct SGXMKIF_HOST_CTL, ui32ResManFlags), PVRSRV_USSE_EDM_RESMAN_CLEANUP_COMPLETE, PVRSRV_USSE_EDM_RESMAN_CLEANUP_COMPLETE, - PDUMP_POLL_OPERATOR_EQUAL, IMG_FALSE, IMG_FALSE, - hUniqueTag); + PDUMP_POLL_OPERATOR_EQUAL, hUniqueTag); #endif l = readl(&psSGXHostCtl->ui32ResManFlags); -- 1.7.5.4 From dde841d1977b313be2b8514f8cea9322862b4f54 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:26 +0100 Subject: [PATCH 28/95] gpu: pvr: pdump: stop depending on dbgdrvif.h Stop including dbgdrvif.h in pdump.c and add empty skeleton for former dbgdrv functionality. So replace the pointer with callbacks with locally defined, mostly empty, functions. Provide stripped down struct DBG_STREAM and define the still referenced flags inside pdump.c. Only functional change is that the dbgdrv module and the pdump userspace utility are now completely useless. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 194 +++++++++++++++++++++++++++++++---------------- 1 files changed, 127 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index f72e344..dc700b8 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -33,13 +33,26 @@ #include "pvrversion.h" #include "pvr_debug.h" -#include "dbgdrvif.h" #include "sgxmmu.h" #include "mm.h" #include "pdump_km.h" #include <linux/tty.h> +#define DEBUG_CAPMODE_FRAMED 0x00000001 +#define DEBUG_CAPMODE_CONTINUOUS 0x00000002 +#define DEBUG_CAPMODE_HOTKEY 0x00000004 +#define DEBUG_CAPMODE_POSTMORTEM 0x00000008 + +#define DEBUG_OUTMODE_STREAMENABLE 0x00000004 + +struct DBG_STREAM { + u32 ui32CapMode; + u32 ui32Start; + u32 ui32End; + IMG_BOOL bInitPhaseComplete; +}; + static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags); static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, u32 ui32Flags); @@ -54,8 +67,6 @@ static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); -static struct DBGKM_SERVICE_TABLE *gpfnDbgDrv; - #define PDUMP_STREAM_PARAM2 0 #define PDUMP_STREAM_SCRIPT2 1 #define PDUMP_NUM_STREAMS 2 @@ -103,61 +114,115 @@ static inline IMG_BOOL PDumpSuspended(void) return atomic_read(&gsPDumpSuspended) != 0; } +/* + * empty pdump backend. + */ +static void * +DbgDrvCreateStream(char *pszName, u32 ui32CapMode, u32 ui32OutMode, + u32 ui32Flags, u32 ui32Pages) +{ + return NULL; +} + +static void +DbgDrvDestroyStream(struct DBG_STREAM *psStream) +{ + +} + +static void +DbgDrvSetCaptureMode(struct DBG_STREAM *psStream, u32 ui32CapMode, + u32 ui32Start, u32 ui32Stop, u32 ui32SampleRate) +{ + +} + +static void +DbgDrvSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) +{ + +} + +static u32 +DbgDrvDBGDrivWrite2(struct DBG_STREAM *psStream, u8 *pui8InBuf, + u32 ui32InBuffSize, u32 ui32Level) +{ + return ui32InBuffSize; +} + +static u32 +DbgDrvWriteBINCM(struct DBG_STREAM *psStream, u8 *pui8InBuf, + u32 ui32InBuffSize, u32 ui32Level) +{ + return ui32InBuffSize; +} + +static void +DbgDrvSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) +{ + +} + +static u32 +DbgDrvIsCaptureFrame(struct DBG_STREAM *psStream, IMG_BOOL bCheckPreviousFrame) +{ + return 1; +} + +static u32 +DbgDrvGetStreamOffset(struct DBG_STREAM *psStream) +{ + return 0; +} + void PDumpInit(void) { u32 i = 0; - if (!gpfnDbgDrv) { - DBGDrvGetServiceTable((void **) &gpfnDbgDrv); - - if (gpfnDbgDrv == NULL) - return; - - if (!gsDBGPdumpState.pszFile) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_FILENAME_SIZE_MAX, - (void **)&gsDBGPdumpState.pszFile, - NULL) != PVRSRV_OK) - goto init_failed; - - if (!gsDBGPdumpState.pszMsg) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_MSG_SIZE_MAX, - (void **)&gsDBGPdumpState.pszMsg, - NULL) != PVRSRV_OK) - goto init_failed; - - if (!gsDBGPdumpState.pszScript) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_SCRIPT_SIZE_MAX, - (void **)&gsDBGPdumpState.pszScript, - NULL) != PVRSRV_OK) - goto init_failed; - - for (i = 0; i < PDUMP_NUM_STREAMS; i++) { - gsDBGPdumpState.psStream[i] = - gpfnDbgDrv->pfnCreateStream(pszStreamName[i], - DEBUG_CAPMODE_FRAMED, - DEBUG_OUTMODE_STREAMENABLE, - 0, 10); - - gpfnDbgDrv->pfnSetCaptureMode(gsDBGPdumpState. - psStream[i], - DEBUG_CAPMODE_FRAMED, - 0xFFFFFFFF, 0xFFFFFFFF, - 1); - gpfnDbgDrv->pfnSetFrame(gsDBGPdumpState.psStream[i], 0); - } - - PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); - PDUMPCOMMENT("Driver Product Version: %s (%s)", - PVRVERSION_STRING, PVRVERSION_FILE); - PDUMPCOMMENT("Start of Init Phase"); + if (!gsDBGPdumpState.pszFile) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_FILENAME_SIZE_MAX, + (void **)&gsDBGPdumpState.pszFile, + NULL) != PVRSRV_OK) + goto init_failed; + + if (!gsDBGPdumpState.pszMsg) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_MSG_SIZE_MAX, + (void **)&gsDBGPdumpState.pszMsg, + NULL) != PVRSRV_OK) + goto init_failed; + + if (!gsDBGPdumpState.pszScript) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_SCRIPT_SIZE_MAX, + (void **)&gsDBGPdumpState.pszScript, + NULL) != PVRSRV_OK) + goto init_failed; + + for (i = 0; i < PDUMP_NUM_STREAMS; i++) { + gsDBGPdumpState.psStream[i] = + DbgDrvCreateStream(pszStreamName[i], + DEBUG_CAPMODE_FRAMED, + DEBUG_OUTMODE_STREAMENABLE, + 0, 10); + + DbgDrvSetCaptureMode(gsDBGPdumpState. + psStream[i], + DEBUG_CAPMODE_FRAMED, + 0xFFFFFFFF, 0xFFFFFFFF, + 1); + DbgDrvSetFrame(gsDBGPdumpState.psStream[i], 0); } + PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); + PDUMPCOMMENT("Driver Product Version: %s (%s)", + PVRVERSION_STRING, PVRVERSION_FILE); + PDUMPCOMMENT("Start of Init Phase"); + return; -init_failed: + init_failed: if (gsDBGPdumpState.pszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, @@ -176,8 +241,6 @@ init_failed: (void *)gsDBGPdumpState.pszMsg, NULL); gsDBGPdumpState.pszMsg = NULL; } - - gpfnDbgDrv = NULL; } void PDumpDeInit(void) @@ -185,7 +248,7 @@ void PDumpDeInit(void) u32 i = 0; for (i = 0; i < PDUMP_NUM_STREAMS; i++) - gpfnDbgDrv->pfnDestroyStream(gsDBGPdumpState.psStream[i]); + DbgDrvDestroyStream(gsDBGPdumpState.psStream[i]); if (gsDBGPdumpState.pszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, @@ -204,8 +267,6 @@ void PDumpDeInit(void) (void *)gsDBGPdumpState.pszMsg, NULL); gsDBGPdumpState.pszMsg = NULL; } - - gpfnDbgDrv = NULL; } void PDumpComment(char *pszFormat, ...) @@ -238,7 +299,7 @@ IMG_BOOL PDumpIsCaptureFrameKM(void) { if (PDumpSuspended()) return IMG_FALSE; - return gpfnDbgDrv->pfnIsCaptureFrame(gsDBGPdumpState. + return DbgDrvIsCaptureFrame(gsDBGPdumpState. psStream[PDUMP_STREAM_SCRIPT2], IMG_FALSE); } @@ -550,7 +611,7 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, PVR_ASSERT(pui8DataLinAddr); ui32ParamOutPos = - gpfnDbgDrv->pfnGetStreamOffset(gsDBGPdumpState. + DbgDrvGetStreamOffset(gsDBGPdumpState. psStream[PDUMP_STREAM_PARAM2]); if (!PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], @@ -644,7 +705,7 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, return PVRSRV_ERROR_GENERIC; ui32ParamOutPos = - gpfnDbgDrv->pfnGetStreamOffset(gsDBGPdumpState. + DbgDrvGetStreamOffset(gsDBGPdumpState. psStream[PDUMP_STREAM_PARAM2]); if (bInitialisePages) { @@ -753,7 +814,7 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); ui32ParamOutPos = - gpfnDbgDrv->pfnGetStreamOffset(gsDBGPdumpState. + DbgDrvGetStreamOffset(gsDBGPdumpState. psStream[PDUMP_STREAM_PARAM2]); if (!PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], @@ -906,7 +967,7 @@ static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, if (psStream == gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2]) { u32 ui32ParamOutPos = - gpfnDbgDrv->pfnGetStreamOffset(gsDBGPdumpState. + DbgDrvGetStreamOffset(gsDBGPdumpState. psStream [PDUMP_STREAM_PARAM2]); @@ -945,12 +1006,12 @@ static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) { - gpfnDbgDrv->pfnSetFrame(psStream, ui32Frame); + DbgDrvSetFrame(psStream, ui32Frame); } static void DbgSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) { - gpfnDbgDrv->pfnSetMarker(psStream, ui32Marker); + DbgDrvSetMarker(psStream, ui32Marker); } static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, @@ -966,12 +1027,11 @@ static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, ui32BytesWritten = ui32BCount; else ui32BytesWritten = - gpfnDbgDrv->pfnDBGDrivWrite2(psStream, pui8Data, - ui32BCount, 1); + DbgDrvDBGDrivWrite2(psStream, pui8Data, + ui32BCount, 1); } else { - ui32BytesWritten = - gpfnDbgDrv->pfnWriteBINCM(psStream, pui8Data, - ui32BCount, 1); + ui32BytesWritten = DbgDrvWriteBINCM(psStream, pui8Data, + ui32BCount, 1); } return ui32BytesWritten; -- 1.7.5.4 From a389f16c51d3e7274c9609ba27f922d51967cd35 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:27 +0100 Subject: [PATCH 29/95] gpu: pvr: pdump: remove dbgdrv Remove now unused dbgdrv files, and set the pdump Kconfig option to bool. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Kconfig | 2 +- drivers/gpu/pvr/Makefile | 9 - drivers/gpu/pvr/dbgdrvif.h | 318 -------- drivers/gpu/pvr/ioctldef.h | 93 --- drivers/gpu/pvr/pvrconfig.h | 2 +- drivers/gpu/pvr/tools/Makefile | 29 - drivers/gpu/pvr/tools/dbgdriv.c | 1652 -------------------------------------- drivers/gpu/pvr/tools/dbgdriv.h | 183 ----- drivers/gpu/pvr/tools/hostfunc.c | 267 ------ drivers/gpu/pvr/tools/hostfunc.h | 58 -- drivers/gpu/pvr/tools/hotkey.c | 101 --- drivers/gpu/pvr/tools/hotkey.h | 60 -- drivers/gpu/pvr/tools/ioctl.c | 399 --------- drivers/gpu/pvr/tools/ioctl.h | 81 -- drivers/gpu/pvr/tools/linuxsrv.h | 47 -- drivers/gpu/pvr/tools/main.c | 197 ----- 16 files changed, 2 insertions(+), 3496 deletions(-) delete mode 100644 drivers/gpu/pvr/dbgdrvif.h delete mode 100644 drivers/gpu/pvr/ioctldef.h delete mode 100644 drivers/gpu/pvr/tools/Makefile delete mode 100644 drivers/gpu/pvr/tools/dbgdriv.c delete mode 100644 drivers/gpu/pvr/tools/dbgdriv.h delete mode 100644 drivers/gpu/pvr/tools/hostfunc.c delete mode 100644 drivers/gpu/pvr/tools/hostfunc.h delete mode 100644 drivers/gpu/pvr/tools/hotkey.c delete mode 100644 drivers/gpu/pvr/tools/hotkey.h delete mode 100644 drivers/gpu/pvr/tools/ioctl.c delete mode 100644 drivers/gpu/pvr/tools/ioctl.h delete mode 100644 drivers/gpu/pvr/tools/linuxsrv.h delete mode 100644 drivers/gpu/pvr/tools/main.c diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig index 96dc456..84a8c48 100644 --- a/drivers/gpu/pvr/Kconfig +++ b/drivers/gpu/pvr/Kconfig @@ -25,7 +25,7 @@ config PVR_DEBUG_EXTRA the driver need to be built in debug mode as well. config PVR_DEBUG_PDUMP - tristate "PDUMP debug support" + bool "PDUMP debug support" depends on PVR default n diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 2603208..34259ad 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -25,21 +25,12 @@ bc_example-objs := bufferclass_example.o bufferclass_example_linux.o \ bufferclass_example_private.o -obj-$(CONFIG_PVR_DEBUG_PDUMP) += pvrdbg.o - -pvrdbg-objs := tools/main.o tools/dbgdriv.o tools/ioctl.o \ - tools/hostfunc.o tools/hotkey.o - - DATE := $(shell date "+%a %B %d %Z %Y" ) CBUILD := -O2 \ -DPVR_BUILD_DIR="\"$(PVR_BUILD_DIR)\"" \ -DPVR_BUILD_DATE="\"$(DATE)\"" ccflags-y += $(CBUILD) -include $(srctree)/$(src)/pvrconfig.h - -ccflags-$(CONFIG_PVR_DEBUG_PDUMP) += -I $(srctree)/$(src)/tools \ - -I $(srctree)/$(src) ccflags-y += $(ccflags-m) diff --git a/drivers/gpu/pvr/dbgdrvif.h b/drivers/gpu/pvr/dbgdrvif.h deleted file mode 100644 index 0e6a110..0000000 --- a/drivers/gpu/pvr/dbgdrvif.h +++ /dev/null @@ -1,318 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _DBGDRVIF_ -#define _DBGDRVIF_ - -#include "ioctldef.h" - -#define DEBUG_CAPMODE_FRAMED 0x00000001 -#define DEBUG_CAPMODE_CONTINUOUS 0x00000002 -#define DEBUG_CAPMODE_HOTKEY 0x00000004 - -#define DEBUG_OUTMODE_STANDARDDBG 0x00000001 -#define DEBUG_OUTMODE_MONO 0x00000002 -#define DEBUG_OUTMODE_STREAMENABLE 0x00000004 -#define DEBUG_OUTMODE_ASYNC 0x00000008 -#define DEBUG_OUTMODE_SGXVGA 0x00000010 - -#define DEBUG_FLAGS_USE_NONPAGED_MEM 0x00000001 -#define DEBUG_FLAGS_NO_BUF_EXPANDSION 0x00000002 -#define DEBUG_FLAGS_ENABLESAMPLE 0x00000004 - -#define DEBUG_FLAGS_TEXTSTREAM 0x80000000 - -#define DEBUG_LEVEL_0 0x00000001 -#define DEBUG_LEVEL_1 0x00000003 -#define DEBUG_LEVEL_2 0x00000007 -#define DEBUG_LEVEL_3 0x0000000F -#define DEBUG_LEVEL_4 0x0000001F -#define DEBUG_LEVEL_5 0x0000003F -#define DEBUG_LEVEL_6 0x0000007F -#define DEBUG_LEVEL_7 0x000000FF -#define DEBUG_LEVEL_8 0x000001FF -#define DEBUG_LEVEL_9 0x000003FF -#define DEBUG_LEVEL_10 0x000007FF -#define DEBUG_LEVEL_11 0x00000FFF - -#define DEBUG_LEVEL_SEL0 0x00000001 -#define DEBUG_LEVEL_SEL1 0x00000002 -#define DEBUG_LEVEL_SEL2 0x00000004 -#define DEBUG_LEVEL_SEL3 0x00000008 -#define DEBUG_LEVEL_SEL4 0x00000010 -#define DEBUG_LEVEL_SEL5 0x00000020 -#define DEBUG_LEVEL_SEL6 0x00000040 -#define DEBUG_LEVEL_SEL7 0x00000080 -#define DEBUG_LEVEL_SEL8 0x00000100 -#define DEBUG_LEVEL_SEL9 0x00000200 -#define DEBUG_LEVEL_SEL10 0x00000400 -#define DEBUG_LEVEL_SEL11 0x00000800 - -#define DEBUG_SERVICE_IOCTL_BASE 0x800 -#define DEBUG_SERVICE_CREATESTREAM \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x01, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_DESTROYSTREAM \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x02, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_GETSTREAM \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x03, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITESTRING \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x04, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_READSTRING \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x05, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x06, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_READ \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x07, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_SETDEBUGMODE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x08, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_SETDEBUGOUTMODE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x09, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_SETDEBUGLEVEL \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0A, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_SETFRAME \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0B, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_GETFRAME \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0C, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_OVERRIDEMODE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0D, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_DEFAULTMODE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0E, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_GETSERVICETABLE \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x0F, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITE2 \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x10, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITESTRINGCM \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x11, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITECM \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x12, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_SETMARKER \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x13, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_GETMARKER \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x14, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_ISCAPTUREFRAME \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x15, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WRITELF \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x16, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_READLF \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x17, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) -#define DEBUG_SERVICE_WAITFOREVENT \ - CTL_CODE(FILE_DEVICE_UNKNOWN, DEBUG_SERVICE_IOCTL_BASE + 0x18, \ - METHOD_BUFFERED, FILE_ANY_ACCESS) - -enum DBG_EVENT { - DBG_EVENT_STREAM_DATA = 1 -}; - -struct DBG_IN_CREATESTREAM { - u32 ui32Pages; - u32 ui32CapMode; - u32 ui32OutMode; - char *pszName; -}; - -struct DBG_IN_FINDSTREAM { - IMG_BOOL bResetStream; - char *pszName; -}; - -struct DBG_IN_WRITESTRING { - void *pvStream; - u32 ui32Level; - char *pszString; -}; - -struct DBG_IN_READSTRING { - void *pvStream; - u32 ui32StringLen; - char *pszString; -}; - -struct DBG_IN_SETDEBUGMODE { - void *pvStream; - u32 ui32Mode; - u32 ui32Start; - u32 ui32End; - u32 ui32SampleRate; -}; - -struct DBG_IN_SETDEBUGOUTMODE { - void *pvStream; - u32 ui32Mode; -}; - -struct DBG_IN_SETDEBUGLEVEL { - void *pvStream; - u32 ui32Level; -}; - -struct DBG_IN_SETFRAME { - void *pvStream; - u32 ui32Frame; -}; - -struct DBG_IN_WRITE { - void *pvStream; - u32 ui32Level; - u32 ui32TransferSize; - u8 *pui8InBuffer; -}; - -struct DBG_IN_READ { - void *pvStream; - IMG_BOOL bReadInitBuffer; - u32 ui32OutBufferSize; - u8 *pui8OutBuffer; -}; - -struct DBG_IN_OVERRIDEMODE { - void *pvStream; - u32 ui32Mode; -}; - -struct DBG_IN_ISCAPTUREFRAME { - void *pvStream; - IMG_BOOL bCheckPreviousFrame; -}; - -struct DBG_IN_SETMARKER { - void *pvStream; - u32 ui32Marker; -}; - -struct DBG_IN_WRITE_LF { - u32 ui32Flags; - void *pvStream; - u32 ui32Level; - u32 ui32BufferSize; - u8 *pui8InBuffer; -}; - -#define WRITELF_FLAGS_RESETBUF 0x00000001 - -struct DBG_STREAM { - struct DBG_STREAM *psNext; - struct DBG_STREAM *psInitStream; - IMG_BOOL bInitPhaseComplete; - u32 ui32Flags; - u32 ui32Base; - u32 ui32Size; - u32 ui32RPtr; - u32 ui32WPtr; - u32 ui32DataWritten; - u32 ui32CapMode; - u32 ui32OutMode; - u32 ui32DebugLevel; - u32 ui32DefaultMode; - u32 ui32Start; - u32 ui32End; - u32 ui32Current; - u32 ui32Access; - u32 ui32SampleRate; - u32 ui32Reserved; - u32 ui32Timeout; - u32 ui32Marker; - char szName[30]; -}; - -struct DBGKM_SERVICE_TABLE { - u32 ui32Size; - void *(*pfnCreateStream)(char *pszName, u32 ui32CapMode, - u32 ui32OutMode, u32 ui32Flags, u32 ui32Pages); - void (*pfnDestroyStream)(struct DBG_STREAM *psStream); - void *(*pfnFindStream)(char *pszName, IMG_BOOL bResetInitBuffer); - u32 (*pfnWriteString)(struct DBG_STREAM *psStream, char *pszString, - u32 ui32Level); - u32 (*pfnReadString)(struct DBG_STREAM *psStream, char *pszString, - u32 ui32Limit); - u32 (*pfnWriteBIN)(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level); - u32 (*pfnReadBIN)(struct DBG_STREAM *psStream, - IMG_BOOL bReadInitBuffer, u32 ui32OutBufferSize, - u8 *pui8OutBuf); - void (*pfnSetCaptureMode)(struct DBG_STREAM *psStream, - u32 ui32CapMode, u32 ui32Start, u32 ui32Stop, - u32 ui32SampleRate); - void (*pfnSetOutputMode)(struct DBG_STREAM *psStream, - u32 ui32OutMode); - void (*pfnSetDebugLevel)(struct DBG_STREAM *psStream, - u32 ui32DebugLevel); - void (*pfnSetFrame)(struct DBG_STREAM *psStream, - u32 ui32Frame); - u32 (*pfnGetFrame)(struct DBG_STREAM *psStream); /* unused */ - void (*pfnOverrideMode)(struct DBG_STREAM *psStream, - u32 ui32Mode); - void (*pfnDefaultMode)(struct DBG_STREAM *psStream); - u32 (*pfnDBGDrivWrite2)(struct DBG_STREAM *psStream, - u8 *pui8InBuf, u32 ui32InBuffSize, u32 ui32Level); - u32 (*pfnWriteStringCM)(struct DBG_STREAM *psStream, char *pszString, - u32 ui32Level); - u32 (*pfnWriteBINCM)(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level); - void (*pfnSetMarker)(struct DBG_STREAM *psStream, u32 ui32Marker); - u32 (*pfnGetMarker)(struct DBG_STREAM *psStream); - void (*pfnStartInitPhase) (struct DBG_STREAM *psStream); - void (*pfnStopInitPhase) (struct DBG_STREAM *psStream); - u32 (*pfnIsCaptureFrame)(struct DBG_STREAM *psStream, - IMG_BOOL bCheckPreviousFrame); - u32 (*pfnWriteLF)(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level, u32 ui32Flags); - u32 (*pfnReadLF)(struct DBG_STREAM *psStream, u32 ui32OutBuffSize, - u8 *pui8OutBuf); - u32 (*pfnGetStreamOffset)(struct DBG_STREAM *psStream); - void (*pfnSetStreamOffset)(struct DBG_STREAM *psStream, - u32 ui32StreamOffset); - u32 (*pfnIsLastCaptureFrame)(struct DBG_STREAM *psStream); - void (*pfnWaitForEvent) (enum DBG_EVENT eEvent); -}; - -extern struct DBGKM_SERVICE_TABLE g_sDBGKMServices; - -void DBGDrvGetServiceTable(void **fn_table); - -#endif diff --git a/drivers/gpu/pvr/ioctldef.h b/drivers/gpu/pvr/ioctldef.h deleted file mode 100644 index 36a1684..0000000 --- a/drivers/gpu/pvr/ioctldef.h +++ /dev/null @@ -1,93 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef __IOCTLDEF_H__ -#define __IOCTLDEF_H__ - -#define MAKEIOCTLINDEX(i) (((i) >> 2) & 0xFFF) - -#define DEVICE_TYPE ULONG - -#define FILE_DEVICE_BEEP 0x00000001 -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DATALINK 0x00000005 -#define FILE_DEVICE_DFS 0x00000006 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_INPORT_PORT 0x0000000a -#define FILE_DEVICE_KEYBOARD 0x0000000b -#define FILE_DEVICE_MAILSLOT 0x0000000c -#define FILE_DEVICE_MIDI_IN 0x0000000d -#define FILE_DEVICE_MIDI_OUT 0x0000000e -#define FILE_DEVICE_MOUSE 0x0000000f -#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 -#define FILE_DEVICE_NAMED_PIPE 0x00000011 -#define FILE_DEVICE_NETWORK 0x00000012 -#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 -#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 -#define FILE_DEVICE_PRINTER 0x00000018 -#define FILE_DEVICE_SCANNER 0x00000019 -#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a -#define FILE_DEVICE_SERIAL_PORT 0x0000001b -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_STREAMS 0x0000001e -#define FILE_DEVICE_TAPE 0x0000001f -#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -#define FILE_DEVICE_TRANSPORT 0x00000021 -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_WAVE_IN 0x00000025 -#define FILE_DEVICE_WAVE_OUT 0x00000026 -#define FILE_DEVICE_8042_PORT 0x00000027 -#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -#define FILE_DEVICE_BATTERY 0x00000029 -#define FILE_DEVICE_BUS_EXTENDER 0x0000002a -#define FILE_DEVICE_MODEM 0x0000002b -#define FILE_DEVICE_VDM 0x0000002c -#define FILE_DEVICE_MASS_STORAGE 0x0000002d - -#define CTL_CODE( DeviceType, Function, Method, Access) ( \ - ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ -) - -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 - -#define FILE_ANY_ACCESS 0 -#define FILE_READ_ACCESS 0x0001 -#define FILE_WRITE_ACCESS 0x0002 - -#endif diff --git a/drivers/gpu/pvr/pvrconfig.h b/drivers/gpu/pvr/pvrconfig.h index 5f16f2f..6b3063b 100644 --- a/drivers/gpu/pvr/pvrconfig.h +++ b/drivers/gpu/pvr/pvrconfig.h @@ -24,7 +24,7 @@ # define DEBUG_BRIDGE_KM 1 #endif -# if (defined CONFIG_PVR_DEBUG_PDUMP) || (defined CONFIG_PVR_DEBUG_PDUMP_MODULE) +# ifdef CONFIG_PVR_DEBUG_PDUMP # define PDUMP 1 # endif diff --git a/drivers/gpu/pvr/tools/Makefile b/drivers/gpu/pvr/tools/Makefile deleted file mode 100644 index 27314da..0000000 --- a/drivers/gpu/pvr/tools/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful but, except -# as otherwise stated in writing, without any warranty; without even the -# implied warranty of merchantability or fitness for a particular purpose. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. -# -# The full GNU General Public License is included in this distribution in -# the file called "COPYING". -# -# Contact Information: -# Imagination Technologies Ltd. <gpl-support@imgtec.com> -# Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - - -objs-$(CONFIG_PVR_TOOLS) += dbgdrv - -dbgdrv-objs := main.c dbgdriv.c ioctl.c hostfunc.c \ - hotkey.c - diff --git a/drivers/gpu/pvr/tools/dbgdriv.c b/drivers/gpu/pvr/tools/dbgdriv.c deleted file mode 100644 index 1ab5e70..0000000 --- a/drivers/gpu/pvr/tools/dbgdriv.c +++ /dev/null @@ -1,1652 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#include <linux/string.h> - -#include "img_types.h" -#include "pvr_debug.h" -#include "dbgdrvif.h" -#include "dbgdriv.h" -#include "hotkey.h" -#include "hostfunc.h" - -#define LAST_FRAME_BUF_SIZE 1024 - -struct DBG_LASTFRAME_BUFFER { - struct DBG_STREAM *psStream; - u8 ui8Buffer[LAST_FRAME_BUF_SIZE]; - u32 ui32BufLen; - struct DBG_LASTFRAME_BUFFER *psNext; -}; - -static struct DBG_STREAM *g_psStreamList; -static struct DBG_LASTFRAME_BUFFER *g_psLFBufferList; - -static u32 g_ui32LOff; -static u32 g_ui32Line; -static u32 g_ui32MonoLines = 25; - -static IMG_BOOL g_bHotkeyMiddump = IMG_FALSE; -static u32 g_ui32HotkeyMiddumpStart = 0xffffffff; -static u32 g_ui32HotkeyMiddumpEnd = 0xffffffff; - -void *g_pvAPIMutex; - -IMG_BOOL gbDumpThisFrame = IMG_FALSE; - -static u32 SpaceInStream(struct DBG_STREAM *psStream); -static IMG_BOOL ExpandStreamBuffer(struct DBG_STREAM *psStream, - u32 ui32NewSize); -struct DBG_LASTFRAME_BUFFER *FindLFBuf(struct DBG_STREAM *psStream); - -struct DBGKM_SERVICE_TABLE g_sDBGKMServices = { - sizeof(struct DBGKM_SERVICE_TABLE), - ExtDBGDrivCreateStream, - ExtDBGDrivDestroyStream, - ExtDBGDrivFindStream, - ExtDBGDrivWriteString, - ExtDBGDrivReadString, - ExtDBGDrivWrite, - ExtDBGDrivRead, - ExtDBGDrivSetCaptureMode, - ExtDBGDrivSetOutputMode, - ExtDBGDrivSetDebugLevel, - ExtDBGDrivSetFrame, - ExtDBGDrivGetFrame, - ExtDBGDrivOverrideMode, - ExtDBGDrivDefaultMode, - ExtDBGDrivWrite2, - ExtDBGDrivWriteStringCM, - ExtDBGDrivWriteCM, - ExtDBGDrivSetMarker, - ExtDBGDrivGetMarker, - ExtDBGDrivStartInitPhase, - ExtDBGDrivStopInitPhase, - ExtDBGDrivIsCaptureFrame, - ExtDBGDrivWriteLF, - ExtDBGDrivReadLF, - ExtDBGDrivGetStreamOffset, - ExtDBGDrivSetStreamOffset, - ExtDBGDrivIsLastCaptureFrame, - ExtDBGDrivWaitForEvent -}; - -void *ExtDBGDrivCreateStream(char *pszName, - u32 ui32CapMode, - u32 ui32OutMode, - u32 ui32Flags, - u32 ui32Size) -{ - void *pvRet; - - HostAquireMutex(g_pvAPIMutex); - - pvRet = - DBGDrivCreateStream(pszName, ui32CapMode, ui32OutMode, ui32Flags, - ui32Size); - - HostReleaseMutex(g_pvAPIMutex); - - return pvRet; -} - -void ExtDBGDrivDestroyStream(struct DBG_STREAM *psStream) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivDestroyStream(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void *ExtDBGDrivFindStream(char *pszName, - IMG_BOOL bResetStream) -{ - void *pvRet; - - HostAquireMutex(g_pvAPIMutex); - - pvRet = DBGDrivFindStream(pszName, bResetStream); - - HostReleaseMutex(g_pvAPIMutex); - - return pvRet; -} - -u32 ExtDBGDrivWriteString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivWriteString(psStream, pszString, ui32Level); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivReadString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Limit) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivReadString(psStream, pszString, ui32Limit); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivWrite(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivWrite(psStream, pui8InBuf, ui32InBuffSize, ui32Level); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivRead(struct DBG_STREAM *psStream, - IMG_BOOL bReadInitBuffer, - u32 ui32OutBuffSize, - u8 *pui8OutBuf) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = - DBGDrivRead(psStream, bReadInitBuffer, ui32OutBuffSize, pui8OutBuf); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -void ExtDBGDrivSetCaptureMode(struct DBG_STREAM *psStream, - u32 ui32Mode, - u32 ui32Start, - u32 ui32End, - u32 ui32SampleRate) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetCaptureMode(psStream, ui32Mode, ui32Start, ui32End, - ui32SampleRate); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void ExtDBGDrivSetOutputMode(struct DBG_STREAM *psStream, - u32 ui32OutMode) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetOutputMode(psStream, ui32OutMode); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void ExtDBGDrivSetDebugLevel(struct DBG_STREAM *psStream, - u32 ui32DebugLevel) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetDebugLevel(psStream, ui32DebugLevel); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void ExtDBGDrivSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetFrame(psStream, ui32Frame); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -u32 ExtDBGDrivGetFrame(struct DBG_STREAM *psStream) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivGetFrame(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivIsLastCaptureFrame(struct DBG_STREAM *psStream) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivIsLastCaptureFrame(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivIsCaptureFrame(struct DBG_STREAM *psStream, - IMG_BOOL bCheckPreviousFrame) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivIsCaptureFrame(psStream, bCheckPreviousFrame); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -void ExtDBGDrivOverrideMode(struct DBG_STREAM *psStream, - u32 ui32Mode) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivOverrideMode(psStream, ui32Mode); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void ExtDBGDrivDefaultMode(struct DBG_STREAM *psStream) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivDefaultMode(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -u32 ExtDBGDrivWrite2(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivWrite2(psStream, pui8InBuf, ui32InBuffSize, ui32Level); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivWriteStringCM(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivWriteStringCM(psStream, pszString, ui32Level); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivWriteCM(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = - DBGDrivWriteCM(psStream, pui8InBuf, ui32InBuffSize, ui32Level); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -void ExtDBGDrivSetMarker(struct DBG_STREAM *psStream, - u32 ui32Marker) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetMarker(psStream, ui32Marker); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -u32 ExtDBGDrivGetMarker(struct DBG_STREAM *psStream) -{ - u32 ui32Marker; - - HostAquireMutex(g_pvAPIMutex); - - ui32Marker = DBGDrivGetMarker(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Marker; -} - -u32 ExtDBGDrivWriteLF(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level, - u32 ui32Flags) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = - DBGDrivWriteLF(psStream, pui8InBuf, ui32InBuffSize, ui32Level, - ui32Flags); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -u32 ExtDBGDrivReadLF(struct DBG_STREAM *psStream, - u32 ui32OutBuffSize, - u8 *pui8OutBuf) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivReadLF(psStream, ui32OutBuffSize, pui8OutBuf); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -void ExtDBGDrivStartInitPhase(struct DBG_STREAM *psStream) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivStartInitPhase(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -void ExtDBGDrivStopInitPhase(struct DBG_STREAM *psStream) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivStopInitPhase(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return; -} - -u32 ExtDBGDrivGetStreamOffset(struct DBG_STREAM *psStream) -{ - u32 ui32Ret; - - HostAquireMutex(g_pvAPIMutex); - - ui32Ret = DBGDrivGetStreamOffset(psStream); - - HostReleaseMutex(g_pvAPIMutex); - - return ui32Ret; -} - -void ExtDBGDrivSetStreamOffset(struct DBG_STREAM *psStream, - u32 ui32StreamOffset) -{ - - HostAquireMutex(g_pvAPIMutex); - - DBGDrivSetStreamOffset(psStream, ui32StreamOffset); - - HostReleaseMutex(g_pvAPIMutex); -} - -void ExtDBGDrivWaitForEvent(enum DBG_EVENT eEvent) -{ -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - DBGDrivWaitForEvent(eEvent); -#else - PVR_UNREFERENCED_PARAMETER(eEvent); -#endif -} - -u32 AtoI(char *szIn) -{ - u32 ui32Len = 0; - u32 ui32Value = 0; - u32 ui32Digit = 1; - u32 ui32Base = 10; - int iPos; - char bc; - - while (szIn[ui32Len] > 0) - ui32Len++; - - if (ui32Len == 0) - return 0; - - iPos = 0; - while (szIn[iPos] == '0') - iPos++; - if (szIn[iPos] == '\0') - return 0; - if (szIn[iPos] == 'x' || szIn[iPos] == 'X') { - ui32Base = 16; - szIn[iPos] = '0'; - } - - for (iPos = ui32Len - 1; iPos >= 0; iPos--) { - bc = szIn[iPos]; - - if ((bc >= 'a') && (bc <= 'f') && ui32Base == 16) - bc -= 'a' - 0xa; - else if ((bc >= 'A') && (bc <= 'F') && ui32Base == 16) - bc -= 'A' - 0xa; - else if ((bc >= '0') && (bc <= '9')) - bc -= '0'; - else - return 0; - - ui32Value += bc * ui32Digit; - - ui32Digit = ui32Digit * ui32Base; - } - return ui32Value; -} - -IMG_BOOL StreamValid(struct DBG_STREAM *psStream) -{ - struct DBG_STREAM *psThis; - - psThis = g_psStreamList; - - while (psThis) - if (psStream && (psThis == psStream)) - return IMG_TRUE; - else - psThis = psThis->psNext; - - return IMG_FALSE; -} - -void Write(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32InBuffSize) -{ - - if ((psStream->ui32WPtr + ui32InBuffSize) > psStream->ui32Size) { - u32 ui32B1 = psStream->ui32Size - psStream->ui32WPtr; - u32 ui32B2 = ui32InBuffSize - ui32B1; - - HostMemCopy((void *) (psStream->ui32Base + - psStream->ui32WPtr), - (void *) pui8Data, ui32B1); - - HostMemCopy((void *) psStream->ui32Base, - (void *) ((u32) pui8Data + ui32B1), - ui32B2); - - psStream->ui32WPtr = ui32B2; - } else { - HostMemCopy((void *) (psStream->ui32Base + - psStream->ui32WPtr), - (void *) pui8Data, ui32InBuffSize); - - psStream->ui32WPtr += ui32InBuffSize; - - if (psStream->ui32WPtr == psStream->ui32Size) - psStream->ui32WPtr = 0; - } - psStream->ui32DataWritten += ui32InBuffSize; -} - -void MonoOut(char *pszString, IMG_BOOL bNewLine) -{ - u32 i; - char *pScreen; - - pScreen = (char *)DBGDRIV_MONOBASE; - - pScreen += g_ui32Line * 160; - - i = 0; - do { - pScreen[g_ui32LOff + (i * 2)] = pszString[i]; - pScreen[g_ui32LOff + (i * 2) + 1] = 127; - i++; - } while ((pszString[i] != 0) && (i < 4096)); - - g_ui32LOff += i * 2; - - if (bNewLine) { - g_ui32LOff = 0; - g_ui32Line++; - } - - if (g_ui32Line == g_ui32MonoLines) { - g_ui32Line = g_ui32MonoLines - 1; - - HostMemCopy((void *) DBGDRIV_MONOBASE, - (void *) (DBGDRIV_MONOBASE + 160), - 160 * (g_ui32MonoLines - 1)); - - HostMemSet((void *) (DBGDRIV_MONOBASE + - (160 * (g_ui32MonoLines - 1))), 0, - 160); - } -} - -void AppendName(char *pszOut, char *pszBase, char *pszName) -{ - u32 i; - u32 ui32Off; - - i = 0; - - while (pszBase[i] != 0) { - pszOut[i] = pszBase[i]; - i++; - } - - ui32Off = i; - i = 0; - - while (pszName[i] != 0) { - pszOut[ui32Off + i] = pszName[i]; - i++; - } - - pszOut[ui32Off + i] = pszName[i]; -} - -void *DBGDrivCreateStream(char *pszName, - u32 ui32CapMode, - u32 ui32OutMode, - u32 ui32Flags, - u32 ui32Size) -{ - struct DBG_STREAM *psStream; - struct DBG_STREAM *psInitStream; - struct DBG_LASTFRAME_BUFFER *psLFBuffer; - u32 ui32Off; - void *pvBase; - - psStream = (struct DBG_STREAM *)DBGDrivFindStream(pszName, IMG_FALSE); - - if (psStream) - return (void *)psStream; - - psStream = HostNonPageablePageAlloc(1); - psInitStream = HostNonPageablePageAlloc(1); - psLFBuffer = HostNonPageablePageAlloc(1); - if ((!psStream) || (!psInitStream) || (!psLFBuffer) - ) { - PVR_DPF(PVR_DBG_ERROR, - "DBGDriv: Couldn't create buffer !!!!!\n\r"); - return NULL; - } - - if ((ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) - pvBase = HostNonPageablePageAlloc(ui32Size); - else - pvBase = HostPageablePageAlloc(ui32Size); - - if (!pvBase) { - PVR_DPF(PVR_DBG_ERROR, - "DBGDriv: Couldn't create buffer !!!!!\n\r"); - HostNonPageablePageFree(psStream); - return NULL; - } - - psStream->psNext = 0; - psStream->ui32Flags = ui32Flags; - psStream->ui32Base = (u32) pvBase; - psStream->ui32Size = ui32Size * 4096; - psStream->ui32RPtr = 0; - psStream->ui32WPtr = 0; - psStream->ui32DataWritten = 0; - psStream->ui32CapMode = ui32CapMode; - psStream->ui32OutMode = ui32OutMode; - psStream->ui32DebugLevel = DEBUG_LEVEL_0; - psStream->ui32DefaultMode = ui32CapMode; - psStream->ui32Start = 0; - psStream->ui32End = 0; - psStream->ui32Current = 0; - psStream->ui32SampleRate = 1; - psStream->ui32Access = 0; - psStream->ui32Timeout = 0; - psStream->ui32Marker = 0; - psStream->bInitPhaseComplete = IMG_FALSE; - - if ((ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) - pvBase = HostNonPageablePageAlloc(ui32Size); - else - pvBase = HostPageablePageAlloc(ui32Size); - - if (!pvBase) { - PVR_DPF(PVR_DBG_ERROR, - "DBGDriv: Couldn't create buffer !!!!!\n\r"); - - if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) - HostNonPageablePageFree((void *) psStream-> - ui32Base); - else - HostPageablePageFree((void *) psStream->ui32Base); - HostNonPageablePageFree(psStream); - return NULL; - } - - psInitStream->psNext = 0; - psInitStream->ui32Flags = ui32Flags; - psInitStream->ui32Base = (u32) pvBase; - psInitStream->ui32Size = ui32Size * 4096; - psInitStream->ui32RPtr = 0; - psInitStream->ui32WPtr = 0; - psInitStream->ui32DataWritten = 0; - psInitStream->ui32CapMode = ui32CapMode; - psInitStream->ui32OutMode = ui32OutMode; - psInitStream->ui32DebugLevel = DEBUG_LEVEL_0; - psInitStream->ui32DefaultMode = ui32CapMode; - psInitStream->ui32Start = 0; - psInitStream->ui32End = 0; - psInitStream->ui32Current = 0; - psInitStream->ui32SampleRate = 1; - psInitStream->ui32Access = 0; - psInitStream->ui32Timeout = 0; - psInitStream->ui32Marker = 0; - psInitStream->bInitPhaseComplete = IMG_FALSE; - - psStream->psInitStream = psInitStream; - - psLFBuffer->psStream = psStream; - psLFBuffer->ui32BufLen = 0; - - g_bHotkeyMiddump = IMG_FALSE; - g_ui32HotkeyMiddumpStart = 0xffffffff; - g_ui32HotkeyMiddumpEnd = 0xffffffff; - - ui32Off = 0; - - do { - psStream->szName[ui32Off] = pszName[ui32Off]; - - ui32Off++; - } while ((pszName[ui32Off] != 0) - && (ui32Off < (4096 - sizeof(struct DBG_STREAM)))); - - psStream->szName[ui32Off] = pszName[ui32Off]; - - psStream->psNext = g_psStreamList; - g_psStreamList = psStream; - - psLFBuffer->psNext = g_psLFBufferList; - g_psLFBufferList = psLFBuffer; - - return (void *)psStream; -} - -void DBGDrivDestroyStream(struct DBG_STREAM *psStream) -{ - struct DBG_STREAM *psStreamThis; - struct DBG_STREAM *psStreamPrev; - struct DBG_LASTFRAME_BUFFER *psLFBuffer; - struct DBG_LASTFRAME_BUFFER *psLFThis; - struct DBG_LASTFRAME_BUFFER *psLFPrev; - - PVR_DPF(PVR_DBG_MESSAGE, "DBGDriv: Destroying stream %s\r\n", - psStream->szName); - - if (!StreamValid(psStream)) - return; - - psLFBuffer = FindLFBuf(psStream); - - psStreamThis = g_psStreamList; - psStreamPrev = 0; - - while (psStreamThis) - if (psStreamThis == psStream) { - if (psStreamPrev) - psStreamPrev->psNext = psStreamThis->psNext; - else - g_psStreamList = psStreamThis->psNext; - - psStreamThis = 0; - } else { - psStreamPrev = psStreamThis; - psStreamThis = psStreamThis->psNext; - } - - psLFThis = g_psLFBufferList; - psLFPrev = 0; - - while (psLFThis) - if (psLFThis == psLFBuffer) { - if (psLFPrev) - psLFPrev->psNext = psLFThis->psNext; - else - g_psLFBufferList = psLFThis->psNext; - - psLFThis = 0; - } else { - psLFPrev = psLFThis; - psLFThis = psLFThis->psNext; - } - - if (psStream->ui32CapMode & DEBUG_CAPMODE_HOTKEY) - DeactivateHotKeys(); - - if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) { - HostNonPageablePageFree((void *) psStream->ui32Base); - HostNonPageablePageFree((void *) psStream->psInitStream-> - ui32Base); - } else { - HostPageablePageFree((void *) psStream->ui32Base); - HostPageablePageFree((void *) psStream->psInitStream-> - ui32Base); - } - - HostNonPageablePageFree(psStream->psInitStream); - HostNonPageablePageFree(psStream); - HostNonPageablePageFree(psLFBuffer); - - if (g_psStreamList == 0) - PVR_DPF(PVR_DBG_MESSAGE, "DBGDriv: Stream list now empty"); - - return; -} - -void *DBGDrivFindStream(char *pszName, - IMG_BOOL bResetStream) -{ - struct DBG_STREAM *psStream; - struct DBG_STREAM *psThis; - u32 ui32Off; - IMG_BOOL bAreSame; - - psStream = 0; - - for (psThis = g_psStreamList; psThis != NULL; - psThis = psThis->psNext) { - bAreSame = IMG_TRUE; - ui32Off = 0; - - if (strlen(psThis->szName) == strlen(pszName)) { - while ((psThis->szName[ui32Off] != 0) - && (pszName[ui32Off] != 0) && (ui32Off < 128) - && bAreSame) { - if (psThis->szName[ui32Off] != pszName[ui32Off]) - bAreSame = IMG_FALSE; - - ui32Off++; - } - } else { - bAreSame = IMG_FALSE; - } - - if (bAreSame) { - psStream = psThis; - break; - } - } - - if (bResetStream && psStream) { - static char szComment[] = "-- Init phase terminated\r\n"; - psStream->psInitStream->ui32RPtr = 0; - psStream->ui32RPtr = 0; - psStream->ui32WPtr = 0; - psStream->ui32DataWritten = - psStream->psInitStream->ui32DataWritten; - if (psStream->bInitPhaseComplete == IMG_FALSE) { - if (psStream->ui32Flags & DEBUG_FLAGS_TEXTSTREAM) - DBGDrivWrite2(psStream, (u8 *) szComment, - sizeof(szComment) - 1, 0x01); - psStream->bInitPhaseComplete = IMG_TRUE; - } - } - - return (void *)psStream; -} - -u32 DBGDrivWriteStringCM(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level) -{ - - if (!StreamValid(psStream)) - return 0xFFFFFFFF; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) - return 0; - } else { - if (psStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) - if ((psStream->ui32Current != g_ui32HotKeyFrame) - || (g_bHotKeyPressed == IMG_FALSE)) - return 0; - } - - return DBGDrivWriteString(psStream, pszString, ui32Level); - -} - -u32 DBGDrivWriteString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level) -{ - u32 ui32Len; - u32 ui32Space; - u32 ui32WPtr; - u8 *pui8Buffer; - - if (!StreamValid(psStream)) - return 0xFFFFFFFF; - - if (!(psStream->ui32DebugLevel & ui32Level)) - return 0xFFFFFFFF; - - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC)) { - if (psStream->ui32OutMode & DEBUG_OUTMODE_STANDARDDBG) - PVR_DPF(PVR_DBG_MESSAGE, "%s: %s\r\n", - psStream->szName, pszString); - - if (psStream->ui32OutMode & DEBUG_OUTMODE_MONO) { - MonoOut(psStream->szName, IMG_FALSE); - MonoOut(": ", IMG_FALSE); - MonoOut(pszString, IMG_TRUE); - } - } - - if (!((psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE) || - (psStream->ui32OutMode & DEBUG_OUTMODE_ASYNC) - ) - ) - return 0xFFFFFFFF; - - ui32Space = SpaceInStream(psStream); - - if (ui32Space > 0) - ui32Space--; - - ui32Len = 0; - ui32WPtr = psStream->ui32WPtr; - pui8Buffer = (u8 *) psStream->ui32Base; - - while ((pszString[ui32Len] != 0) && (ui32Len < ui32Space)) { - pui8Buffer[ui32WPtr] = pszString[ui32Len]; - ui32Len++; - ui32WPtr++; - if (ui32WPtr == psStream->ui32Size) - ui32WPtr = 0; - } - - if (ui32Len < ui32Space) { - - pui8Buffer[ui32WPtr] = pszString[ui32Len]; - ui32Len++; - ui32WPtr++; - if (ui32WPtr == psStream->ui32Size) - ui32WPtr = 0; - - psStream->ui32WPtr = ui32WPtr; - psStream->ui32DataWritten += ui32Len; - } else { - ui32Len = 0; - } - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - if (ui32Len) - HostSignalEvent(DBG_EVENT_STREAM_DATA); -#endif - - return ui32Len; -} - -u32 DBGDrivReadString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Limit) -{ - u32 ui32OutLen; - u32 ui32Len; - u32 ui32Offset; - u8 *pui8Buff; - - if (!StreamValid(psStream)) - return 0; - - pui8Buff = (u8 *) psStream->ui32Base; - ui32Offset = psStream->ui32RPtr; - - if (psStream->ui32RPtr == psStream->ui32WPtr) - return 0; - - ui32Len = 0; - while ((pui8Buff[ui32Offset] != 0) - && (ui32Offset != psStream->ui32WPtr)) { - ui32Offset++; - ui32Len++; - - if (ui32Offset == psStream->ui32Size) - ui32Offset = 0; - } - - ui32OutLen = ui32Len + 1; - - if (ui32Len > ui32Limit) - return 0; - - ui32Offset = psStream->ui32RPtr; - ui32Len = 0; - - while ((pui8Buff[ui32Offset] != 0) && (ui32Len < ui32Limit)) { - pszString[ui32Len] = pui8Buff[ui32Offset]; - ui32Offset++; - ui32Len++; - - if (ui32Offset == psStream->ui32Size) - ui32Offset = 0; - } - - pszString[ui32Len] = pui8Buff[ui32Offset]; - - psStream->ui32RPtr = ui32Offset + 1; - - if (psStream->ui32RPtr == psStream->ui32Size) - psStream->ui32RPtr = 0; - - return ui32OutLen; -} - -u32 DBGDrivWrite(struct DBG_STREAM *psMainStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - u32 ui32Space; - struct DBG_STREAM *psStream; - - if (!StreamValid(psMainStream)) - return 0xFFFFFFFF; - - if (!(psMainStream->ui32DebugLevel & ui32Level)) - return 0xFFFFFFFF; - - if (psMainStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psMainStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) - return 0xFFFFFFFF; - } else { - if (psMainStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) - if ((psMainStream->ui32Current != g_ui32HotKeyFrame) - || (g_bHotKeyPressed == IMG_FALSE)) - return 0xFFFFFFFF; - - } - - if (psMainStream->bInitPhaseComplete) - psStream = psMainStream; - else - psStream = psMainStream->psInitStream; - - ui32Space = SpaceInStream(psStream); - - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE)) - return 0; - - if (ui32Space < 8) - return 0; - - if (ui32Space <= (ui32InBuffSize + 4)) - ui32InBuffSize = ui32Space - 8; - - Write(psStream, (u8 *) &ui32InBuffSize, 4); - Write(psStream, pui8InBuf, ui32InBuffSize); - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - if (ui32InBuffSize) - HostSignalEvent(DBG_EVENT_STREAM_DATA); -#endif - return ui32InBuffSize; -} - -u32 DBGDrivWriteCM(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - - if (!StreamValid(psStream)) - return 0xFFFFFFFF; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) - return 0xFFFFFFFF; - } else { - if (psStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) - if ((psStream->ui32Current != g_ui32HotKeyFrame) - || (g_bHotKeyPressed == IMG_FALSE)) - return 0xFFFFFFFF; - } - - return DBGDrivWrite2(psStream, pui8InBuf, ui32InBuffSize, ui32Level); -} - -u32 DBGDrivWrite2(struct DBG_STREAM *psMainStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level) -{ - u32 ui32Space; - struct DBG_STREAM *psStream; - - if (!StreamValid(psMainStream)) - return 0xFFFFFFFF; - - if (!(psMainStream->ui32DebugLevel & ui32Level)) - return 0xFFFFFFFF; - - if (psMainStream->bInitPhaseComplete) - psStream = psMainStream; - else - psStream = psMainStream->psInitStream; - - ui32Space = SpaceInStream(psStream); - - if (!(psStream->ui32OutMode & DEBUG_OUTMODE_STREAMENABLE)) - return 0; - - if (psStream->ui32Flags & DEBUG_FLAGS_NO_BUF_EXPANDSION) { - - if (ui32Space < 32) - return 0; - } else { - if ((ui32Space < 32) || (ui32Space <= (ui32InBuffSize + 4))) { - u32 ui32NewBufSize; - - ui32NewBufSize = 2 * psStream->ui32Size; - - if (ui32InBuffSize > psStream->ui32Size) - ui32NewBufSize += ui32InBuffSize; - - if (!ExpandStreamBuffer(psStream, ui32NewBufSize)) - if (ui32Space < 32) - return 0; - - ui32Space = SpaceInStream(psStream); - } - } - - if (ui32Space <= (ui32InBuffSize + 4)) - ui32InBuffSize = ui32Space - 4; - - Write(psStream, pui8InBuf, ui32InBuffSize); - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - if (ui32InBuffSize) - HostSignalEvent(DBG_EVENT_STREAM_DATA); -#endif - return ui32InBuffSize; -} - -u32 DBGDrivRead(struct DBG_STREAM *psMainStream, - IMG_BOOL bReadInitBuffer, - u32 ui32OutBuffSize, - u8 *pui8OutBuf) -{ - u32 ui32Data; - struct DBG_STREAM *psStream; - - if (!StreamValid(psMainStream)) - return 0; - - if (bReadInitBuffer) - psStream = psMainStream->psInitStream; - else - psStream = psMainStream; - - if (psStream->ui32RPtr == psStream->ui32WPtr) - return 0; - - if (psStream->ui32RPtr <= psStream->ui32WPtr) { - ui32Data = psStream->ui32WPtr - psStream->ui32RPtr; - } else { - ui32Data = - psStream->ui32WPtr + (psStream->ui32Size - - psStream->ui32RPtr); - } - - if (ui32Data > ui32OutBuffSize) - ui32Data = ui32OutBuffSize; - - if ((psStream->ui32RPtr + ui32Data) > psStream->ui32Size) { - u32 ui32B1 = psStream->ui32Size - psStream->ui32RPtr; - u32 ui32B2 = ui32Data - ui32B1; - - HostMemCopy((void *) pui8OutBuf, - (void *) (psStream->ui32Base + - psStream->ui32RPtr), ui32B1); - - HostMemCopy((void *) ((u32) pui8OutBuf + ui32B1), - (void *) psStream->ui32Base, ui32B2); - - psStream->ui32RPtr = ui32B2; - } else { - HostMemCopy((void *) pui8OutBuf, - (void *) (psStream->ui32Base + - psStream->ui32RPtr), ui32Data); - - psStream->ui32RPtr += ui32Data; - - if (psStream->ui32RPtr == psStream->ui32Size) - psStream->ui32RPtr = 0; - } - - return ui32Data; -} - -void DBGDrivSetCaptureMode(struct DBG_STREAM *psStream, - u32 ui32Mode, - u32 ui32Start, - u32 ui32End, - u32 ui32SampleRate) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32CapMode = ui32Mode; - psStream->ui32DefaultMode = ui32Mode; - psStream->ui32Start = ui32Start; - psStream->ui32End = ui32End; - psStream->ui32SampleRate = ui32SampleRate; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_HOTKEY) - ActivateHotKeys(psStream); -} - -void DBGDrivSetOutputMode(struct DBG_STREAM *psStream, - u32 ui32OutMode) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32OutMode = ui32OutMode; -} - -void DBGDrivSetDebugLevel(struct DBG_STREAM *psStream, - u32 ui32DebugLevel) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32DebugLevel = ui32DebugLevel; -} - -void DBGDrivSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32Current = ui32Frame; - - if ((ui32Frame >= psStream->ui32Start) && - (ui32Frame <= psStream->ui32End) && - (((ui32Frame - psStream->ui32Start) % psStream->ui32SampleRate) == - 0)) - psStream->ui32Flags |= DEBUG_FLAGS_ENABLESAMPLE; - else - psStream->ui32Flags &= ~DEBUG_FLAGS_ENABLESAMPLE; - - if (g_bHotkeyMiddump) { - if ((ui32Frame >= g_ui32HotkeyMiddumpStart) && - (ui32Frame <= g_ui32HotkeyMiddumpEnd) && - (((ui32Frame - - g_ui32HotkeyMiddumpStart) % psStream->ui32SampleRate) == - 0)) { - psStream->ui32Flags |= DEBUG_FLAGS_ENABLESAMPLE; - } else { - psStream->ui32Flags &= ~DEBUG_FLAGS_ENABLESAMPLE; - if (psStream->ui32Current > g_ui32HotkeyMiddumpEnd) - g_bHotkeyMiddump = IMG_FALSE; - } - } - - if (g_bHotKeyRegistered) { - g_bHotKeyRegistered = IMG_FALSE; - - PVR_DPF(PVR_DBG_MESSAGE, "Hotkey pressed (%08x)!\n", - psStream); - - if (!g_bHotKeyPressed) { - - g_ui32HotKeyFrame = psStream->ui32Current + 2; - - g_bHotKeyPressed = IMG_TRUE; - } - - if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) - && (psStream->ui32CapMode & DEBUG_CAPMODE_HOTKEY)) { - if (!g_bHotkeyMiddump) { - - g_ui32HotkeyMiddumpStart = - g_ui32HotKeyFrame + 1; - g_ui32HotkeyMiddumpEnd = 0xffffffff; - g_bHotkeyMiddump = IMG_TRUE; - PVR_DPF(PVR_DBG_MESSAGE, - "Sampling every %d frame(s)\n", - psStream->ui32SampleRate); - } else { - - g_ui32HotkeyMiddumpEnd = g_ui32HotKeyFrame; - PVR_DPF(PVR_DBG_MESSAGE, - "Turning off sampling\n"); - } - } - - } - - if (psStream->ui32Current > g_ui32HotKeyFrame) - g_bHotKeyPressed = IMG_FALSE; -} - -u32 DBGDrivGetFrame(struct DBG_STREAM *psStream) -{ - - if (!StreamValid(psStream)) - return 0; - - return psStream->ui32Current; -} - -u32 DBGDrivIsLastCaptureFrame(struct DBG_STREAM *psStream) -{ - u32 ui32NextFrame; - - if (!StreamValid(psStream)) - return IMG_FALSE; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - ui32NextFrame = - psStream->ui32Current + psStream->ui32SampleRate; - if (ui32NextFrame > psStream->ui32End) - return IMG_TRUE; - } - return IMG_FALSE; -} - -u32 DBGDrivIsCaptureFrame(struct DBG_STREAM *psStream, - IMG_BOOL bCheckPreviousFrame) -{ - u32 ui32FrameShift = bCheckPreviousFrame ? 1 : 0; - - if (!StreamValid(psStream)) - return IMG_FALSE; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - - if (g_bHotkeyMiddump) { - if ((psStream->ui32Current >= - (g_ui32HotkeyMiddumpStart - ui32FrameShift)) - && (psStream->ui32Current <= - (g_ui32HotkeyMiddumpEnd - ui32FrameShift)) - && - ((((psStream->ui32Current + ui32FrameShift) - - g_ui32HotkeyMiddumpStart) % - psStream->ui32SampleRate) == 0)) - return IMG_TRUE; - } else { - if ((psStream->ui32Current >= - (psStream->ui32Start - ui32FrameShift)) - && (psStream->ui32Current <= - (psStream->ui32End - ui32FrameShift)) - && - ((((psStream->ui32Current + ui32FrameShift) - - psStream->ui32Start) % - psStream->ui32SampleRate) == 0)) - return IMG_TRUE; - } - } else if (psStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) { - if ((psStream->ui32Current == - (g_ui32HotKeyFrame - ui32FrameShift)) - && (g_bHotKeyPressed)) - return IMG_TRUE; - } - - - return IMG_FALSE; -} - -void DBGDrivOverrideMode(struct DBG_STREAM *psStream, u32 ui32Mode) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32CapMode = ui32Mode; -} - -void DBGDrivDefaultMode(struct DBG_STREAM *psStream) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32CapMode = psStream->ui32DefaultMode; -} - -void DBGDrivSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) -{ - - if (!StreamValid(psStream)) - return; - - psStream->ui32Marker = ui32Marker; -} - -u32 DBGDrivGetMarker(struct DBG_STREAM *psStream) -{ - - if (!StreamValid(psStream)) - return 0; - - return psStream->ui32Marker; -} - -u32 DBGDrivGetStreamOffset(struct DBG_STREAM *psMainStream) -{ - struct DBG_STREAM *psStream; - - if (!StreamValid(psMainStream)) - return 0; - - if (psMainStream->bInitPhaseComplete) - psStream = psMainStream; - else - psStream = psMainStream->psInitStream; - - return psStream->ui32DataWritten; -} - -void DBGDrivSetStreamOffset(struct DBG_STREAM *psMainStream, - u32 ui32StreamOffset) -{ - struct DBG_STREAM *psStream; - - if (!StreamValid(psMainStream)) - return; - - if (psMainStream->bInitPhaseComplete) - psStream = psMainStream; - else - psStream = psMainStream->psInitStream; - - psStream->ui32DataWritten = ui32StreamOffset; -} - -u32 DBGDrivGetServiceTable(void) -{ - return (u32)&g_sDBGKMServices; -} - -u32 DBGDrivWriteLF(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level, - u32 ui32Flags) -{ - struct DBG_LASTFRAME_BUFFER *psLFBuffer; - - if (!StreamValid(psStream)) - return 0xFFFFFFFF; - - if (!(psStream->ui32DebugLevel & ui32Level)) - return 0xFFFFFFFF; - - if (psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) { - if (!(psStream->ui32Flags & DEBUG_FLAGS_ENABLESAMPLE)) - return 0xFFFFFFFF; - } else if (psStream->ui32CapMode == DEBUG_CAPMODE_HOTKEY) { - if ((psStream->ui32Current != g_ui32HotKeyFrame) - || (g_bHotKeyPressed == IMG_FALSE)) - return 0xFFFFFFFF; - } - - psLFBuffer = FindLFBuf(psStream); - - if (ui32Flags & WRITELF_FLAGS_RESETBUF) { - - ui32InBuffSize = - (ui32InBuffSize > - LAST_FRAME_BUF_SIZE) ? LAST_FRAME_BUF_SIZE : - ui32InBuffSize; - HostMemCopy((void *) psLFBuffer->ui8Buffer, - (void *) pui8InBuf, ui32InBuffSize); - psLFBuffer->ui32BufLen = ui32InBuffSize; - } else { - - ui32InBuffSize = - ((psLFBuffer->ui32BufLen + ui32InBuffSize) > - LAST_FRAME_BUF_SIZE) ? (LAST_FRAME_BUF_SIZE - - psLFBuffer-> - ui32BufLen) : ui32InBuffSize; - HostMemCopy((void *) (&psLFBuffer-> - ui8Buffer[psLFBuffer->ui32BufLen]), - (void *) pui8InBuf, ui32InBuffSize); - psLFBuffer->ui32BufLen += ui32InBuffSize; - } - - return ui32InBuffSize; -} - -u32 DBGDrivReadLF(struct DBG_STREAM *psStream, - u32 ui32OutBuffSize, - u8 *pui8OutBuf) -{ - struct DBG_LASTFRAME_BUFFER *psLFBuffer; - u32 ui32Data; - - if (!StreamValid(psStream)) - return 0; - - psLFBuffer = FindLFBuf(psStream); - - ui32Data = - (ui32OutBuffSize < - psLFBuffer->ui32BufLen) ? ui32OutBuffSize : psLFBuffer->ui32BufLen; - - HostMemCopy((void *) pui8OutBuf, (void *) psLFBuffer->ui8Buffer, - ui32Data); - - return ui32Data; -} - -void DBGDrivStartInitPhase(struct DBG_STREAM *psStream) -{ - psStream->bInitPhaseComplete = IMG_FALSE; -} - -void DBGDrivStopInitPhase(struct DBG_STREAM *psStream) -{ - psStream->bInitPhaseComplete = IMG_TRUE; -} - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) -void DBGDrivWaitForEvent(enum DBG_EVENT eEvent) -{ - HostWaitForEvent(eEvent); -} -#endif - -static IMG_BOOL ExpandStreamBuffer(struct DBG_STREAM *psStream, u32 ui32NewSize) -{ - void *pvNewBuf; - u32 ui32NewSizeInPages; - u32 ui32NewWOffset; - u32 ui32SpaceInOldBuf; - - if (psStream->ui32Size >= ui32NewSize) - return IMG_FALSE; - - ui32SpaceInOldBuf = SpaceInStream(psStream); - - ui32NewSizeInPages = ((ui32NewSize + 0xfff) & ~0xfff) / 4096; - - if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) - pvNewBuf = HostNonPageablePageAlloc(ui32NewSizeInPages); - else - pvNewBuf = HostPageablePageAlloc(ui32NewSizeInPages); - - if (pvNewBuf == NULL) - return IMG_FALSE; - - if (psStream->ui32RPtr <= psStream->ui32WPtr) { - - HostMemCopy((void *) pvNewBuf, - (void *) (psStream->ui32Base + - psStream->ui32RPtr), - psStream->ui32WPtr - psStream->ui32RPtr); - } else { - u32 ui32FirstCopySize; - - ui32FirstCopySize = psStream->ui32Size - psStream->ui32RPtr; - - HostMemCopy((void *) pvNewBuf, - (void *) (psStream->ui32Base + - psStream->ui32RPtr), - ui32FirstCopySize); - - HostMemCopy((void *) ((u32) pvNewBuf + - ui32FirstCopySize), - (void *) psStream->ui32Base, - psStream->ui32WPtr); - } - - ui32NewWOffset = psStream->ui32Size - ui32SpaceInOldBuf; - - if ((psStream->ui32Flags & DEBUG_FLAGS_USE_NONPAGED_MEM) != 0) - HostNonPageablePageFree((void *) psStream->ui32Base); - else - HostPageablePageFree((void *) psStream->ui32Base); - - psStream->ui32Base = (u32) pvNewBuf; - psStream->ui32RPtr = 0; - psStream->ui32WPtr = ui32NewWOffset; - psStream->ui32Size = ui32NewSizeInPages * 4096; - - return IMG_TRUE; -} - -static u32 SpaceInStream(struct DBG_STREAM *psStream) -{ - u32 ui32Space; - - if (psStream->ui32RPtr > psStream->ui32WPtr) - ui32Space = psStream->ui32RPtr - psStream->ui32WPtr; - else - ui32Space = - psStream->ui32RPtr + (psStream->ui32Size - - psStream->ui32WPtr); - - return ui32Space; -} - -void DestroyAllStreams(void) -{ - while (g_psStreamList != NULL) - DBGDrivDestroyStream(g_psStreamList); - return; -} - -struct DBG_LASTFRAME_BUFFER *FindLFBuf(struct DBG_STREAM *psStream) -{ - struct DBG_LASTFRAME_BUFFER *psLFBuffer; - - psLFBuffer = g_psLFBufferList; - - while (psLFBuffer) { - if (psLFBuffer->psStream == psStream) - break; - - psLFBuffer = psLFBuffer->psNext; - } - - return psLFBuffer; -} diff --git a/drivers/gpu/pvr/tools/dbgdriv.h b/drivers/gpu/pvr/tools/dbgdriv.h deleted file mode 100644 index 4e2ebc3..0000000 --- a/drivers/gpu/pvr/tools/dbgdriv.h +++ /dev/null @@ -1,183 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _DBGDRIV_ -#define _DBGDRIV_ - -#define BUFFER_SIZE (64 * PAGESIZE) - -#define DBGDRIV_VERSION 0x100 -#define MAX_PROCESSES 2 -#define BLOCK_USED 0x01 -#define BLOCK_LOCKED 0x02 -#define DBGDRIV_MONOBASE 0x000B0000 - -extern void *g_pvAPIMutex; - -void *DBGDrivCreateStream(char *pszName, - u32 ui32CapMode, - u32 ui32OutMode, - u32 ui32Flags, - u32 ui32Pages); -void DBGDrivDestroyStream(struct DBG_STREAM *psStream); -void *DBGDrivFindStream(char *pszName, - IMG_BOOL bResetStream); -u32 DBGDrivWriteString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level); -u32 DBGDrivReadString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Limit); -u32 DBGDrivWrite(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level); -u32 DBGDrivWrite2(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level); -u32 DBGDrivRead(struct DBG_STREAM *psStream, - IMG_BOOL bReadInitBuffer, - u32 ui32OutBufferSize, - u8 *pui8OutBuf); -void DBGDrivSetCaptureMode(struct DBG_STREAM *psStream, - u32 ui32Mode, - u32 ui32Start, - u32 ui32Stop, - u32 ui32SampleRate); -void DBGDrivSetOutputMode(struct DBG_STREAM *psStream, - u32 ui32OutMode); -void DBGDrivSetDebugLevel(struct DBG_STREAM *psStream, - u32 ui32DebugLevel); -void DBGDrivSetFrame(struct DBG_STREAM *psStream, - u32 ui32Frame); -u32 DBGDrivGetFrame(struct DBG_STREAM *psStream); -void DBGDrivOverrideMode(struct DBG_STREAM *psStream, - u32 ui32Mode); -void DBGDrivDefaultMode(struct DBG_STREAM *psStream); -u32 DBGDrivGetServiceTable(void); -u32 DBGDrivWriteStringCM(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level); -u32 DBGDrivWriteCM(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level); -void DBGDrivSetMarker(struct DBG_STREAM *psStream, - u32 ui32Marker); -u32 DBGDrivGetMarker(struct DBG_STREAM *psStream); -u32 DBGDrivIsLastCaptureFrame(struct DBG_STREAM *psStream); -u32 DBGDrivIsCaptureFrame(struct DBG_STREAM *psStream, - IMG_BOOL bCheckPreviousFrame); -u32 DBGDrivWriteLF(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level, - u32 ui32Flags); -u32 DBGDrivReadLF(struct DBG_STREAM *psStream, - u32 ui32OutBuffSize, - u8 *pui8OutBuf); -void DBGDrivStartInitPhase(struct DBG_STREAM *psStream); -void DBGDrivStopInitPhase(struct DBG_STREAM *psStream); -u32 DBGDrivGetStreamOffset(struct DBG_STREAM *psStream); -void DBGDrivSetStreamOffset(struct DBG_STREAM *psStream, u32 ui32StreamOffset); -void DBGDrivWaitForEvent(enum DBG_EVENT eEvent); - -void DestroyAllStreams(void); - -u32 AtoI(char *szIn); - -void HostMemSet(void *pvDest, u8 ui8Value, u32 ui32Size); -void HostMemCopy(void *pvDest, void *pvSrc, u32 ui32Size); -IMG_BOOL StreamValid(struct DBG_STREAM *psStream); -void Write(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32InBuffSize); -void MonoOut(char *pszString, IMG_BOOL bNewLine); - -void *ExtDBGDrivCreateStream(char *pszName, - u32 ui32CapMode, - u32 ui32OutMode, - u32 ui32Flags, - u32 ui32Size); -void ExtDBGDrivDestroyStream(struct DBG_STREAM *psStream); -void *ExtDBGDrivFindStream(char *pszName, - IMG_BOOL bResetStream); -u32 ExtDBGDrivWriteString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Level); -u32 ExtDBGDrivReadString(struct DBG_STREAM *psStream, - char *pszString, - u32 ui32Limit); -u32 ExtDBGDrivWrite(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level); -u32 ExtDBGDrivRead(struct DBG_STREAM *psStream, - IMG_BOOL bReadInitBuffer, - u32 ui32OutBuffSize, - u8 *pui8OutBuf); -void ExtDBGDrivSetCaptureMode(struct DBG_STREAM *psStream, - u32 ui32Mode, - u32 ui32Start, - u32 ui32End, - u32 ui32SampleRate); -void ExtDBGDrivSetOutputMode(struct DBG_STREAM *psStream, - u32 ui32OutMode); -void ExtDBGDrivSetDebugLevel(struct DBG_STREAM *psStream, - u32 ui32DebugLevel); -void ExtDBGDrivSetFrame(struct DBG_STREAM *psStream, - u32 ui32Frame); -u32 ExtDBGDrivGetFrame(struct DBG_STREAM *psStream); -void ExtDBGDrivOverrideMode(struct DBG_STREAM *psStream, - u32 ui32Mode); -void ExtDBGDrivDefaultMode(struct DBG_STREAM *psStream); -u32 ExtDBGDrivWrite2(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level); -u32 ExtDBGDrivWriteStringCM(struct DBG_STREAM *psStream, char *pszString, - u32 ui32Level); -u32 ExtDBGDrivWriteCM(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level); -void ExtDBGDrivSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker); -u32 ExtDBGDrivGetMarker(struct DBG_STREAM *psStream); -void ExtDBGDrivStartInitPhase(struct DBG_STREAM *psStream); -void ExtDBGDrivStopInitPhase(struct DBG_STREAM *psStream); -u32 ExtDBGDrivIsLastCaptureFrame(struct DBG_STREAM *psStream); -u32 ExtDBGDrivIsCaptureFrame(struct DBG_STREAM *psStream, - IMG_BOOL bCheckPreviousFrame); -u32 ExtDBGDrivWriteLF(struct DBG_STREAM *psStream, - u8 *pui8InBuf, - u32 ui32InBuffSize, - u32 ui32Level, - u32 ui32Flags); -u32 ExtDBGDrivReadLF(struct DBG_STREAM *psStream, - u32 ui32OutBuffSize, - u8 *pui8OutBuf); -u32 ExtDBGDrivGetStreamOffset(struct DBG_STREAM *psStream); -void ExtDBGDrivSetStreamOffset(struct DBG_STREAM *psStream, - u32 ui32StreamOffset); -void ExtDBGDrivWaitForEvent(enum DBG_EVENT eEvent); - -#endif diff --git a/drivers/gpu/pvr/tools/hostfunc.c b/drivers/gpu/pvr/tools/hostfunc.c deleted file mode 100644 index efc9f68..0000000 --- a/drivers/gpu/pvr/tools/hostfunc.c +++ /dev/null @@ -1,267 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#include <linux/version.h> -#include <linux/errno.h> -#include <linux/module.h> -#include <linux/fs.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/string.h> -#include <asm/page.h> -#include <linux/vmalloc.h> -#include <linux/mutex.h> -#include <linux/hardirq.h> - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) -#include <linux/sched.h> -#include <linux/wait.h> -#include <linux/jiffies.h> -#include <linux/delay.h> -#endif - -#include "img_types.h" -#include "pvr_debug.h" - -#include "dbgdrvif.h" -#include "hostfunc.h" - -#define PVR_STRING_TERMINATOR '\0' -#define PVR_IS_FILE_SEPARATOR(character) \ - (((character) == '\\') || ((character) == '/')) - -static u32 gPVRDebugLevel = DBGPRIV_WARNING; - -void PVRSRVDebugPrintf(u32 ui32DebugLevel, - const char *pszFileName, - u32 ui32Line, const char *pszFormat, ... - ) -{ - IMG_BOOL bTrace, bDebug; - char *pszLeafName; - - pszLeafName = (char *)strrchr(pszFileName, '\\'); - - if (pszLeafName) - pszFileName = pszLeafName; - - bTrace = gPVRDebugLevel & ui32DebugLevel & DBGPRIV_CALLTRACE; - bDebug = ((gPVRDebugLevel & DBGPRIV_ALLLEVELS) >= ui32DebugLevel); - - if (bTrace || bDebug) { - va_list vaArgs; - static char szBuffer[256]; - - va_start(vaArgs, pszFormat); - - if (bDebug) { - switch (ui32DebugLevel) { - case DBGPRIV_FATAL: - { - strcpy(szBuffer, "PVR_K:(Fatal): "); - break; - } - case DBGPRIV_ERROR: - { - strcpy(szBuffer, "PVR_K:(Error): "); - break; - } - case DBGPRIV_WARNING: - { - strcpy(szBuffer, "PVR_K:(Warning): "); - break; - } - case DBGPRIV_MESSAGE: - { - strcpy(szBuffer, "PVR_K:(Message): "); - break; - } - case DBGPRIV_VERBOSE: - { - strcpy(szBuffer, "PVR_K:(Verbose): "); - break; - } - default: - { - strcpy(szBuffer, - "PVR_K:(Unknown message level)"); - break; - } - } - } else { - strcpy(szBuffer, "PVR_K: "); - } - - vsprintf(&szBuffer[strlen(szBuffer)], pszFormat, vaArgs); - - if (!bTrace) - sprintf(&szBuffer[strlen(szBuffer)], " [%d, %s]", - (int)ui32Line, pszFileName); - - printk(KERN_INFO "%s\r\n", szBuffer); - - va_end(vaArgs); - } -} - -void HostMemSet(void *pvDest, u8 ui8Value, u32 ui32Size) -{ - memset(pvDest, (int)ui8Value, (size_t) ui32Size); -} - -void HostMemCopy(void *pvDst, void *pvSrc, u32 ui32Size) -{ - memcpy(pvDst, pvSrc, ui32Size); -} - -u32 HostReadRegistryDWORDFromString(char *pcKey, char *pcValueName, - u32 *pui32Data) -{ - - return 0; -} - -void *HostPageablePageAlloc(u32 ui32Pages) -{ - return (void *)vmalloc(ui32Pages * PAGE_SIZE); -} - -void HostPageablePageFree(void *pvBase) -{ - vfree(pvBase); -} - -void *HostNonPageablePageAlloc(u32 ui32Pages) -{ - return (void *)vmalloc(ui32Pages * PAGE_SIZE); -} - -void HostNonPageablePageFree(void *pvBase) -{ - vfree(pvBase); -} - -void *HostMapKrnBufIntoUser(void *pvKrnAddr, u32 ui32Size, - void **ppvMdl) -{ - - return NULL; -} - -void HostUnMapKrnBufFromUser(void *pvUserAddr, void *pvMdl, - void *pvProcess) -{ - -} - -void HostCreateRegDeclStreams(void) -{ - -} - -void *HostCreateMutex(void) -{ - struct mutex *psSem; - - psSem = kmalloc(sizeof(*psSem), GFP_KERNEL); - if (psSem) - mutex_init(psSem); - - return psSem; -} - -void HostAquireMutex(void *pvMutex) -{ - BUG_ON(in_interrupt()); - -#if defined(PVR_DEBUG_DBGDRV_DETECT_HOST_MUTEX_COLLISIONS) - if (mutex_trylock((struct mutex *)pvMutex)) { - printk(KERN_INFO "HostAquireMutex: Waiting for mutex\n"); - mutex_lock((struct mutex *)pvMutex); - } -#else - mutex_lock((struct mutex *)pvMutex); -#endif -} - -void HostReleaseMutex(void *pvMutex) -{ - mutex_unlock((struct mutex *)pvMutex); -} - -void HostDestroyMutex(void *pvMutex) -{ - kfree(pvMutex); -} - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - -#define EVENT_WAIT_TIMEOUT_MS 500 -#define EVENT_WAIT_TIMEOUT_JIFFIES (EVENT_WAIT_TIMEOUT_MS * HZ / 1000) - -static int iStreamData; -static wait_queue_head_t sStreamDataEvent; - -s32 HostCreateEventObjects(void) -{ - init_waitqueue_head(&sStreamDataEvent); - - return 0; -} - -void HostWaitForEvent(enum DBG_EVENT eEvent) -{ - switch (eEvent) { - case DBG_EVENT_STREAM_DATA: - - wait_event_interruptible_timeout(sStreamDataEvent, - iStreamData != 0, - EVENT_WAIT_TIMEOUT_JIFFIES); - iStreamData = 0; - break; - default: - - msleep_interruptible(EVENT_WAIT_TIMEOUT_MS); - break; - } -} - -void HostSignalEvent(enum DBG_EVENT eEvent) -{ - switch (eEvent) { - case DBG_EVENT_STREAM_DATA: - iStreamData = 1; - wake_up_interruptible(&sStreamDataEvent); - break; - default: - break; - } -} - -void HostDestroyEventObjects(void) -{ -} -#endif diff --git a/drivers/gpu/pvr/tools/hostfunc.h b/drivers/gpu/pvr/tools/hostfunc.h deleted file mode 100644 index 64f8823..0000000 --- a/drivers/gpu/pvr/tools/hostfunc.h +++ /dev/null @@ -1,58 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _HOSTFUNC_ -#define _HOSTFUNC_ - -#define HOST_PAGESIZE (4096) -#define DBG_MEMORY_INITIALIZER (0xe2) - -u32 HostReadRegistryDWORDFromString(char *pcKey, char *pcValueName, - u32 *pui32Data); - -void *HostPageablePageAlloc(u32 ui32Pages); -void HostPageablePageFree(void *pvBase); -void *HostNonPageablePageAlloc(u32 ui32Pages); -void HostNonPageablePageFree(void *pvBase); - -void *HostMapKrnBufIntoUser(void *pvKrnAddr, u32 ui32Size, void **ppvMdl); -void HostUnMapKrnBufFromUser(void *pvUserAddr, void *pvMdl, void *pvProcess); - -void HostCreateRegDeclStreams(void); - -void *HostCreateMutex(void); -void HostAquireMutex(void *pvMutex); -void HostReleaseMutex(void *pvMutex); -void HostDestroyMutex(void *pvMutex); - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) -s32 HostCreateEventObjects(void); -void HostWaitForEvent(enum DBG_EVENT eEvent); -void HostSignalEvent(enum DBG_EVENT eEvent); -void HostDestroyEventObjects(void); -#endif - -#endif diff --git a/drivers/gpu/pvr/tools/hotkey.c b/drivers/gpu/pvr/tools/hotkey.c deleted file mode 100644 index b5a2eb8..0000000 --- a/drivers/gpu/pvr/tools/hotkey.c +++ /dev/null @@ -1,101 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#include "img_types.h" -#include "pvr_debug.h" -#include "dbgdrvif.h" -#include "dbgdriv.h" -#include "hotkey.h" -#include "hostfunc.h" - -u32 g_ui32HotKeyFrame = 0xFFFFFFFF; -IMG_BOOL g_bHotKeyPressed = IMG_FALSE; -IMG_BOOL g_bHotKeyRegistered = IMG_FALSE; - -struct PRIVATEHOTKEYDATA g_PrivateHotKeyData; - -void ReadInHotKeys(void) -{ - g_PrivateHotKeyData.ui32ScanCode = 0x58; - g_PrivateHotKeyData.ui32ShiftState = 0x0; - - HostReadRegistryDWORDFromString("DEBUG\\Streams", "ui32ScanCode", - &g_PrivateHotKeyData.ui32ScanCode); - HostReadRegistryDWORDFromString("DEBUG\\Streams", "ui32ShiftState", - &g_PrivateHotKeyData.ui32ShiftState); -} - -void RegisterKeyPressed(u32 dwui32ScanCode, struct HOTKEYINFO *pInfo) -{ - struct DBG_STREAM *psStream; - - PVR_UNREFERENCED_PARAMETER(pInfo); - - if (dwui32ScanCode == g_PrivateHotKeyData.ui32ScanCode) { - PVR_DPF(PVR_DBG_MESSAGE, "PDUMP Hotkey pressed !\n"); - - psStream = (struct DBG_STREAM *) - g_PrivateHotKeyData.sHotKeyInfo.pvStream; - - if (!g_bHotKeyPressed) { - - g_ui32HotKeyFrame = psStream->ui32Current + 2; - - g_bHotKeyPressed = IMG_TRUE; - } - } -} - -void ActivateHotKeys(struct DBG_STREAM *psStream) -{ - - ReadInHotKeys(); - - if (!g_PrivateHotKeyData.sHotKeyInfo.hHotKey) { - if (g_PrivateHotKeyData.ui32ScanCode != 0) { - PVR_DPF(PVR_DBG_MESSAGE, - "Activate HotKey for PDUMP.\n"); - - g_PrivateHotKeyData.sHotKeyInfo.pvStream = psStream; - - DefineHotKey(g_PrivateHotKeyData.ui32ScanCode, - g_PrivateHotKeyData.ui32ShiftState, - &g_PrivateHotKeyData.sHotKeyInfo); - } else { - g_PrivateHotKeyData.sHotKeyInfo.hHotKey = 0; - } - } -} - -void DeactivateHotKeys(void) -{ - if (g_PrivateHotKeyData.sHotKeyInfo.hHotKey != 0) { - PVR_DPF(PVR_DBG_MESSAGE, "Deactivate HotKey.\n"); - - RemoveHotKey(g_PrivateHotKeyData.sHotKeyInfo.hHotKey); - g_PrivateHotKeyData.sHotKeyInfo.hHotKey = 0; - } -} diff --git a/drivers/gpu/pvr/tools/hotkey.h b/drivers/gpu/pvr/tools/hotkey.h deleted file mode 100644 index 56c559f..0000000 --- a/drivers/gpu/pvr/tools/hotkey.h +++ /dev/null @@ -1,60 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _HOTKEY_ -#define _HOTKEY_ - -struct HOTKEYINFO { - u8 ui8ScanCode; - u8 ui8Type; - u8 ui8Flag; - u8 ui8Filler1; - u32 ui32ShiftState; - u32 ui32HotKeyProc; - void *pvStream; - u32 hHotKey; -}; - -struct PRIVATEHOTKEYDATA { - u32 ui32ScanCode; - u32 ui32ShiftState; - struct HOTKEYINFO sHotKeyInfo; -}; - -extern u32 g_ui32HotKeyFrame; -extern IMG_BOOL g_bHotKeyPressed; -extern IMG_BOOL g_bHotKeyRegistered; - -void ReadInHotKeys(void); -void ActivateHotKeys(struct DBG_STREAM *psStream); -void DeactivateHotKeys(void); - -void RemoveHotKey(u32 hHotKey); -void DefineHotKey(u32 ui32ScanCode, u32 ui32ShiftState, - struct HOTKEYINFO *psInfo); -void RegisterKeyPressed(u32 ui32ScanCode, struct HOTKEYINFO *psInfo); - -#endif diff --git a/drivers/gpu/pvr/tools/ioctl.c b/drivers/gpu/pvr/tools/ioctl.c deleted file mode 100644 index ddba527..0000000 --- a/drivers/gpu/pvr/tools/ioctl.c +++ /dev/null @@ -1,399 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#include <linux/uaccess.h> - -#include "img_types.h" -#include "dbgdrvif.h" -#include "dbgdriv.h" -#include "hotkey.h" - -u32 DBGDIOCDrivCreateStream(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_CREATESTREAM *psIn; - void **ppvOut; - static char name[32]; - - psIn = (struct DBG_IN_CREATESTREAM *)pvInBuffer; - ppvOut = (void **)pvOutBuffer; - - - if (copy_from_user(name, psIn->pszName, 32) != 0) - return IMG_FALSE; - *ppvOut = - ExtDBGDrivCreateStream(name, psIn->ui32CapMode, psIn->ui32OutMode, - 0, psIn->ui32Pages); - - - return IMG_TRUE; -} - -u32 DBGDIOCDrivDestroyStream(void *pvInBuffer, - void *pvOutBuffer) -{ - u32 *pStream; - struct DBG_STREAM *psStream; - - pStream = (u32 *) pvInBuffer; - psStream = (struct DBG_STREAM *)*pStream; - - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivDestroyStream(psStream); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivGetStream(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_FINDSTREAM *psParams; - u32 *pui32Stream; - - psParams = (struct DBG_IN_FINDSTREAM *)pvInBuffer; - pui32Stream = (u32 *) pvOutBuffer; - - *pui32Stream = - (u32) ExtDBGDrivFindStream(psParams->pszName, - psParams->bResetStream); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWriteString(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_WRITESTRING *psParams; - u32 *pui32OutLen; - - psParams = (struct DBG_IN_WRITESTRING *)pvInBuffer; - pui32OutLen = (u32 *) pvOutBuffer; - - *pui32OutLen = - ExtDBGDrivWriteString((struct DBG_STREAM *)psParams->pvStream, - psParams->pszString, psParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWriteStringCM(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_WRITESTRING *psParams; - u32 *pui32OutLen; - - psParams = (struct DBG_IN_WRITESTRING *)pvInBuffer; - pui32OutLen = (u32 *) pvOutBuffer; - - *pui32OutLen = - ExtDBGDrivWriteStringCM((struct DBG_STREAM *)psParams->pvStream, - psParams->pszString, psParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivReadString(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32OutLen; - struct DBG_IN_READSTRING *psParams; - - psParams = (struct DBG_IN_READSTRING *)pvInBuffer; - pui32OutLen = (u32 *) pvOutBuffer; - - *pui32OutLen = - ExtDBGDrivReadString(psParams->pvStream, psParams->pszString, - psParams->ui32StringLen); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWrite(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32BytesCopied; - struct DBG_IN_WRITE *psInParams; - - psInParams = (struct DBG_IN_WRITE *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = - ExtDBGDrivWrite((struct DBG_STREAM *)psInParams->pvStream, - psInParams->pui8InBuffer, - psInParams->ui32TransferSize, - psInParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWrite2(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32BytesCopied; - struct DBG_IN_WRITE *psInParams; - - psInParams = (struct DBG_IN_WRITE *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = - ExtDBGDrivWrite2((struct DBG_STREAM *)psInParams->pvStream, - psInParams->pui8InBuffer, - psInParams->ui32TransferSize, - psInParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWriteCM(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32BytesCopied; - struct DBG_IN_WRITE *psInParams; - - psInParams = (struct DBG_IN_WRITE *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = - ExtDBGDrivWriteCM((struct DBG_STREAM *)psInParams->pvStream, - psInParams->pui8InBuffer, - psInParams->ui32TransferSize, - psInParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivRead(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32BytesCopied; - struct DBG_IN_READ *psInParams; - - psInParams = (struct DBG_IN_READ *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = - ExtDBGDrivRead((struct DBG_STREAM *)psInParams->pvStream, - psInParams->bReadInitBuffer, - psInParams->ui32OutBufferSize, - psInParams->pui8OutBuffer); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivSetCaptureMode(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_SETDEBUGMODE *psParams; - - psParams = (struct DBG_IN_SETDEBUGMODE *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivSetCaptureMode((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Mode, - psParams->ui32Start, - psParams->ui32End, psParams->ui32SampleRate); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivSetOutMode(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_SETDEBUGOUTMODE *psParams; - - psParams = (struct DBG_IN_SETDEBUGOUTMODE *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivSetOutputMode((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Mode); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivSetDebugLevel(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_SETDEBUGLEVEL *psParams; - - psParams = (struct DBG_IN_SETDEBUGLEVEL *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivSetDebugLevel((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Level); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivSetFrame(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_SETFRAME *psParams; - - psParams = (struct DBG_IN_SETFRAME *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivSetFrame((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Frame); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivGetFrame(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pStream; - struct DBG_STREAM *psStream; - u32 *pui32Current; - - pStream = (u32 *) pvInBuffer; - psStream = (struct DBG_STREAM *)*pStream; - pui32Current = (u32 *) pvOutBuffer; - - *pui32Current = ExtDBGDrivGetFrame(psStream); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivIsCaptureFrame(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_ISCAPTUREFRAME *psParams; - u32 *pui32Current; - - psParams = (struct DBG_IN_ISCAPTUREFRAME *)pvInBuffer; - pui32Current = (u32 *) pvOutBuffer; - - *pui32Current = - ExtDBGDrivIsCaptureFrame((struct DBG_STREAM *)psParams->pvStream, - psParams->bCheckPreviousFrame); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivOverrideMode(void *pvInBuffer, - void *pvOutBuffer) -{ - struct DBG_IN_OVERRIDEMODE *psParams; - - psParams = (struct DBG_IN_OVERRIDEMODE *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivOverrideMode((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Mode); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivDefaultMode(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pStream; - struct DBG_STREAM *psStream; - - pStream = (u32 *) pvInBuffer; - psStream = (struct DBG_STREAM *)*pStream; - - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivDefaultMode(psStream); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivSetMarker(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_SETMARKER *psParams; - - psParams = (struct DBG_IN_SETMARKER *)pvInBuffer; - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivSetMarker((struct DBG_STREAM *)psParams->pvStream, - psParams->ui32Marker); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivGetMarker(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pStream; - struct DBG_STREAM *psStream; - u32 *pui32Current; - - pStream = (u32 *) pvInBuffer; - psStream = (struct DBG_STREAM *)*pStream; - pui32Current = (u32 *) pvOutBuffer; - - *pui32Current = ExtDBGDrivGetMarker(psStream); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivGetServiceTable(void *pvInBuffer, - void *pvOutBuffer) -{ - u32 *pui32Out; - - PVR_UNREFERENCED_PARAMETER(pvInBuffer); - pui32Out = (u32 *) pvOutBuffer; - - *pui32Out = DBGDrivGetServiceTable(); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWriteLF(void *pvInBuffer, void *pvOutBuffer) -{ - struct DBG_IN_WRITE_LF *psInParams; - u32 *pui32BytesCopied; - - psInParams = (struct DBG_IN_WRITE_LF *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = ExtDBGDrivWriteLF(psInParams->pvStream, - psInParams->pui8InBuffer, - psInParams->ui32BufferSize, - psInParams->ui32Level, - psInParams->ui32Flags); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivReadLF(void *pvInBuffer, void *pvOutBuffer) -{ - u32 *pui32BytesCopied; - struct DBG_IN_READ *psInParams; - - psInParams = (struct DBG_IN_READ *)pvInBuffer; - pui32BytesCopied = (u32 *) pvOutBuffer; - - *pui32BytesCopied = - ExtDBGDrivReadLF((struct DBG_STREAM *)psInParams->pvStream, - psInParams->ui32OutBufferSize, - psInParams->pui8OutBuffer); - - return IMG_TRUE; -} - -u32 DBGDIOCDrivWaitForEvent(void *pvInBuffer, void *pvOutBuffer) -{ - enum DBG_EVENT eEvent = (enum DBG_EVENT)(*(u32 *) pvInBuffer); - - PVR_UNREFERENCED_PARAMETER(pvOutBuffer); - - ExtDBGDrivWaitForEvent(eEvent); - - return IMG_TRUE; -} diff --git a/drivers/gpu/pvr/tools/ioctl.h b/drivers/gpu/pvr/tools/ioctl.h deleted file mode 100644 index fcb1ff1..0000000 --- a/drivers/gpu/pvr/tools/ioctl.h +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _IOCTL_ -#define _IOCTL_ - -u32 DBGDIOCDrivCreateStream(void *, void *); -u32 DBGDIOCDrivDestroyStream(void *, void *); -u32 DBGDIOCDrivGetStream(void *, void *); -u32 DBGDIOCDrivWriteString(void *, void *); -u32 DBGDIOCDrivReadString(void *, void *); -u32 DBGDIOCDrivWrite(void *, void *); -u32 DBGDIOCDrivWrite2(void *, void *); -u32 DBGDIOCDrivRead(void *, void *); -u32 DBGDIOCDrivSetCaptureMode(void *, void *); -u32 DBGDIOCDrivSetOutMode(void *, void *); -u32 DBGDIOCDrivSetDebugLevel(void *, void *); -u32 DBGDIOCDrivSetFrame(void *, void *); -u32 DBGDIOCDrivGetFrame(void *, void *); -u32 DBGDIOCDrivOverrideMode(void *, void *); -u32 DBGDIOCDrivDefaultMode(void *, void *); -u32 DBGDIOCDrivGetServiceTable(void *, void *); -u32 DBGDIOCDrivWriteStringCM(void *, void *); -u32 DBGDIOCDrivWriteCM(void *, void *); -u32 DBGDIOCDrivSetMarker(void *, void *); -u32 DBGDIOCDrivGetMarker(void *, void *); -u32 DBGDIOCDrivIsCaptureFrame(void *, void *); -u32 DBGDIOCDrivWriteLF(void *, void *); -u32 DBGDIOCDrivReadLF(void *, void *); -u32 DBGDIOCDrivWaitForEvent(void *, void *); - -u32(*g_DBGDrivProc[])(void *, void *) = { -DBGDIOCDrivCreateStream, - DBGDIOCDrivDestroyStream, - DBGDIOCDrivGetStream, - DBGDIOCDrivWriteString, - DBGDIOCDrivReadString, - DBGDIOCDrivWrite, - DBGDIOCDrivRead, - DBGDIOCDrivSetCaptureMode, - DBGDIOCDrivSetOutMode, - DBGDIOCDrivSetDebugLevel, - DBGDIOCDrivSetFrame, - DBGDIOCDrivGetFrame, - DBGDIOCDrivOverrideMode, - DBGDIOCDrivDefaultMode, - DBGDIOCDrivGetServiceTable, - DBGDIOCDrivWrite2, - DBGDIOCDrivWriteStringCM, - DBGDIOCDrivWriteCM, - DBGDIOCDrivSetMarker, - DBGDIOCDrivGetMarker, - DBGDIOCDrivIsCaptureFrame, - DBGDIOCDrivWriteLF, DBGDIOCDrivReadLF, DBGDIOCDrivWaitForEvent}; - -#define MAX_DBGVXD_W32_API (sizeof(g_DBGDrivProc)/sizeof(u32)) - -#endif diff --git a/drivers/gpu/pvr/tools/linuxsrv.h b/drivers/gpu/pvr/tools/linuxsrv.h deleted file mode 100644 index 822ba4e..0000000 --- a/drivers/gpu/pvr/tools/linuxsrv.h +++ /dev/null @@ -1,47 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _LINUXSRV_H__ -#define _LINUXSRV_H__ - -struct IOCTL_PACKAGE { - u32 ui32Cmd; - u32 ui32Size; - void *pInBuffer; - u32 ui32InBufferSize; - void *pOutBuffer; - u32 ui32OutBufferSize; -}; - -u32 DeviceIoControl(u32 hDevice, - u32 ui32ControlCode, - void *pInBuffer, - u32 ui32InBufferSize, - void *pOutBuffer, - u32 ui32OutBufferSize, - u32 *pui32BytesReturned); - -#endif diff --git a/drivers/gpu/pvr/tools/main.c b/drivers/gpu/pvr/tools/main.c deleted file mode 100644 index 5de15cc..0000000 --- a/drivers/gpu/pvr/tools/main.c +++ /dev/null @@ -1,197 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#include <linux/errno.h> -#include <linux/module.h> -#include <linux/fs.h> -#include <linux/kernel.h> -#include <linux/kdev_t.h> -#include <linux/pci.h> -#include <linux/list.h> -#include <linux/init.h> -#include <linux/vmalloc.h> -#include <linux/uaccess.h> - -#include "img_types.h" -#include "linuxsrv.h" -#include "ioctl.h" -#include "dbgdrvif.h" -#include "dbgdriv.h" -#include "hostfunc.h" -#include "pvr_debug.h" - -#define DRVNAME "dbgdrv" - -MODULE_AUTHOR("Imagination Technologies Ltd. <gpl-support@imgtec.com>"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE(DRVNAME); - -static int AssignedMajorNumber; - -static long dbgdrv_ioctl(struct file *, unsigned int, unsigned long); - -static int dbgdrv_open(struct inode unref__ * pInode, - struct file unref__ * pFile) -{ - return 0; -} - -static int dbgdrv_release(struct inode unref__ * pInode, - struct file unref__ * pFile) -{ - return 0; -} - -static int dbgdrv_mmap(struct file *pFile, struct vm_area_struct *ps_vma) -{ - return 0; -} - -static const struct file_operations dbgdrv_fops = { -owner: THIS_MODULE, -unlocked_ioctl : dbgdrv_ioctl, -open : dbgdrv_open, -release : dbgdrv_release, -mmap : dbgdrv_mmap, -}; - -void DBGDrvGetServiceTable(void **fn_table) -{ - *fn_table = &g_sDBGKMServices; - -} -EXPORT_SYMBOL(DBGDrvGetServiceTable); - -void cleanup_module(void) -{ - if (AssignedMajorNumber > 0) - unregister_chrdev(AssignedMajorNumber, DRVNAME); - -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - HostDestroyEventObjects(); -#endif - - if (g_pvAPIMutex != NULL) - HostDestroyMutex(g_pvAPIMutex); - - return; -} - -int init_module(void) -{ - g_pvAPIMutex = HostCreateMutex(); - if (g_pvAPIMutex == NULL) { - cleanup_module(); - return -ENOMEM; - } -#if defined(SUPPORT_DBGDRV_EVENT_OBJECTS) - - (void)HostCreateEventObjects(); -#endif - - AssignedMajorNumber = - register_chrdev(AssignedMajorNumber, DRVNAME, &dbgdrv_fops); - - if (AssignedMajorNumber <= 0) { - PVR_DPF(PVR_DBG_ERROR, " unable to get major\n"); - cleanup_module(); - return -EBUSY; - } - - return 0; -} - -static long dbgdrv_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct IOCTL_PACKAGE *pIP = (struct IOCTL_PACKAGE *)arg; - - char *buffer, *in, *out; - - if ((pIP->ui32InBufferSize > (PAGE_SIZE >> 1)) - || (pIP->ui32OutBufferSize > (PAGE_SIZE >> 1))) { - PVR_DPF(PVR_DBG_ERROR, - "Sizes of the buffers are too large, cannot do ioctl\n"); - return -1; - } - - buffer = (char *)HostPageablePageAlloc(1); - if (!buffer) { - PVR_DPF(PVR_DBG_ERROR, - "Failed to allocate buffer, cannot do ioctl\n"); - return -EFAULT; - } - - in = buffer; - out = buffer + (PAGE_SIZE >> 1); - - if (copy_from_user(in, pIP->pInBuffer, pIP->ui32InBufferSize) != 0) - goto init_failed; - - cmd = ((pIP->ui32Cmd >> 2) & 0xFFF) - 0x801; - - if (pIP->ui32Cmd == DEBUG_SERVICE_READ) { - char *ui8Tmp; - u32 *pui32BytesCopied = (u32 *) out; - struct DBG_IN_READ *psReadInParams = (struct DBG_IN_READ *)in; - - ui8Tmp = vmalloc(psReadInParams->ui32OutBufferSize); - if (!ui8Tmp) - goto init_failed; - *pui32BytesCopied = ExtDBGDrivRead((struct DBG_STREAM *) - psReadInParams->pvStream, - psReadInParams->bReadInitBuffer, - psReadInParams->ui32OutBufferSize, ui8Tmp); - if (copy_to_user(psReadInParams->pui8OutBuffer, ui8Tmp, - *pui32BytesCopied) != 0) { - vfree(ui8Tmp); - goto init_failed; - } - vfree(ui8Tmp); - } else { - (g_DBGDrivProc[cmd]) (in, out); - } - - if (copy_to_user(pIP->pOutBuffer, out, pIP->ui32OutBufferSize) != 0) - goto init_failed; - - HostPageablePageFree((void *) buffer); - return 0; - -init_failed: - HostPageablePageFree((void *) buffer); - return -EFAULT; -} - -void RemoveHotKey(unsigned hHotKey) -{ - -} - -void DefineHotKey(unsigned ScanCode, unsigned ShiftState, void *pInfo) -{ - -} - -- 1.7.5.4 From 26ca63ad8992c392f56847a90f7fd40a55b0235d Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:28 +0100 Subject: [PATCH 30/95] gpu: pvr: pdump: remove wrapping of globals in pdump.c The gsDBGPdumpState struct just clutters up the place. No functional change. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 425 ++++++++++++++++++++++++----------------------- 1 files changed, 214 insertions(+), 211 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index dc700b8..a7345c2 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -67,6 +67,11 @@ static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); +static u32 gui32ParamFileNum; +static char *gpszMsg; +static char *gpszScript; +static char *gpszFile; + #define PDUMP_STREAM_PARAM2 0 #define PDUMP_STREAM_SCRIPT2 1 #define PDUMP_NUM_STREAMS 2 @@ -75,35 +80,7 @@ static char *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", "ScriptStream2" }; -#define __PDBG_PDUMP_STATE_GET_MSG_STRING(ERROR) \ - char *pszMsg = gsDBGPdumpState.pszMsg; \ - if ((!pszMsg) || PDumpSuspended()) \ - return ERROR - -#define __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(ERROR) \ - char *pszScript = gsDBGPdumpState.pszScript; \ - if ((!pszScript) || PDumpSuspended()) \ - return ERROR - -#define __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(ERROR) \ - char *pszScript = gsDBGPdumpState.pszScript; \ - char *pszFile = gsDBGPdumpState.pszFile; \ - if ((!pszScript) || (!pszFile) || PDumpSuspended()) \ - return ERROR - -struct PDBG_PDUMP_STATE { - struct DBG_STREAM *psStream[PDUMP_NUM_STREAMS]; - u32 ui32ParamFileNum; - - char *pszMsg; - char *pszScript; - char *pszFile; - -}; - -static struct PDBG_PDUMP_STATE gsDBGPdumpState = { - {NULL}, 0, NULL, NULL, NULL -}; +static struct DBG_STREAM *gpsStream[PDUMP_NUM_STREAMS] = {NULL}; #define SZ_MSG_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) #define SZ_SCRIPT_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) @@ -179,40 +156,38 @@ void PDumpInit(void) { u32 i = 0; - if (!gsDBGPdumpState.pszFile) + if (!gpszFile) if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, - (void **)&gsDBGPdumpState.pszFile, + (void **)&gpszFile, NULL) != PVRSRV_OK) goto init_failed; - if (!gsDBGPdumpState.pszMsg) + if (!gpszMsg) if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, - (void **)&gsDBGPdumpState.pszMsg, + (void **)&gpszMsg, NULL) != PVRSRV_OK) goto init_failed; - if (!gsDBGPdumpState.pszScript) + if (!gpszScript) if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, - (void **)&gsDBGPdumpState.pszScript, + (void **)&gpszScript, NULL) != PVRSRV_OK) goto init_failed; for (i = 0; i < PDUMP_NUM_STREAMS; i++) { - gsDBGPdumpState.psStream[i] = + gpsStream[i] = DbgDrvCreateStream(pszStreamName[i], DEBUG_CAPMODE_FRAMED, DEBUG_OUTMODE_STREAMENABLE, 0, 10); - DbgDrvSetCaptureMode(gsDBGPdumpState. - psStream[i], + DbgDrvSetCaptureMode(gpsStream[i], DEBUG_CAPMODE_FRAMED, - 0xFFFFFFFF, 0xFFFFFFFF, - 1); - DbgDrvSetFrame(gsDBGPdumpState.psStream[i], 0); + 0xFFFFFFFF, 0xFFFFFFFF, 1); + DbgDrvSetFrame(gpsStream[i], 0); } PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); @@ -224,22 +199,22 @@ void PDumpInit(void) init_failed: - if (gsDBGPdumpState.pszFile) { + if (gpszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, - (void *)gsDBGPdumpState.pszFile, NULL); - gsDBGPdumpState.pszFile = NULL; + (void *)gpszFile, NULL); + gpszFile = NULL; } - if (gsDBGPdumpState.pszScript) { + if (gpszScript) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, - (void *)gsDBGPdumpState.pszScript, NULL); - gsDBGPdumpState.pszScript = NULL; + (void *)gpszScript, NULL); + gpszScript = NULL; } - if (gsDBGPdumpState.pszMsg) { + if (gpszMsg) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, - (void *)gsDBGPdumpState.pszMsg, NULL); - gsDBGPdumpState.pszMsg = NULL; + (void *)gpszMsg, NULL); + gpszMsg = NULL; } } @@ -248,24 +223,24 @@ void PDumpDeInit(void) u32 i = 0; for (i = 0; i < PDUMP_NUM_STREAMS; i++) - DbgDrvDestroyStream(gsDBGPdumpState.psStream[i]); + DbgDrvDestroyStream(gpsStream[i]); - if (gsDBGPdumpState.pszFile) { + if (gpszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, - (void *)gsDBGPdumpState.pszFile, NULL); - gsDBGPdumpState.pszFile = NULL; + (void *)gpszFile, NULL); + gpszFile = NULL; } - if (gsDBGPdumpState.pszScript) { + if (gpszScript) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, - (void *)gsDBGPdumpState.pszScript, NULL); - gsDBGPdumpState.pszScript = NULL; + (void *)gpszScript, NULL); + gpszScript = NULL; } - if (gsDBGPdumpState.pszMsg) { + if (gpszMsg) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, - (void *)gsDBGPdumpState.pszMsg, NULL); - gsDBGPdumpState.pszMsg = NULL; + (void *)gpszMsg, NULL); + gpszMsg = NULL; } } @@ -273,55 +248,58 @@ void PDumpComment(char *pszFormat, ...) { va_list ap; - __PDBG_PDUMP_STATE_GET_MSG_STRING(); + if (PDumpSuspended()) + return; va_start(ap, pszFormat); - vsnprintf(pszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); va_end(ap); - PDumpCommentKM(pszMsg, PDUMP_FLAGS_CONTINUOUS); + PDumpCommentKM(gpszMsg, PDUMP_FLAGS_CONTINUOUS); } void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) { va_list ap; - __PDBG_PDUMP_STATE_GET_MSG_STRING(); + if (PDumpSuspended()) + return; va_start(ap, pszFormat); - vsnprintf(pszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); va_end(ap); - PDumpCommentKM(pszMsg, ui32Flags); + PDumpCommentKM(gpszMsg, ui32Flags); } IMG_BOOL PDumpIsCaptureFrameKM(void) { if (PDumpSuspended()) return IMG_FALSE; - return DbgDrvIsCaptureFrame(gsDBGPdumpState. - psStream[PDUMP_STREAM_SCRIPT2], - IMG_FALSE); + return DbgDrvIsCaptureFrame(gpsStream[PDUMP_STREAM_SCRIPT2], + IMG_FALSE); } enum PVRSRV_ERROR PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(gpszScript, ui32Flags); return PVRSRV_OK; } void PDumpReg(u32 ui32Reg, u32 ui32Data) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, @@ -332,7 +310,9 @@ enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, #define POLL_COUNT_SHORT (1000000 / POLL_DELAY) u32 ui32PollCount; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(PVRSRV_ERROR_GENERIC); + + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; if (((ui32RegAddr == EUR_CR_EVENT_STATUS) && (ui32RegValue & ui32Mask & @@ -347,11 +327,11 @@ enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, else ui32PollCount = POLL_COUNT_SHORT; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "POL :SGXREG:0x%8.8X 0x%8.8X 0x%8.8X %d %u %d\r\n", ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, POLL_DELAY); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(gpszScript, ui32Flags); return PVRSRV_OK; } @@ -371,17 +351,20 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + + if (PDumpSuspended()) + return; + PVR_UNREFERENCED_PARAMETER(pvLinAddr); PVR_ASSERT(((u32) ui32DevVAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(hOSMemHandle); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", ui32DevVAddr, ui32NumBytes, ui32PageSize); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); ui32Offset = 0; ui32NumPages = ui32NumBytes / ui32PageSize; @@ -392,11 +375,11 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); ui32Page = sDevPAddr.uiAddr / ui32PageSize; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", (u32)hUniqueTag, ui32Page * ui32PageSize, ui32PageSize, ui32PageSize, ui32Page * ui32PageSize); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } } @@ -408,14 +391,16 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + + if (PDumpSuspended()) + return; PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", ui32PTSize, SGX_MMU_PAGE_SIZE); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); pui8LinAddr = (u8 *) pvLinAddr; @@ -426,12 +411,12 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "MALLOC :SGXMEM:PA_%8.8X%8.8lX 0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, ui32Page * SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, ui32Page * SGX_MMU_PAGE_SIZE); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); pui8LinAddr += SGX_MMU_PAGE_SIZE; } } @@ -443,14 +428,16 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumPages, ui32PageCounter; struct IMG_DEV_PHYADDR sDevPAddr; struct PVRSRV_DEVICE_NODE *psDeviceNode; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + + if (PDumpSuspended()) + return; PVR_ASSERT(((u32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, "-- FREE :SGXMEM:VA_%8.8X\r\n", + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); ui32NumPages = ui32NumBytes / ui32PageSize; psDeviceNode = psBMHeap->pBMContext->psDeviceNode; @@ -462,10 +449,10 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, pMMUHeap, sDevVAddr); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", (u32)hUniqueTag, sDevPAddr.uiAddr); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } else { } @@ -482,13 +469,15 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + + if (PDumpSuspended()) + return; PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- FREE :SGXMEM:PAGE_TABLE\r\n"); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); pui8LinAddr = (u8 *) pvLinAddr; @@ -500,36 +489,36 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; pui8LinAddr += SGX_MMU_PAGE_SIZE; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", (u32)hUniqueTag, ui32Page * SGX_MMU_PAGE_SIZE); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } } void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, - SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32)hUniqueTag, ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), ui32Data & (SGX_MMU_PAGE_SIZE - 1)); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, void *hUniqueTag) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, - SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32) hUniqueTag, ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), ui32Data & (SGX_MMU_PAGE_SIZE - 1)); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(gpszScript, ui32Flags); } enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, @@ -544,16 +533,18 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); + + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; PVR_ASSERT((ui32Offset + sizeof(u32)) <= psMemInfo->ui32AllocSize); - if (gsDBGPdumpState.ui32ParamFileNum == 0) - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); + if (gui32ParamFileNum == 0) + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); else - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gsDBGPdumpState.ui32ParamFileNum); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", + gui32ParamFileNum); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -566,13 +557,13 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr += ui32PageOffset; - snprintf(pszScript, - SZ_SCRIPT_SIZE_MAX, "POL :SGXMEM:" + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "POL :SGXMEM:" "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); - PDumpWriteString2(pszScript, 0); + + PDumpWriteString2(gpszScript, 0); return PVRSRV_OK; } @@ -592,7 +583,8 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, u32 ui32CurrentOffset; u32 ui32BytesRemaining; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); @@ -611,26 +603,25 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, PVR_ASSERT(pui8DataLinAddr); ui32ParamOutPos = - DbgDrvGetStreamOffset(gsDBGPdumpState. - psStream[PDUMP_STREAM_PARAM2]); + DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (!PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], - pui8DataLinAddr, ui32Bytes, ui32Flags)) - return PVRSRV_ERROR_GENERIC; + if (!PDumpWriteILock(gpsStream[PDUMP_STREAM_PARAM2], + pui8DataLinAddr, ui32Bytes, ui32Flags)) + return PVRSRV_ERROR_GENERIC; - if (gsDBGPdumpState.ui32ParamFileNum == 0) { - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); + if (gui32ParamFileNum == 0) { + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); } else { - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gsDBGPdumpState.ui32ParamFileNum); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", + gui32ParamFileNum); } - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X 0x%8.8X %s\r\n", psMemInfo->sDevVAddr.uiAddr, - ui32Offset, ui32Bytes, ui32ParamOutPos, pszFile); - PDumpWriteString2(pszScript, ui32Flags); + ui32Offset, ui32Bytes, ui32ParamOutPos, gpszFile); + PDumpWriteString2(gpszScript, ui32Flags); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -664,14 +655,14 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, ui32PageByteOffset = 0; } - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %s\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos, pszFile); - PDumpWriteString2(pszScript, ui32Flags); + ui32BlockBytes, ui32ParamOutPos, gpszFile); + PDumpWriteString2(gpszScript, ui32Flags); ui32BytesRemaining -= ui32BlockBytes; ui32CurrentOffset += ui32BlockBytes; @@ -696,7 +687,8 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32Offset; u32 ui32ParamOutPos; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; if (ui32Flags) ; @@ -705,21 +697,20 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, return PVRSRV_ERROR_GENERIC; ui32ParamOutPos = - DbgDrvGetStreamOffset(gsDBGPdumpState. - psStream[PDUMP_STREAM_PARAM2]); + DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); if (bInitialisePages) { if (!PDumpWriteILock - (gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], pvLinAddr, + (gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, ui32Bytes, PDUMP_FLAGS_CONTINUOUS)) return PVRSRV_ERROR_GENERIC; - if (gsDBGPdumpState.ui32ParamFileNum == 0) - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); + if (gui32ParamFileNum == 0) + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); else - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gsDBGPdumpState.ui32ParamFileNum); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", + gui32ParamFileNum); } ui32PageOffset = (u32) pvLinAddr & (HOST_PAGESIZE() - 1); @@ -738,15 +729,15 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32BlockBytes = ui32Bytes; if (bInitialisePages) { - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " "0x%8.8X %s\r\n", (u32) hUniqueTag1, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos, pszFile); - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + ui32BlockBytes, ui32ParamOutPos, gpszFile); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } else { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(u32)) { @@ -755,7 +746,7 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32Offset)); if ((ui32PTE & SGX_MMU_PDE_ADDR_MASK) != 0) { - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32)hUniqueTag1, @@ -774,7 +765,7 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, PVR_ASSERT(! (ui32PTE & SGX_MMU_PTE_VALID)); - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X%8.8X\r\n", (u32) hUniqueTag1, (sDevPAddr.uiAddr + @@ -785,7 +776,7 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, (SGX_MMU_PAGE_SIZE - 1), ui32PTE, (u32)hUniqueTag2); } - PDumpWriteString2(pszScript, + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } } @@ -811,22 +802,22 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; ui32ParamOutPos = - DbgDrvGetStreamOffset(gsDBGPdumpState. - psStream[PDUMP_STREAM_PARAM2]); + DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (!PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2], + if (!PDumpWriteILock(gpsStream[PDUMP_STREAM_PARAM2], (u8 *)&sPDDevPAddr, sizeof(struct IMG_DEV_PHYADDR), PDUMP_FLAGS_CONTINUOUS)) return PVRSRV_ERROR_GENERIC; - if (gsDBGPdumpState.ui32ParamFileNum == 0) - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); + if (gui32ParamFileNum == 0) + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); else - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gsDBGPdumpState.ui32ParamFileNum); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", + gui32ParamFileNum); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -840,7 +831,7 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr += ui32PageByteOffset; if ((sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK) != 0) { - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32) hUniqueTag1, @@ -851,7 +842,7 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sPDDevPAddr.uiAddr & ~SGX_MMU_PDE_ADDR_MASK); } else { PVR_ASSERT(!(sDevPAddr.uiAddr & SGX_MMU_PTE_VALID)); - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", (u32)hUniqueTag1, @@ -859,7 +850,7 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), sPDDevPAddr.uiAddr); } - PDumpWriteString2(pszScript, PDUMP_FLAGS_CONTINUOUS); + PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); return PVRSRV_OK; } @@ -869,9 +860,8 @@ enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame) u32 ui32Stream; for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) - if (gsDBGPdumpState.psStream[ui32Stream]) - DbgSetFrame(gsDBGPdumpState.psStream[ui32Stream], - ui32Frame); + if (gpsStream[ui32Stream]) + DbgSetFrame(gpsStream[ui32Stream], ui32Frame); return PVRSRV_OK; } @@ -880,7 +870,9 @@ enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) { u32 ui32Count = 0; enum PVRSRV_ERROR eError; - __PDBG_PDUMP_STATE_GET_MSG_STRING(PVRSRV_ERROR_GENERIC); + + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) eError = PVRSRV_ERROR_GENERIC; @@ -890,24 +882,24 @@ enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) if (!PDumpWriteString2("-- ", ui32Flags)) return eError; - snprintf(pszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); + snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); - while ((pszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) + while ((gpszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) ui32Count++; - if ((pszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { - pszMsg[ui32Count] = '\n'; + if ((gpszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { + gpszMsg[ui32Count] = '\n'; ui32Count++; - pszMsg[ui32Count] = '\0'; + gpszMsg[ui32Count] = '\0'; } - if ((pszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { - pszMsg[ui32Count - 1] = '\r'; - pszMsg[ui32Count] = '\n'; + if ((gpszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { + gpszMsg[ui32Count - 1] = '\r'; + gpszMsg[ui32Count] = '\n'; ui32Count++; - pszMsg[ui32Count] = '\0'; + gpszMsg[ui32Count] = '\0'; } - PDumpWriteString2(pszMsg, ui32Flags); + PDumpWriteString2(gpszMsg, ui32Flags); return PVRSRV_OK; } @@ -918,11 +910,13 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; + PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " "0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", @@ -930,7 +924,7 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, ui32FileOffset, ePixelFormat, ui32Width, ui32Height, ui32StrideInBytes, eMemFormat); - PDumpWriteString2(pszScript, ui32PDumpFlags); + PDumpWriteString2(gpszScript, ui32PDumpFlags); return PVRSRV_OK; } @@ -938,21 +932,22 @@ static enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(PVRSRV_ERROR_GENERIC); + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, ui32FileOffset, pszFileName); - PDumpWriteString2(pszScript, ui32PDumpFlags); + PDumpWriteString2(gpszScript, ui32PDumpFlags); return PVRSRV_OK; } static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags) { - return PDumpWriteILock(gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2], + return PDumpWriteILock(gpsStream[PDUMP_STREAM_SCRIPT2], (u8 *)pszString, strlen(pszString), ui32Flags); } @@ -965,22 +960,19 @@ static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, if (!psStream || PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) return IMG_TRUE; - if (psStream == gsDBGPdumpState.psStream[PDUMP_STREAM_PARAM2]) { + if (psStream == gpsStream[PDUMP_STREAM_PARAM2]) { u32 ui32ParamOutPos = - DbgDrvGetStreamOffset(gsDBGPdumpState. - psStream - [PDUMP_STREAM_PARAM2]); + DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); if (ui32ParamOutPos + ui32Count > MAX_FILE_SIZE) - if ((gsDBGPdumpState.psStream[PDUMP_STREAM_SCRIPT2] + if ((gpsStream[PDUMP_STREAM_SCRIPT2] && PDumpWriteString2 ("\r\n-- Splitting pdump output file\r\n\r\n", ui32Flags))) { - DbgSetMarker(gsDBGPdumpState. - psStream[PDUMP_STREAM_PARAM2], + DbgSetMarker(gpsStream[PDUMP_STREAM_PARAM2], ui32ParamOutPos); - gsDBGPdumpState.ui32ParamFileNum++; + gui32ParamFileNum++; } } @@ -1043,16 +1035,17 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, u32 ui32FileOffset; u32 i; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); + if (PDumpSuspended()) + return; ui32FileOffset = 0; PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump 3D signature registers\r\n"); - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", ui32DumpFrameNum); for (i = 0; i < ui32NumRegisters; i++) { - PDumpReadRegKM(pszFile, ui32FileOffset, pui32Registers[i], + PDumpReadRegKM(gpszFile, ui32FileOffset, pui32Registers[i], sizeof(u32), 0); ui32FileOffset += sizeof(u32); } @@ -1061,12 +1054,14 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, static void PDumpCountRead(char *pszFileName, u32 ui32Address, u32 ui32Size, u32 *pui32FileOffset) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, *pui32FileOffset, pszFileName); - PDumpWriteString2(pszScript, 0); + + PDumpWriteString2(gpszScript, 0); *pui32FileOffset += ui32Size; } @@ -1077,15 +1072,16 @@ void PDumpCounterRegisters(u32 ui32DumpFrameNum, u32 ui32FileOffset; u32 i; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); + if (PDumpSuspended()) + return; PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump counter registers\r\n"); - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); ui32FileOffset = 0; for (i = 0; i < ui32NumRegisters; i++) - PDumpCountRead(pszFile, pui32Registers[i], sizeof(u32), + PDumpCountRead(gpszFile, pui32Registers[i], sizeof(u32), &ui32FileOffset); } @@ -1095,16 +1091,17 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, u32 ui32FileOffset; u32 i; - __PDBG_PDUMP_STATE_GET_SCRIPT_AND_FILE_STRING(); + if (PDumpSuspended()) + return; PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump TA signature registers\r\n"); - snprintf(pszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", ui32DumpFrameNum); ui32FileOffset = ui32TAKickCount * ui32NumRegisters * sizeof(u32); for (i = 0; i < ui32NumRegisters; i++) { - PDumpReadRegKM(pszFile, ui32FileOffset, pui32Registers[i], + PDumpReadRegKM(gpszFile, ui32FileOffset, pui32Registers[i], sizeof(u32), 0); ui32FileOffset += sizeof(u32); } @@ -1112,36 +1109,40 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(gpszScript, ui32Flags); } void PDumpCycleCountRegRead(const u32 ui32RegOffset) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - snprintf(pszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); - PDumpWriteString2(pszScript, 0); + PDumpWriteString2(gpszScript, 0); } void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, u32 ui32PDumpFlags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; + PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); - PDumpWriteString2(pszScript, ui32PDumpFlags); + PDumpWriteString2(gpszScript, ui32PDumpFlags); } void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, @@ -1154,7 +1155,8 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= psROffMemInfo->ui32AllocSize); @@ -1174,22 +1176,23 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, sDevPAddr.uiAddr += ui32PageOffset; - snprintf(pszScript, + snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), ui32WPosVal, ui32PacketSize, ui32BufferSize); - PDumpWriteString2(pszScript, ui32Flags); + PDumpWriteString2(gpszScript, ui32Flags); } void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) { - __PDBG_PDUMP_STATE_GET_SCRIPT_STRING(); + if (PDumpSuspended()) + return; - sprintf(pszScript, "IDL %u\r\n", ui32Clocks); - PDumpWriteString2(pszScript, ui32Flags); + sprintf(gpszScript, "IDL %u\r\n", ui32Clocks); + PDumpWriteString2(gpszScript, ui32Flags); } void PDumpSuspendKM(void) -- 1.7.5.4 From 377f6c7451be3593cb839980f27e5255b618e814 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:29 +0100 Subject: [PATCH 31/95] gpu: pvr: pdump: remove pdump marker code This was used to signal to the userspace tool that the parameter stream has grown beyond 1GB. We can handle files bigger than that in our world. No functional change, as far as the services module is concerned. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 72 ++++------------------------------------------ 1 files changed, 7 insertions(+), 65 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index a7345c2..64ed76e 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -57,17 +57,13 @@ static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags); static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, u32 ui32Flags); static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame); -static void DbgSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker); static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32BCount, u32 ui32Flags); #define MIN(a, b) (a > b ? b : a) -#define MAX_FILE_SIZE 0x40000000 - static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); -static u32 gui32ParamFileNum; static char *gpszMsg; static char *gpszScript; static char *gpszFile; @@ -134,12 +130,6 @@ DbgDrvWriteBINCM(struct DBG_STREAM *psStream, u8 *pui8InBuf, return ui32InBuffSize; } -static void -DbgDrvSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) -{ - -} - static u32 DbgDrvIsCaptureFrame(struct DBG_STREAM *psStream, IMG_BOOL bCheckPreviousFrame) { @@ -540,12 +530,6 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVR_ASSERT((ui32Offset + sizeof(u32)) <= psMemInfo->ui32AllocSize); - if (gui32ParamFileNum == 0) - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); - else - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gui32ParamFileNum); - CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); ui32PageOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); @@ -609,18 +593,11 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, pui8DataLinAddr, ui32Bytes, ui32Flags)) return PVRSRV_ERROR_GENERIC; - if (gui32ParamFileNum == 0) { - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); - } else { - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gui32ParamFileNum); - } - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X 0x%8.8X %s\r\n", + "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X 0x%8.8X %%0%%.prm\r\n", psMemInfo->sDevVAddr.uiAddr, - ui32Offset, ui32Bytes, ui32ParamOutPos, gpszFile); + ui32Offset, ui32Bytes, ui32ParamOutPos); PDumpWriteString2(gpszScript, ui32Flags); CpuPAddr = @@ -657,11 +634,11 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %s\r\n", + "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %%0%%.prm\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos, gpszFile); + ui32BlockBytes, ui32ParamOutPos); PDumpWriteString2(gpszScript, ui32Flags); ui32BytesRemaining -= ui32BlockBytes; @@ -699,20 +676,12 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32ParamOutPos = DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (bInitialisePages) { - + if (bInitialisePages) if (!PDumpWriteILock (gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, ui32Bytes, PDUMP_FLAGS_CONTINUOUS)) return PVRSRV_ERROR_GENERIC; - if (gui32ParamFileNum == 0) - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); - else - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gui32ParamFileNum); - } - ui32PageOffset = (u32) pvLinAddr & (HOST_PAGESIZE() - 1); ui32NumPages = (ui32PageOffset + ui32Bytes + HOST_PAGESIZE() - 1) / @@ -732,11 +701,11 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " - "0x%8.8X %s\r\n", + "0x%8.8X %%0%%.prm\r\n", (u32) hUniqueTag1, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos, gpszFile); + ui32BlockBytes, ui32ParamOutPos); PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } else { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; @@ -813,12 +782,6 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, PDUMP_FLAGS_CONTINUOUS)) return PVRSRV_ERROR_GENERIC; - if (gui32ParamFileNum == 0) - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%.prm"); - else - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "%%0%%%u.prm", - gui32ParamFileNum); - CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); ui32PageByteOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); @@ -960,22 +923,6 @@ static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, if (!psStream || PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) return IMG_TRUE; - if (psStream == gpsStream[PDUMP_STREAM_PARAM2]) { - u32 ui32ParamOutPos = - DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - - if (ui32ParamOutPos + ui32Count > MAX_FILE_SIZE) - if ((gpsStream[PDUMP_STREAM_SCRIPT2] - && - PDumpWriteString2 - ("\r\n-- Splitting pdump output file\r\n\r\n", - ui32Flags))) { - DbgSetMarker(gpsStream[PDUMP_STREAM_PARAM2], - ui32ParamOutPos); - gui32ParamFileNum++; - } - } - while (((u32) ui32Count > 0) && (ui32Written != 0xFFFFFFFF)) { ui32Written = DbgWrite(psStream, &pui8Data[ui32Off], ui32Count, @@ -1001,11 +948,6 @@ static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) DbgDrvSetFrame(psStream, ui32Frame); } -static void DbgSetMarker(struct DBG_STREAM *psStream, u32 ui32Marker) -{ - DbgDrvSetMarker(psStream, ui32Marker); -} - static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32BCount, u32 ui32Flags) { -- 1.7.5.4 From 406924fa93e114559d615908c7601ccf8d0ee851 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:30 +0100 Subject: [PATCH 32/95] gpu: pvr: pdump: move functions around to better reflect dependencies This way, no prototypes have to be provided, and the use of PDUMP macros is also avoided. No functional changes. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 334 +++++++++++++++++++++++------------------------ 1 files changed, 161 insertions(+), 173 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 64ed76e..9b6cac3 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -53,13 +53,6 @@ struct DBG_STREAM { IMG_BOOL bInitPhaseComplete; }; -static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags); -static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32Count, u32 ui32Flags); -static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame); -static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32BCount, u32 ui32Flags); - #define MIN(a, b) (a > b ? b : a) static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); @@ -82,6 +75,17 @@ static struct DBG_STREAM *gpsStream[PDUMP_NUM_STREAMS] = {NULL}; #define SZ_SCRIPT_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) #define SZ_FILENAME_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) + +void PDumpSuspendKM(void) +{ + atomic_inc(&gsPDumpSuspended); +} + +void PDumpResumeKM(void) +{ + atomic_dec(&gsPDumpSuspended); +} + static inline IMG_BOOL PDumpSuspended(void) { return atomic_read(&gsPDumpSuspended) != 0; @@ -142,6 +146,148 @@ DbgDrvGetStreamOffset(struct DBG_STREAM *psStream) return 0; } +static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, + u32 ui32BCount, u32 ui32Flags) +{ + u32 ui32BytesWritten; + + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { + if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) && + (psStream->ui32Start == 0xFFFFFFFF) && + (psStream->ui32End == 0xFFFFFFFF) && + psStream->bInitPhaseComplete) + ui32BytesWritten = ui32BCount; + else + ui32BytesWritten = + DbgDrvDBGDrivWrite2(psStream, pui8Data, + ui32BCount, 1); + } else + ui32BytesWritten = DbgDrvWriteBINCM(psStream, pui8Data, + ui32BCount, 1); + + return ui32BytesWritten; +} + +static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, + u32 ui32Count, u32 ui32Flags) +{ + u32 ui32Written = 0; + u32 ui32Off = 0; + + if (!psStream || PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) + return IMG_TRUE; + + while (((u32) ui32Count > 0) && (ui32Written != 0xFFFFFFFF)) { + ui32Written = + DbgWrite(psStream, &pui8Data[ui32Off], ui32Count, + ui32Flags); + + if (ui32Written == 0) + OSReleaseThreadQuanta(); + + if (ui32Written != 0xFFFFFFFF) { + ui32Off += ui32Written; + ui32Count -= ui32Written; + } + } + + if (ui32Written == 0xFFFFFFFF) + return IMG_FALSE; + + return IMG_TRUE; +} + +static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags) +{ + return PDumpWriteILock(gpsStream[PDUMP_STREAM_SCRIPT2], + (u8 *)pszString, strlen(pszString), ui32Flags); +} + +enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) +{ + u32 ui32Count = 0; + enum PVRSRV_ERROR eError; + + if (PDumpSuspended()) + return PVRSRV_ERROR_GENERIC; + + if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) + eError = PVRSRV_ERROR_GENERIC; + else + eError = PVRSRV_ERROR_CMD_NOT_PROCESSED; + + if (!PDumpWriteString2("-- ", ui32Flags)) + return eError; + + snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); + + while ((gpszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) + ui32Count++; + + if ((gpszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { + gpszMsg[ui32Count] = '\n'; + ui32Count++; + gpszMsg[ui32Count] = '\0'; + } + if ((gpszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { + gpszMsg[ui32Count - 1] = '\r'; + gpszMsg[ui32Count] = '\n'; + ui32Count++; + gpszMsg[ui32Count] = '\0'; + } + + PDumpWriteString2(gpszMsg, ui32Flags); + + return PVRSRV_OK; +} + +void PDumpComment(char *pszFormat, ...) +{ + va_list ap; + + if (PDumpSuspended()) + return; + + va_start(ap, pszFormat); + vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + va_end(ap); + + PDumpCommentKM(gpszMsg, PDUMP_FLAGS_CONTINUOUS); +} + +void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) +{ + va_list ap; + + if (PDumpSuspended()) + return; + + va_start(ap, pszFormat); + vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + va_end(ap); + + PDumpCommentKM(gpszMsg, ui32Flags); +} + +enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame) +{ + u32 ui32Stream; + + for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) + if (gpsStream[ui32Stream]) + DbgDrvSetFrame(gpsStream[ui32Stream], ui32Frame); + + return PVRSRV_OK; +} + +IMG_BOOL PDumpIsCaptureFrameKM(void) +{ + if (PDumpSuspended()) + return IMG_FALSE; + return DbgDrvIsCaptureFrame(gpsStream[PDUMP_STREAM_SCRIPT2], + IMG_FALSE); +} + void PDumpInit(void) { u32 i = 0; @@ -180,10 +326,10 @@ void PDumpInit(void) DbgDrvSetFrame(gpsStream[i], 0); } - PDUMPCOMMENT("Driver Product Name: %s", VS_PRODUCT_NAME); - PDUMPCOMMENT("Driver Product Version: %s (%s)", + PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME); + PDumpComment("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FILE); - PDUMPCOMMENT("Start of Init Phase"); + PDumpComment("Start of Init Phase"); return; @@ -234,42 +380,6 @@ void PDumpDeInit(void) } } -void PDumpComment(char *pszFormat, ...) -{ - va_list ap; - - if (PDumpSuspended()) - return; - - va_start(ap, pszFormat); - vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); - va_end(ap); - - PDumpCommentKM(gpszMsg, PDUMP_FLAGS_CONTINUOUS); -} - -void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) -{ - va_list ap; - - if (PDumpSuspended()) - return; - - va_start(ap, pszFormat); - vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); - va_end(ap); - - PDumpCommentKM(gpszMsg, ui32Flags); -} - -IMG_BOOL PDumpIsCaptureFrameKM(void) -{ - if (PDumpSuspended()) - return IMG_FALSE; - return DbgDrvIsCaptureFrame(gpsStream[PDUMP_STREAM_SCRIPT2], - IMG_FALSE); -} - enum PVRSRV_ERROR PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) { if (PDumpSuspended()) @@ -818,55 +928,6 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame) -{ - u32 ui32Stream; - - for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) - if (gpsStream[ui32Stream]) - DbgSetFrame(gpsStream[ui32Stream], ui32Frame); - - return PVRSRV_OK; -} - -enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) -{ - u32 ui32Count = 0; - enum PVRSRV_ERROR eError; - - if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; - - if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) - eError = PVRSRV_ERROR_GENERIC; - else - eError = PVRSRV_ERROR_CMD_NOT_PROCESSED; - - if (!PDumpWriteString2("-- ", ui32Flags)) - return eError; - - snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); - - while ((gpszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) - ui32Count++; - - if ((gpszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { - gpszMsg[ui32Count] = '\n'; - ui32Count++; - gpszMsg[ui32Count] = '\0'; - } - if ((gpszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { - gpszMsg[ui32Count - 1] = '\r'; - gpszMsg[ui32Count] = '\n'; - ui32Count++; - gpszMsg[ui32Count] = '\0'; - } - - PDumpWriteString2(gpszMsg, ui32Flags); - - return PVRSRV_OK; -} - enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, struct IMG_DEV_VIRTADDR sDevBaseAddr, @@ -876,7 +937,7 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, if (PDumpSuspended()) return PVRSRV_ERROR_GENERIC; - PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, + PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); snprintf(gpszScript, @@ -908,69 +969,6 @@ static enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, return PVRSRV_OK; } -static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags) -{ - return PDumpWriteILock(gpsStream[PDUMP_STREAM_SCRIPT2], - (u8 *)pszString, strlen(pszString), ui32Flags); -} - -static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32Count, u32 ui32Flags) -{ - u32 ui32Written = 0; - u32 ui32Off = 0; - - if (!psStream || PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) - return IMG_TRUE; - - while (((u32) ui32Count > 0) && (ui32Written != 0xFFFFFFFF)) { - ui32Written = - DbgWrite(psStream, &pui8Data[ui32Off], ui32Count, - ui32Flags); - - if (ui32Written == 0) - OSReleaseThreadQuanta(); - - if (ui32Written != 0xFFFFFFFF) { - ui32Off += ui32Written; - ui32Count -= ui32Written; - } - } - - if (ui32Written == 0xFFFFFFFF) - return IMG_FALSE; - - return IMG_TRUE; -} - -static void DbgSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) -{ - DbgDrvSetFrame(psStream, ui32Frame); -} - -static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32BCount, u32 ui32Flags) -{ - u32 ui32BytesWritten; - - if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { - if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) && - (psStream->ui32Start == 0xFFFFFFFF) && - (psStream->ui32End == 0xFFFFFFFF) && - psStream->bInitPhaseComplete) - ui32BytesWritten = ui32BCount; - else - ui32BytesWritten = - DbgDrvDBGDrivWrite2(psStream, pui8Data, - ui32BCount, 1); - } else { - ui32BytesWritten = DbgDrvWriteBINCM(psStream, pui8Data, - ui32BCount, 1); - } - - return ui32BytesWritten; -} - void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, u32 *pui32Registers, u32 ui32NumRegisters) { @@ -982,7 +980,7 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, ui32FileOffset = 0; - PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump 3D signature registers\r\n"); + PDumpCommentWithFlags(0, "\r\n-- Dump 3D signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", ui32DumpFrameNum); @@ -1017,7 +1015,7 @@ void PDumpCounterRegisters(u32 ui32DumpFrameNum, if (PDumpSuspended()) return; - PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump counter registers\r\n"); + PDumpCommentWithFlags(0, "\r\n-- Dump counter registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); ui32FileOffset = 0; @@ -1036,7 +1034,7 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, if (PDumpSuspended()) return; - PDUMPCOMMENTWITHFLAGS(0, "\r\n-- Dump TA signature registers\r\n"); + PDumpCommentWithFlags(0, "\r\n-- Dump TA signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", ui32DumpFrameNum); @@ -1076,7 +1074,7 @@ void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, if (PDumpSuspended()) return; - PDUMPCOMMENTWITHFLAGS(ui32PDumpFlags, + PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); snprintf(gpszScript, @@ -1137,14 +1135,4 @@ void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) PDumpWriteString2(gpszScript, ui32Flags); } -void PDumpSuspendKM(void) -{ - atomic_inc(&gsPDumpSuspended); -} - -void PDumpResumeKM(void) -{ - atomic_dec(&gsPDumpSuspended); -} - #endif -- 1.7.5.4 From 53f9abbf8ddb3e667801ffdfc465c282f07d0583 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:31 +0100 Subject: [PATCH 33/95] gpu: pvr: pdump: reduce error propagation from pdump to userspace When pdump logging fails, the driver should, as much as possible, continue working. Bad arguments should however be flagged. This allows for a rewrite of DbgWrite()/PdumpWriteILock() to pdump_write(). Also remove the parameter write in PDumpPDDevPAddrKM, this parameter data is simply not referenced and the data sent to the script anyway. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 111 ++++++++++--------- drivers/gpu/pvr/pdump.c | 201 ++++++++++++--------------------- drivers/gpu/pvr/pdump_common.c | 27 ++--- drivers/gpu/pvr/pdump_km.h | 65 ++++++------ 4 files changed, 175 insertions(+), 229 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 5da331e..81e5309 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1059,8 +1059,11 @@ static int PDumpCommentBW(u32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_COMMENT); PVR_UNREFERENCED_PARAMETER(psPerProc); - psRetOUT->eError = PDumpCommentKM(&psPDumpCommentIN->szComment[0], - psPDumpCommentIN->ui32Flags); + PDumpCommentKM(&psPDumpCommentIN->szComment[0], + psPDumpCommentIN->ui32Flags); + + psRetOUT->eError = PVRSRV_OK; + return 0; } @@ -1072,7 +1075,9 @@ static int PDumpSetFrameBW(u32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_SETFRAME); PVR_UNREFERENCED_PARAMETER(psPerProc); - psRetOUT->eError = PDumpSetFrameKM(psPDumpSetFrameIN->ui32Frame); + PDumpSetFrameKM(psPDumpSetFrameIN->ui32Frame); + + psRetOUT->eError = PVRSRV_OK; return 0; } @@ -1085,10 +1090,11 @@ static int PDumpRegWithFlagsBW(u32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_REG); PVR_UNREFERENCED_PARAMETER(psPerProc); - psRetOUT->eError = - PDumpRegWithFlagsKM(psPDumpRegDumpIN->sHWReg.ui32RegAddr, - psPDumpRegDumpIN->sHWReg.ui32RegVal, - psPDumpRegDumpIN->ui32Flags); + PDumpRegWithFlagsKM(psPDumpRegDumpIN->sHWReg.ui32RegAddr, + psPDumpRegDumpIN->sHWReg.ui32RegVal, + psPDumpRegDumpIN->ui32Flags); + + psRetOUT->eError = PVRSRV_OK; return 0; } @@ -1101,11 +1107,12 @@ static int PDumpRegPolBW(u32 ui32BridgeID, PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_REGPOL); PVR_UNREFERENCED_PARAMETER(psPerProc); - psRetOUT->eError = - PDumpRegPolWithFlagsKM(psPDumpRegPolIN->sHWReg.ui32RegAddr, - psPDumpRegPolIN->sHWReg.ui32RegVal, - psPDumpRegPolIN->ui32Mask, - psPDumpRegPolIN->ui32Flags); + PDumpRegPolWithFlagsKM(psPDumpRegPolIN->sHWReg.ui32RegAddr, + psPDumpRegPolIN->sHWReg.ui32RegVal, + psPDumpRegPolIN->ui32Mask, + psPDumpRegPolIN->ui32Flags); + + psRetOUT->eError = PVRSRV_OK; return 0; } @@ -1126,13 +1133,12 @@ static int PDumpMemPolBW(u32 ui32BridgeID, if (psRetOUT->eError != PVRSRV_OK) return 0; - psRetOUT->eError = - PDumpMemPolKM(((struct PVRSRV_KERNEL_MEM_INFO *)pvMemInfo), - psPDumpMemPolIN->ui32Offset, - psPDumpMemPolIN->ui32Value, - psPDumpMemPolIN->ui32Mask, - PDUMP_POLL_OPERATOR_EQUAL, - MAKEUNIQUETAG(pvMemInfo)); + PDumpMemPolKM(((struct PVRSRV_KERNEL_MEM_INFO *)pvMemInfo), + psPDumpMemPolIN->ui32Offset, + psPDumpMemPolIN->ui32Value, + psPDumpMemPolIN->ui32Mask, + PDUMP_POLL_OPERATOR_EQUAL, + MAKEUNIQUETAG(pvMemInfo)); return 0; } @@ -1154,11 +1160,11 @@ static int PDumpMemBW(u32 ui32BridgeID, return 0; psRetOUT->eError = PDumpMemUM(psPerProc, psPDumpMemDumpIN->pvAltLinAddr, - psPDumpMemDumpIN->pvLinAddr, - pvMemInfo, psPDumpMemDumpIN->ui32Offset, - psPDumpMemDumpIN->ui32Bytes, - psPDumpMemDumpIN->ui32Flags, - MAKEUNIQUETAG(pvMemInfo)); + psPDumpMemDumpIN->pvLinAddr, + pvMemInfo, psPDumpMemDumpIN->ui32Offset, + psPDumpMemDumpIN->ui32Bytes, + psPDumpMemDumpIN->ui32Flags, + MAKEUNIQUETAG(pvMemInfo)); return 0; } @@ -1171,16 +1177,18 @@ static int PDumpBitmapBW(u32 ui32BridgeID, PVR_UNREFERENCED_PARAMETER(psPerProc); PVR_UNREFERENCED_PARAMETER(ui32BridgeID); - psRetOUT->eError = PDumpBitmapKM(&psPDumpBitmapIN->szFileName[0], - psPDumpBitmapIN->ui32FileOffset, - psPDumpBitmapIN->ui32Width, - psPDumpBitmapIN->ui32Height, - psPDumpBitmapIN->ui32StrideInBytes, - psPDumpBitmapIN->sDevBaseAddr, - psPDumpBitmapIN->ui32Size, - psPDumpBitmapIN->ePixelFormat, - psPDumpBitmapIN->eMemFormat, - psPDumpBitmapIN->ui32Flags); + PDumpBitmapKM(&psPDumpBitmapIN->szFileName[0], + psPDumpBitmapIN->ui32FileOffset, + psPDumpBitmapIN->ui32Width, + psPDumpBitmapIN->ui32Height, + psPDumpBitmapIN->ui32StrideInBytes, + psPDumpBitmapIN->sDevBaseAddr, + psPDumpBitmapIN->ui32Size, + psPDumpBitmapIN->ePixelFormat, + psPDumpBitmapIN->eMemFormat, + psPDumpBitmapIN->ui32Flags); + + psRetOUT->eError = PVRSRV_OK; return 0; } @@ -1203,12 +1211,12 @@ static int PDumpSyncDumpBW(u32 ui32BridgeID, return 0; psRetOUT->eError = - PDumpMemUM(psPerProc, psPDumpSyncDumpIN->pvAltLinAddr, NULL, - ((struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)-> - psSyncDataMemInfoKM, - psPDumpSyncDumpIN->ui32Offset, ui32Bytes, 0, - MAKEUNIQUETAG(((struct PVRSRV_KERNEL_SYNC_INFO *) - pvSyncInfo)->psSyncDataMemInfoKM)); + PDumpMemUM(psPerProc, psPDumpSyncDumpIN->pvAltLinAddr, NULL, + ((struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)-> + psSyncDataMemInfoKM, + psPDumpSyncDumpIN->ui32Offset, ui32Bytes, 0, + MAKEUNIQUETAG(((struct PVRSRV_KERNEL_SYNC_INFO *) + pvSyncInfo)->psSyncDataMemInfoKM)); return 0; } @@ -1237,13 +1245,12 @@ static int PDumpSyncPolBW(u32 ui32BridgeID, ui32Offset = offsetof(struct PVRSRV_SYNC_DATA, ui32WriteOpsComplete); - psRetOUT->eError = - PDumpMemPolKM(((struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)-> - psSyncDataMemInfoKM, ui32Offset, - psPDumpSyncPolIN->ui32Value, - psPDumpSyncPolIN->ui32Mask, PDUMP_POLL_OPERATOR_EQUAL, - MAKEUNIQUETAG(((struct PVRSRV_KERNEL_SYNC_INFO *) - pvSyncInfo)->psSyncDataMemInfoKM)); + PDumpMemPolKM(((struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)-> + psSyncDataMemInfoKM, ui32Offset, + psPDumpSyncPolIN->ui32Value, + psPDumpSyncPolIN->ui32Mask, PDUMP_POLL_OPERATOR_EQUAL, + MAKEUNIQUETAG(((struct PVRSRV_KERNEL_SYNC_INFO *) + pvSyncInfo)->psSyncDataMemInfoKM)); return 0; } @@ -1297,11 +1304,11 @@ static int PDumpPDDevPAddrBW(u32 ui32BridgeID, if (psRetOUT->eError != PVRSRV_OK) return 0; - psRetOUT->eError = - PDumpPDDevPAddrKM((struct PVRSRV_KERNEL_MEM_INFO *)pvMemInfo, - psPDumpPDDevPAddrIN->ui32Offset, - psPDumpPDDevPAddrIN->sPDDevPAddr, - MAKEUNIQUETAG(pvMemInfo), PDUMP_PD_UNIQUETAG); + PDumpPDDevPAddrKM((struct PVRSRV_KERNEL_MEM_INFO *)pvMemInfo, + psPDumpPDDevPAddrIN->ui32Offset, + psPDumpPDDevPAddrIN->sPDDevPAddr, + MAKEUNIQUETAG(pvMemInfo), PDUMP_PD_UNIQUETAG); + return 0; } diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 9b6cac3..a41d666 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -120,18 +120,18 @@ DbgDrvSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) } -static u32 +static void DbgDrvDBGDrivWrite2(struct DBG_STREAM *psStream, u8 *pui8InBuf, u32 ui32InBuffSize, u32 ui32Level) { - return ui32InBuffSize; + } -static u32 +static void DbgDrvWriteBINCM(struct DBG_STREAM *psStream, u8 *pui8InBuf, u32 ui32InBuffSize, u32 ui32Level) { - return ui32InBuffSize; + } static u32 @@ -146,78 +146,46 @@ DbgDrvGetStreamOffset(struct DBG_STREAM *psStream) return 0; } -static u32 DbgWrite(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32BCount, u32 ui32Flags) +static enum PVRSRV_ERROR +pdump_write(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, + u32 ui32Flags) { - u32 ui32BytesWritten; + if (!psStream) /* will always hit with the empty backend. */ + return PVRSRV_OK; + + if (PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) + return PVRSRV_OK; if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) && (psStream->ui32Start == 0xFFFFFFFF) && (psStream->ui32End == 0xFFFFFFFF) && psStream->bInitPhaseComplete) - ui32BytesWritten = ui32BCount; + return PVRSRV_OK; else - ui32BytesWritten = - DbgDrvDBGDrivWrite2(psStream, pui8Data, - ui32BCount, 1); + DbgDrvDBGDrivWrite2(psStream, pui8Data, + ui32Count, 1); } else - ui32BytesWritten = DbgDrvWriteBINCM(psStream, pui8Data, - ui32BCount, 1); - - return ui32BytesWritten; -} - -static IMG_BOOL PDumpWriteILock(struct DBG_STREAM *psStream, u8 *pui8Data, - u32 ui32Count, u32 ui32Flags) -{ - u32 ui32Written = 0; - u32 ui32Off = 0; - - if (!psStream || PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) - return IMG_TRUE; - - while (((u32) ui32Count > 0) && (ui32Written != 0xFFFFFFFF)) { - ui32Written = - DbgWrite(psStream, &pui8Data[ui32Off], ui32Count, - ui32Flags); - - if (ui32Written == 0) - OSReleaseThreadQuanta(); - - if (ui32Written != 0xFFFFFFFF) { - ui32Off += ui32Written; - ui32Count -= ui32Written; - } - } - - if (ui32Written == 0xFFFFFFFF) - return IMG_FALSE; + DbgDrvWriteBINCM(psStream, pui8Data, ui32Count, 1); - return IMG_TRUE; + /* placeholder, will get proper error handling later. */ + return PVRSRV_OK; } -static IMG_BOOL PDumpWriteString2(char *pszString, u32 ui32Flags) +static void PDumpWriteString2(char *pszString, u32 ui32Flags) { - return PDumpWriteILock(gpsStream[PDUMP_STREAM_SCRIPT2], - (u8 *)pszString, strlen(pszString), ui32Flags); + (void) pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], + (u8 *)pszString, strlen(pszString), ui32Flags); } -enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) +void PDumpCommentKM(char *pszComment, u32 ui32Flags) { u32 ui32Count = 0; - enum PVRSRV_ERROR eError; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; - - if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) - eError = PVRSRV_ERROR_GENERIC; - else - eError = PVRSRV_ERROR_CMD_NOT_PROCESSED; + return; - if (!PDumpWriteString2("-- ", ui32Flags)) - return eError; + PDumpWriteString2("-- ", ui32Flags); snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); @@ -237,8 +205,6 @@ enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags) } PDumpWriteString2(gpszMsg, ui32Flags); - - return PVRSRV_OK; } void PDumpComment(char *pszFormat, ...) @@ -269,15 +235,13 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) PDumpCommentKM(gpszMsg, ui32Flags); } -enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame) +void PDumpSetFrameKM(u32 ui32Frame) { u32 ui32Stream; for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) if (gpsStream[ui32Stream]) DbgDrvSetFrame(gpsStream[ui32Stream], ui32Frame); - - return PVRSRV_OK; } IMG_BOOL PDumpIsCaptureFrameKM(void) @@ -380,16 +344,14 @@ void PDumpDeInit(void) } } -enum PVRSRV_ERROR PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) +void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) { if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return; snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); PDumpWriteString2(gpszScript, ui32Flags); - - return PVRSRV_OK; } void PDumpReg(u32 ui32Reg, u32 ui32Data) @@ -402,8 +364,8 @@ void PDumpReg(u32 ui32Reg, u32 ui32Data) PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } -enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask, u32 ui32Flags) +void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask, u32 ui32Flags) { #define POLL_DELAY 1000 #define POLL_COUNT_LONG (2000000000 / POLL_DELAY) @@ -412,7 +374,7 @@ enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32PollCount; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return; if (((ui32RegAddr == EUR_CR_EVENT_STATUS) && (ui32RegValue & ui32Mask & @@ -432,14 +394,12 @@ enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, POLL_DELAY); PDumpWriteString2(gpszScript, ui32Flags); - - return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) +void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) { - return PDumpRegPolWithFlagsKM(ui32RegAddr, ui32RegValue, ui32Mask, - PDUMP_FLAGS_CONTINUOUS); + PDumpRegPolWithFlagsKM(ui32RegAddr, ui32RegValue, ui32Mask, + PDUMP_FLAGS_CONTINUOUS); } void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, @@ -621,10 +581,9 @@ void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, PDumpWriteString2(gpszScript, ui32Flags); } -enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Value, u32 ui32Mask, - enum PDUMP_POLL_OPERATOR eOperator, - void *hUniqueTag) +void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Value, u32 ui32Mask, + enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag) { #define MEMPOLL_DELAY (1000) #define MEMPOLL_COUNT (2000000000 / MEMPOLL_DELAY) @@ -635,7 +594,7 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_CPU_PHYADDR CpuPAddr; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return; PVR_ASSERT((ui32Offset + sizeof(u32)) <= psMemInfo->ui32AllocSize); @@ -658,14 +617,11 @@ enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); PDumpWriteString2(gpszScript, 0); - - return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, - void *hUniqueTag) +enum PVRSRV_ERROR +PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) { u32 ui32PageByteOffset; u8 *pui8DataLinAddr = NULL; @@ -676,14 +632,15 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, u32 ui32ParamOutPos; u32 ui32CurrentOffset; u32 ui32BytesRemaining; + enum PVRSRV_ERROR eError; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return PVRSRV_OK; PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); if (ui32Bytes == 0) - return PVRSRV_OK; + return PVRSRV_ERROR_GENERIC; if (pvAltLinAddr) { pui8DataLinAddr = pvAltLinAddr; @@ -699,9 +656,10 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, ui32ParamOutPos = DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (!PDumpWriteILock(gpsStream[PDUMP_STREAM_PARAM2], - pui8DataLinAddr, ui32Bytes, ui32Flags)) - return PVRSRV_ERROR_GENERIC; + eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pui8DataLinAddr, + ui32Bytes, ui32Flags); + if (eError != PVRSRV_OK) + return eError; snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, @@ -760,10 +718,10 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32Bytes, u32 ui32Flags, - IMG_BOOL bInitialisePages, void *hUniqueTag1, - void *hUniqueTag2) +enum PVRSRV_ERROR +PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, + u32 ui32Bytes, u32 ui32Flags, IMG_BOOL bInitialisePages, + void *hUniqueTag1, void *hUniqueTag2) { u32 ui32NumPages; u32 ui32PageOffset; @@ -773,9 +731,10 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, struct IMG_CPU_PHYADDR sCpuPAddr; u32 ui32Offset; u32 ui32ParamOutPos; + enum PVRSRV_ERROR eError; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return PVRSRV_OK; if (ui32Flags) ; @@ -786,11 +745,12 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32ParamOutPos = DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (bInitialisePages) - if (!PDumpWriteILock - (gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, - ui32Bytes, PDUMP_FLAGS_CONTINUOUS)) - return PVRSRV_ERROR_GENERIC; + if (bInitialisePages) { + eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, + ui32Bytes, PDUMP_FLAGS_CONTINUOUS); + if (eError != PVRSRV_OK) + return eError; + } ui32PageOffset = (u32) pvLinAddr & (HOST_PAGESIZE() - 1); ui32NumPages = @@ -869,12 +829,11 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, - struct IMG_DEV_PHYADDR sPDDevPAddr, - void *hUniqueTag1, void *hUniqueTag2) +void +PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, + void *hUniqueTag1, void *hUniqueTag2) { - u32 ui32ParamOutPos; struct IMG_CPU_PHYADDR CpuPAddr; u32 ui32PageByteOffset; struct IMG_DEV_VIRTADDR sDevVAddr; @@ -882,15 +841,7 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_PHYADDR sDevPAddr; if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; - - ui32ParamOutPos = - DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - - if (!PDumpWriteILock(gpsStream[PDUMP_STREAM_PARAM2], - (u8 *)&sPDDevPAddr, sizeof(struct IMG_DEV_PHYADDR), - PDUMP_FLAGS_CONTINUOUS)) - return PVRSRV_ERROR_GENERIC; + return; CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -924,18 +875,16 @@ enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sPDDevPAddr.uiAddr); } PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); - - return PVRSRV_OK; } -enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, - struct IMG_DEV_VIRTADDR sDevBaseAddr, - u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, - enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) +void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, + struct IMG_DEV_VIRTADDR sDevBaseAddr, + u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, + enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) { if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return; PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); @@ -949,15 +898,13 @@ enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, ui32StrideInBytes, eMemFormat); PDumpWriteString2(gpszScript, ui32PDumpFlags); - return PVRSRV_OK; } -static enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Address, u32 ui32Size, - u32 ui32PDumpFlags) +static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags) { if (PDumpSuspended()) - return PVRSRV_ERROR_GENERIC; + return; snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, @@ -965,8 +912,6 @@ static enum PVRSRV_ERROR PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, ui32Address, ui32FileOffset, pszFileName); PDumpWriteString2(gpszScript, ui32PDumpFlags); - - return PVRSRV_OK; } void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, diff --git a/drivers/gpu/pvr/pdump_common.c b/drivers/gpu/pvr/pdump_common.c index 80c795a..14ce8f6 100644 --- a/drivers/gpu/pvr/pdump_common.c +++ b/drivers/gpu/pvr/pdump_common.c @@ -77,20 +77,22 @@ void PDumpDeInitCommon(void) PDumpDeInit(); } -enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psPerProc, - void *pvAltLinAddrUM, void *pvLinAddrUM, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, - void *hUniqueTag) +enum PVRSRV_ERROR +PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psPerProc, + void *pvAltLinAddrUM, void *pvLinAddrUM, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, + void *hUniqueTag) { void *pvAddrUM; void *pvAddrKM; u32 ui32BytesDumped; u32 ui32CurrentOffset; - if (psMemInfo->pvLinAddrKM != NULL && pvAltLinAddrUM == NULL) + if (psMemInfo->pvLinAddrKM != NULL && pvAltLinAddrUM == NULL) { return PDumpMemKM(NULL, psMemInfo, ui32Offset, ui32Bytes, ui32Flags, hUniqueTag); + } pvAddrUM = (pvAltLinAddrUM != NULL) ? pvAltLinAddrUM : ((pvLinAddrUM != NULL) ? VPTR_PLUS(pvLinAddrUM, @@ -119,21 +121,14 @@ enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psPerProc, pvAddrKM, pvAddrUM, ui32BytesToDump); if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, - "PDumpMemUM: OSCopyFromUser failed (%d), eError"); - return PVRSRV_ERROR_GENERIC; + "PDumpMemUM: OSCopyFromUser failed (%d)", eError); + return eError; } eError = PDumpMemKM(pvAddrKM, psMemInfo, ui32CurrentOffset, ui32BytesToDump, ui32Flags, hUniqueTag); - - if (eError != PVRSRV_OK) { - if (ui32BytesDumped != 0) - PVR_DPF(PVR_DBG_ERROR, - "PDumpMemUM: PDumpMemKM failed (%d)", - eError); - PVR_ASSERT(ui32BytesDumped == 0); + if (eError != PVRSRV_OK) return eError; - } VPTR_INC(pvAddrUM, ui32BytesToDump); ui32CurrentOffset += ui32BytesToDump; diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 5d22fb7..5a18fe5 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -43,23 +43,22 @@ (((struct BM_BUF *)(((struct PVRSRV_KERNEL_MEM_INFO *) \ hMemInfo)->sMemBlk.hBuffer))->pMapping) -enum PVRSRV_ERROR PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO +void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Value, u32 ui32Mask, enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag); -enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA - *psProcData, void *pvAltLinAddr, - void *pvLinAddr, - struct PVRSRV_KERNEL_MEM_INFO - *psMemInfo, u32 ui32Offset, - u32 ui32Bytes, u32 ui32Flags, - void *hUniqueTag); +enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psProcData, + void *pvAltLinAddr, void *pvLinAddr, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, + void *hUniqueTag); enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, - u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag); + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, + u32 ui32Flags, void *hUniqueTag); enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, @@ -71,28 +70,28 @@ void PDumpInitCommon(void); void PDumpDeInitCommon(void); void PDumpInit(void); void PDumpDeInit(void); -enum PVRSRV_ERROR PDumpSetFrameKM(u32 ui32Frame); -enum PVRSRV_ERROR PDumpCommentKM(char *pszComment, u32 ui32Flags); -enum PVRSRV_ERROR PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Flags); - -enum PVRSRV_ERROR PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, - struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, - enum PDUMP_PIXEL_FORMAT ePixelFormat, - enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags); +void PDumpSetFrameKM(u32 ui32Frame); +void PDumpCommentKM(char *pszComment, u32 ui32Flags); +void PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Flags); + +void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, + struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, + enum PDUMP_PIXEL_FORMAT ePixelFormat, + enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags); void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, - struct IMG_DEV_VIRTADDR sDevBaseAddr, - u32 ui32Size, u32 ui32PDumpFlags); + struct IMG_DEV_VIRTADDR sDevBaseAddr, + u32 ui32Size, u32 ui32PDumpFlags); void PDumpReg(u32 dwReg, u32 dwData); void PDumpComment(char *pszFormat, ...); void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...); -enum PVRSRV_ERROR PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask); -enum PVRSRV_ERROR PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask, u32 ui32Flags); +void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask); +void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask, u32 ui32Flags); IMG_BOOL PDumpIsCaptureFrameKM(void); @@ -100,19 +99,19 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, u32 ui32PageSize, void *hUniqueTag); void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); + void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, - u32 ui32PageSize, void *hUniqueTag, IMG_BOOL bInterleaved); + u32 ui32PageSize, void *hUniqueTag, IMG_BOOL bInterleaved); void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); + void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); void PDumpPDReg(u32 ui32Reg, u32 ui32dwData, void *hUniqueTag); void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, - void *hUniqueTag); + void *hUniqueTag); -enum PVRSRV_ERROR PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, - void *hUniqueTag1, void *hUniqueTag2); +void PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, + void *hUniqueTag1, void *hUniqueTag2); void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, u32 *pui32Registers, u32 ui32NumRegisters); -- 1.7.5.4 From 10ddabd2b198c8982eefbfd749c7a3928088685d Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:32 +0100 Subject: [PATCH 34/95] gpu: pvr: pdump: rewrite PDumpWriteString2() to pdump_print() Making pdump_print accept variable arguments directly significantly simplifies string printing to script, throughout the whole of pdump.c Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 271 ++++++++++++++++++++--------------------------- 1 files changed, 114 insertions(+), 157 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index a41d666..3b37d5b 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -172,10 +172,20 @@ pdump_write(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, return PVRSRV_OK; } -static void PDumpWriteString2(char *pszString, u32 ui32Flags) +static void +pdump_print(u32 flags, char *pszFormat, ...) { + va_list ap; + + if (PDumpSuspended()) + return; + + va_start(ap, pszFormat); + vsnprintf(gpszScript, SZ_MSG_SIZE_MAX, pszFormat, ap); + va_end(ap); + (void) pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], - (u8 *)pszString, strlen(pszString), ui32Flags); + (u8 *)gpszScript, strlen(gpszScript), flags); } void PDumpCommentKM(char *pszComment, u32 ui32Flags) @@ -185,9 +195,7 @@ void PDumpCommentKM(char *pszComment, u32 ui32Flags) if (PDumpSuspended()) return; - PDumpWriteString2("-- ", ui32Flags); - - snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "%s", pszComment); + snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "-- %s", pszComment); while ((gpszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) ui32Count++; @@ -204,7 +212,8 @@ void PDumpCommentKM(char *pszComment, u32 ui32Flags) gpszMsg[ui32Count] = '\0'; } - PDumpWriteString2(gpszMsg, ui32Flags); + pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], + (u8 *)gpszMsg, strlen(gpszMsg), ui32Flags); } void PDumpComment(char *pszFormat, ...) @@ -349,9 +358,8 @@ void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, + "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); } void PDumpReg(u32 ui32Reg, u32 ui32Data) @@ -359,9 +367,8 @@ void PDumpReg(u32 ui32Reg, u32 ui32Data) if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); } void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, @@ -389,11 +396,10 @@ void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, else ui32PollCount = POLL_COUNT_SHORT; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "POL :SGXREG:0x%8.8X 0x%8.8X 0x%8.8X %d %u %d\r\n", - ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, - POLL_DELAY); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, + "POL :SGXREG:0x%8.8X 0x%8.8X 0x%8.8X %d %u %d\r\n", + ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, + POLL_DELAY); } void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) @@ -421,10 +427,8 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, PVR_ASSERT(hOSMemHandle); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "-- MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", ui32DevVAddr, - ui32NumBytes, ui32PageSize); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- MALLOC :SGXMEM:VA_%8.8X 0x%8.8X" + " %u\r\n", ui32DevVAddr, ui32NumBytes, ui32PageSize); ui32Offset = 0; ui32NumPages = ui32NumBytes / ui32PageSize; @@ -435,11 +439,11 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); ui32Page = sDevPAddr.uiAddr / ui32PageSize; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", - (u32)hUniqueTag, ui32Page * ui32PageSize, - ui32PageSize, ui32PageSize, ui32Page * ui32PageSize); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", + (u32)hUniqueTag, ui32Page * ui32PageSize, + ui32PageSize, ui32PageSize, + ui32Page * ui32PageSize); } } @@ -457,10 +461,9 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "-- MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", ui32PTSize, - SGX_MMU_PAGE_SIZE); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "-- MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", + ui32PTSize, SGX_MMU_PAGE_SIZE); pui8LinAddr = (u8 *) pvLinAddr; @@ -471,12 +474,12 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "MALLOC :SGXMEM:PA_%8.8X%8.8lX 0x%lX %lu 0x%8.8lX\r\n", - (u32)hUniqueTag, ui32Page * SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, - ui32Page * SGX_MMU_PAGE_SIZE); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC " + ":SGXMEM:PA_%8.8X%8.8lX 0x%lX %lu 0x%8.8lX\r\n", + (u32)hUniqueTag, + ui32Page * SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, + SGX_MMU_PAGE_SIZE, ui32Page * SGX_MMU_PAGE_SIZE); + pui8LinAddr += SGX_MMU_PAGE_SIZE; } } @@ -495,9 +498,8 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, PVR_ASSERT(((u32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "-- FREE :SGXMEM:VA_%8.8X\r\n", - sDevVAddr.uiAddr); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- FREE :SGXMEM:VA_%8.8X\r\n", + sDevVAddr.uiAddr); ui32NumPages = ui32NumBytes / ui32PageSize; psDeviceNode = psBMHeap->pBMContext->psDeviceNode; @@ -508,11 +510,9 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap-> pMMUHeap, sDevVAddr); - - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", + (u32)hUniqueTag, sDevPAddr.uiAddr); } else { } @@ -535,9 +535,7 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "-- FREE :SGXMEM:PAGE_TABLE\r\n"); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- FREE :SGXMEM:PAGE_TABLE\r\n"); pui8LinAddr = (u8 *) pvLinAddr; @@ -549,10 +547,9 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; pui8LinAddr += SGX_MMU_PAGE_SIZE; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", (u32)hUniqueTag, - ui32Page * SGX_MMU_PAGE_SIZE); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", (u32)hUniqueTag, + ui32Page * SGX_MMU_PAGE_SIZE); } } @@ -561,11 +558,11 @@ void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - ui32Reg, (u32)hUniqueTag, ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), - ui32Data & (SGX_MMU_PAGE_SIZE - 1)); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", + ui32Reg, (u32)hUniqueTag, + ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), + ui32Data & (SGX_MMU_PAGE_SIZE - 1)); } void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, @@ -574,11 +571,11 @@ void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - ui32Reg, (u32) hUniqueTag, ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), - ui32Data & (SGX_MMU_PAGE_SIZE - 1)); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, + "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", + ui32Reg, (u32)hUniqueTag, + ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), + ui32Data & (SGX_MMU_PAGE_SIZE - 1)); } void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, @@ -610,13 +607,12 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr += ui32PageOffset; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "POL :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %d %d %d\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); - - PDumpWriteString2(gpszScript, 0); + pdump_print(0, "POL :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " + "0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + ui32Value, ui32Mask, eOperator, + MEMPOLL_COUNT, MEMPOLL_DELAY); } enum PVRSRV_ERROR @@ -661,12 +657,9 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, if (eError != PVRSRV_OK) return eError; - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, - "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X 0x%8.8X %%0%%.prm\r\n", - psMemInfo->sDevVAddr.uiAddr, - ui32Offset, ui32Bytes, ui32ParamOutPos); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X " + "0x%8.8X %%0%%.prm\r\n", psMemInfo->sDevVAddr.uiAddr, + ui32Offset, ui32Bytes, ui32ParamOutPos); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -700,14 +693,11 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, ui32PageByteOffset = 0; } - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X %%0%%.prm\r\n", - (u32) hUniqueTag, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" + " 0x%8.8X 0x%8.8X %%0%%.prm\r\n", (u32) hUniqueTag, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + ui32BlockBytes, ui32ParamOutPos); ui32BytesRemaining -= ui32BlockBytes; ui32CurrentOffset += ui32BlockBytes; @@ -736,9 +726,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, if (PDumpSuspended()) return PVRSRV_OK; - if (ui32Flags) - ; - if (!pvLinAddr) return PVRSRV_ERROR_GENERIC; @@ -768,15 +755,12 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, ui32BlockBytes = ui32Bytes; if (bInitialisePages) { - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, "LDB :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " - "0x%8.8X %%0%%.prm\r\n", - (u32) hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos); - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" + "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X " + "%%0%%.prm\r\n", (u32) hUniqueTag1, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + ui32BlockBytes, ui32ParamOutPos); } else { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(u32)) { @@ -785,8 +769,7 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, ui32Offset)); if ((ui32PTE & SGX_MMU_PDE_ADDR_MASK) != 0) { - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, + pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32)hUniqueTag1, (sDevPAddr.uiAddr + @@ -804,7 +787,7 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, PVR_ASSERT(! (ui32PTE & SGX_MMU_PTE_VALID)); - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, + pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X%8.8X\r\n", (u32) hUniqueTag1, (sDevPAddr.uiAddr + @@ -815,8 +798,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, (SGX_MMU_PAGE_SIZE - 1), ui32PTE, (u32)hUniqueTag2); } - PDumpWriteString2(gpszScript, - PDUMP_FLAGS_CONTINUOUS); } } @@ -855,26 +836,23 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr += ui32PageByteOffset; if ((sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK) != 0) { - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, + pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - (u32) hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - (u32)hUniqueTag2, - sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK, - sPDDevPAddr.uiAddr & ~SGX_MMU_PDE_ADDR_MASK); + (u32) hUniqueTag1, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + (u32)hUniqueTag2, + sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK, + sPDDevPAddr.uiAddr & ~SGX_MMU_PDE_ADDR_MASK); } else { PVR_ASSERT(!(sDevPAddr.uiAddr & SGX_MMU_PTE_VALID)); - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, - "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", - (u32)hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - sPDDevPAddr.uiAddr); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", + (u32)hUniqueTag1, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sPDDevPAddr.uiAddr); } - PDumpWriteString2(gpszScript, PDUMP_FLAGS_CONTINUOUS); } void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, @@ -889,15 +867,12 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump bitmap of render\r\n"); - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, - "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " - "0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", - pszFileName, pszFileName, sDevBaseAddr.uiAddr, ui32Size, - ui32FileOffset, ePixelFormat, ui32Width, ui32Height, - ui32StrideInBytes, eMemFormat); - - PDumpWriteString2(gpszScript, ui32PDumpFlags); + pdump_print(ui32PDumpFlags, + "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " + "0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", + pszFileName, pszFileName, sDevBaseAddr.uiAddr, ui32Size, + ui32FileOffset, ePixelFormat, ui32Width, ui32Height, + ui32StrideInBytes, eMemFormat); } static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, @@ -906,12 +881,8 @@ static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, if (PDumpSuspended()) return; - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, - "SAB :SGXREG:0x%08X 0x%08X %s\r\n", - ui32Address, ui32FileOffset, pszFileName); - - PDumpWriteString2(gpszScript, ui32PDumpFlags); + pdump_print(ui32PDumpFlags, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", + ui32Address, ui32FileOffset, pszFileName); } void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, @@ -942,11 +913,8 @@ static void PDumpCountRead(char *pszFileName, u32 ui32Address, u32 ui32Size, if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, - "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, - *pui32FileOffset, pszFileName); - - PDumpWriteString2(gpszScript, 0); + pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, + *pui32FileOffset, pszFileName); *pui32FileOffset += ui32Size; } @@ -997,9 +965,7 @@ void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", - ui32RegOffset); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); } void PDumpCycleCountRegRead(const u32 ui32RegOffset) @@ -1007,9 +973,7 @@ void PDumpCycleCountRegRead(const u32 ui32RegOffset) if (PDumpSuspended()) return; - snprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, "RDW :SGXREG:0x%X\r\n", - ui32RegOffset); - PDumpWriteString2(gpszScript, 0); + pdump_print(0, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); } void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, @@ -1021,13 +985,9 @@ void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, PDumpCommentWithFlags(ui32PDumpFlags, "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); - - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, - "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", - sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); - - PDumpWriteString2(gpszScript, ui32PDumpFlags); + pdump_print(ui32PDumpFlags, + "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", + sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); } void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, @@ -1061,14 +1021,12 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, sDevPAddr.uiAddr += ui32PageOffset; - snprintf(gpszScript, - SZ_SCRIPT_SIZE_MAX, + pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X 0x%8.8X\r\n", - (u32) hUniqueTag, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32WPosVal, ui32PacketSize, ui32BufferSize); - PDumpWriteString2(gpszScript, ui32Flags); + (u32) hUniqueTag, + sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + ui32WPosVal, ui32PacketSize, ui32BufferSize); } void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) @@ -1076,8 +1034,7 @@ void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) if (PDumpSuspended()) return; - sprintf(gpszScript, "IDL %u\r\n", ui32Clocks); - PDumpWriteString2(gpszScript, ui32Flags); + pdump_print(ui32Flags, "IDL %u\r\n", ui32Clocks); } #endif -- 1.7.5.4 From 0c9a432f67a7f02362b15620b62eebf5130cc8b3 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:33 +0100 Subject: [PATCH 35/95] gpu: pvr: pdump: rewrite PDumpCommentKM And turn some standard printing where the strings starts with "--" into comments. No functional change. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 102 ++++++++++++++++++++-------------------------- 1 files changed, 44 insertions(+), 58 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 3b37d5b..57f1fc7 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -57,10 +57,6 @@ struct DBG_STREAM { static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); -static char *gpszMsg; -static char *gpszScript; -static char *gpszFile; - #define PDUMP_STREAM_PARAM2 0 #define PDUMP_STREAM_SCRIPT2 1 #define PDUMP_NUM_STREAMS 2 @@ -71,10 +67,12 @@ static char *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", static struct DBG_STREAM *gpsStream[PDUMP_NUM_STREAMS] = {NULL}; -#define SZ_MSG_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) -#define SZ_SCRIPT_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) -#define SZ_FILENAME_SIZE_MAX (PVRSRV_PDUMP_MAX_COMMENT_SIZE - 1) - +#define SZ_COMMENT_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE +#define SZ_SCRIPT_SIZE_MAX (SZ_COMMENT_SIZE_MAX + 5) +#define SZ_FILENAME_SIZE_MAX SZ_COMMENT_SIZE_MAX +static char *gpszComment; +static char *gpszScript; +static char *gpszFile; void PDumpSuspendKM(void) { @@ -181,7 +179,7 @@ pdump_print(u32 flags, char *pszFormat, ...) return; va_start(ap, pszFormat); - vsnprintf(gpszScript, SZ_MSG_SIZE_MAX, pszFormat, ap); + vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, pszFormat, ap); va_end(ap); (void) pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], @@ -190,30 +188,20 @@ pdump_print(u32 flags, char *pszFormat, ...) void PDumpCommentKM(char *pszComment, u32 ui32Flags) { - u32 ui32Count = 0; + int len; if (PDumpSuspended()) return; - snprintf(gpszMsg, SZ_MSG_SIZE_MAX, "-- %s", pszComment); + len = strlen(pszComment); - while ((gpszMsg[ui32Count] != 0) && (ui32Count < SZ_MSG_SIZE_MAX)) - ui32Count++; + if ((len > 1) && (pszComment[len - 1] == '\n')) + pszComment[len - 1] = 0; - if ((gpszMsg[ui32Count - 1] != '\n') && (ui32Count < SZ_MSG_SIZE_MAX)) { - gpszMsg[ui32Count] = '\n'; - ui32Count++; - gpszMsg[ui32Count] = '\0'; - } - if ((gpszMsg[ui32Count - 2] != '\r') && (ui32Count < SZ_MSG_SIZE_MAX)) { - gpszMsg[ui32Count - 1] = '\r'; - gpszMsg[ui32Count] = '\n'; - ui32Count++; - gpszMsg[ui32Count] = '\0'; - } + if ((len > 2) && (pszComment[len - 2] == '\r')) + pszComment[len - 2] = 0; - pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], - (u8 *)gpszMsg, strlen(gpszMsg), ui32Flags); + pdump_print(ui32Flags, "-- %s\r\n", pszComment); } void PDumpComment(char *pszFormat, ...) @@ -224,10 +212,10 @@ void PDumpComment(char *pszFormat, ...) return; va_start(ap, pszFormat); - vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); va_end(ap); - PDumpCommentKM(gpszMsg, PDUMP_FLAGS_CONTINUOUS); + PDumpCommentKM(gpszComment, PDUMP_FLAGS_CONTINUOUS); } void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) @@ -238,10 +226,10 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) return; va_start(ap, pszFormat); - vsnprintf(gpszMsg, SZ_MSG_SIZE_MAX, pszFormat, ap); + vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); va_end(ap); - PDumpCommentKM(gpszMsg, ui32Flags); + PDumpCommentKM(gpszComment, ui32Flags); } void PDumpSetFrameKM(u32 ui32Frame) @@ -272,10 +260,10 @@ void PDumpInit(void) NULL) != PVRSRV_OK) goto init_failed; - if (!gpszMsg) + if (!gpszComment) if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_MSG_SIZE_MAX, - (void **)&gpszMsg, + SZ_COMMENT_SIZE_MAX, + (void **)&gpszComment, NULL) != PVRSRV_OK) goto init_failed; @@ -320,10 +308,10 @@ void PDumpInit(void) gpszScript = NULL; } - if (gpszMsg) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, - (void *)gpszMsg, NULL); - gpszMsg = NULL; + if (gpszComment) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, + (void *)gpszComment, NULL); + gpszComment = NULL; } } @@ -346,10 +334,10 @@ void PDumpDeInit(void) gpszScript = NULL; } - if (gpszMsg) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_MSG_SIZE_MAX, - (void *)gpszMsg, NULL); - gpszMsg = NULL; + if (gpszComment) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, + (void *)gpszComment, NULL); + gpszComment = NULL; } } @@ -427,8 +415,8 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, PVR_ASSERT(hOSMemHandle); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- MALLOC :SGXMEM:VA_%8.8X 0x%8.8X" - " %u\r\n", ui32DevVAddr, ui32NumBytes, ui32PageSize); + PDumpComment("MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", + ui32DevVAddr, ui32NumBytes, ui32PageSize); ui32Offset = 0; ui32NumPages = ui32NumBytes / ui32PageSize; @@ -461,9 +449,8 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "-- MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", - ui32PTSize, SGX_MMU_PAGE_SIZE); + PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", + ui32PTSize, SGX_MMU_PAGE_SIZE); pui8LinAddr = (u8 *) pvLinAddr; @@ -498,8 +485,7 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, PVR_ASSERT(((u32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); - pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- FREE :SGXMEM:VA_%8.8X\r\n", - sDevVAddr.uiAddr); + PDumpComment("FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); ui32NumPages = ui32NumBytes / ui32PageSize; psDeviceNode = psBMHeap->pBMContext->psDeviceNode; @@ -535,7 +521,7 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); - pdump_print(PDUMP_FLAGS_CONTINUOUS, "-- FREE :SGXMEM:PAGE_TABLE\r\n"); + PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); pui8LinAddr = (u8 *) pvLinAddr; @@ -657,9 +643,10 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, if (eError != PVRSRV_OK) return eError; - pdump_print(ui32Flags, "-- LDB :SGXMEM:VA_%8.8X:0x%8.8X 0x%8.8X " - "0x%8.8X %%0%%.prm\r\n", psMemInfo->sDevVAddr.uiAddr, - ui32Offset, ui32Bytes, ui32ParamOutPos); + PDumpCommentWithFlags(ui32Flags, "LDB :SGXMEM:VA_%8.8X:0x%8.8X " + "0x%8.8X 0x%8.8X %%0%%.prm\r\n", + psMemInfo->sDevVAddr.uiAddr, ui32Offset, + ui32Bytes, ui32ParamOutPos); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -864,8 +851,7 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, if (PDumpSuspended()) return; - PDumpCommentWithFlags(ui32PDumpFlags, - "\r\n-- Dump bitmap of render\r\n"); + PDumpCommentWithFlags(ui32PDumpFlags, "Dump bitmap of render\r\n"); pdump_print(ui32PDumpFlags, "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " @@ -896,7 +882,7 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, ui32FileOffset = 0; - PDumpCommentWithFlags(0, "\r\n-- Dump 3D signature registers\r\n"); + PDumpCommentWithFlags(0, "Dump 3D signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", ui32DumpFrameNum); @@ -928,7 +914,7 @@ void PDumpCounterRegisters(u32 ui32DumpFrameNum, if (PDumpSuspended()) return; - PDumpCommentWithFlags(0, "\r\n-- Dump counter registers\r\n"); + PDumpCommentWithFlags(0, "Dump counter registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); ui32FileOffset = 0; @@ -947,7 +933,7 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, if (PDumpSuspended()) return; - PDumpCommentWithFlags(0, "\r\n-- Dump TA signature registers\r\n"); + PDumpCommentWithFlags(0, "Dump TA signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", ui32DumpFrameNum); @@ -984,7 +970,7 @@ void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, return; PDumpCommentWithFlags(ui32PDumpFlags, - "\r\n-- Dump Hardware Performance Circular Buffer\r\n"); + "Dump Hardware Performance Circular Buffer\r\n"); pdump_print(ui32PDumpFlags, "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); -- 1.7.5.4 From 6323965404dd65d8da6cb3fdf12ada05c73165c9 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:34 +0100 Subject: [PATCH 36/95] gpu: pvr: pdump: remove param offset handling Currently, we are not storing any data, but in future, we will be storing both script and param to the same stream. This removes the need to reference the param stream from the script stream, and the logical issues that arise from this, especially in light of frame based storage, with frame culling happening. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 30 +++++++----------------------- 1 files changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 57f1fc7..07bebb8 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -138,12 +138,6 @@ DbgDrvIsCaptureFrame(struct DBG_STREAM *psStream, IMG_BOOL bCheckPreviousFrame) return 1; } -static u32 -DbgDrvGetStreamOffset(struct DBG_STREAM *psStream) -{ - return 0; -} - static enum PVRSRV_ERROR pdump_write(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, u32 ui32Flags) @@ -611,7 +605,6 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_VIRTADDR sDevVAddr; struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR CpuPAddr; - u32 ui32ParamOutPos; u32 ui32CurrentOffset; u32 ui32BytesRemaining; enum PVRSRV_ERROR eError; @@ -635,18 +628,15 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, PVR_ASSERT(pui8DataLinAddr); - ui32ParamOutPos = - DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pui8DataLinAddr, ui32Bytes, ui32Flags); if (eError != PVRSRV_OK) return eError; PDumpCommentWithFlags(ui32Flags, "LDB :SGXMEM:VA_%8.8X:0x%8.8X " - "0x%8.8X 0x%8.8X %%0%%.prm\r\n", + "0x%8.8X\r\n", psMemInfo->sDevVAddr.uiAddr, ui32Offset, - ui32Bytes, ui32ParamOutPos); + ui32Bytes); CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); @@ -681,14 +671,13 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, } pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" - " 0x%8.8X 0x%8.8X %%0%%.prm\r\n", (u32) hUniqueTag, + " 0x%8.8X\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos); + ui32BlockBytes); ui32BytesRemaining -= ui32BlockBytes; ui32CurrentOffset += ui32BlockBytes; - ui32ParamOutPos += ui32BlockBytes; } PVR_ASSERT(ui32BytesRemaining == 0); @@ -707,7 +696,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR sCpuPAddr; u32 ui32Offset; - u32 ui32ParamOutPos; enum PVRSRV_ERROR eError; if (PDumpSuspended()) @@ -716,9 +704,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, if (!pvLinAddr) return PVRSRV_ERROR_GENERIC; - ui32ParamOutPos = - DbgDrvGetStreamOffset(gpsStream[PDUMP_STREAM_PARAM2]); - if (bInitialisePages) { eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, ui32Bytes, PDUMP_FLAGS_CONTINUOUS); @@ -743,11 +728,11 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, if (bInitialisePages) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X " - "%%0%%.prm\r\n", (u32) hUniqueTag1, + "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", + (u32) hUniqueTag1, sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), - ui32BlockBytes, ui32ParamOutPos); + ui32BlockBytes); } else { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(u32)) { @@ -791,7 +776,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, ui32PageOffset = 0; ui32Bytes -= ui32BlockBytes; pui8LinAddr += ui32BlockBytes; - ui32ParamOutPos += ui32BlockBytes; } return PVRSRV_OK; -- 1.7.5.4 From 014c6760d4728773247b581a3ce5d348be608f47 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:35 +0100 Subject: [PATCH 37/95] gpu: pvr: pdump: review use of PDumpSuspended PDumpSuspended is handled by pdump_write() now. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 91 ++-------------------------------------------- 1 files changed, 4 insertions(+), 87 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 07bebb8..093c1e0 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -169,9 +169,6 @@ pdump_print(u32 flags, char *pszFormat, ...) { va_list ap; - if (PDumpSuspended()) - return; - va_start(ap, pszFormat); vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, pszFormat, ap); va_end(ap); @@ -182,12 +179,7 @@ pdump_print(u32 flags, char *pszFormat, ...) void PDumpCommentKM(char *pszComment, u32 ui32Flags) { - int len; - - if (PDumpSuspended()) - return; - - len = strlen(pszComment); + int len = strlen(pszComment); if ((len > 1) && (pszComment[len - 1] == '\n')) pszComment[len - 1] = 0; @@ -202,9 +194,6 @@ void PDumpComment(char *pszFormat, ...) { va_list ap; - if (PDumpSuspended()) - return; - va_start(ap, pszFormat); vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); va_end(ap); @@ -216,9 +205,6 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) { va_list ap; - if (PDumpSuspended()) - return; - va_start(ap, pszFormat); vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); va_end(ap); @@ -230,6 +216,9 @@ void PDumpSetFrameKM(u32 ui32Frame) { u32 ui32Stream; + if (PDumpSuspended()) + return; + for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) if (gpsStream[ui32Stream]) DbgDrvSetFrame(gpsStream[ui32Stream], ui32Frame); @@ -337,18 +326,12 @@ void PDumpDeInit(void) void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) { - if (PDumpSuspended()) - return; - pdump_print(ui32Flags, "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); } void PDumpReg(u32 ui32Reg, u32 ui32Data) { - if (PDumpSuspended()) - return; - pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); } @@ -362,9 +345,6 @@ void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32PollCount; - if (PDumpSuspended()) - return; - if (((ui32RegAddr == EUR_CR_EVENT_STATUS) && (ui32RegValue & ui32Mask & EUR_CR_EVENT_STATUS_TA_FINISHED_MASK)) || @@ -400,9 +380,6 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - if (PDumpSuspended()) - return; - PVR_UNREFERENCED_PARAMETER(pvLinAddr); PVR_ASSERT(((u32) ui32DevVAddr & (ui32PageSize - 1)) == 0); @@ -438,9 +415,6 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - if (PDumpSuspended()) - return; - PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", @@ -473,9 +447,6 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, struct IMG_DEV_PHYADDR sDevPAddr; struct PVRSRV_DEVICE_NODE *psDeviceNode; - if (PDumpSuspended()) - return; - PVR_ASSERT(((u32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); @@ -510,9 +481,6 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Page; - if (PDumpSuspended()) - return; - PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); @@ -535,9 +503,6 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) { - if (PDumpSuspended()) - return; - pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32)hUniqueTag, @@ -548,9 +513,6 @@ void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, void *hUniqueTag) { - if (PDumpSuspended()) - return; - pdump_print(ui32Flags, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32)hUniqueTag, @@ -570,9 +532,6 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; - if (PDumpSuspended()) - return; - PVR_ASSERT((ui32Offset + sizeof(u32)) <= psMemInfo->ui32AllocSize); @@ -609,9 +568,6 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32BytesRemaining; enum PVRSRV_ERROR eError; - if (PDumpSuspended()) - return PVRSRV_OK; - PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); if (ui32Bytes == 0) @@ -698,9 +654,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, u32 ui32Offset; enum PVRSRV_ERROR eError; - if (PDumpSuspended()) - return PVRSRV_OK; - if (!pvLinAddr) return PVRSRV_ERROR_GENERIC; @@ -792,9 +745,6 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; - if (PDumpSuspended()) - return; - CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); ui32PageByteOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); @@ -832,9 +782,6 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) { - if (PDumpSuspended()) - return; - PDumpCommentWithFlags(ui32PDumpFlags, "Dump bitmap of render\r\n"); pdump_print(ui32PDumpFlags, @@ -848,9 +795,6 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags) { - if (PDumpSuspended()) - return; - pdump_print(ui32PDumpFlags, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, ui32FileOffset, pszFileName); } @@ -861,9 +805,6 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, u32 ui32FileOffset; u32 i; - if (PDumpSuspended()) - return; - ui32FileOffset = 0; PDumpCommentWithFlags(0, "Dump 3D signature registers\r\n"); @@ -880,9 +821,6 @@ void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, static void PDumpCountRead(char *pszFileName, u32 ui32Address, u32 ui32Size, u32 *pui32FileOffset) { - if (PDumpSuspended()) - return; - pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, *pui32FileOffset, pszFileName); @@ -895,9 +833,6 @@ void PDumpCounterRegisters(u32 ui32DumpFrameNum, u32 ui32FileOffset; u32 i; - if (PDumpSuspended()) - return; - PDumpCommentWithFlags(0, "Dump counter registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); @@ -914,9 +849,6 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, u32 ui32FileOffset; u32 i; - if (PDumpSuspended()) - return; - PDumpCommentWithFlags(0, "Dump TA signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", ui32DumpFrameNum); @@ -932,17 +864,11 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) { - if (PDumpSuspended()) - return; - pdump_print(ui32Flags, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); } void PDumpCycleCountRegRead(const u32 ui32RegOffset) { - if (PDumpSuspended()) - return; - pdump_print(0, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); } @@ -950,9 +876,6 @@ void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, u32 ui32PDumpFlags) { - if (PDumpSuspended()) - return; - PDumpCommentWithFlags(ui32PDumpFlags, "Dump Hardware Performance Circular Buffer\r\n"); pdump_print(ui32PDumpFlags, @@ -970,9 +893,6 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; - if (PDumpSuspended()) - return; - PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= psROffMemInfo->ui32AllocSize); @@ -1001,9 +921,6 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) { - if (PDumpSuspended()) - return; - pdump_print(ui32Flags, "IDL %u\r\n", ui32Clocks); } -- 1.7.5.4 From d47eefb6020ed9af17c5b82bb53f8c9800334e3d Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:36 +0100 Subject: [PATCH 38/95] gpu: pvr: pdump: assume that SGX_MMU_PAGE_SIZE equals PAGE_SIZE This way, the address mangling code becomes a lot clearer. The following changes are made: SGX_MMU_PAGE_SIZE -> PAGE_SIZE. SGX_MMU_PDE_ADDR_MASK -> PAGE_MASK ~(PAGE_SIZE - 1) -> PAGE_MASK (Address >> SGX_MMU_PAGE_SHIFT) * PAGE_SIZE -> Address & PAGE_MASK A few functions which get SGX_MMU_PAGE_SIZE passed lose this argument and use PAGE_SIZE internally. No functional changes on machines where PAGE_SIZE is the same for the host as for the sgx. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/buffer_manager.c | 2 - drivers/gpu/pvr/mmu.c | 7 +- drivers/gpu/pvr/pdump.c | 138 +++++++++++++++++++------------------ drivers/gpu/pvr/pdump_km.h | 10 ++-- 4 files changed, 79 insertions(+), 78 deletions(-) diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index a4109b4..096c15b 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1113,7 +1113,6 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, pMapping->hOSMemHandle, ui32PDumpSize, - pMapping->pBMHeap->sDevArena.ui32DataPageSize, (void *)pMapping); } #endif @@ -1182,7 +1181,6 @@ static void DevMemoryFree(struct BM_MAPPING *pMapping) ui32PSize = pMapping->uSize; PDUMPFREEPAGES(pMapping->pBMHeap, pMapping->DevVAddr, ui32PSize, - pMapping->pBMHeap->sDevArena.ui32DataPageSize, (void *)pMapping, (IMG_BOOL)(pMapping-> ui32Flags & PVRSRV_MEM_INTERLEAVED)); #endif diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index ed7b111..af3bcfa 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -144,7 +144,7 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) && ppsPTInfoList[ui32PTIndex]->PTPageCpuVAddr) PDUMPFREEPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, ppsPTInfoList[ui32PTIndex]->PTPageCpuVAddr, - SGX_MMU_PAGE_SIZE, PDUMP_PT_UNIQUETAG); + PDUMP_PT_UNIQUETAG); switch (pMMUHeap->psDevArena->DevMemHeapType) { case DEVICE_MEMORY_HEAP_SHARED: @@ -400,7 +400,6 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, PDUMPMALLOCPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, ppsPTInfoList[i]->PTPageCpuVAddr, - SGX_MMU_PAGE_SIZE, PDUMP_PT_UNIQUETAG); PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, @@ -555,7 +554,7 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, PDUMPCOMMENT("Alloc page directory"); PDUMPMALLOCPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, pvPDCpuVAddr, - SGX_MMU_PAGE_SIZE, PDUMP_PD_UNIQUETAG); + PDUMP_PD_UNIQUETAG); if (pvPDCpuVAddr) { pui32Tmp = (u32 *) pvPDCpuVAddr; @@ -602,7 +601,7 @@ void MMU_Finalise(struct MMU_CONTEXT *psMMUContext) PDUMPCOMMENT("Free page directory"); PDUMPFREEPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, psMMUContext->pvPDCpuVAddr, - SGX_MMU_PAGE_SIZE, PDUMP_PT_UNIQUETAG); + PDUMP_PT_UNIQUETAG); pui32Tmp = (u32 *) psMMUContext->pvPDCpuVAddr; diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 093c1e0..85e8328 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -39,6 +39,16 @@ #include <linux/tty.h> +/* + * There is no sense in having SGX_MMU_PAGE_SIZE differ from PAGE_SIZE. + * Especially the calculations in this file, while obviously an attempt to work + * around possibly differing host and gpu page sizes, are impossible when + * page size is not the same everywhere. + */ +#if PAGE_SIZE != SGX_MMU_PAGE_SIZE +#error Host page size differs from GPU page size! +#endif + #define DEBUG_CAPMODE_FRAMED 0x00000001 #define DEBUG_CAPMODE_CONTINUOUS 0x00000002 #define DEBUG_CAPMODE_HOTKEY 0x00000004 @@ -372,53 +382,50 @@ void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, - u32 ui32PageSize, void *hUniqueTag) + void *hUniqueTag) { u32 ui32Offset; u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32Page; PVR_UNREFERENCED_PARAMETER(pvLinAddr); - PVR_ASSERT(((u32) ui32DevVAddr & (ui32PageSize - 1)) == 0); + PVR_ASSERT(((u32) ui32DevVAddr & ~PAGE_MASK) == 0); PVR_ASSERT(hOSMemHandle); - PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); + PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); PDumpComment("MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", - ui32DevVAddr, ui32NumBytes, ui32PageSize); + ui32DevVAddr, ui32NumBytes, PAGE_SIZE); ui32Offset = 0; - ui32NumPages = ui32NumBytes / ui32PageSize; + ui32NumPages = ui32NumBytes / PAGE_SIZE; while (ui32NumPages--) { sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); - PVR_ASSERT((sCpuPAddr.uiAddr & (ui32PageSize - 1)) == 0); - ui32Offset += ui32PageSize; + PVR_ASSERT((sCpuPAddr.uiAddr & ~PAGE_MASK) == 0); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - ui32Page = sDevPAddr.uiAddr / ui32PageSize; pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", - (u32)hUniqueTag, ui32Page * ui32PageSize, - ui32PageSize, ui32PageSize, - ui32Page * ui32PageSize); + (u32)hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK, + PAGE_SIZE, PAGE_SIZE, sDevPAddr.uiAddr & PAGE_MASK); + + ui32Offset += PAGE_SIZE; } } void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32PTSize, void *hUniqueTag) + void *pvLinAddr, void *hUniqueTag) { u8 *pui8LinAddr; u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32Page; - PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); + PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", - ui32PTSize, SGX_MMU_PAGE_SIZE); + PAGE_SIZE, PAGE_SIZE); pui8LinAddr = (u8 *) pvLinAddr; @@ -427,32 +434,30 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, while (ui32NumPages--) { sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC " ":SGXMEM:PA_%8.8X%8.8lX 0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, - ui32Page * SGX_MMU_PAGE_SIZE, SGX_MMU_PAGE_SIZE, - SGX_MMU_PAGE_SIZE, ui32Page * SGX_MMU_PAGE_SIZE); + sDevPAddr.uiAddr & PAGE_MASK, PAGE_SIZE, + PAGE_SIZE, sDevPAddr.uiAddr & PAGE_MASK); - pui8LinAddr += SGX_MMU_PAGE_SIZE; + pui8LinAddr += PAGE_SIZE; } } void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, - u32 ui32NumBytes, u32 ui32PageSize, void *hUniqueTag, - IMG_BOOL bInterleaved) + u32 ui32NumBytes, void *hUniqueTag, IMG_BOOL bInterleaved) { u32 ui32NumPages, ui32PageCounter; struct IMG_DEV_PHYADDR sDevPAddr; struct PVRSRV_DEVICE_NODE *psDeviceNode; - PVR_ASSERT(((u32) sDevVAddr.uiAddr & (ui32PageSize - 1)) == 0); - PVR_ASSERT(((u32) ui32NumBytes & (ui32PageSize - 1)) == 0); + PVR_ASSERT(((u32) sDevVAddr.uiAddr & ~PAGE_MASK) == 0); + PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); PDumpComment("FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); - ui32NumPages = ui32NumBytes / ui32PageSize; + ui32NumPages = ui32NumBytes / PAGE_SIZE; psDeviceNode = psBMHeap->pBMContext->psDeviceNode; for (ui32PageCounter = 0; ui32PageCounter < ui32NumPages; ui32PageCounter++) { @@ -468,20 +473,19 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, } - sDevVAddr.uiAddr += ui32PageSize; + sDevVAddr.uiAddr += PAGE_SIZE; } } void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32PTSize, void *hUniqueTag) + void *pvLinAddr, void *hUniqueTag) { u8 *pui8LinAddr; u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32Page; - PVR_ASSERT(((u32) pvLinAddr & (ui32PTSize - 1)) == 0); + PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); @@ -492,12 +496,12 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, while (ui32NumPages--) { sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - ui32Page = sDevPAddr.uiAddr >> SGX_MMU_PAGE_SHIFT; - pui8LinAddr += SGX_MMU_PAGE_SIZE; pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", (u32)hUniqueTag, - ui32Page * SGX_MMU_PAGE_SIZE); + sDevPAddr.uiAddr & PAGE_MASK); + + pui8LinAddr += PAGE_SIZE; } } @@ -506,8 +510,8 @@ void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32)hUniqueTag, - ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), - ui32Data & (SGX_MMU_PAGE_SIZE - 1)); + ui32Data & PAGE_MASK, + ui32Data & ~PAGE_MASK); } void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, @@ -516,8 +520,8 @@ void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, pdump_print(ui32Flags, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", ui32Reg, (u32)hUniqueTag, - ui32Data & ~(SGX_MMU_PAGE_SIZE - 1), - ui32Data & (SGX_MMU_PAGE_SIZE - 1)); + ui32Data & PAGE_MASK, + ui32Data & ~PAGE_MASK); } void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, @@ -537,7 +541,7 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); + ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset - ui32PageOffset; @@ -548,8 +552,8 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, pdump_print(0, "POL :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " "0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); } @@ -596,7 +600,7 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageByteOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); + ui32PageByteOffset = CpuPAddr.uiAddr & ~PAGE_MASK; sDevVAddr = psMemInfo->sDevVAddr; sDevVAddr.uiAddr += ui32Offset; @@ -628,8 +632,8 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" " 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, ui32BlockBytes); ui32BytesRemaining -= ui32BlockBytes; @@ -664,18 +668,18 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, return eError; } - ui32PageOffset = (u32) pvLinAddr & (HOST_PAGESIZE() - 1); + ui32PageOffset = (u32) pvLinAddr & ~PAGE_MASK; ui32NumPages = - (ui32PageOffset + ui32Bytes + HOST_PAGESIZE() - 1) / - HOST_PAGESIZE(); + (ui32PageOffset + ui32Bytes + PAGE_SIZE - 1) / + PAGE_SIZE; pui8LinAddr = (u8 *) pvLinAddr; while (ui32NumPages--) { sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - if (ui32PageOffset + ui32Bytes > HOST_PAGESIZE()) - ui32BlockBytes = HOST_PAGESIZE() - ui32PageOffset; + if (ui32PageOffset + ui32Bytes > PAGE_SIZE) + ui32BlockBytes = PAGE_SIZE - ui32PageOffset; else ui32BlockBytes = ui32Bytes; @@ -683,8 +687,8 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", (u32) hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, ui32BlockBytes); } else { for (ui32Offset = 0; ui32Offset < ui32BlockBytes; @@ -693,21 +697,21 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, *((u32 *) (pui8LinAddr + ui32Offset)); - if ((ui32PTE & SGX_MMU_PDE_ADDR_MASK) != 0) { + if ((ui32PTE & PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32)hUniqueTag1, (sDevPAddr.uiAddr + ui32Offset) & - ~(SGX_MMU_PAGE_SIZE - 1), + PAGE_MASK, (sDevPAddr.uiAddr + ui32Offset) & - (SGX_MMU_PAGE_SIZE - 1), + ~PAGE_MASK, (u32)hUniqueTag2, ui32PTE & - SGX_MMU_PDE_ADDR_MASK, + PAGE_MASK, ui32PTE & - ~SGX_MMU_PDE_ADDR_MASK); + ~PAGE_MASK); } else { PVR_ASSERT(! (ui32PTE & @@ -717,10 +721,10 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, (u32) hUniqueTag1, (sDevPAddr.uiAddr + ui32Offset) & - ~(SGX_MMU_PAGE_SIZE - 1), + PAGE_MASK, (sDevPAddr.uiAddr + ui32Offset) & - (SGX_MMU_PAGE_SIZE - 1), + ~PAGE_MASK, ui32PTE, (u32)hUniqueTag2); } } @@ -747,7 +751,7 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageByteOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); + ui32PageByteOffset = CpuPAddr.uiAddr & ~PAGE_MASK; sDevVAddr = psMemInfo->sDevVAddr; sDevVAddr.uiAddr += ui32Offset; @@ -756,22 +760,22 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); sDevPAddr.uiAddr += ui32PageByteOffset; - if ((sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK) != 0) { + if ((sPDDevPAddr.uiAddr & PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32) hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, (u32)hUniqueTag2, - sPDDevPAddr.uiAddr & SGX_MMU_PDE_ADDR_MASK, - sPDDevPAddr.uiAddr & ~SGX_MMU_PDE_ADDR_MASK); + sPDDevPAddr.uiAddr & PAGE_MASK, + sPDDevPAddr.uiAddr & ~PAGE_MASK); } else { PVR_ASSERT(!(sDevPAddr.uiAddr & SGX_MMU_PTE_VALID)); pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", (u32)hUniqueTag1, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, sPDDevPAddr.uiAddr); } } @@ -903,7 +907,7 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, CpuPAddr = OSMemHandleToCpuPAddr(psROffMemInfo->sMemBlk.hOSMemHandle, ui32ROffOffset); - ui32PageOffset = CpuPAddr.uiAddr & (PAGE_SIZE - 1); + ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageOffset; @@ -914,8 +918,8 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr & ~(SGX_MMU_PAGE_SIZE - 1), - sDevPAddr.uiAddr & (SGX_MMU_PAGE_SIZE - 1), + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, ui32WPosVal, ui32PacketSize, ui32BufferSize); } diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 5a18fe5..91ca87f 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -97,14 +97,14 @@ IMG_BOOL PDumpIsCaptureFrameKM(void); void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, - u32 ui32NumBytes, u32 ui32PageSize, void *hUniqueTag); + u32 ui32NumBytes, void *hUniqueTag); void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); + void *pvLinAddr, void *hUniqueTag); void PDumpFreePages(struct BM_HEAP *psBMHeap, - struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, - u32 ui32PageSize, void *hUniqueTag, IMG_BOOL bInterleaved); + struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, + void *hUniqueTag, IMG_BOOL bInterleaved); void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, u32 ui32NumBytes, void *hUniqueTag); + void *pvLinAddr, void *hUniqueTag); void PDumpPDReg(u32 ui32Reg, u32 ui32dwData, void *hUniqueTag); void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, void *hUniqueTag); -- 1.7.5.4 From 7ef81e2878049c936502967072f3d12161e17177 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:37 +0100 Subject: [PATCH 39/95] gpu: pvr: pdump: clean up logic across pdump.c This patch is the least obvious of the set. It removes useless variables, superfluous calculations, cleans up loops, and makes a few functions wrap others instead of copying them. Should be no functional change, but as said, very non-obvious. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 295 +++++++++++++++-------------------------------- 1 files changed, 92 insertions(+), 203 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 85e8328..86ab4e3 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -63,8 +63,6 @@ struct DBG_STREAM { IMG_BOOL bInitPhaseComplete; }; -#define MIN(a, b) (a > b ? b : a) - static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); #define PDUMP_STREAM_PARAM2 0 @@ -149,7 +147,7 @@ DbgDrvIsCaptureFrame(struct DBG_STREAM *psStream, IMG_BOOL bCheckPreviousFrame) } static enum PVRSRV_ERROR -pdump_write(struct DBG_STREAM *psStream, u8 *pui8Data, u32 ui32Count, +pdump_write(struct DBG_STREAM *psStream, void *pui8Data, u32 ui32Count, u32 ui32Flags) { if (!psStream) /* will always hit with the empty backend. */ @@ -184,7 +182,7 @@ pdump_print(u32 flags, char *pszFormat, ...) va_end(ap); (void) pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], - (u8 *)gpszScript, strlen(gpszScript), flags); + gpszScript, strlen(gpszScript), flags); } void PDumpCommentKM(char *pszComment, u32 ui32Flags) @@ -342,8 +340,7 @@ void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) void PDumpReg(u32 ui32Reg, u32 ui32Data) { - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); + PDumpRegWithFlagsKM(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS); } void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, @@ -355,15 +352,11 @@ void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32PollCount; - if (((ui32RegAddr == EUR_CR_EVENT_STATUS) && - (ui32RegValue & ui32Mask & - EUR_CR_EVENT_STATUS_TA_FINISHED_MASK)) || - ((ui32RegAddr == EUR_CR_EVENT_STATUS) && - (ui32RegValue & ui32Mask & - EUR_CR_EVENT_STATUS_PIXELBE_END_RENDER_MASK)) || - ((ui32RegAddr == EUR_CR_EVENT_STATUS) && - (ui32RegValue & ui32Mask & - EUR_CR_EVENT_STATUS_DPM_3D_MEM_FREE_MASK))) + if ((ui32RegAddr == EUR_CR_EVENT_STATUS) && + ((ui32RegValue & ui32Mask) & + (EUR_CR_EVENT_STATUS_TA_FINISHED_MASK | + EUR_CR_EVENT_STATUS_PIXELBE_END_RENDER_MASK | + EUR_CR_EVENT_STATUS_DPM_3D_MEM_FREE_MASK))) ui32PollCount = POLL_COUNT_LONG; else ui32PollCount = POLL_COUNT_SHORT; @@ -384,10 +377,9 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, void *hUniqueTag) { - u32 ui32Offset; - u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; + u32 ui32Offset; PVR_UNREFERENCED_PARAMETER(pvLinAddr); @@ -398,9 +390,8 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, PDumpComment("MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", ui32DevVAddr, ui32NumBytes, PAGE_SIZE); - ui32Offset = 0; - ui32NumPages = ui32NumBytes / PAGE_SIZE; - while (ui32NumPages--) { + for (ui32Offset = 0; ui32Offset < ui32NumBytes; + ui32Offset += PAGE_SIZE) { sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); PVR_ASSERT((sCpuPAddr.uiAddr & ~PAGE_MASK) == 0); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); @@ -409,16 +400,12 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", (u32)hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK, PAGE_SIZE, PAGE_SIZE, sDevPAddr.uiAddr & PAGE_MASK); - - ui32Offset += PAGE_SIZE; } } void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, void *hUniqueTag) { - u8 *pui8LinAddr; - u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; @@ -427,41 +414,30 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", PAGE_SIZE, PAGE_SIZE); - pui8LinAddr = (u8 *) pvLinAddr; + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - ui32NumPages = 1; - - while (ui32NumPages--) { - sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC " - ":SGXMEM:PA_%8.8X%8.8lX 0x%lX %lu 0x%8.8lX\r\n", - (u32)hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK, PAGE_SIZE, - PAGE_SIZE, sDevPAddr.uiAddr & PAGE_MASK); - - pui8LinAddr += PAGE_SIZE; - } + pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8lX " + "0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, + sDevPAddr.uiAddr & PAGE_MASK, PAGE_SIZE, PAGE_SIZE, + sDevPAddr.uiAddr & PAGE_MASK); } void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, void *hUniqueTag, IMG_BOOL bInterleaved) { - u32 ui32NumPages, ui32PageCounter; struct IMG_DEV_PHYADDR sDevPAddr; - struct PVRSRV_DEVICE_NODE *psDeviceNode; + struct PVRSRV_DEVICE_NODE *psDeviceNode = + psBMHeap->pBMContext->psDeviceNode; + int i; PVR_ASSERT(((u32) sDevVAddr.uiAddr & ~PAGE_MASK) == 0); PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); PDumpComment("FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); - ui32NumPages = ui32NumBytes / PAGE_SIZE; - psDeviceNode = psBMHeap->pBMContext->psDeviceNode; - for (ui32PageCounter = 0; ui32PageCounter < ui32NumPages; - ui32PageCounter++) { - if (!bInterleaved || (ui32PageCounter % 2) == 0) { + for (i = 0; (i * PAGE_SIZE) < ui32NumBytes; i++) { + if (!bInterleaved || (i % 2) == 0) { sDevPAddr = psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap-> pMMUHeap, @@ -469,8 +445,6 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", (u32)hUniqueTag, sDevPAddr.uiAddr); - } else { - } sDevVAddr.uiAddr += PAGE_SIZE; @@ -480,8 +454,6 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, void *hUniqueTag) { - u8 *pui8LinAddr; - u32 ui32NumPages; struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; @@ -489,29 +461,11 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); - pui8LinAddr = (u8 *) pvLinAddr; - - ui32NumPages = 1; - - while (ui32NumPages--) { - sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK); - - pui8LinAddr += PAGE_SIZE; - } -} + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); -void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) -{ - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - ui32Reg, (u32)hUniqueTag, - ui32Data & PAGE_MASK, - ui32Data & ~PAGE_MASK); + pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", + (u32)hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK); } void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, @@ -524,6 +478,12 @@ void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, ui32Data & ~PAGE_MASK); } +void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) +{ + PDumpPDRegWithFlags(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS, + hUniqueTag); +} + void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Value, u32 ui32Mask, enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag) @@ -562,14 +522,10 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) { - u32 ui32PageByteOffset; - u8 *pui8DataLinAddr = NULL; struct IMG_DEV_VIRTADDR sDevVPageAddr; - struct IMG_DEV_VIRTADDR sDevVAddr; struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR CpuPAddr; - u32 ui32CurrentOffset; - u32 ui32BytesRemaining; + u32 ui32PageOffset; enum PVRSRV_ERROR eError; PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); @@ -577,19 +533,16 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, if (ui32Bytes == 0) return PVRSRV_ERROR_GENERIC; - if (pvAltLinAddr) { - pui8DataLinAddr = pvAltLinAddr; - } else { - if (psMemInfo->pvLinAddrKM) - pui8DataLinAddr = - (u8 *) psMemInfo->pvLinAddrKM + ui32Offset; - - } - - PVR_ASSERT(pui8DataLinAddr); + if (pvAltLinAddr) + eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], + pvAltLinAddr, ui32Bytes, ui32Flags); + else if (psMemInfo->pvLinAddrKM) + eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes, ui32Flags); + else + return PVRSRV_ERROR_GENERIC; - eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pui8DataLinAddr, - ui32Bytes, ui32Flags); if (eError != PVRSRV_OK) return eError; @@ -600,35 +553,19 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageByteOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - - sDevVAddr = psMemInfo->sDevVAddr; - sDevVAddr.uiAddr += ui32Offset; - - ui32BytesRemaining = ui32Bytes; - ui32CurrentOffset = ui32Offset; + ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - while (ui32BytesRemaining > 0) { - u32 ui32BlockBytes = MIN(ui32BytesRemaining, PAGE_SIZE); - CpuPAddr = - OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, - ui32CurrentOffset); + while (ui32Bytes) { + u32 ui32BlockBytes = + min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); sDevVPageAddr.uiAddr = - psMemInfo->sDevVAddr.uiAddr + ui32CurrentOffset - - ui32PageByteOffset; + psMemInfo->sDevVAddr.uiAddr + ui32Offset - + ui32PageOffset; BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageByteOffset; - - if (ui32PageByteOffset) { - ui32BlockBytes = - MIN(ui32BytesRemaining, - PAGE_ALIGN(CpuPAddr.uiAddr) - CpuPAddr.uiAddr); - - ui32PageByteOffset = 0; - } + sDevPAddr.uiAddr += ui32PageOffset; pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" " 0x%8.8X\r\n", (u32) hUniqueTag, @@ -636,10 +573,10 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, sDevPAddr.uiAddr & ~PAGE_MASK, ui32BlockBytes); - ui32BytesRemaining -= ui32BlockBytes; - ui32CurrentOffset += ui32BlockBytes; + ui32PageOffset = 0; + ui32Bytes -= ui32BlockBytes; + ui32Offset += ui32BlockBytes; } - PVR_ASSERT(ui32BytesRemaining == 0); return PVRSRV_OK; } @@ -649,13 +586,9 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, u32 ui32Bytes, u32 ui32Flags, IMG_BOOL bInitialisePages, void *hUniqueTag1, void *hUniqueTag2) { - u32 ui32NumPages; - u32 ui32PageOffset; - u32 ui32BlockBytes; - u8 *pui8LinAddr; struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR sCpuPAddr; - u32 ui32Offset; + u32 ui32PageOffset; enum PVRSRV_ERROR eError; if (!pvLinAddr) @@ -668,20 +601,14 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, return eError; } - ui32PageOffset = (u32) pvLinAddr & ~PAGE_MASK; - ui32NumPages = - (ui32PageOffset + ui32Bytes + PAGE_SIZE - 1) / - PAGE_SIZE; - pui8LinAddr = (u8 *) pvLinAddr; + ui32PageOffset = (u32)pvLinAddr & ~PAGE_MASK; - while (ui32NumPages--) { - sCpuPAddr = OSMapLinToCPUPhys(pui8LinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + while (ui32Bytes) { + u32 ui32BlockBytes = + min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); - if (ui32PageOffset + ui32Bytes > PAGE_SIZE) - ui32BlockBytes = PAGE_SIZE - ui32PageOffset; - else - ui32BlockBytes = ui32Bytes; + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); if (bInitialisePages) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" @@ -691,27 +618,22 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, sDevPAddr.uiAddr & ~PAGE_MASK, ui32BlockBytes); } else { + u32 ui32Offset; + for (ui32Offset = 0; ui32Offset < ui32BlockBytes; ui32Offset += sizeof(u32)) { u32 ui32PTE = - *((u32 *) (pui8LinAddr + - ui32Offset)); + *((u32 *)(pvLinAddr + ui32Offset)); if ((ui32PTE & PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32)hUniqueTag1, - (sDevPAddr.uiAddr + - ui32Offset) & - PAGE_MASK, - (sDevPAddr.uiAddr + - ui32Offset) & - ~PAGE_MASK, + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, (u32)hUniqueTag2, - ui32PTE & - PAGE_MASK, - ui32PTE & - ~PAGE_MASK); + ui32PTE & PAGE_MASK, + ui32PTE & ~PAGE_MASK); } else { PVR_ASSERT(! (ui32PTE & @@ -719,20 +641,18 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X%8.8X\r\n", (u32) hUniqueTag1, - (sDevPAddr.uiAddr + - ui32Offset) & - PAGE_MASK, - (sDevPAddr.uiAddr + - ui32Offset) & - ~PAGE_MASK, + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, ui32PTE, (u32)hUniqueTag2); } + + sDevPAddr.uiAddr += sizeof(u32); } } ui32PageOffset = 0; ui32Bytes -= ui32BlockBytes; - pui8LinAddr += ui32BlockBytes; + pvLinAddr += ui32BlockBytes; } return PVRSRV_OK; @@ -744,21 +664,18 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, void *hUniqueTag1, void *hUniqueTag2) { struct IMG_CPU_PHYADDR CpuPAddr; - u32 ui32PageByteOffset; - struct IMG_DEV_VIRTADDR sDevVAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; + u32 ui32PageOffset; CpuPAddr = OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageByteOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - - sDevVAddr = psMemInfo->sDevVAddr; - sDevVAddr.uiAddr += ui32Offset; + ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageByteOffset; + sDevVPageAddr.uiAddr = + psMemInfo->sDevVAddr.uiAddr + ui32Offset - ui32PageOffset; BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageByteOffset; + sDevPAddr.uiAddr += ui32PageOffset; if ((sPDDevPAddr.uiAddr & PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, @@ -796,62 +713,43 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, ui32StrideInBytes, eMemFormat); } -static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Address, u32 ui32Size, u32 ui32PDumpFlags) +static void +PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address) { - pdump_print(ui32PDumpFlags, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", + pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, ui32FileOffset, pszFileName); } void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, u32 *pui32Registers, u32 ui32NumRegisters) { - u32 ui32FileOffset; u32 i; - ui32FileOffset = 0; - PDumpCommentWithFlags(0, "Dump 3D signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", ui32DumpFrameNum); - for (i = 0; i < ui32NumRegisters; i++) { - PDumpReadRegKM(gpszFile, ui32FileOffset, pui32Registers[i], - sizeof(u32), 0); - ui32FileOffset += sizeof(u32); - } -} - -static void PDumpCountRead(char *pszFileName, u32 ui32Address, u32 ui32Size, - u32 *pui32FileOffset) -{ - pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, - *pui32FileOffset, pszFileName); - - *pui32FileOffset += ui32Size; + for (i = 0; i < ui32NumRegisters; i++) + PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); } void PDumpCounterRegisters(u32 ui32DumpFrameNum, u32 *pui32Registers, u32 ui32NumRegisters) { - u32 ui32FileOffset; u32 i; PDumpCommentWithFlags(0, "Dump counter registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", ui32DumpFrameNum); - ui32FileOffset = 0; for (i = 0; i < ui32NumRegisters; i++) - PDumpCountRead(gpszFile, pui32Registers[i], sizeof(u32), - &ui32FileOffset); + PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); } void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, u32 *pui32Registers, u32 ui32NumRegisters) { - u32 ui32FileOffset; - u32 i; + u32 i, ui32FileOffset; PDumpCommentWithFlags(0, "Dump TA signature registers\r\n"); snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", @@ -859,11 +757,9 @@ void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, ui32FileOffset = ui32TAKickCount * ui32NumRegisters * sizeof(u32); - for (i = 0; i < ui32NumRegisters; i++) { - PDumpReadRegKM(gpszFile, ui32FileOffset, pui32Registers[i], - sizeof(u32), 0); - ui32FileOffset += sizeof(u32); - } + for (i = 0; i < ui32NumRegisters; i++) + PDumpReadRegKM(gpszFile, ui32FileOffset + i * sizeof(u32), + pui32Registers[i]); } void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) @@ -873,7 +769,7 @@ void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) void PDumpCycleCountRegRead(const u32 ui32RegOffset) { - pdump_print(0, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); + PDumpRegRead(ui32RegOffset, 0); } void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, @@ -891,33 +787,26 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, u32 ui32ROffOffset, u32 ui32WPosVal, u32 ui32PacketSize, u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag) { - u32 ui32PageOffset; - struct IMG_DEV_VIRTADDR sDevVAddr; struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_CPU_PHYADDR CpuPAddr; + u32 ui32PageOffset; PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= psROffMemInfo->ui32AllocSize); - sDevVAddr = psROffMemInfo->sDevVAddr; - - sDevVAddr.uiAddr += ui32ROffOffset; - CpuPAddr = OSMemHandleToCpuPAddr(psROffMemInfo->sMemBlk.hOSMemHandle, ui32ROffOffset); ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - sDevVPageAddr.uiAddr = sDevVAddr.uiAddr - ui32PageOffset; - + sDevVPageAddr.uiAddr = psROffMemInfo->sDevVAddr.uiAddr + + ui32ROffOffset - ui32PageOffset; BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageOffset; - pdump_print(ui32Flags, - "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X 0x%8.8X 0x%8.8X\r\n", - (u32) hUniqueTag, + pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" + " 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK, sDevPAddr.uiAddr & ~PAGE_MASK, ui32WPosVal, ui32PacketSize, ui32BufferSize); -- 1.7.5.4 From 31e93cf3062da80fcfaed4464a716579249d9715 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:38 +0100 Subject: [PATCH 40/95] gpu: pvr: pdump: remove page offset juggling The offset from the start of the page never changes when changing address spaces, just the page address changes. If an out of place assert is removed, (as all it could change is the address printed in an error message), then BM_GetPhysPageAddr() takes any address, and returns the physical address of the page. It can deal with an offset, and will return the page address without offset. These two facts were used to reduce the address wrangling logic even further. An obviously wrong masking was fixed in PDumpMem2KM. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/buffer_manager.c | 2 - drivers/gpu/pvr/pdump.c | 83 +++++++++++--------------------------- 2 files changed, 24 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index 096c15b..87e60cf 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1404,8 +1404,6 @@ enum PVRSRV_ERROR BM_GetPhysPageAddr(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, return PVRSRV_ERROR_INVALID_PARAMS; } - PVR_ASSERT((sDevVPageAddr.uiAddr & 0xFFF) == 0); - psDeviceNode = ((struct BM_BUF *)psMemInfo->sMemBlk.hBuffer)->pMapping->pBMHeap-> pBMContext->psDeviceNode; diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 86ab4e3..437cc0d 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -393,13 +393,12 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, for (ui32Offset = 0; ui32Offset < ui32NumBytes; ui32Offset += PAGE_SIZE) { sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); - PVR_ASSERT((sCpuPAddr.uiAddr & ~PAGE_MASK) == 0); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK, - PAGE_SIZE, PAGE_SIZE, sDevPAddr.uiAddr & PAGE_MASK); + (u32)hUniqueTag, sDevPAddr.uiAddr, PAGE_SIZE, + PAGE_SIZE, sDevPAddr.uiAddr); } } @@ -419,8 +418,8 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8lX " "0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK, PAGE_SIZE, PAGE_SIZE, - sDevPAddr.uiAddr & PAGE_MASK); + sDevPAddr.uiAddr, PAGE_SIZE, + PAGE_SIZE, sDevPAddr.uiAddr); } void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, @@ -465,7 +464,7 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr & PAGE_MASK); + (u32)hUniqueTag, sDevPAddr.uiAddr); } void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, @@ -491,29 +490,20 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, #define MEMPOLL_DELAY (1000) #define MEMPOLL_COUNT (2000000000 / MEMPOLL_DELAY) - u32 ui32PageOffset; struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; - struct IMG_CPU_PHYADDR CpuPAddr; + u32 ui32PageOffset; PVR_ASSERT((ui32Offset + sizeof(u32)) <= psMemInfo->ui32AllocSize); - CpuPAddr = - OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - - sDevVPageAddr.uiAddr = - psMemInfo->sDevVAddr.uiAddr + ui32Offset - ui32PageOffset; - + sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageOffset; - pdump_print(0, "POL :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " "0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, + sDevPAddr.uiAddr, ui32PageOffset, ui32Value, ui32Mask, eOperator, MEMPOLL_COUNT, MEMPOLL_DELAY); } @@ -524,7 +514,6 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, { struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; - struct IMG_CPU_PHYADDR CpuPAddr; u32 ui32PageOffset; enum PVRSRV_ERROR eError; @@ -551,26 +540,20 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, psMemInfo->sDevVAddr.uiAddr, ui32Offset, ui32Bytes); - CpuPAddr = - OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; + ui32PageOffset = + (psMemInfo->sDevVAddr.uiAddr + ui32Offset) & ~PAGE_MASK; while (ui32Bytes) { u32 ui32BlockBytes = min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); sDevVPageAddr.uiAddr = - psMemInfo->sDevVAddr.uiAddr + ui32Offset - - ui32PageOffset; - + psMemInfo->sDevVAddr.uiAddr + ui32Offset; BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageOffset; - pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" " 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, + sDevPAddr.uiAddr, ui32PageOffset, ui32BlockBytes); ui32PageOffset = 0; @@ -588,7 +571,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, { struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR sCpuPAddr; - u32 ui32PageOffset; enum PVRSRV_ERROR eError; if (!pvLinAddr) @@ -601,11 +583,10 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, return eError; } - ui32PageOffset = (u32)pvLinAddr & ~PAGE_MASK; - while (ui32Bytes) { u32 ui32BlockBytes = - min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); + min(ui32Bytes, + (u32)(PAGE_SIZE - ((u32)pvLinAddr & ~PAGE_MASK))); sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); @@ -625,7 +606,7 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, u32 ui32PTE = *((u32 *)(pvLinAddr + ui32Offset)); - if ((ui32PTE & PAGE_MASK) != 0) { + if ((ui32PTE & ~PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32)hUniqueTag1, @@ -650,7 +631,6 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, } } - ui32PageOffset = 0; ui32Bytes -= ui32BlockBytes; pvLinAddr += ui32BlockBytes; } @@ -663,26 +643,19 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, void *hUniqueTag1, void *hUniqueTag2) { - struct IMG_CPU_PHYADDR CpuPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32PageOffset; - CpuPAddr = - OSMemHandleToCpuPAddr(psMemInfo->sMemBlk.hOSMemHandle, ui32Offset); - ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - - sDevVPageAddr.uiAddr = - psMemInfo->sDevVAddr.uiAddr + ui32Offset - ui32PageOffset; + sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageOffset; if ((sPDDevPAddr.uiAddr & PAGE_MASK) != 0) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", (u32) hUniqueTag1, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, + sDevPAddr.uiAddr, ui32PageOffset, (u32)hUniqueTag2, sPDDevPAddr.uiAddr & PAGE_MASK, sPDDevPAddr.uiAddr & ~PAGE_MASK); @@ -691,8 +664,7 @@ PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, pdump_print(PDUMP_FLAGS_CONTINUOUS, "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", (u32)hUniqueTag1, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, + sDevPAddr.uiAddr, ui32PageOffset, sPDDevPAddr.uiAddr); } } @@ -789,26 +761,19 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, { struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; - struct IMG_CPU_PHYADDR CpuPAddr; u32 ui32PageOffset; PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= psROffMemInfo->ui32AllocSize); - CpuPAddr = - OSMemHandleToCpuPAddr(psROffMemInfo->sMemBlk.hOSMemHandle, - ui32ROffOffset); - ui32PageOffset = CpuPAddr.uiAddr & ~PAGE_MASK; - - sDevVPageAddr.uiAddr = psROffMemInfo->sDevVAddr.uiAddr + - ui32ROffOffset - ui32PageOffset; + sDevVPageAddr.uiAddr = + psROffMemInfo->sDevVAddr.uiAddr + ui32ROffOffset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); - sDevPAddr.uiAddr += ui32PageOffset; pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" " 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, + sDevPAddr.uiAddr, ui32PageOffset, ui32WPosVal, ui32PacketSize, ui32BufferSize); } -- 1.7.5.4 From 7a1ad6f75fdee252b1b70224a9c87d7c56cd94ba Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:39 +0100 Subject: [PATCH 41/95] gpu: pvr: pdump: sanitise stream handling Upper level pdump calls now have pdump_print and pdump_dump to their disposal. The former dumps strings, the second dumps raw data to the pdump stream. This commit also sanitises debug mode handling to have disabled, standard and full modes only. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pdump.c | 173 +++++++++++++++-------------------------------- 1 files changed, 56 insertions(+), 117 deletions(-) diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index 437cc0d..f87e10d 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -27,18 +27,14 @@ #if defined(PDUMP) #include <asm/atomic.h> #include <stdarg.h> + #include "sgxdefs.h" #include "services_headers.h" - #include "pvrversion.h" -#include "pvr_debug.h" - #include "sgxmmu.h" #include "mm.h" #include "pdump_km.h" -#include <linux/tty.h> - /* * There is no sense in having SGX_MMU_PAGE_SIZE differ from PAGE_SIZE. * Especially the calculations in this file, while obviously an attempt to work @@ -49,32 +45,8 @@ #error Host page size differs from GPU page size! #endif -#define DEBUG_CAPMODE_FRAMED 0x00000001 -#define DEBUG_CAPMODE_CONTINUOUS 0x00000002 -#define DEBUG_CAPMODE_HOTKEY 0x00000004 -#define DEBUG_CAPMODE_POSTMORTEM 0x00000008 - -#define DEBUG_OUTMODE_STREAMENABLE 0x00000004 - -struct DBG_STREAM { - u32 ui32CapMode; - u32 ui32Start; - u32 ui32End; - IMG_BOOL bInitPhaseComplete; -}; - static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); -#define PDUMP_STREAM_PARAM2 0 -#define PDUMP_STREAM_SCRIPT2 1 -#define PDUMP_NUM_STREAMS 2 - -static char *pszStreamName[PDUMP_NUM_STREAMS] = { "ParamStream2", - "ScriptStream2" -}; - -static struct DBG_STREAM *gpsStream[PDUMP_NUM_STREAMS] = {NULL}; - #define SZ_COMMENT_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE #define SZ_SCRIPT_SIZE_MAX (SZ_COMMENT_SIZE_MAX + 5) #define SZ_FILENAME_SIZE_MAX SZ_COMMENT_SIZE_MAX @@ -82,6 +54,13 @@ static char *gpszComment; static char *gpszScript; static char *gpszFile; +#define DEBUG_MODE_DISABLED 0 +#define DEBUG_MODE_STANDARD 1 +#define DEBUG_MODE_FULL 2 + +static u32 dbgdrv_mode = DEBUG_MODE_DISABLED; +static u32 dbgdrv_frame_number; + void PDumpSuspendKM(void) { atomic_inc(&gsPDumpSuspended); @@ -100,89 +79,74 @@ static inline IMG_BOOL PDumpSuspended(void) /* * empty pdump backend. */ -static void * -DbgDrvCreateStream(char *pszName, u32 ui32CapMode, u32 ui32OutMode, - u32 ui32Flags, u32 ui32Pages) +static void +dbgdrv_frame_set(u32 frame) { - return NULL; + dbgdrv_frame_number = frame; } -static void -DbgDrvDestroyStream(struct DBG_STREAM *psStream) +static enum PVRSRV_ERROR +dbgdrv_write_data(void *buffer, int size) { - + return PVRSRV_OK; } static void -DbgDrvSetCaptureMode(struct DBG_STREAM *psStream, u32 ui32CapMode, - u32 ui32Start, u32 ui32Stop, u32 ui32SampleRate) +dbgdrv_write_string(char *string) { } -static void -DbgDrvSetFrame(struct DBG_STREAM *psStream, u32 ui32Frame) +static bool +dbgdrv_capturing(void) { - + if (dbgdrv_mode == DEBUG_MODE_FULL) + return true; + else + return false; } -static void -DbgDrvDBGDrivWrite2(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level) +static bool dbgdrv_flags_check(u32 flags) { - + if (flags & PDUMP_FLAGS_NEVER) + return false; + else if (dbgdrv_mode == DEBUG_MODE_FULL) + return true; + else if ((dbgdrv_mode == DEBUG_MODE_STANDARD) && + (flags & PDUMP_FLAGS_CONTINUOUS)) + return true; + else + return false; } static void -DbgDrvWriteBINCM(struct DBG_STREAM *psStream, u8 *pui8InBuf, - u32 ui32InBuffSize, u32 ui32Level) +pdump_print(u32 flags, char *format, ...) { + va_list ap; -} + if (PDumpSuspended()) + return; -static u32 -DbgDrvIsCaptureFrame(struct DBG_STREAM *psStream, IMG_BOOL bCheckPreviousFrame) -{ - return 1; + if (!dbgdrv_flags_check(flags)) + return; + + va_start(ap, format); + vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, format, ap); + va_end(ap); + + dbgdrv_write_string(gpszScript); } static enum PVRSRV_ERROR -pdump_write(struct DBG_STREAM *psStream, void *pui8Data, u32 ui32Count, - u32 ui32Flags) +pdump_dump(u32 flags, void *buffer, u32 size) { - if (!psStream) /* will always hit with the empty backend. */ + if (PDumpSuspended()) return PVRSRV_OK; - if (PDumpSuspended() || (ui32Flags & PDUMP_FLAGS_NEVER)) + if (!dbgdrv_flags_check(flags)) return PVRSRV_OK; - if (ui32Flags & PDUMP_FLAGS_CONTINUOUS) { - if ((psStream->ui32CapMode & DEBUG_CAPMODE_FRAMED) && - (psStream->ui32Start == 0xFFFFFFFF) && - (psStream->ui32End == 0xFFFFFFFF) && - psStream->bInitPhaseComplete) - return PVRSRV_OK; - else - DbgDrvDBGDrivWrite2(psStream, pui8Data, - ui32Count, 1); - } else - DbgDrvWriteBINCM(psStream, pui8Data, ui32Count, 1); - - /* placeholder, will get proper error handling later. */ - return PVRSRV_OK; -} - -static void -pdump_print(u32 flags, char *pszFormat, ...) -{ - va_list ap; - - va_start(ap, pszFormat); - vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, pszFormat, ap); - va_end(ap); - - (void) pdump_write(gpsStream[PDUMP_STREAM_SCRIPT2], - gpszScript, strlen(gpszScript), flags); + return dbgdrv_write_data(buffer, size); } void PDumpCommentKM(char *pszComment, u32 ui32Flags) @@ -222,28 +186,22 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) void PDumpSetFrameKM(u32 ui32Frame) { - u32 ui32Stream; - if (PDumpSuspended()) return; - for (ui32Stream = 0; ui32Stream < PDUMP_NUM_STREAMS; ui32Stream++) - if (gpsStream[ui32Stream]) - DbgDrvSetFrame(gpsStream[ui32Stream], ui32Frame); + dbgdrv_frame_set(ui32Frame); } IMG_BOOL PDumpIsCaptureFrameKM(void) { if (PDumpSuspended()) return IMG_FALSE; - return DbgDrvIsCaptureFrame(gpsStream[PDUMP_STREAM_SCRIPT2], - IMG_FALSE); + + return dbgdrv_capturing(); } void PDumpInit(void) { - u32 i = 0; - if (!gpszFile) if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, @@ -265,19 +223,6 @@ void PDumpInit(void) NULL) != PVRSRV_OK) goto init_failed; - for (i = 0; i < PDUMP_NUM_STREAMS; i++) { - gpsStream[i] = - DbgDrvCreateStream(pszStreamName[i], - DEBUG_CAPMODE_FRAMED, - DEBUG_OUTMODE_STREAMENABLE, - 0, 10); - - DbgDrvSetCaptureMode(gpsStream[i], - DEBUG_CAPMODE_FRAMED, - 0xFFFFFFFF, 0xFFFFFFFF, 1); - DbgDrvSetFrame(gpsStream[i], 0); - } - PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME); PDumpComment("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FILE); @@ -308,11 +253,6 @@ void PDumpInit(void) void PDumpDeInit(void) { - u32 i = 0; - - for (i = 0; i < PDUMP_NUM_STREAMS; i++) - DbgDrvDestroyStream(gpsStream[i]); - if (gpszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, (void *)gpszFile, NULL); @@ -523,12 +463,11 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, return PVRSRV_ERROR_GENERIC; if (pvAltLinAddr) - eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], - pvAltLinAddr, ui32Bytes, ui32Flags); + eError = pdump_dump(ui32Flags, pvAltLinAddr, ui32Bytes); else if (psMemInfo->pvLinAddrKM) - eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], - psMemInfo->pvLinAddrKM + ui32Offset, - ui32Bytes, ui32Flags); + eError = pdump_dump(ui32Flags, + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes); else return PVRSRV_ERROR_GENERIC; @@ -577,8 +516,8 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, return PVRSRV_ERROR_GENERIC; if (bInitialisePages) { - eError = pdump_write(gpsStream[PDUMP_STREAM_PARAM2], pvLinAddr, - ui32Bytes, PDUMP_FLAGS_CONTINUOUS); + eError = pdump_dump(PDUMP_FLAGS_CONTINUOUS, pvLinAddr, + ui32Bytes); if (eError != PVRSRV_OK) return eError; } -- 1.7.5.4 From 7edb36e15e52d2fe6dbeceb77c5a256766b3e4c9 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:40 +0100 Subject: [PATCH 42/95] gpu: pvr: pdump: rewrite PDumpMemUM() Now that we have cleared up the streams, we can delay the copy_from_user() until copying into the streams. This makes PDumpMemUM highly similar to PDumpMemKM. So, split out the printing part from PDumpMemKM, and handle parameter stream dumping separately for PDumpMemKM and PDumpMemUM. In turn, this allows the removal of the separate buffer which was the heart of pdump_common.c, which is removed as well. No functional change. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 3 +- drivers/gpu/pvr/bridged_pvr_bridge.c | 4 +- drivers/gpu/pvr/bridged_sgx_bridge.c | 8 +- drivers/gpu/pvr/pdump.c | 92 ++++++++++++++++------ drivers/gpu/pvr/pdump_common.c | 141 ---------------------------------- drivers/gpu/pvr/pdump_km.h | 9 +-- 6 files changed, 76 insertions(+), 181 deletions(-) delete mode 100644 drivers/gpu/pvr/pdump_common.c diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 34259ad..db1f491 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -10,8 +10,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o pdump.o proc.o \ sgxinit.o sgxreset.o sgxutils.o sgxkick.o \ sgxtransfer.o mmu.o pb.o perproc.o sysconfig.o \ sysutils.o osperproc.o bridged_support.o \ - bridged_sgx_bridge.o sgxpower.o pdump_common.o \ - pvr_events.o + bridged_sgx_bridge.o sgxpower.o pvr_events.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debugfs.o diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 81e5309..6568cb6 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1159,7 +1159,7 @@ static int PDumpMemBW(u32 ui32BridgeID, if (psRetOUT->eError != PVRSRV_OK) return 0; - psRetOUT->eError = PDumpMemUM(psPerProc, psPDumpMemDumpIN->pvAltLinAddr, + psRetOUT->eError = PDumpMemUM(psPDumpMemDumpIN->pvAltLinAddr, psPDumpMemDumpIN->pvLinAddr, pvMemInfo, psPDumpMemDumpIN->ui32Offset, psPDumpMemDumpIN->ui32Bytes, @@ -1211,7 +1211,7 @@ static int PDumpSyncDumpBW(u32 ui32BridgeID, return 0; psRetOUT->eError = - PDumpMemUM(psPerProc, psPDumpSyncDumpIN->pvAltLinAddr, NULL, + PDumpMemUM(psPDumpSyncDumpIN->pvAltLinAddr, NULL, ((struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo)-> psSyncDataMemInfoKM, psPDumpSyncDumpIN->ui32Offset, ui32Bytes, 0, diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index 3a1aaec..7f61b30 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -1470,8 +1470,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, } PDUMPCOMMENTWITHFLAGS(0, "%s\r\n", pszName); - PDUMPMEMUM(psPerProc, - NULL, psBuffer->pvLinAddr, + PDUMPMEMUM(NULL, psBuffer->pvLinAddr, (struct PVRSRV_KERNEL_MEM_INFO *)psBuffer-> hKernelMemInfo, psBuffer->ui32Start, @@ -1490,8 +1489,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, MAKEUNIQUETAG(psCtrlMemInfoKM)); } PDUMPCOMMENTWITHFLAGS(0, "%s (part 1)\r\n", pszName); - PDUMPMEMUM(psPerProc, - NULL, psBuffer->pvLinAddr, + PDUMPMEMUM(NULL, psBuffer->pvLinAddr, (struct PVRSRV_KERNEL_MEM_INFO *)psBuffer-> hKernelMemInfo, psBuffer->ui32Start, @@ -1512,7 +1510,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, MAKEUNIQUETAG(psCtrlMemInfoKM)); } PDUMPCOMMENTWITHFLAGS(0, "%s (part 2)\r\n", pszName); - PDUMPMEMUM(psPerProc, NULL, psBuffer->pvLinAddr, + PDUMPMEMUM(NULL, psBuffer->pvLinAddr, (struct PVRSRV_KERNEL_MEM_INFO *)psBuffer-> hKernelMemInfo, 0, psBuffer->ui32End, 0, hUniqueTag); diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c index f87e10d..daf50a3 100644 --- a/drivers/gpu/pvr/pdump.c +++ b/drivers/gpu/pvr/pdump.c @@ -86,7 +86,7 @@ dbgdrv_frame_set(u32 frame) } static enum PVRSRV_ERROR -dbgdrv_write_data(void *buffer, int size) +dbgdrv_write_data(void *buffer, int size, bool from_user) { return PVRSRV_OK; } @@ -138,7 +138,7 @@ pdump_print(u32 flags, char *format, ...) } static enum PVRSRV_ERROR -pdump_dump(u32 flags, void *buffer, u32 size) +pdump_dump(u32 flags, void *buffer, u32 size, bool from_user) { if (PDumpSuspended()) return PVRSRV_OK; @@ -146,7 +146,7 @@ pdump_dump(u32 flags, void *buffer, u32 size) if (!dbgdrv_flags_check(flags)) return PVRSRV_OK; - return dbgdrv_write_data(buffer, size); + return dbgdrv_write_data(buffer, size, from_user); } void PDumpCommentKM(char *pszComment, u32 ui32Flags) @@ -448,31 +448,13 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, MEMPOLL_COUNT, MEMPOLL_DELAY); } -enum PVRSRV_ERROR -PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) +static void +pdump_mem_print(u32 ui32Flags, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, void *hUniqueTag) { struct IMG_DEV_VIRTADDR sDevVPageAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32PageOffset; - enum PVRSRV_ERROR eError; - - PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); - - if (ui32Bytes == 0) - return PVRSRV_ERROR_GENERIC; - - if (pvAltLinAddr) - eError = pdump_dump(ui32Flags, pvAltLinAddr, ui32Bytes); - else if (psMemInfo->pvLinAddrKM) - eError = pdump_dump(ui32Flags, - psMemInfo->pvLinAddrKM + ui32Offset, - ui32Bytes); - else - return PVRSRV_ERROR_GENERIC; - - if (eError != PVRSRV_OK) - return eError; PDumpCommentWithFlags(ui32Flags, "LDB :SGXMEM:VA_%8.8X:0x%8.8X " "0x%8.8X\r\n", @@ -499,6 +481,66 @@ PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, ui32Bytes -= ui32BlockBytes; ui32Offset += ui32BlockBytes; } +} + +enum PVRSRV_ERROR +PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) +{ + enum PVRSRV_ERROR eError; + + PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); + + if (!ui32Bytes) + return PVRSRV_ERROR_GENERIC; + + if (pvAltLinAddr) + eError = pdump_dump(ui32Flags, pvAltLinAddr, ui32Bytes, false); + else if (psMemInfo->pvLinAddrKM) + eError = pdump_dump(ui32Flags, + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes, false); + else + return PVRSRV_ERROR_GENERIC; + + if (eError != PVRSRV_OK) + return eError; + + pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, + hUniqueTag); + + return PVRSRV_OK; +} + +enum PVRSRV_ERROR +PDumpMemUM(void *pvAltLinAddrUM, void *pvLinAddrUM, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) +{ + enum PVRSRV_ERROR eError; + + PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); + + if (!ui32Bytes) + return PVRSRV_ERROR_GENERIC; + + if (pvAltLinAddrUM) + eError = pdump_dump(ui32Flags, pvAltLinAddrUM, ui32Bytes, true); + else if (psMemInfo->pvLinAddrKM) + eError = pdump_dump(ui32Flags, + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes, false); + else if (pvLinAddrUM) + eError = pdump_dump(ui32Flags, pvLinAddrUM + ui32Offset, + ui32Bytes, true); + else + return PVRSRV_ERROR_GENERIC; + + if (eError != PVRSRV_OK) + return eError; + + pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, + hUniqueTag); return PVRSRV_OK; } @@ -517,7 +559,7 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, if (bInitialisePages) { eError = pdump_dump(PDUMP_FLAGS_CONTINUOUS, pvLinAddr, - ui32Bytes); + ui32Bytes, false); if (eError != PVRSRV_OK) return eError; } diff --git a/drivers/gpu/pvr/pdump_common.c b/drivers/gpu/pvr/pdump_common.c deleted file mode 100644 index 14ce8f6..0000000 --- a/drivers/gpu/pvr/pdump_common.c +++ /dev/null @@ -1,141 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#if defined(PDUMP) -#include "services_headers.h" -#include "pdump_km.h" - -#if !defined(PDUMP_TEMP_BUFFER_SIZE) -#define PDUMP_TEMP_BUFFER_SIZE (64 * 1024L) -#endif - -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#define PTR_PLUS(t, p, x) ((t *)(((char *)(p)) + (x))) -#define VPTR_PLUS(p, x) PTR_PLUS(void, p, x) -#define VPTR_INC(p, x) (p = VPTR_PLUS(p, x)) - -static void *gpvTempBuffer; -static void *ghTempBufferBlockAlloc; - -static void *GetTempBuffer(void) -{ - if (gpvTempBuffer == NULL) { - enum PVRSRV_ERROR eError = OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - PDUMP_TEMP_BUFFER_SIZE, - &gpvTempBuffer, - &ghTempBufferBlockAlloc); - if (eError != PVRSRV_OK) - PVR_DPF(PVR_DBG_ERROR, - "GetTempBuffer: OSAllocMem failed: %d", - eError); - } - - return gpvTempBuffer; -} - -static void FreeTempBuffer(void) -{ - if (gpvTempBuffer != NULL) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, PDUMP_TEMP_BUFFER_SIZE, - gpvTempBuffer, ghTempBufferBlockAlloc); - gpvTempBuffer = NULL; - } -} - -void PDumpInitCommon(void) -{ - (void)GetTempBuffer(); - PDumpInit(); -} - -void PDumpDeInitCommon(void) -{ - FreeTempBuffer(); - PDumpDeInit(); -} - -enum PVRSRV_ERROR -PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psPerProc, - void *pvAltLinAddrUM, void *pvLinAddrUM, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, - void *hUniqueTag) -{ - void *pvAddrUM; - void *pvAddrKM; - u32 ui32BytesDumped; - u32 ui32CurrentOffset; - - if (psMemInfo->pvLinAddrKM != NULL && pvAltLinAddrUM == NULL) { - return PDumpMemKM(NULL, psMemInfo, ui32Offset, ui32Bytes, - ui32Flags, hUniqueTag); - } - - pvAddrUM = (pvAltLinAddrUM != NULL) ? pvAltLinAddrUM : - ((pvLinAddrUM != NULL) ? VPTR_PLUS(pvLinAddrUM, - ui32Offset) : NULL); - - pvAddrKM = GetTempBuffer(); - - PVR_ASSERT(pvAddrUM != NULL && pvAddrKM != NULL); - if (pvAddrUM == NULL || pvAddrKM == NULL) { - PVR_DPF(PVR_DBG_ERROR, "PDumpMemUM: Nothing to dump"); - return PVRSRV_ERROR_GENERIC; - } - - if (ui32Bytes > PDUMP_TEMP_BUFFER_SIZE) - PDumpCommentWithFlags(ui32Flags, - "Dumping 0x%8.8lx bytes of memory, in blocks of 0x%8.8lx bytes", - ui32Bytes, (u32) PDUMP_TEMP_BUFFER_SIZE); - - ui32CurrentOffset = ui32Offset; - for (ui32BytesDumped = 0; ui32BytesDumped < ui32Bytes;) { - enum PVRSRV_ERROR eError; - u32 ui32BytesToDump = - MIN(PDUMP_TEMP_BUFFER_SIZE, ui32Bytes - ui32BytesDumped); - - eError = OSCopyFromUser(psPerProc, - pvAddrKM, pvAddrUM, ui32BytesToDump); - if (eError != PVRSRV_OK) { - PVR_DPF(PVR_DBG_ERROR, - "PDumpMemUM: OSCopyFromUser failed (%d)", eError); - return eError; - } - - eError = PDumpMemKM(pvAddrKM, psMemInfo, ui32CurrentOffset, - ui32BytesToDump, ui32Flags, hUniqueTag); - if (eError != PVRSRV_OK) - return eError; - - VPTR_INC(pvAddrUM, ui32BytesToDump); - ui32CurrentOffset += ui32BytesToDump; - ui32BytesDumped += ui32BytesToDump; - } - - return PVRSRV_OK; -} - -#endif diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h index 91ca87f..f3d7146 100644 --- a/drivers/gpu/pvr/pdump_km.h +++ b/drivers/gpu/pvr/pdump_km.h @@ -49,8 +49,7 @@ void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag); -enum PVRSRV_ERROR PDumpMemUM(struct PVRSRV_PER_PROCESS_DATA *psProcData, - void *pvAltLinAddr, void *pvLinAddr, +enum PVRSRV_ERROR PDumpMemUM(void *pvAltLinAddr, void *pvLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag); @@ -66,8 +65,6 @@ enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32Flags, IMG_BOOL bInitialisePages, void *hUniqueTag1, void *hUniqueTag2); -void PDumpInitCommon(void); -void PDumpDeInitCommon(void); void PDumpInit(void); void PDumpDeInit(void); void PDumpSetFrameKM(u32 ui32Frame); @@ -141,8 +138,8 @@ void PDumpResumeKM(void); #define PDUMPMEM PDumpMemKM #define PDUMPMEM2 PDumpMem2KM #define PDUMPMEMUM PDumpMemUM -#define PDUMPINIT PDumpInitCommon -#define PDUMPDEINIT PDumpDeInitCommon +#define PDUMPINIT PDumpInit +#define PDUMPDEINIT PDumpDeInit #define PDUMPREGWITHFLAGS PDumpRegWithFlagsKM #define PDUMPREG PDumpReg #define PDUMPCOMMENT PDumpComment -- 1.7.5.4 From eaf26a9ebd366acd113c462d6739f7348c3369eb Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:41 +0100 Subject: [PATCH 43/95] gpu: pvr: pdump: move pdump.c and pdump_km.h to pvr_pdump.[ch] Also make pvr_pdump.c build fully conditional. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 3 +- drivers/gpu/pvr/bridged_pvr_bridge.c | 2 +- drivers/gpu/pvr/bridged_sgx_bridge.c | 2 +- drivers/gpu/pvr/buffer_manager.c | 2 +- drivers/gpu/pvr/devicemem.c | 2 +- drivers/gpu/pvr/mmu.c | 2 +- drivers/gpu/pvr/pb.c | 2 +- drivers/gpu/pvr/pdump.c | 766 ---------------------------------- drivers/gpu/pvr/pdump_km.h | 186 -------- drivers/gpu/pvr/power.c | 2 +- drivers/gpu/pvr/pvr_pdump.c | 763 +++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_pdump.h | 186 ++++++++ drivers/gpu/pvr/pvrsrv.c | 2 +- drivers/gpu/pvr/sgxinit.c | 2 +- drivers/gpu/pvr/sgxkick.c | 2 +- drivers/gpu/pvr/sgxpower.c | 2 +- drivers/gpu/pvr/sgxreset.c | 2 +- drivers/gpu/pvr/sgxtransfer.c | 2 +- drivers/gpu/pvr/sgxutils.c | 2 +- drivers/gpu/pvr/sysconfig.c | 2 +- 20 files changed, 966 insertions(+), 968 deletions(-) delete mode 100644 drivers/gpu/pvr/pdump.c delete mode 100644 drivers/gpu/pvr/pdump_km.h create mode 100644 drivers/gpu/pvr/pvr_pdump.c create mode 100644 drivers/gpu/pvr/pvr_pdump.h diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index db1f491..efb593b 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_PVR) += omaplfb.o pvrsrvkm.o omaplfb-objs := omaplfb_displayclass.o omaplfb_linux.o -pvrsrvkm-objs := osfunc.o mmap.o module.o pdump.o proc.o \ +pvrsrvkm-objs := osfunc.o mmap.o module.o proc.o \ pvr_bridge_k.o mm.o event.o \ buffer_manager.o devicemem.o deviceclass.o \ handle.o hash.o pvrsrv.o queue.o ra.o \ @@ -15,6 +15,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o pdump.o proc.o \ pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debugfs.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o +pvrsrvkm-objs-$(CONFIG_PVR_DEBUG_PDUMP) += pvr_pdump.o pvrsrvkm-objs += $(pvrsrvkm-objs-y) $(pvrsrvkm-objs-m) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 6568cb6..2ce50ce 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -37,7 +37,7 @@ #include "device.h" #include "buffer_manager.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "syscommon.h" #include "bridged_pvr_bridge.h" diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index 7f61b30..a6afdb7 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -41,7 +41,7 @@ #include "bridged_pvr_bridge.h" #include "bridged_sgx_bridge.h" #include "sgxutils.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "pvr_events.h" int SGXGetClientInfoBW(u32 ui32BridgeID, diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index 87e60cf..535f3ae 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -28,7 +28,7 @@ #include "sysconfig.h" #include "hash.h" #include "ra.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "mmu.h" #define MIN(a, b) (a > b ? b : a) diff --git a/drivers/gpu/pvr/devicemem.c b/drivers/gpu/pvr/devicemem.c index 3912f2b..881cf24 100644 --- a/drivers/gpu/pvr/devicemem.c +++ b/drivers/gpu/pvr/devicemem.c @@ -28,7 +28,7 @@ #include "services_headers.h" #include "buffer_manager.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "pvr_bridge_km.h" #include <linux/pagemap.h> diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index af3bcfa..2311626 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -30,7 +30,7 @@ #include "buffer_manager.h" #include "hash.h" #include "ra.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "sgxapi_km.h" #include "sgx_bridge_km.h" #include "sgxinfo.h" diff --git a/drivers/gpu/pvr/pb.c b/drivers/gpu/pvr/pb.c index ffd8f69..5088a8c 100644 --- a/drivers/gpu/pvr/pb.c +++ b/drivers/gpu/pvr/pb.c @@ -32,7 +32,7 @@ #include "sgxinfokm.h" #include "pvr_bridge_km.h" #include "sgx_bridge_km.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "sgxutils.h" static struct RESMAN_ITEM *psResItemCreateSharedPB; diff --git a/drivers/gpu/pvr/pdump.c b/drivers/gpu/pvr/pdump.c deleted file mode 100644 index daf50a3..0000000 --- a/drivers/gpu/pvr/pdump.c +++ /dev/null @@ -1,766 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#if defined(PDUMP) -#include <asm/atomic.h> -#include <stdarg.h> - -#include "sgxdefs.h" -#include "services_headers.h" -#include "pvrversion.h" -#include "sgxmmu.h" -#include "mm.h" -#include "pdump_km.h" - -/* - * There is no sense in having SGX_MMU_PAGE_SIZE differ from PAGE_SIZE. - * Especially the calculations in this file, while obviously an attempt to work - * around possibly differing host and gpu page sizes, are impossible when - * page size is not the same everywhere. - */ -#if PAGE_SIZE != SGX_MMU_PAGE_SIZE -#error Host page size differs from GPU page size! -#endif - -static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); - -#define SZ_COMMENT_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE -#define SZ_SCRIPT_SIZE_MAX (SZ_COMMENT_SIZE_MAX + 5) -#define SZ_FILENAME_SIZE_MAX SZ_COMMENT_SIZE_MAX -static char *gpszComment; -static char *gpszScript; -static char *gpszFile; - -#define DEBUG_MODE_DISABLED 0 -#define DEBUG_MODE_STANDARD 1 -#define DEBUG_MODE_FULL 2 - -static u32 dbgdrv_mode = DEBUG_MODE_DISABLED; -static u32 dbgdrv_frame_number; - -void PDumpSuspendKM(void) -{ - atomic_inc(&gsPDumpSuspended); -} - -void PDumpResumeKM(void) -{ - atomic_dec(&gsPDumpSuspended); -} - -static inline IMG_BOOL PDumpSuspended(void) -{ - return atomic_read(&gsPDumpSuspended) != 0; -} - -/* - * empty pdump backend. - */ -static void -dbgdrv_frame_set(u32 frame) -{ - dbgdrv_frame_number = frame; -} - -static enum PVRSRV_ERROR -dbgdrv_write_data(void *buffer, int size, bool from_user) -{ - return PVRSRV_OK; -} - -static void -dbgdrv_write_string(char *string) -{ - -} - -static bool -dbgdrv_capturing(void) -{ - if (dbgdrv_mode == DEBUG_MODE_FULL) - return true; - else - return false; -} - -static bool dbgdrv_flags_check(u32 flags) -{ - if (flags & PDUMP_FLAGS_NEVER) - return false; - else if (dbgdrv_mode == DEBUG_MODE_FULL) - return true; - else if ((dbgdrv_mode == DEBUG_MODE_STANDARD) && - (flags & PDUMP_FLAGS_CONTINUOUS)) - return true; - else - return false; -} - -static void -pdump_print(u32 flags, char *format, ...) -{ - va_list ap; - - if (PDumpSuspended()) - return; - - if (!dbgdrv_flags_check(flags)) - return; - - va_start(ap, format); - vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, format, ap); - va_end(ap); - - dbgdrv_write_string(gpszScript); -} - -static enum PVRSRV_ERROR -pdump_dump(u32 flags, void *buffer, u32 size, bool from_user) -{ - if (PDumpSuspended()) - return PVRSRV_OK; - - if (!dbgdrv_flags_check(flags)) - return PVRSRV_OK; - - return dbgdrv_write_data(buffer, size, from_user); -} - -void PDumpCommentKM(char *pszComment, u32 ui32Flags) -{ - int len = strlen(pszComment); - - if ((len > 1) && (pszComment[len - 1] == '\n')) - pszComment[len - 1] = 0; - - if ((len > 2) && (pszComment[len - 2] == '\r')) - pszComment[len - 2] = 0; - - pdump_print(ui32Flags, "-- %s\r\n", pszComment); -} - -void PDumpComment(char *pszFormat, ...) -{ - va_list ap; - - va_start(ap, pszFormat); - vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); - va_end(ap); - - PDumpCommentKM(gpszComment, PDUMP_FLAGS_CONTINUOUS); -} - -void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) -{ - va_list ap; - - va_start(ap, pszFormat); - vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); - va_end(ap); - - PDumpCommentKM(gpszComment, ui32Flags); -} - -void PDumpSetFrameKM(u32 ui32Frame) -{ - if (PDumpSuspended()) - return; - - dbgdrv_frame_set(ui32Frame); -} - -IMG_BOOL PDumpIsCaptureFrameKM(void) -{ - if (PDumpSuspended()) - return IMG_FALSE; - - return dbgdrv_capturing(); -} - -void PDumpInit(void) -{ - if (!gpszFile) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_FILENAME_SIZE_MAX, - (void **)&gpszFile, - NULL) != PVRSRV_OK) - goto init_failed; - - if (!gpszComment) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_COMMENT_SIZE_MAX, - (void **)&gpszComment, - NULL) != PVRSRV_OK) - goto init_failed; - - if (!gpszScript) - if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, - SZ_SCRIPT_SIZE_MAX, - (void **)&gpszScript, - NULL) != PVRSRV_OK) - goto init_failed; - - PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME); - PDumpComment("Driver Product Version: %s (%s)", - PVRVERSION_STRING, PVRVERSION_FILE); - PDumpComment("Start of Init Phase"); - - return; - - init_failed: - - if (gpszFile) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, - (void *)gpszFile, NULL); - gpszFile = NULL; - } - - if (gpszScript) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, - (void *)gpszScript, NULL); - gpszScript = NULL; - } - - if (gpszComment) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, - (void *)gpszComment, NULL); - gpszComment = NULL; - } -} - -void PDumpDeInit(void) -{ - if (gpszFile) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, - (void *)gpszFile, NULL); - gpszFile = NULL; - } - - if (gpszScript) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, - (void *)gpszScript, NULL); - gpszScript = NULL; - } - - if (gpszComment) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, - (void *)gpszComment, NULL); - gpszComment = NULL; - } -} - -void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) -{ - pdump_print(ui32Flags, - "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); -} - -void PDumpReg(u32 ui32Reg, u32 ui32Data) -{ - PDumpRegWithFlagsKM(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS); -} - -void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask, u32 ui32Flags) -{ -#define POLL_DELAY 1000 -#define POLL_COUNT_LONG (2000000000 / POLL_DELAY) -#define POLL_COUNT_SHORT (1000000 / POLL_DELAY) - - u32 ui32PollCount; - - if ((ui32RegAddr == EUR_CR_EVENT_STATUS) && - ((ui32RegValue & ui32Mask) & - (EUR_CR_EVENT_STATUS_TA_FINISHED_MASK | - EUR_CR_EVENT_STATUS_PIXELBE_END_RENDER_MASK | - EUR_CR_EVENT_STATUS_DPM_3D_MEM_FREE_MASK))) - ui32PollCount = POLL_COUNT_LONG; - else - ui32PollCount = POLL_COUNT_SHORT; - - pdump_print(ui32Flags, - "POL :SGXREG:0x%8.8X 0x%8.8X 0x%8.8X %d %u %d\r\n", - ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, - POLL_DELAY); -} - -void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) -{ - PDumpRegPolWithFlagsKM(ui32RegAddr, ui32RegValue, ui32Mask, - PDUMP_FLAGS_CONTINUOUS); -} - -void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, - void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, - void *hUniqueTag) -{ - struct IMG_CPU_PHYADDR sCpuPAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32Offset; - - PVR_UNREFERENCED_PARAMETER(pvLinAddr); - - PVR_ASSERT(((u32) ui32DevVAddr & ~PAGE_MASK) == 0); - PVR_ASSERT(hOSMemHandle); - PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); - - PDumpComment("MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", - ui32DevVAddr, ui32NumBytes, PAGE_SIZE); - - for (ui32Offset = 0; ui32Offset < ui32NumBytes; - ui32Offset += PAGE_SIZE) { - sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr, PAGE_SIZE, - PAGE_SIZE, sDevPAddr.uiAddr); - } -} - -void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag) -{ - struct IMG_CPU_PHYADDR sCpuPAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - - PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); - - PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", - PAGE_SIZE, PAGE_SIZE); - - sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8lX " - "0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr, PAGE_SIZE, - PAGE_SIZE, sDevPAddr.uiAddr); -} - -void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, - u32 ui32NumBytes, void *hUniqueTag, IMG_BOOL bInterleaved) -{ - struct IMG_DEV_PHYADDR sDevPAddr; - struct PVRSRV_DEVICE_NODE *psDeviceNode = - psBMHeap->pBMContext->psDeviceNode; - int i; - - PVR_ASSERT(((u32) sDevVAddr.uiAddr & ~PAGE_MASK) == 0); - PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); - - PDumpComment("FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); - - for (i = 0; (i * PAGE_SIZE) < ui32NumBytes; i++) { - if (!bInterleaved || (i % 2) == 0) { - sDevPAddr = - psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap-> - pMMUHeap, - sDevVAddr); - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr); - } - - sDevVAddr.uiAddr += PAGE_SIZE; - } -} - -void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag) -{ - struct IMG_CPU_PHYADDR sCpuPAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - - PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); - - PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); - - sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr); -} - -void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, - void *hUniqueTag) -{ - pdump_print(ui32Flags, - "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - ui32Reg, (u32)hUniqueTag, - ui32Data & PAGE_MASK, - ui32Data & ~PAGE_MASK); -} - -void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) -{ - PDumpPDRegWithFlags(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS, - hUniqueTag); -} - -void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Value, u32 ui32Mask, - enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag) -{ -#define MEMPOLL_DELAY (1000) -#define MEMPOLL_COUNT (2000000000 / MEMPOLL_DELAY) - - struct IMG_DEV_PHYADDR sDevPAddr; - struct IMG_DEV_VIRTADDR sDevVPageAddr; - u32 ui32PageOffset; - - PVR_ASSERT((ui32Offset + sizeof(u32)) <= - psMemInfo->ui32AllocSize); - - sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; - ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; - BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - - pdump_print(0, "POL :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " - "0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, - sDevPAddr.uiAddr, ui32PageOffset, - ui32Value, ui32Mask, eOperator, - MEMPOLL_COUNT, MEMPOLL_DELAY); -} - -static void -pdump_mem_print(u32 ui32Flags, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, void *hUniqueTag) -{ - struct IMG_DEV_VIRTADDR sDevVPageAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32PageOffset; - - PDumpCommentWithFlags(ui32Flags, "LDB :SGXMEM:VA_%8.8X:0x%8.8X " - "0x%8.8X\r\n", - psMemInfo->sDevVAddr.uiAddr, ui32Offset, - ui32Bytes); - - ui32PageOffset = - (psMemInfo->sDevVAddr.uiAddr + ui32Offset) & ~PAGE_MASK; - - while (ui32Bytes) { - u32 ui32BlockBytes = - min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); - - sDevVPageAddr.uiAddr = - psMemInfo->sDevVAddr.uiAddr + ui32Offset; - BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - - pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" - " 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr, ui32PageOffset, - ui32BlockBytes); - - ui32PageOffset = 0; - ui32Bytes -= ui32BlockBytes; - ui32Offset += ui32BlockBytes; - } -} - -enum PVRSRV_ERROR -PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) -{ - enum PVRSRV_ERROR eError; - - PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); - - if (!ui32Bytes) - return PVRSRV_ERROR_GENERIC; - - if (pvAltLinAddr) - eError = pdump_dump(ui32Flags, pvAltLinAddr, ui32Bytes, false); - else if (psMemInfo->pvLinAddrKM) - eError = pdump_dump(ui32Flags, - psMemInfo->pvLinAddrKM + ui32Offset, - ui32Bytes, false); - else - return PVRSRV_ERROR_GENERIC; - - if (eError != PVRSRV_OK) - return eError; - - pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, - hUniqueTag); - - return PVRSRV_OK; -} - -enum PVRSRV_ERROR -PDumpMemUM(void *pvAltLinAddrUM, void *pvLinAddrUM, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) -{ - enum PVRSRV_ERROR eError; - - PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); - - if (!ui32Bytes) - return PVRSRV_ERROR_GENERIC; - - if (pvAltLinAddrUM) - eError = pdump_dump(ui32Flags, pvAltLinAddrUM, ui32Bytes, true); - else if (psMemInfo->pvLinAddrKM) - eError = pdump_dump(ui32Flags, - psMemInfo->pvLinAddrKM + ui32Offset, - ui32Bytes, false); - else if (pvLinAddrUM) - eError = pdump_dump(ui32Flags, pvLinAddrUM + ui32Offset, - ui32Bytes, true); - else - return PVRSRV_ERROR_GENERIC; - - if (eError != PVRSRV_OK) - return eError; - - pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, - hUniqueTag); - - return PVRSRV_OK; -} - -enum PVRSRV_ERROR -PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, - u32 ui32Bytes, u32 ui32Flags, IMG_BOOL bInitialisePages, - void *hUniqueTag1, void *hUniqueTag2) -{ - struct IMG_DEV_PHYADDR sDevPAddr; - struct IMG_CPU_PHYADDR sCpuPAddr; - enum PVRSRV_ERROR eError; - - if (!pvLinAddr) - return PVRSRV_ERROR_GENERIC; - - if (bInitialisePages) { - eError = pdump_dump(PDUMP_FLAGS_CONTINUOUS, pvLinAddr, - ui32Bytes, false); - if (eError != PVRSRV_OK) - return eError; - } - - while (ui32Bytes) { - u32 ui32BlockBytes = - min(ui32Bytes, - (u32)(PAGE_SIZE - ((u32)pvLinAddr & ~PAGE_MASK))); - - sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); - - if (bInitialisePages) { - pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" - "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", - (u32) hUniqueTag1, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, - ui32BlockBytes); - } else { - u32 ui32Offset; - - for (ui32Offset = 0; ui32Offset < ui32BlockBytes; - ui32Offset += sizeof(u32)) { - u32 ui32PTE = - *((u32 *)(pvLinAddr + ui32Offset)); - - if ((ui32PTE & ~PAGE_MASK) != 0) { - pdump_print(PDUMP_FLAGS_CONTINUOUS, -"WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - (u32)hUniqueTag1, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, - (u32)hUniqueTag2, - ui32PTE & PAGE_MASK, - ui32PTE & ~PAGE_MASK); - } else { - PVR_ASSERT(! - (ui32PTE & - SGX_MMU_PTE_VALID)); - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X%8.8X\r\n", - (u32) hUniqueTag1, - sDevPAddr.uiAddr & PAGE_MASK, - sDevPAddr.uiAddr & ~PAGE_MASK, - ui32PTE, (u32)hUniqueTag2); - } - - sDevPAddr.uiAddr += sizeof(u32); - } - } - - ui32Bytes -= ui32BlockBytes; - pvLinAddr += ui32BlockBytes; - } - - return PVRSRV_OK; -} - -void -PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, - void *hUniqueTag1, void *hUniqueTag2) -{ - struct IMG_DEV_VIRTADDR sDevVPageAddr; - struct IMG_DEV_PHYADDR sDevPAddr; - u32 ui32PageOffset; - - sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; - ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; - BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); - - if ((sPDDevPAddr.uiAddr & PAGE_MASK) != 0) { - pdump_print(PDUMP_FLAGS_CONTINUOUS, -"WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - (u32) hUniqueTag1, - sDevPAddr.uiAddr, ui32PageOffset, - (u32)hUniqueTag2, - sPDDevPAddr.uiAddr & PAGE_MASK, - sPDDevPAddr.uiAddr & ~PAGE_MASK); - } else { - PVR_ASSERT(!(sDevPAddr.uiAddr & SGX_MMU_PTE_VALID)); - pdump_print(PDUMP_FLAGS_CONTINUOUS, - "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", - (u32)hUniqueTag1, - sDevPAddr.uiAddr, ui32PageOffset, - sPDDevPAddr.uiAddr); - } -} - -void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, - struct IMG_DEV_VIRTADDR sDevBaseAddr, - u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, - enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) -{ - PDumpCommentWithFlags(ui32PDumpFlags, "Dump bitmap of render\r\n"); - - pdump_print(ui32PDumpFlags, - "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " - "0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", - pszFileName, pszFileName, sDevBaseAddr.uiAddr, ui32Size, - ui32FileOffset, ePixelFormat, ui32Width, ui32Height, - ui32StrideInBytes, eMemFormat); -} - -static void -PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address) -{ - pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", - ui32Address, ui32FileOffset, pszFileName); -} - -void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, - u32 *pui32Registers, u32 ui32NumRegisters) -{ - u32 i; - - PDumpCommentWithFlags(0, "Dump 3D signature registers\r\n"); - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", - ui32DumpFrameNum); - - for (i = 0; i < ui32NumRegisters; i++) - PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); -} - -void PDumpCounterRegisters(u32 ui32DumpFrameNum, - u32 *pui32Registers, u32 ui32NumRegisters) -{ - u32 i; - - PDumpCommentWithFlags(0, "Dump counter registers\r\n"); - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", - ui32DumpFrameNum); - - for (i = 0; i < ui32NumRegisters; i++) - PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); -} - -void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, - u32 *pui32Registers, u32 ui32NumRegisters) -{ - u32 i, ui32FileOffset; - - PDumpCommentWithFlags(0, "Dump TA signature registers\r\n"); - snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", - ui32DumpFrameNum); - - ui32FileOffset = ui32TAKickCount * ui32NumRegisters * sizeof(u32); - - for (i = 0; i < ui32NumRegisters; i++) - PDumpReadRegKM(gpszFile, ui32FileOffset + i * sizeof(u32), - pui32Registers[i]); -} - -void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) -{ - pdump_print(ui32Flags, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); -} - -void PDumpCycleCountRegRead(const u32 ui32RegOffset) -{ - PDumpRegRead(ui32RegOffset, 0); -} - -void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, - struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, - u32 ui32PDumpFlags) -{ - PDumpCommentWithFlags(ui32PDumpFlags, - "Dump Hardware Performance Circular Buffer\r\n"); - pdump_print(ui32PDumpFlags, - "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", - sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); -} - -void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, - u32 ui32ROffOffset, u32 ui32WPosVal, u32 ui32PacketSize, - u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag) -{ - struct IMG_DEV_PHYADDR sDevPAddr; - struct IMG_DEV_VIRTADDR sDevVPageAddr; - u32 ui32PageOffset; - - PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= - psROffMemInfo->ui32AllocSize); - - sDevVPageAddr.uiAddr = - psROffMemInfo->sDevVAddr.uiAddr + ui32ROffOffset; - ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; - BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); - - pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" - " 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, - sDevPAddr.uiAddr, ui32PageOffset, - ui32WPosVal, ui32PacketSize, ui32BufferSize); -} - -void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) -{ - pdump_print(ui32Flags, "IDL %u\r\n", ui32Clocks); -} - -#endif diff --git a/drivers/gpu/pvr/pdump_km.h b/drivers/gpu/pvr/pdump_km.h deleted file mode 100644 index f3d7146..0000000 --- a/drivers/gpu/pvr/pdump_km.h +++ /dev/null @@ -1,186 +0,0 @@ -/********************************************************************** - * - * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful but, except - * as otherwise stated in writing, without any warranty; without even the - * implied warranty of merchantability or fitness for a particular purpose. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * - * The full GNU General Public License is included in this distribution in - * the file called "COPYING". - * - * Contact Information: - * Imagination Technologies Ltd. <gpl-support@imgtec.com> - * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK - * - ******************************************************************************/ - -#ifndef _PDUMP_KM_H_ -#define _PDUMP_KM_H_ - - -#define PDUMP_FLAGS_NEVER 0x08000000 -#define PDUMP_FLAGS_TOOUT2MEM 0x10000000 -#define PDUMP_FLAGS_LASTFRAME 0x20000000 -#define PDUMP_FLAGS_RESETLFBUFFER 0x40000000 -#define PDUMP_FLAGS_CONTINUOUS 0x80000000 - -#define PDUMP_PD_UNIQUETAG ((void *)0) -#define PDUMP_PT_UNIQUETAG ((void *)0) - -#ifdef PDUMP - -#define MAKEUNIQUETAG(hMemInfo) \ - (((struct BM_BUF *)(((struct PVRSRV_KERNEL_MEM_INFO *) \ - hMemInfo)->sMemBlk.hBuffer))->pMapping) - -void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO - *psMemInfo, u32 ui32Offset, - u32 ui32Value, u32 ui32Mask, - enum PDUMP_POLL_OPERATOR eOperator, - void *hUniqueTag); - -enum PVRSRV_ERROR PDumpMemUM(void *pvAltLinAddr, void *pvLinAddr, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, - void *hUniqueTag); - -enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, - struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, u32 ui32Bytes, - u32 ui32Flags, void *hUniqueTag); - -enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, - u32 ui32Bytes, - u32 ui32Flags, - IMG_BOOL bInitialisePages, - void *hUniqueTag1, void *hUniqueTag2); -void PDumpInit(void); -void PDumpDeInit(void); -void PDumpSetFrameKM(u32 ui32Frame); -void PDumpCommentKM(char *pszComment, u32 ui32Flags); -void PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Flags); - -void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, - u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, - struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, - enum PDUMP_PIXEL_FORMAT ePixelFormat, - enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags); -void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, - struct IMG_DEV_VIRTADDR sDevBaseAddr, - u32 ui32Size, u32 ui32PDumpFlags); -void PDumpReg(u32 dwReg, u32 dwData); - -void PDumpComment(char *pszFormat, ...); - -void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...); -void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask); -void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, - u32 ui32Mask, u32 ui32Flags); - -IMG_BOOL PDumpIsCaptureFrameKM(void); - -void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, - u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, - u32 ui32NumBytes, void *hUniqueTag); -void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag); -void PDumpFreePages(struct BM_HEAP *psBMHeap, - struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, - void *hUniqueTag, IMG_BOOL bInterleaved); -void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag); -void PDumpPDReg(u32 ui32Reg, u32 ui32dwData, void *hUniqueTag); -void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, - void *hUniqueTag); - -void PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, - u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, - void *hUniqueTag1, void *hUniqueTag2); - -void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, - u32 *pui32Registers, u32 ui32NumRegisters); - -void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, - u32 *pui32Registers, u32 ui32NumRegisters); - -void PDumpRegRead(const u32 dwRegOffset, u32 ui32Flags); - -void PDumpCycleCountRegRead(const u32 dwRegOffset); - -void PDumpCounterRegisters(u32 ui32DumpFrameNum, - u32 *pui32Registers, u32 ui32NumRegisters); - -void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, - u32 ui32ROffOffset, - u32 ui32WPosVal, - u32 ui32PacketSize, - u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag); - -void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags); - -void PDumpSuspendKM(void); -void PDumpResumeKM(void); - -#define PDUMPMEMPOL PDumpMemPolKM -#define PDUMPMEM PDumpMemKM -#define PDUMPMEM2 PDumpMem2KM -#define PDUMPMEMUM PDumpMemUM -#define PDUMPINIT PDumpInit -#define PDUMPDEINIT PDumpDeInit -#define PDUMPREGWITHFLAGS PDumpRegWithFlagsKM -#define PDUMPREG PDumpReg -#define PDUMPCOMMENT PDumpComment -#define PDUMPCOMMENTWITHFLAGS PDumpCommentWithFlags -#define PDUMPREGPOL PDumpRegPolKM -#define PDUMPREGPOLWITHFLAGS PDumpRegPolWithFlagsKM -#define PDUMPMALLOCPAGES PDumpMallocPages -#define PDUMPMALLOCPAGETABLE PDumpMallocPageTable -#define PDUMPFREEPAGES PDumpFreePages -#define PDUMPFREEPAGETABLE PDumpFreePageTable -#define PDUMPPDREGWITHFLAGS PDumpPDRegWithFlags -#define PDUMPCBP PDumpCBP -#define PDUMPIDLWITHFLAGS PDumpIDLWithFlags -#define PDUMPSUSPEND PDumpSuspendKM -#define PDUMPRESUME PDumpResumeKM - -#else - -#define MAKEUNIQUETAG(hMemInfo) (0) - -#define PDUMPMEMPOL(args...) -#define PDUMPMEM(args...) -#define PDUMPMEM2(args...) -#define PDUMPMEMUM(args...) -#define PDUMPINIT(args...) -#define PDUMPDEINIT(args...) -#define PDUMPREGWITHFLAGS(args...) -#define PDUMPREG(args...) -#define PDUMPCOMMENT(args...) -#define PDUMPCOMMENTWITHFLAGS(args...) -#define PDUMPREGPOL(args...) -#define PDUMPREGPOLWITHFLAGS(args...) -#define PDUMPMALLOCPAGES(args...) -#define PDUMPMALLOCPAGETABLE(args...) -#define PDUMPFREEPAGES(args...) -#define PDUMPFREEPAGETABLE(args...) -#define PDUMPPDREGWITHFLAGS(args...) -#define PDUMPCBP(args...) -#define PDUMPIDLWITHFLAGS(args...) -#define PDUMPSUSPEND(args...) -#define PDUMPRESUME(args...) -#endif - -#endif diff --git a/drivers/gpu/pvr/power.c b/drivers/gpu/pvr/power.c index a33e0de..3d6d087 100644 --- a/drivers/gpu/pvr/power.c +++ b/drivers/gpu/pvr/power.c @@ -24,7 +24,7 @@ * ******************************************************************************/ #include "services_headers.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include <linux/kernel.h> #include <linux/mutex.h> #include <linux/sched.h> diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c new file mode 100644 index 0000000..4bf8cd4 --- /dev/null +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -0,0 +1,763 @@ +/* + * + * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful but, except + * as otherwise stated in writing, without any warranty; without even the + * implied warranty of merchantability or fitness for a particular purpose. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + * + * Contact Information: + * Imagination Technologies Ltd. <gpl-support@imgtec.com> + * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK + * + */ + +#include <asm/atomic.h> +#include <stdarg.h> + +#include "sgxdefs.h" +#include "services_headers.h" +#include "pvrversion.h" +#include "sgxmmu.h" +#include "mm.h" +#include "pvr_pdump.h" + +/* + * There is no sense in having SGX_MMU_PAGE_SIZE differ from PAGE_SIZE. + * Especially the calculations in this file, while obviously an attempt to work + * around possibly differing host and gpu page sizes, are impossible when + * page size is not the same everywhere. + */ +#if PAGE_SIZE != SGX_MMU_PAGE_SIZE +#error Host page size differs from GPU page size! +#endif + +static atomic_t gsPDumpSuspended = ATOMIC_INIT(0); + +#define SZ_COMMENT_SIZE_MAX PVRSRV_PDUMP_MAX_COMMENT_SIZE +#define SZ_SCRIPT_SIZE_MAX (SZ_COMMENT_SIZE_MAX + 5) +#define SZ_FILENAME_SIZE_MAX SZ_COMMENT_SIZE_MAX +static char *gpszComment; +static char *gpszScript; +static char *gpszFile; + +#define DEBUG_MODE_DISABLED 0 +#define DEBUG_MODE_STANDARD 1 +#define DEBUG_MODE_FULL 2 + +static u32 dbgdrv_mode = DEBUG_MODE_DISABLED; +static u32 dbgdrv_frame_number; + +void PDumpSuspendKM(void) +{ + atomic_inc(&gsPDumpSuspended); +} + +void PDumpResumeKM(void) +{ + atomic_dec(&gsPDumpSuspended); +} + +static inline IMG_BOOL PDumpSuspended(void) +{ + return atomic_read(&gsPDumpSuspended) != 0; +} + +/* + * empty pdump backend. + */ +static void +dbgdrv_frame_set(u32 frame) +{ + dbgdrv_frame_number = frame; +} + +static enum PVRSRV_ERROR +dbgdrv_write_data(void *buffer, int size, bool from_user) +{ + return PVRSRV_OK; +} + +static void +dbgdrv_write_string(char *string) +{ + +} + +static bool +dbgdrv_capturing(void) +{ + if (dbgdrv_mode == DEBUG_MODE_FULL) + return true; + else + return false; +} + +static bool dbgdrv_flags_check(u32 flags) +{ + if (flags & PDUMP_FLAGS_NEVER) + return false; + else if (dbgdrv_mode == DEBUG_MODE_FULL) + return true; + else if ((dbgdrv_mode == DEBUG_MODE_STANDARD) && + (flags & PDUMP_FLAGS_CONTINUOUS)) + return true; + else + return false; +} + +static void +pdump_print(u32 flags, char *format, ...) +{ + va_list ap; + + if (PDumpSuspended()) + return; + + if (!dbgdrv_flags_check(flags)) + return; + + va_start(ap, format); + vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, format, ap); + va_end(ap); + + dbgdrv_write_string(gpszScript); +} + +static enum PVRSRV_ERROR +pdump_dump(u32 flags, void *buffer, u32 size, bool from_user) +{ + if (PDumpSuspended()) + return PVRSRV_OK; + + if (!dbgdrv_flags_check(flags)) + return PVRSRV_OK; + + return dbgdrv_write_data(buffer, size, from_user); +} + +void PDumpCommentKM(char *pszComment, u32 ui32Flags) +{ + int len = strlen(pszComment); + + if ((len > 1) && (pszComment[len - 1] == '\n')) + pszComment[len - 1] = 0; + + if ((len > 2) && (pszComment[len - 2] == '\r')) + pszComment[len - 2] = 0; + + pdump_print(ui32Flags, "-- %s\r\n", pszComment); +} + +void PDumpComment(char *pszFormat, ...) +{ + va_list ap; + + va_start(ap, pszFormat); + vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); + va_end(ap); + + PDumpCommentKM(gpszComment, PDUMP_FLAGS_CONTINUOUS); +} + +void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) +{ + va_list ap; + + va_start(ap, pszFormat); + vsnprintf(gpszComment, SZ_COMMENT_SIZE_MAX, pszFormat, ap); + va_end(ap); + + PDumpCommentKM(gpszComment, ui32Flags); +} + +void PDumpSetFrameKM(u32 ui32Frame) +{ + if (PDumpSuspended()) + return; + + dbgdrv_frame_set(ui32Frame); +} + +IMG_BOOL PDumpIsCaptureFrameKM(void) +{ + if (PDumpSuspended()) + return IMG_FALSE; + + return dbgdrv_capturing(); +} + +void PDumpInit(void) +{ + if (!gpszFile) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_FILENAME_SIZE_MAX, + (void **)&gpszFile, + NULL) != PVRSRV_OK) + goto init_failed; + + if (!gpszComment) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_COMMENT_SIZE_MAX, + (void **)&gpszComment, + NULL) != PVRSRV_OK) + goto init_failed; + + if (!gpszScript) + if (OSAllocMem(PVRSRV_OS_PAGEABLE_HEAP, + SZ_SCRIPT_SIZE_MAX, + (void **)&gpszScript, + NULL) != PVRSRV_OK) + goto init_failed; + + PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME); + PDumpComment("Driver Product Version: %s (%s)", + PVRVERSION_STRING, PVRVERSION_FILE); + PDumpComment("Start of Init Phase"); + + return; + + init_failed: + + if (gpszFile) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, + (void *)gpszFile, NULL); + gpszFile = NULL; + } + + if (gpszScript) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, + (void *)gpszScript, NULL); + gpszScript = NULL; + } + + if (gpszComment) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, + (void *)gpszComment, NULL); + gpszComment = NULL; + } +} + +void PDumpDeInit(void) +{ + if (gpszFile) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, + (void *)gpszFile, NULL); + gpszFile = NULL; + } + + if (gpszScript) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_SCRIPT_SIZE_MAX, + (void *)gpszScript, NULL); + gpszScript = NULL; + } + + if (gpszComment) { + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_COMMENT_SIZE_MAX, + (void *)gpszComment, NULL); + gpszComment = NULL; + } +} + +void PDumpRegWithFlagsKM(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) +{ + pdump_print(ui32Flags, + "WRW :SGXREG:0x%8.8X 0x%8.8X\r\n", ui32Reg, ui32Data); +} + +void PDumpReg(u32 ui32Reg, u32 ui32Data) +{ + PDumpRegWithFlagsKM(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS); +} + +void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask, u32 ui32Flags) +{ +#define POLL_DELAY 1000 +#define POLL_COUNT_LONG (2000000000 / POLL_DELAY) +#define POLL_COUNT_SHORT (1000000 / POLL_DELAY) + + u32 ui32PollCount; + + if ((ui32RegAddr == EUR_CR_EVENT_STATUS) && + ((ui32RegValue & ui32Mask) & + (EUR_CR_EVENT_STATUS_TA_FINISHED_MASK | + EUR_CR_EVENT_STATUS_PIXELBE_END_RENDER_MASK | + EUR_CR_EVENT_STATUS_DPM_3D_MEM_FREE_MASK))) + ui32PollCount = POLL_COUNT_LONG; + else + ui32PollCount = POLL_COUNT_SHORT; + + pdump_print(ui32Flags, + "POL :SGXREG:0x%8.8X 0x%8.8X 0x%8.8X %d %u %d\r\n", + ui32RegAddr, ui32RegValue, ui32Mask, 0, ui32PollCount, + POLL_DELAY); +} + +void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) +{ + PDumpRegPolWithFlagsKM(ui32RegAddr, ui32RegValue, ui32Mask, + PDUMP_FLAGS_CONTINUOUS); +} + +void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, + void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, + void *hUniqueTag) +{ + struct IMG_CPU_PHYADDR sCpuPAddr; + struct IMG_DEV_PHYADDR sDevPAddr; + u32 ui32Offset; + + PVR_UNREFERENCED_PARAMETER(pvLinAddr); + + PVR_ASSERT(((u32) ui32DevVAddr & ~PAGE_MASK) == 0); + PVR_ASSERT(hOSMemHandle); + PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); + + PDumpComment("MALLOC :SGXMEM:VA_%8.8X 0x%8.8X %u\r\n", + ui32DevVAddr, ui32NumBytes, PAGE_SIZE); + + for (ui32Offset = 0; ui32Offset < ui32NumBytes; + ui32Offset += PAGE_SIZE) { + sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", + (u32)hUniqueTag, sDevPAddr.uiAddr, PAGE_SIZE, + PAGE_SIZE, sDevPAddr.uiAddr); + } +} + +void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, + void *pvLinAddr, void *hUniqueTag) +{ + struct IMG_CPU_PHYADDR sCpuPAddr; + struct IMG_DEV_PHYADDR sDevPAddr; + + PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); + + PDumpComment("MALLOC :SGXMEM:PAGE_TABLE 0x%8.8X %lu\r\n", + PAGE_SIZE, PAGE_SIZE); + + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + + pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8lX " + "0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, + sDevPAddr.uiAddr, PAGE_SIZE, + PAGE_SIZE, sDevPAddr.uiAddr); +} + +void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, + u32 ui32NumBytes, void *hUniqueTag, IMG_BOOL bInterleaved) +{ + struct IMG_DEV_PHYADDR sDevPAddr; + struct PVRSRV_DEVICE_NODE *psDeviceNode = + psBMHeap->pBMContext->psDeviceNode; + int i; + + PVR_ASSERT(((u32) sDevVAddr.uiAddr & ~PAGE_MASK) == 0); + PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); + + PDumpComment("FREE :SGXMEM:VA_%8.8X\r\n", sDevVAddr.uiAddr); + + for (i = 0; (i * PAGE_SIZE) < ui32NumBytes; i++) { + if (!bInterleaved || (i % 2) == 0) { + sDevPAddr = + psDeviceNode->pfnMMUGetPhysPageAddr(psBMHeap-> + pMMUHeap, + sDevVAddr); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "FREE :SGXMEM:PA_%8.8X%8.8X\r\n", + (u32)hUniqueTag, sDevPAddr.uiAddr); + } + + sDevVAddr.uiAddr += PAGE_SIZE; + } +} + +void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, + void *pvLinAddr, void *hUniqueTag) +{ + struct IMG_CPU_PHYADDR sCpuPAddr; + struct IMG_DEV_PHYADDR sDevPAddr; + + PVR_ASSERT(((u32) pvLinAddr & ~PAGE_MASK) == 0); + + PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); + + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + + pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", + (u32)hUniqueTag, sDevPAddr.uiAddr); +} + +void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, + void *hUniqueTag) +{ + pdump_print(ui32Flags, + "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", + ui32Reg, (u32)hUniqueTag, + ui32Data & PAGE_MASK, + ui32Data & ~PAGE_MASK); +} + +void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) +{ + PDumpPDRegWithFlags(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS, + hUniqueTag); +} + +void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Value, u32 ui32Mask, + enum PDUMP_POLL_OPERATOR eOperator, void *hUniqueTag) +{ +#define MEMPOLL_DELAY (1000) +#define MEMPOLL_COUNT (2000000000 / MEMPOLL_DELAY) + + struct IMG_DEV_PHYADDR sDevPAddr; + struct IMG_DEV_VIRTADDR sDevVPageAddr; + u32 ui32PageOffset; + + PVR_ASSERT((ui32Offset + sizeof(u32)) <= + psMemInfo->ui32AllocSize); + + sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; + BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); + + pdump_print(0, "POL :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X " + "0x%8.8X %d %d %d\r\n", (u32)hUniqueTag, + sDevPAddr.uiAddr, ui32PageOffset, + ui32Value, ui32Mask, eOperator, + MEMPOLL_COUNT, MEMPOLL_DELAY); +} + +static void +pdump_mem_print(u32 ui32Flags, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, void *hUniqueTag) +{ + struct IMG_DEV_VIRTADDR sDevVPageAddr; + struct IMG_DEV_PHYADDR sDevPAddr; + u32 ui32PageOffset; + + PDumpCommentWithFlags(ui32Flags, "LDB :SGXMEM:VA_%8.8X:0x%8.8X " + "0x%8.8X\r\n", + psMemInfo->sDevVAddr.uiAddr, ui32Offset, + ui32Bytes); + + ui32PageOffset = + (psMemInfo->sDevVAddr.uiAddr + ui32Offset) & ~PAGE_MASK; + + while (ui32Bytes) { + u32 ui32BlockBytes = + min(ui32Bytes, (u32)PAGE_SIZE - ui32PageOffset); + + sDevVPageAddr.uiAddr = + psMemInfo->sDevVAddr.uiAddr + ui32Offset; + BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); + + pdump_print(ui32Flags, "LDB :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX" + " 0x%8.8X\r\n", (u32) hUniqueTag, + sDevPAddr.uiAddr, ui32PageOffset, + ui32BlockBytes); + + ui32PageOffset = 0; + ui32Bytes -= ui32BlockBytes; + ui32Offset += ui32BlockBytes; + } +} + +enum PVRSRV_ERROR +PDumpMemKM(void *pvAltLinAddr, struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) +{ + enum PVRSRV_ERROR eError; + + PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); + + if (!ui32Bytes) + return PVRSRV_ERROR_GENERIC; + + if (pvAltLinAddr) + eError = pdump_dump(ui32Flags, pvAltLinAddr, ui32Bytes, false); + else if (psMemInfo->pvLinAddrKM) + eError = pdump_dump(ui32Flags, + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes, false); + else + return PVRSRV_ERROR_GENERIC; + + if (eError != PVRSRV_OK) + return eError; + + pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, + hUniqueTag); + + return PVRSRV_OK; +} + +enum PVRSRV_ERROR +PDumpMemUM(void *pvAltLinAddrUM, void *pvLinAddrUM, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag) +{ + enum PVRSRV_ERROR eError; + + PVR_ASSERT((ui32Offset + ui32Bytes) <= psMemInfo->ui32AllocSize); + + if (!ui32Bytes) + return PVRSRV_ERROR_GENERIC; + + if (pvAltLinAddrUM) + eError = pdump_dump(ui32Flags, pvAltLinAddrUM, ui32Bytes, true); + else if (psMemInfo->pvLinAddrKM) + eError = pdump_dump(ui32Flags, + psMemInfo->pvLinAddrKM + ui32Offset, + ui32Bytes, false); + else if (pvLinAddrUM) + eError = pdump_dump(ui32Flags, pvLinAddrUM + ui32Offset, + ui32Bytes, true); + else + return PVRSRV_ERROR_GENERIC; + + if (eError != PVRSRV_OK) + return eError; + + pdump_mem_print(ui32Flags, psMemInfo, ui32Offset, ui32Bytes, + hUniqueTag); + + return PVRSRV_OK; +} + +enum PVRSRV_ERROR +PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, + u32 ui32Bytes, u32 ui32Flags, IMG_BOOL bInitialisePages, + void *hUniqueTag1, void *hUniqueTag2) +{ + struct IMG_DEV_PHYADDR sDevPAddr; + struct IMG_CPU_PHYADDR sCpuPAddr; + enum PVRSRV_ERROR eError; + + if (!pvLinAddr) + return PVRSRV_ERROR_GENERIC; + + if (bInitialisePages) { + eError = pdump_dump(PDUMP_FLAGS_CONTINUOUS, pvLinAddr, + ui32Bytes, false); + if (eError != PVRSRV_OK) + return eError; + } + + while (ui32Bytes) { + u32 ui32BlockBytes = + min(ui32Bytes, + (u32)(PAGE_SIZE - ((u32)pvLinAddr & ~PAGE_MASK))); + + sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + + if (bInitialisePages) { + pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" + "PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", + (u32) hUniqueTag1, + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, + ui32BlockBytes); + } else { + u32 ui32Offset; + + for (ui32Offset = 0; ui32Offset < ui32BlockBytes; + ui32Offset += sizeof(u32)) { + u32 ui32PTE = + *((u32 *)(pvLinAddr + ui32Offset)); + + if ((ui32PTE & ~PAGE_MASK) != 0) { + pdump_print(PDUMP_FLAGS_CONTINUOUS, +"WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", + (u32)hUniqueTag1, + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, + (u32)hUniqueTag2, + ui32PTE & PAGE_MASK, + ui32PTE & ~PAGE_MASK); + } else { + PVR_ASSERT(! + (ui32PTE & + SGX_MMU_PTE_VALID)); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X%8.8X\r\n", + (u32) hUniqueTag1, + sDevPAddr.uiAddr & PAGE_MASK, + sDevPAddr.uiAddr & ~PAGE_MASK, + ui32PTE, (u32)hUniqueTag2); + } + + sDevPAddr.uiAddr += sizeof(u32); + } + } + + ui32Bytes -= ui32BlockBytes; + pvLinAddr += ui32BlockBytes; + } + + return PVRSRV_OK; +} + +void +PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, + void *hUniqueTag1, void *hUniqueTag2) +{ + struct IMG_DEV_VIRTADDR sDevVPageAddr; + struct IMG_DEV_PHYADDR sDevPAddr; + u32 ui32PageOffset; + + sDevVPageAddr.uiAddr = psMemInfo->sDevVAddr.uiAddr + ui32Offset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; + BM_GetPhysPageAddr(psMemInfo, sDevVPageAddr, &sDevPAddr); + + if ((sPDDevPAddr.uiAddr & PAGE_MASK) != 0) { + pdump_print(PDUMP_FLAGS_CONTINUOUS, +"WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", + (u32) hUniqueTag1, + sDevPAddr.uiAddr, ui32PageOffset, + (u32)hUniqueTag2, + sPDDevPAddr.uiAddr & PAGE_MASK, + sPDDevPAddr.uiAddr & ~PAGE_MASK); + } else { + PVR_ASSERT(!(sDevPAddr.uiAddr & SGX_MMU_PTE_VALID)); + pdump_print(PDUMP_FLAGS_CONTINUOUS, + "WRW :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X\r\n", + (u32)hUniqueTag1, + sDevPAddr.uiAddr, ui32PageOffset, + sPDDevPAddr.uiAddr); + } +} + +void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, + struct IMG_DEV_VIRTADDR sDevBaseAddr, + u32 ui32Size, enum PDUMP_PIXEL_FORMAT ePixelFormat, + enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags) +{ + PDumpCommentWithFlags(ui32PDumpFlags, "Dump bitmap of render\r\n"); + + pdump_print(ui32PDumpFlags, + "SII %s %s.bin :SGXMEM:v:0x%08X 0x%08X " + "0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\r\n", + pszFileName, pszFileName, sDevBaseAddr.uiAddr, ui32Size, + ui32FileOffset, ePixelFormat, ui32Width, ui32Height, + ui32StrideInBytes, eMemFormat); +} + +static void +PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address) +{ + pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", + ui32Address, ui32FileOffset, pszFileName); +} + +void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters) +{ + u32 i; + + PDumpCommentWithFlags(0, "Dump 3D signature registers\r\n"); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_3d.sig", + ui32DumpFrameNum); + + for (i = 0; i < ui32NumRegisters; i++) + PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); +} + +void PDumpCounterRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters) +{ + u32 i; + + PDumpCommentWithFlags(0, "Dump counter registers\r\n"); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u.perf", + ui32DumpFrameNum); + + for (i = 0; i < ui32NumRegisters; i++) + PDumpReadRegKM(gpszFile, i * sizeof(u32), pui32Registers[i]); +} + +void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, + u32 *pui32Registers, u32 ui32NumRegisters) +{ + u32 i, ui32FileOffset; + + PDumpCommentWithFlags(0, "Dump TA signature registers\r\n"); + snprintf(gpszFile, SZ_FILENAME_SIZE_MAX, "out%u_ta.sig", + ui32DumpFrameNum); + + ui32FileOffset = ui32TAKickCount * ui32NumRegisters * sizeof(u32); + + for (i = 0; i < ui32NumRegisters; i++) + PDumpReadRegKM(gpszFile, ui32FileOffset + i * sizeof(u32), + pui32Registers[i]); +} + +void PDumpRegRead(const u32 ui32RegOffset, u32 ui32Flags) +{ + pdump_print(ui32Flags, "RDW :SGXREG:0x%X\r\n", ui32RegOffset); +} + +void PDumpCycleCountRegRead(const u32 ui32RegOffset) +{ + PDumpRegRead(ui32RegOffset, 0); +} + +void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, + struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, + u32 ui32PDumpFlags) +{ + PDumpCommentWithFlags(ui32PDumpFlags, + "Dump Hardware Performance Circular Buffer\r\n"); + pdump_print(ui32PDumpFlags, + "SAB :SGXMEM:v:0x%08X 0x%08X 0x%08X %s.bin\r\n", + sDevBaseAddr.uiAddr, ui32Size, ui32FileOffset, pszFileName); +} + +void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, + u32 ui32ROffOffset, u32 ui32WPosVal, u32 ui32PacketSize, + u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag) +{ + struct IMG_DEV_PHYADDR sDevPAddr; + struct IMG_DEV_VIRTADDR sDevVPageAddr; + u32 ui32PageOffset; + + PVR_ASSERT((ui32ROffOffset + sizeof(u32)) <= + psROffMemInfo->ui32AllocSize); + + sDevVPageAddr.uiAddr = + psROffMemInfo->sDevVAddr.uiAddr + ui32ROffOffset; + ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; + BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); + + pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" + " 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, + sDevPAddr.uiAddr, ui32PageOffset, + ui32WPosVal, ui32PacketSize, ui32BufferSize); +} + +void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags) +{ + pdump_print(ui32Flags, "IDL %u\r\n", ui32Clocks); +} diff --git a/drivers/gpu/pvr/pvr_pdump.h b/drivers/gpu/pvr/pvr_pdump.h new file mode 100644 index 0000000..30232cb --- /dev/null +++ b/drivers/gpu/pvr/pvr_pdump.h @@ -0,0 +1,186 @@ +/********************************************************************** + * + * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful but, except + * as otherwise stated in writing, without any warranty; without even the + * implied warranty of merchantability or fitness for a particular purpose. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + * + * Contact Information: + * Imagination Technologies Ltd. <gpl-support@imgtec.com> + * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK + * + ******************************************************************************/ + +#ifndef _PVR_PDUMP_H_ +#define _PVR_PDUMP_H_ + + +#define PDUMP_FLAGS_NEVER 0x08000000 +#define PDUMP_FLAGS_TOOUT2MEM 0x10000000 +#define PDUMP_FLAGS_LASTFRAME 0x20000000 +#define PDUMP_FLAGS_RESETLFBUFFER 0x40000000 +#define PDUMP_FLAGS_CONTINUOUS 0x80000000 + +#define PDUMP_PD_UNIQUETAG ((void *)0) +#define PDUMP_PT_UNIQUETAG ((void *)0) + +#ifdef PDUMP + +#define MAKEUNIQUETAG(hMemInfo) \ + (((struct BM_BUF *)(((struct PVRSRV_KERNEL_MEM_INFO *) \ + hMemInfo)->sMemBlk.hBuffer))->pMapping) + +void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO + *psMemInfo, u32 ui32Offset, + u32 ui32Value, u32 ui32Mask, + enum PDUMP_POLL_OPERATOR eOperator, + void *hUniqueTag); + +enum PVRSRV_ERROR PDumpMemUM(void *pvAltLinAddr, void *pvLinAddr, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, + void *hUniqueTag); + +enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, + struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, u32 ui32Bytes, + u32 ui32Flags, void *hUniqueTag); + +enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, + void *pvLinAddr, + u32 ui32Bytes, + u32 ui32Flags, + IMG_BOOL bInitialisePages, + void *hUniqueTag1, void *hUniqueTag2); +void PDumpInit(void); +void PDumpDeInit(void); +void PDumpSetFrameKM(u32 ui32Frame); +void PDumpCommentKM(char *pszComment, u32 ui32Flags); +void PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Flags); + +void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Width, u32 ui32Height, u32 ui32StrideInBytes, + struct IMG_DEV_VIRTADDR sDevBaseAddr, u32 ui32Size, + enum PDUMP_PIXEL_FORMAT ePixelFormat, + enum PDUMP_MEM_FORMAT eMemFormat, u32 ui32PDumpFlags); +void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, + struct IMG_DEV_VIRTADDR sDevBaseAddr, + u32 ui32Size, u32 ui32PDumpFlags); +void PDumpReg(u32 dwReg, u32 dwData); + +void PDumpComment(char *pszFormat, ...); + +void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...); +void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask); +void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, + u32 ui32Mask, u32 ui32Flags); + +IMG_BOOL PDumpIsCaptureFrameKM(void); + +void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, + u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, + u32 ui32NumBytes, void *hUniqueTag); +void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, + void *pvLinAddr, void *hUniqueTag); +void PDumpFreePages(struct BM_HEAP *psBMHeap, + struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, + void *hUniqueTag, IMG_BOOL bInterleaved); +void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, + void *pvLinAddr, void *hUniqueTag); +void PDumpPDReg(u32 ui32Reg, u32 ui32dwData, void *hUniqueTag); +void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, + void *hUniqueTag); + +void PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, + u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, + void *hUniqueTag1, void *hUniqueTag2); + +void PDumpTASignatureRegisters(u32 ui32DumpFrameNum, u32 ui32TAKickCount, + u32 *pui32Registers, u32 ui32NumRegisters); + +void PDump3DSignatureRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters); + +void PDumpRegRead(const u32 dwRegOffset, u32 ui32Flags); + +void PDumpCycleCountRegRead(const u32 dwRegOffset); + +void PDumpCounterRegisters(u32 ui32DumpFrameNum, + u32 *pui32Registers, u32 ui32NumRegisters); + +void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, + u32 ui32ROffOffset, + u32 ui32WPosVal, + u32 ui32PacketSize, + u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag); + +void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags); + +void PDumpSuspendKM(void); +void PDumpResumeKM(void); + +#define PDUMPMEMPOL PDumpMemPolKM +#define PDUMPMEM PDumpMemKM +#define PDUMPMEM2 PDumpMem2KM +#define PDUMPMEMUM PDumpMemUM +#define PDUMPINIT PDumpInit +#define PDUMPDEINIT PDumpDeInit +#define PDUMPREGWITHFLAGS PDumpRegWithFlagsKM +#define PDUMPREG PDumpReg +#define PDUMPCOMMENT PDumpComment +#define PDUMPCOMMENTWITHFLAGS PDumpCommentWithFlags +#define PDUMPREGPOL PDumpRegPolKM +#define PDUMPREGPOLWITHFLAGS PDumpRegPolWithFlagsKM +#define PDUMPMALLOCPAGES PDumpMallocPages +#define PDUMPMALLOCPAGETABLE PDumpMallocPageTable +#define PDUMPFREEPAGES PDumpFreePages +#define PDUMPFREEPAGETABLE PDumpFreePageTable +#define PDUMPPDREGWITHFLAGS PDumpPDRegWithFlags +#define PDUMPCBP PDumpCBP +#define PDUMPIDLWITHFLAGS PDumpIDLWithFlags +#define PDUMPSUSPEND PDumpSuspendKM +#define PDUMPRESUME PDumpResumeKM + +#else + +#define MAKEUNIQUETAG(hMemInfo) (0) + +#define PDUMPMEMPOL(args...) +#define PDUMPMEM(args...) +#define PDUMPMEM2(args...) +#define PDUMPMEMUM(args...) +#define PDUMPINIT(args...) +#define PDUMPDEINIT(args...) +#define PDUMPREGWITHFLAGS(args...) +#define PDUMPREG(args...) +#define PDUMPCOMMENT(args...) +#define PDUMPCOMMENTWITHFLAGS(args...) +#define PDUMPREGPOL(args...) +#define PDUMPREGPOLWITHFLAGS(args...) +#define PDUMPMALLOCPAGES(args...) +#define PDUMPMALLOCPAGETABLE(args...) +#define PDUMPFREEPAGES(args...) +#define PDUMPFREEPAGETABLE(args...) +#define PDUMPPDREGWITHFLAGS(args...) +#define PDUMPCBP(args...) +#define PDUMPIDLWITHFLAGS(args...) +#define PDUMPSUSPEND(args...) +#define PDUMPRESUME(args...) +#endif + +#endif /* _PVR_PDUMP_H_ */ diff --git a/drivers/gpu/pvr/pvrsrv.c b/drivers/gpu/pvr/pvrsrv.c index 72365ea..2bfb856 100644 --- a/drivers/gpu/pvr/pvrsrv.c +++ b/drivers/gpu/pvr/pvrsrv.c @@ -31,7 +31,7 @@ #include "pvr_bridge_km.h" #include "handle.h" #include "perproc.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "ra.h" #include "pvr_events.h" diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 1942ba6..210c66d 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -47,7 +47,7 @@ #include "resman.h" #include "bridged_support.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "ra.h" #include "mmu.h" #include "mm.h" diff --git a/drivers/gpu/pvr/sgxkick.c b/drivers/gpu/pvr/sgxkick.c index 4054988..6678b49 100644 --- a/drivers/gpu/pvr/sgxkick.c +++ b/drivers/gpu/pvr/sgxkick.c @@ -30,7 +30,7 @@ #include "sgxinfokm.h" #if defined(PDUMP) #include "sgxapi_km.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #endif #include "sgx_bridge_km.h" #include "osfunc.h" diff --git a/drivers/gpu/pvr/sgxpower.c b/drivers/gpu/pvr/sgxpower.c index 551b1a2..30cfb58 100644 --- a/drivers/gpu/pvr/sgxpower.c +++ b/drivers/gpu/pvr/sgxpower.c @@ -33,7 +33,7 @@ #include "sgxapi_km.h" #include "sgxinfokm.h" #include "sgxutils.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #define MS_TO_NS(x) ((x) * 1000000ULL) #define SGX_CMD_BURST_THRESHOLD_NS MS_TO_NS(3) diff --git a/drivers/gpu/pvr/sgxreset.c b/drivers/gpu/pvr/sgxreset.c index ad76a01..4d9dab0 100644 --- a/drivers/gpu/pvr/sgxreset.c +++ b/drivers/gpu/pvr/sgxreset.c @@ -30,7 +30,7 @@ #include "sgxinfokm.h" #include "sgxconfig.h" -#include "pdump_km.h" +#include "pvr_pdump.h" static void SGXResetSoftReset(struct PVRSRV_SGXDEV_INFO *psDevInfo, IMG_BOOL bResetBIF, u32 ui32PDUMPFlags, diff --git a/drivers/gpu/pvr/sgxtransfer.c b/drivers/gpu/pvr/sgxtransfer.c index 410b97e..22d2ac8 100644 --- a/drivers/gpu/pvr/sgxtransfer.c +++ b/drivers/gpu/pvr/sgxtransfer.c @@ -32,7 +32,7 @@ #include "buffer_manager.h" #include "sgxinfo.h" #include "sysconfig.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "mmu.h" #include "pvr_bridge.h" #include "sgx_bridge_km.h" diff --git a/drivers/gpu/pvr/sgxutils.c b/drivers/gpu/pvr/sgxutils.c index 05973df..860cbb6 100644 --- a/drivers/gpu/pvr/sgxutils.c +++ b/drivers/gpu/pvr/sgxutils.c @@ -33,7 +33,7 @@ #include "sgxinfo.h" #include "sgxinfokm.h" #include "sysconfig.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "mmu.h" #include "pvr_bridge_km.h" #include "sgx_bridge_km.h" diff --git a/drivers/gpu/pvr/sysconfig.c b/drivers/gpu/pvr/sysconfig.c index 8ce48e4..45b9d1f 100644 --- a/drivers/gpu/pvr/sysconfig.c +++ b/drivers/gpu/pvr/sysconfig.c @@ -30,7 +30,7 @@ #include "kerneldisplay.h" #include "oemfuncs.h" #include "sgxinfo.h" -#include "pdump_km.h" +#include "pvr_pdump.h" #include "sgxinfokm.h" #include "syslocal.h" #include "sysconfig.h" -- 1.7.5.4 From d4a405bec1f2450df3787eb6dc26bc7ed0f2d206 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:42 +0100 Subject: [PATCH 44/95] gpu: pvr: pdump: remove unused arguments The eDeviceType passed to SysCpuPAddrToDevPAddr is not used by SysCpuPAddrToDevPAddr at all. So stop passing eDeviceType to pdump functions. In the other cases, hUniqueTag is very unique indeed. Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 2 +- drivers/gpu/pvr/bridged_sgx_bridge.c | 6 ++-- drivers/gpu/pvr/buffer_manager.c | 3 +- drivers/gpu/pvr/mmu.c | 58 +++++++++++++--------------------- drivers/gpu/pvr/pvr_pdump.c | 44 ++++++++++--------------- drivers/gpu/pvr/pvr_pdump.h | 21 ++++-------- drivers/gpu/pvr/sgxreset.c | 2 +- 7 files changed, 53 insertions(+), 83 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 2ce50ce..1028b76 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1264,7 +1264,7 @@ static int PDumpPDRegBW(u32 ui32BridgeID, PVR_UNREFERENCED_PARAMETER(psPerProc); PDumpPDReg(psPDumpPDRegDumpIN->sHWReg.ui32RegAddr, - psPDumpPDRegDumpIN->sHWReg.ui32RegVal, PDUMP_PD_UNIQUETAG); + psPDumpPDRegDumpIN->sHWReg.ui32RegVal); psRetOUT->eError = PVRSRV_OK; return 0; diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index a6afdb7..f3a24a4 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -1465,7 +1465,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, PDUMPCBP(psCtrlMemInfoKM, ui32Offset, psBuffer->ui32Start, psBuffer->ui32SpaceUsed, - psBuffer->ui32BufferSize, 0, + psBuffer->ui32BufferSize, MAKEUNIQUETAG(psCtrlMemInfoKM)); } @@ -1485,7 +1485,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, PDUMPCBP(psCtrlMemInfoKM, ui32Offset, psBuffer->ui32Start, psBuffer->ui32BackEndLength, - psBuffer->ui32BufferSize, 0, + psBuffer->ui32BufferSize, MAKEUNIQUETAG(psCtrlMemInfoKM)); } PDUMPCOMMENTWITHFLAGS(0, "%s (part 1)\r\n", pszName); @@ -1506,7 +1506,7 @@ static void DumpBufferArray(struct PVRSRV_PER_PROCESS_DATA *psPerProc, pszName); PDUMPCBP(psCtrlMemInfoKM, ui32Offset, 0, psBuffer->ui32End, - psBuffer->ui32BufferSize, 0, + psBuffer->ui32BufferSize, MAKEUNIQUETAG(psCtrlMemInfoKM)); } PDUMPCOMMENTWITHFLAGS(0, "%s (part 2)\r\n", pszName); diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index 535f3ae..6c4023e 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1110,8 +1110,7 @@ static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, ui32PDumpSize = pMapping->pBMHeap->sDevArena.ui32DataPageSize; - PDUMPMALLOCPAGES(psDeviceNode->sDevId.eDeviceType, - pMapping->DevVAddr.uiAddr, pMapping->CpuVAddr, + PDUMPMALLOCPAGES(pMapping->DevVAddr.uiAddr, pMapping->hOSMemHandle, ui32PDumpSize, (void *)pMapping); } diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index 2311626..1c70c20 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -142,9 +142,7 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) pMMUHeap->ui32PTPageCount); if (ppsPTInfoList[ui32PTIndex] && ppsPTInfoList[ui32PTIndex]->PTPageCpuVAddr) - PDUMPFREEPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, - ppsPTInfoList[ui32PTIndex]->PTPageCpuVAddr, - PDUMP_PT_UNIQUETAG); + PDUMPFREEPAGETABLE(ppsPTInfoList[ui32PTIndex]->PTPageCpuVAddr); switch (pMMUHeap->psDevArena->DevMemHeapType) { case DEVICE_MEMORY_HEAP_SHARED: @@ -159,10 +157,8 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) (u32 *) psMMUContext->pvPDCpuVAddr; pui32PDEntry += ui32PDIndex; pui32PDEntry[ui32PTIndex] = 0; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *) & - pui32PDEntry[ui32PTIndex], - sizeof(u32), 0, IMG_FALSE, + PDUMPMEM2((void *) &pui32PDEntry[ui32PTIndex], + sizeof(u32), IMG_FALSE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); psMMUContext = psMMUContext->psNext; @@ -177,9 +173,8 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) (u32 *) pMMUHeap->psMMUContext->pvPDCpuVAddr; pui32PDEntry += ui32PDIndex; pui32PDEntry[ui32PTIndex] = 0; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *) &pui32PDEntry[ui32PTIndex], - sizeof(u32), 0, IMG_FALSE, + PDUMPMEM2((void *) &pui32PDEntry[ui32PTIndex], + sizeof(u32), IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); break; } @@ -398,13 +393,11 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, OSMemSet(ppsPTInfoList[i]->PTPageCpuVAddr, 0, SGX_MMU_PAGE_SIZE); - PDUMPMALLOCPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, - ppsPTInfoList[i]->PTPageCpuVAddr, + PDUMPMALLOCPAGETABLE(ppsPTInfoList[i]->PTPageCpuVAddr, PDUMP_PT_UNIQUETAG); - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - ppsPTInfoList[i]->PTPageCpuVAddr, - SGX_MMU_PAGE_SIZE, 0, IMG_TRUE, + PDUMPMEM2(ppsPTInfoList[i]->PTPageCpuVAddr, + SGX_MMU_PAGE_SIZE, IMG_TRUE, PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); switch (pMMUHeap->psDevArena->DevMemHeapType) { @@ -427,10 +420,8 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, SGX_MMU_PDE_VALID; PDUMPMEM2 - (PVRSRV_DEVICE_TYPE_SGX, - (void *)&pui32PDEntry[i], - sizeof(u32), 0, - IMG_FALSE, + ((void *)&pui32PDEntry[i], + sizeof(u32), IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); @@ -445,10 +436,9 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, pui32PDEntry[i] = sDevPAddr.uiAddr | SGX_MMU_PDE_VALID; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *)&pui32PDEntry[i], - sizeof(u32), 0, - IMG_FALSE, PDUMP_PD_UNIQUETAG, + PDUMPMEM2((void *)&pui32PDEntry[i], + sizeof(u32), IMG_FALSE, + PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); break; @@ -553,8 +543,7 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, PDUMPCOMMENT("Alloc page directory"); - PDUMPMALLOCPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, pvPDCpuVAddr, - PDUMP_PD_UNIQUETAG); + PDUMPMALLOCPAGETABLE(pvPDCpuVAddr, PDUMP_PD_UNIQUETAG); if (pvPDCpuVAddr) { pui32Tmp = (u32 *) pvPDCpuVAddr; @@ -568,8 +557,8 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, pui32Tmp[i] = 0; PDUMPCOMMENT("Page directory contents"); - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, 0, - IMG_TRUE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPMEM2(pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, IMG_TRUE, + PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); psMMUContext->pvPDCpuVAddr = pvPDCpuVAddr; psMMUContext->sPDDevPAddr = sPDDevPAddr; @@ -600,8 +589,7 @@ void MMU_Finalise(struct MMU_CONTEXT *psMMUContext) } PDUMPCOMMENT("Free page directory"); - PDUMPFREEPAGETABLE(PVRSRV_DEVICE_TYPE_SGX, psMMUContext->pvPDCpuVAddr, - PDUMP_PT_UNIQUETAG); + PDUMPFREEPAGETABLE(psMMUContext->pvPDCpuVAddr); pui32Tmp = (u32 *) psMMUContext->pvPDCpuVAddr; @@ -677,9 +665,8 @@ void MMU_InsertHeap(struct MMU_CONTEXT *psMMUContext, pui32PDCpuVAddr[ui32PDEntry] = pui32KernelPDCpuVAddr[ui32PDEntry]; if (pui32PDCpuVAddr[ui32PDEntry]) { - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *) &pui32PDCpuVAddr[ui32PDEntry], - sizeof(u32), 0, IMG_FALSE, + PDUMPMEM2((void *) &pui32PDCpuVAddr[ui32PDEntry], + sizeof(u32), IMG_FALSE, PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); bInvalidateDirectoryCache = IMG_TRUE; @@ -726,10 +713,9 @@ static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, if (psPTInfo) { pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; - PDUMPMEM2(PVRSRV_DEVICE_TYPE_SGX, - (void *)&pui32PTEntry[ui32PTIndex], - ui32PTDumpCount * sizeof(u32), 0, - IMG_FALSE, PDUMP_PT_UNIQUETAG, hUniqueTag); + PDUMPMEM2((void *)&pui32PTEntry[ui32PTIndex], + ui32PTDumpCount * sizeof(u32), IMG_FALSE, + PDUMP_PT_UNIQUETAG, hUniqueTag); } ui32NumPTEntries -= ui32PTDumpCount; diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index 4bf8cd4..95a978c 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -312,16 +312,13 @@ void PDumpRegPolKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Mask) PDUMP_FLAGS_CONTINUOUS); } -void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, - void *pvLinAddr, void *hOSMemHandle, u32 ui32NumBytes, - void *hUniqueTag) +void PDumpMallocPages(u32 ui32DevVAddr, void *hOSMemHandle, + u32 ui32NumBytes, void *hUniqueTag) { struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; u32 ui32Offset; - PVR_UNREFERENCED_PARAMETER(pvLinAddr); - PVR_ASSERT(((u32) ui32DevVAddr & ~PAGE_MASK) == 0); PVR_ASSERT(hOSMemHandle); PVR_ASSERT(((u32) ui32NumBytes & ~PAGE_MASK) == 0); @@ -332,7 +329,7 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, for (ui32Offset = 0; ui32Offset < ui32NumBytes; ui32Offset += PAGE_SIZE) { sCpuPAddr = OSMemHandleToCpuPAddr(hOSMemHandle, ui32Offset); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(0, sCpuPAddr); pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8X %u %u 0x%8.8X\r\n", @@ -341,8 +338,7 @@ void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, u32 ui32DevVAddr, } } -void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag) +void PDumpMallocPageTable(void *pvLinAddr, void *hUniqueTag) { struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; @@ -353,7 +349,7 @@ void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PAGE_SIZE, PAGE_SIZE); sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(0, sCpuPAddr); pdump_print(PDUMP_FLAGS_CONTINUOUS, "MALLOC :SGXMEM:PA_%8.8X%8.8lX " "0x%lX %lu 0x%8.8lX\r\n", (u32)hUniqueTag, @@ -389,8 +385,7 @@ void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, } } -void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag) +void PDumpFreePageTable(void *pvLinAddr) { struct IMG_CPU_PHYADDR sCpuPAddr; struct IMG_DEV_PHYADDR sDevPAddr; @@ -400,26 +395,24 @@ void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, PDumpComment("FREE :SGXMEM:PAGE_TABLE\r\n"); sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(0, sCpuPAddr); pdump_print(PDUMP_FLAGS_CONTINUOUS, "FREE :SGXMEM:PA_%8.8X%8.8lX\r\n", - (u32)hUniqueTag, sDevPAddr.uiAddr); + PDUMP_PT_UNIQUETAG, sDevPAddr.uiAddr); } -void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, - void *hUniqueTag) +void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags) { pdump_print(ui32Flags, "WRW :SGXREG:0x%8.8X :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX\r\n", - ui32Reg, (u32)hUniqueTag, + ui32Reg, PDUMP_PD_UNIQUETAG, ui32Data & PAGE_MASK, ui32Data & ~PAGE_MASK); } -void PDumpPDReg(u32 ui32Reg, u32 ui32Data, void *hUniqueTag) +void PDumpPDReg(u32 ui32Reg, u32 ui32Data) { - PDumpPDRegWithFlags(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS, - hUniqueTag); + PDumpPDRegWithFlags(ui32Reg, ui32Data, PDUMP_FLAGS_CONTINUOUS); } void PDumpMemPolKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, @@ -545,8 +538,7 @@ PDumpMemUM(void *pvAltLinAddrUM, void *pvLinAddrUM, } enum PVRSRV_ERROR -PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, - u32 ui32Bytes, u32 ui32Flags, IMG_BOOL bInitialisePages, +PDumpMem2KM(void *pvLinAddr, u32 ui32Bytes, IMG_BOOL bInitialisePages, void *hUniqueTag1, void *hUniqueTag2) { struct IMG_DEV_PHYADDR sDevPAddr; @@ -569,7 +561,7 @@ PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, void *pvLinAddr, (u32)(PAGE_SIZE - ((u32)pvLinAddr & ~PAGE_MASK))); sCpuPAddr = OSMapLinToCPUPhys(pvLinAddr); - sDevPAddr = SysCpuPAddrToDevPAddr(eDeviceType, sCpuPAddr); + sDevPAddr = SysCpuPAddrToDevPAddr(0, sCpuPAddr); if (bInitialisePages) { pdump_print(PDUMP_FLAGS_CONTINUOUS, "LDB :SGXMEM:" @@ -665,8 +657,8 @@ void PDumpBitmapKM(char *pszFileName, u32 ui32FileOffset, ui32StrideInBytes, eMemFormat); } -static void -PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, u32 ui32Address) +static void PDumpReadRegKM(char *pszFileName, u32 ui32FileOffset, + u32 ui32Address) { pdump_print(0, "SAB :SGXREG:0x%08X 0x%08X %s\r\n", ui32Address, ui32FileOffset, pszFileName); @@ -737,7 +729,7 @@ void PDumpHWPerfCBKM(char *pszFileName, u32 ui32FileOffset, void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, u32 ui32ROffOffset, u32 ui32WPosVal, u32 ui32PacketSize, - u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag) + u32 ui32BufferSize, void *hUniqueTag) { struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_DEV_VIRTADDR sDevVPageAddr; @@ -751,7 +743,7 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, ui32PageOffset = sDevVPageAddr.uiAddr & ~PAGE_MASK; BM_GetPhysPageAddr(psROffMemInfo, sDevVPageAddr, &sDevPAddr); - pdump_print(ui32Flags, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" + pdump_print(0, "CBP :SGXMEM:PA_%8.8X%8.8lX:0x%8.8lX 0x%8.8X" " 0x%8.8X 0x%8.8X\r\n", (u32) hUniqueTag, sDevPAddr.uiAddr, ui32PageOffset, ui32WPosVal, ui32PacketSize, ui32BufferSize); diff --git a/drivers/gpu/pvr/pvr_pdump.h b/drivers/gpu/pvr/pvr_pdump.h index 30232cb..d73a895 100644 --- a/drivers/gpu/pvr/pvr_pdump.h +++ b/drivers/gpu/pvr/pvr_pdump.h @@ -59,10 +59,7 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag); -enum PVRSRV_ERROR PDumpMem2KM(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, - u32 ui32Bytes, - u32 ui32Flags, +enum PVRSRV_ERROR PDumpMem2KM(void *pvLinAddr, u32 ui32Bytes, IMG_BOOL bInitialisePages, void *hUniqueTag1, void *hUniqueTag2); void PDumpInit(void); @@ -92,19 +89,15 @@ void PDumpRegPolWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, IMG_BOOL PDumpIsCaptureFrameKM(void); -void PDumpMallocPages(enum PVRSRV_DEVICE_TYPE eDeviceType, - u32 ui32DevVAddr, void *pvLinAddr, void *hOSMemHandle, +void PDumpMallocPages(u32 ui32DevVAddr, void *hOSMemHandle, u32 ui32NumBytes, void *hUniqueTag); -void PDumpMallocPageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag); +void PDumpMallocPageTable(void *pvLinAddr, void *hUniqueTag); void PDumpFreePages(struct BM_HEAP *psBMHeap, struct IMG_DEV_VIRTADDR sDevVAddr, u32 ui32NumBytes, void *hUniqueTag, IMG_BOOL bInterleaved); -void PDumpFreePageTable(enum PVRSRV_DEVICE_TYPE eDeviceType, - void *pvLinAddr, void *hUniqueTag); -void PDumpPDReg(u32 ui32Reg, u32 ui32dwData, void *hUniqueTag); -void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags, - void *hUniqueTag); +void PDumpFreePageTable(void *pvLinAddr); +void PDumpPDReg(u32 ui32Reg, u32 ui32dwData); +void PDumpPDRegWithFlags(u32 ui32Reg, u32 ui32Data, u32 ui32Flags); void PDumpPDDevPAddrKM(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo, u32 ui32Offset, struct IMG_DEV_PHYADDR sPDDevPAddr, @@ -127,7 +120,7 @@ void PDumpCBP(struct PVRSRV_KERNEL_MEM_INFO *psROffMemInfo, u32 ui32ROffOffset, u32 ui32WPosVal, u32 ui32PacketSize, - u32 ui32BufferSize, u32 ui32Flags, void *hUniqueTag); + u32 ui32BufferSize, void *hUniqueTag); void PDumpIDLWithFlags(u32 ui32Clocks, u32 ui32Flags); diff --git a/drivers/gpu/pvr/sgxreset.c b/drivers/gpu/pvr/sgxreset.c index 4d9dab0..b84961e 100644 --- a/drivers/gpu/pvr/sgxreset.c +++ b/drivers/gpu/pvr/sgxreset.c @@ -205,7 +205,7 @@ void SGXReset(struct PVRSRV_SGXDEV_INFO *psDevInfo, u32 ui32PDUMPFlags) psDevInfo->sKernelPDDevPAddr.uiAddr); PDUMPPDREGWITHFLAGS(ui32EDMDirListReg, psDevInfo->sKernelPDDevPAddr.uiAddr, - ui32PDUMPFlags, PDUMP_PD_UNIQUETAG); + ui32PDUMPFlags); } SGXResetInvalDC(psDevInfo, ui32PDUMPFlags, IMG_TRUE); -- 1.7.5.4 From f25f90c117e2c4aea03ba8a973b779d41a4c0011 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:43 +0100 Subject: [PATCH 45/95] gpu: pvr: pdump: rename PDumpMem2KM to PDumpPageTableKM Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/mmu.c | 47 ++++++++++++++++++++++--------------------- drivers/gpu/pvr/pvr_pdump.c | 4 +- drivers/gpu/pvr/pvr_pdump.h | 10 ++++---- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index 1c70c20..0c68876 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -157,10 +157,11 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) (u32 *) psMMUContext->pvPDCpuVAddr; pui32PDEntry += ui32PDIndex; pui32PDEntry[ui32PTIndex] = 0; - PDUMPMEM2((void *) &pui32PDEntry[ui32PTIndex], - sizeof(u32), IMG_FALSE, - PDUMP_PT_UNIQUETAG, - PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE((void *) &pui32PDEntry + [ui32PTIndex], + sizeof(u32), IMG_FALSE, + PDUMP_PT_UNIQUETAG, + PDUMP_PT_UNIQUETAG); psMMUContext = psMMUContext->psNext; } break; @@ -173,9 +174,9 @@ static void _DeferredFreePageTable(struct MMU_HEAP *pMMUHeap, u32 ui32PTIndex) (u32 *) pMMUHeap->psMMUContext->pvPDCpuVAddr; pui32PDEntry += ui32PDIndex; pui32PDEntry[ui32PTIndex] = 0; - PDUMPMEM2((void *) &pui32PDEntry[ui32PTIndex], - sizeof(u32), IMG_FALSE, - PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE((void *) &pui32PDEntry[ui32PTIndex], + sizeof(u32), IMG_FALSE, + PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); break; } default: @@ -396,9 +397,9 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, PDUMPMALLOCPAGETABLE(ppsPTInfoList[i]->PTPageCpuVAddr, PDUMP_PT_UNIQUETAG); - PDUMPMEM2(ppsPTInfoList[i]->PTPageCpuVAddr, - SGX_MMU_PAGE_SIZE, IMG_TRUE, - PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE(ppsPTInfoList[i]->PTPageCpuVAddr, + SGX_MMU_PAGE_SIZE, IMG_TRUE, + PDUMP_PT_UNIQUETAG, PDUMP_PT_UNIQUETAG); switch (pMMUHeap->psDevArena->DevMemHeapType) { case DEVICE_MEMORY_HEAP_SHARED: @@ -419,7 +420,7 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, sDevPAddr.uiAddr | SGX_MMU_PDE_VALID; - PDUMPMEM2 + PDUMPPAGETABLE ((void *)&pui32PDEntry[i], sizeof(u32), IMG_FALSE, PDUMP_PD_UNIQUETAG, @@ -436,10 +437,10 @@ static IMG_BOOL _DeferredAllocPagetables(struct MMU_HEAP *pMMUHeap, pui32PDEntry[i] = sDevPAddr.uiAddr | SGX_MMU_PDE_VALID; - PDUMPMEM2((void *)&pui32PDEntry[i], - sizeof(u32), IMG_FALSE, - PDUMP_PD_UNIQUETAG, - PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE((void *)&pui32PDEntry[i], + sizeof(u32), IMG_FALSE, + PDUMP_PD_UNIQUETAG, + PDUMP_PT_UNIQUETAG); break; } @@ -557,8 +558,8 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, pui32Tmp[i] = 0; PDUMPCOMMENT("Page directory contents"); - PDUMPMEM2(pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, IMG_TRUE, - PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE(pvPDCpuVAddr, SGX_MMU_PAGE_SIZE, IMG_TRUE, + PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); psMMUContext->pvPDCpuVAddr = pvPDCpuVAddr; psMMUContext->sPDDevPAddr = sPDDevPAddr; @@ -665,9 +666,9 @@ void MMU_InsertHeap(struct MMU_CONTEXT *psMMUContext, pui32PDCpuVAddr[ui32PDEntry] = pui32KernelPDCpuVAddr[ui32PDEntry]; if (pui32PDCpuVAddr[ui32PDEntry]) { - PDUMPMEM2((void *) &pui32PDCpuVAddr[ui32PDEntry], - sizeof(u32), IMG_FALSE, - PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); + PDUMPPAGETABLE((void *) &pui32PDCpuVAddr[ui32PDEntry], + sizeof(u32), IMG_FALSE, + PDUMP_PD_UNIQUETAG, PDUMP_PT_UNIQUETAG); bInvalidateDirectoryCache = IMG_TRUE; } @@ -713,9 +714,9 @@ static void MMU_PDumpPageTables(struct MMU_HEAP *pMMUHeap, if (psPTInfo) { pui32PTEntry = (u32 *)psPTInfo->PTPageCpuVAddr; - PDUMPMEM2((void *)&pui32PTEntry[ui32PTIndex], - ui32PTDumpCount * sizeof(u32), IMG_FALSE, - PDUMP_PT_UNIQUETAG, hUniqueTag); + PDUMPPAGETABLE((void *)&pui32PTEntry[ui32PTIndex], + ui32PTDumpCount * sizeof(u32), IMG_FALSE, + PDUMP_PT_UNIQUETAG, hUniqueTag); } ui32NumPTEntries -= ui32PTDumpCount; diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index 95a978c..1989204 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -538,8 +538,8 @@ PDumpMemUM(void *pvAltLinAddrUM, void *pvLinAddrUM, } enum PVRSRV_ERROR -PDumpMem2KM(void *pvLinAddr, u32 ui32Bytes, IMG_BOOL bInitialisePages, - void *hUniqueTag1, void *hUniqueTag2) +PDumpPageTableKM(void *pvLinAddr, u32 ui32Bytes, IMG_BOOL bInitialisePages, + void *hUniqueTag1, void *hUniqueTag2) { struct IMG_DEV_PHYADDR sDevPAddr; struct IMG_CPU_PHYADDR sCpuPAddr; diff --git a/drivers/gpu/pvr/pvr_pdump.h b/drivers/gpu/pvr/pvr_pdump.h index d73a895..895e698 100644 --- a/drivers/gpu/pvr/pvr_pdump.h +++ b/drivers/gpu/pvr/pvr_pdump.h @@ -59,9 +59,9 @@ enum PVRSRV_ERROR PDumpMemKM(void *pvAltLinAddr, u32 ui32Offset, u32 ui32Bytes, u32 ui32Flags, void *hUniqueTag); -enum PVRSRV_ERROR PDumpMem2KM(void *pvLinAddr, u32 ui32Bytes, - IMG_BOOL bInitialisePages, - void *hUniqueTag1, void *hUniqueTag2); +enum PVRSRV_ERROR PDumpPageTableKM(void *pvLinAddr, u32 ui32Bytes, + IMG_BOOL bInitialisePages, + void *hUniqueTag1, void *hUniqueTag2); void PDumpInit(void); void PDumpDeInit(void); void PDumpSetFrameKM(u32 ui32Frame); @@ -129,7 +129,7 @@ void PDumpResumeKM(void); #define PDUMPMEMPOL PDumpMemPolKM #define PDUMPMEM PDumpMemKM -#define PDUMPMEM2 PDumpMem2KM +#define PDUMPPAGETABLE PDumpPageTableKM #define PDUMPMEMUM PDumpMemUM #define PDUMPINIT PDumpInit #define PDUMPDEINIT PDumpDeInit @@ -155,7 +155,7 @@ void PDumpResumeKM(void); #define PDUMPMEMPOL(args...) #define PDUMPMEM(args...) -#define PDUMPMEM2(args...) +#define PDUMPPAGETABLE(args...) #define PDUMPMEMUM(args...) #define PDUMPINIT(args...) #define PDUMPDEINIT(args...) -- 1.7.5.4 From 4c188d8104d6805fe53d4932510779e70d018e46 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:44 +0100 Subject: [PATCH 46/95] gpu: pvr: pdump: silence sparse warnings in sgx_bridge pdump code Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgx_bridge.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/sgx_bridge.h b/drivers/gpu/pvr/sgx_bridge.h index 9b83616..dab97c7f 100644 --- a/drivers/gpu/pvr/sgx_bridge.h +++ b/drivers/gpu/pvr/sgx_bridge.h @@ -290,7 +290,7 @@ struct PVRSRV_BRIDGE_IN_PDUMP_3D_SIGNATURE_REGISTERS { u32 ui32BridgeFlags; u32 ui32DumpFrameNum; IMG_BOOL bLastFrame; - u32 *pui32Registers; + u32 __user *pui32Registers; u32 ui32NumRegisters; }; @@ -298,7 +298,7 @@ struct PVRSRV_BRIDGE_IN_PDUMP_COUNTER_REGISTERS { u32 ui32BridgeFlags; u32 ui32DumpFrameNum; IMG_BOOL bLastFrame; - u32 *pui32Registers; + u32 __user *pui32Registers; u32 ui32NumRegisters; }; @@ -307,7 +307,7 @@ struct PVRSRV_BRIDGE_IN_PDUMP_TA_SIGNATURE_REGISTERS { u32 ui32DumpFrameNum; u32 ui32TAKickCount; IMG_BOOL bLastFrame; - u32 *pui32Registers; + u32 __user *pui32Registers; u32 ui32NumRegisters; }; -- 1.7.5.4 From 9c7d89e174258125debf8d6f424a591917b012cf Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:45 +0100 Subject: [PATCH 47/95] gpu: pvr: pdump: move empty back-end into pvr_pdumpfs.[ch] Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 2 +- drivers/gpu/pvr/pvr_pdump.c | 64 ++++------------------------------- drivers/gpu/pvr/pvr_pdumpfs.c | 72 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_pdumpfs.h | 28 ++++++++++++++++ 4 files changed, 109 insertions(+), 57 deletions(-) create mode 100644 drivers/gpu/pvr/pvr_pdumpfs.c create mode 100644 drivers/gpu/pvr/pvr_pdumpfs.h diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index efb593b..69534d6 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -15,7 +15,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o proc.o \ pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debugfs.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o -pvrsrvkm-objs-$(CONFIG_PVR_DEBUG_PDUMP) += pvr_pdump.o +pvrsrvkm-objs-$(CONFIG_PVR_DEBUG_PDUMP) += pvr_pdump.o pvr_pdumpfs.o pvrsrvkm-objs += $(pvrsrvkm-objs-y) $(pvrsrvkm-objs-m) diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index 1989204..b333344 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -32,7 +32,9 @@ #include "pvrversion.h" #include "sgxmmu.h" #include "mm.h" + #include "pvr_pdump.h" +#include "pvr_pdumpfs.h" /* * There is no sense in having SGX_MMU_PAGE_SIZE differ from PAGE_SIZE. @@ -53,13 +55,6 @@ static char *gpszComment; static char *gpszScript; static char *gpszFile; -#define DEBUG_MODE_DISABLED 0 -#define DEBUG_MODE_STANDARD 1 -#define DEBUG_MODE_FULL 2 - -static u32 dbgdrv_mode = DEBUG_MODE_DISABLED; -static u32 dbgdrv_frame_number; - void PDumpSuspendKM(void) { atomic_inc(&gsPDumpSuspended); @@ -75,49 +70,6 @@ static inline IMG_BOOL PDumpSuspended(void) return atomic_read(&gsPDumpSuspended) != 0; } -/* - * empty pdump backend. - */ -static void -dbgdrv_frame_set(u32 frame) -{ - dbgdrv_frame_number = frame; -} - -static enum PVRSRV_ERROR -dbgdrv_write_data(void *buffer, int size, bool from_user) -{ - return PVRSRV_OK; -} - -static void -dbgdrv_write_string(char *string) -{ - -} - -static bool -dbgdrv_capturing(void) -{ - if (dbgdrv_mode == DEBUG_MODE_FULL) - return true; - else - return false; -} - -static bool dbgdrv_flags_check(u32 flags) -{ - if (flags & PDUMP_FLAGS_NEVER) - return false; - else if (dbgdrv_mode == DEBUG_MODE_FULL) - return true; - else if ((dbgdrv_mode == DEBUG_MODE_STANDARD) && - (flags & PDUMP_FLAGS_CONTINUOUS)) - return true; - else - return false; -} - static void pdump_print(u32 flags, char *format, ...) { @@ -126,14 +78,14 @@ pdump_print(u32 flags, char *format, ...) if (PDumpSuspended()) return; - if (!dbgdrv_flags_check(flags)) + if (!pdumpfs_flags_check(flags)) return; va_start(ap, format); vsnprintf(gpszScript, SZ_SCRIPT_SIZE_MAX, format, ap); va_end(ap); - dbgdrv_write_string(gpszScript); + pdumpfs_write_string(gpszScript); } static enum PVRSRV_ERROR @@ -142,10 +94,10 @@ pdump_dump(u32 flags, void *buffer, u32 size, bool from_user) if (PDumpSuspended()) return PVRSRV_OK; - if (!dbgdrv_flags_check(flags)) + if (!pdumpfs_flags_check(flags)) return PVRSRV_OK; - return dbgdrv_write_data(buffer, size, from_user); + return pdumpfs_write_data(buffer, size, from_user); } void PDumpCommentKM(char *pszComment, u32 ui32Flags) @@ -188,7 +140,7 @@ void PDumpSetFrameKM(u32 ui32Frame) if (PDumpSuspended()) return; - dbgdrv_frame_set(ui32Frame); + pdumpfs_frame_set(ui32Frame); } IMG_BOOL PDumpIsCaptureFrameKM(void) @@ -196,7 +148,7 @@ IMG_BOOL PDumpIsCaptureFrameKM(void) if (PDumpSuspended()) return IMG_FALSE; - return dbgdrv_capturing(); + return pdumpfs_capture_enabled(); } void PDumpInit(void) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c new file mode 100644 index 0000000..a1a3de7 --- /dev/null +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010-2011 by Luc Verhaegen <libv@codethink.co.uk> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "img_defs.h" +#include "services_headers.h" +#include "pvr_pdump.h" +#include "pvr_pdumpfs.h" + +enum pdumpfs_mode { + PDUMPFS_MODE_DISABLED, + PDUMPFS_MODE_STANDARD, + PDUMPFS_MODE_FULL, +}; + +static enum pdumpfs_mode pdumpfs_mode = PDUMPFS_MODE_DISABLED; +static u32 pdumpfs_frame_number; + +void +pdumpfs_frame_set(u32 frame) +{ + pdumpfs_frame_number = frame; +} + +bool +pdumpfs_capture_enabled(void) +{ + if (pdumpfs_mode == PDUMPFS_MODE_FULL) + return true; + else + return false; +} + +bool +pdumpfs_flags_check(u32 flags) +{ + if (flags & PDUMP_FLAGS_NEVER) + return false; + else if (pdumpfs_mode == PDUMPFS_MODE_FULL) + return true; + else if ((pdumpfs_mode == PDUMPFS_MODE_STANDARD) && + (flags & PDUMP_FLAGS_CONTINUOUS)) + return true; + else + return false; +} + +enum PVRSRV_ERROR +pdumpfs_write_data(void *buffer, size_t size, bool from_user) +{ + return PVRSRV_OK; +} + +void +pdumpfs_write_string(char *string) +{ + +} diff --git a/drivers/gpu/pvr/pvr_pdumpfs.h b/drivers/gpu/pvr/pvr_pdumpfs.h new file mode 100644 index 0000000..cc5c769 --- /dev/null +++ b/drivers/gpu/pvr/pvr_pdumpfs.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2010 by Luc Verhaegen <libv@codethink.co.uk> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _PVR_PDUMPFS_H_ +#define _PVR_PDUMPFS_H_ + +void pdumpfs_frame_set(u32 frame); +bool pdumpfs_capture_enabled(void); +bool pdumpfs_flags_check(u32 flags); +enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user); +void pdumpfs_write_string(char *string); + +#endif /* _PVR_PDUMPFS_H_ */ -- 1.7.5.4 From 79a85d110ab62cf7c3a63d625612a4e3e9d73414 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:46 +0100 Subject: [PATCH 48/95] gpu: pvr: pdumpfs: add pdumpfs_mutex Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdump.c | 7 +++++ drivers/gpu/pvr/pvr_pdumpfs.c | 57 ++++++++++++++++++++++++++++++++++++---- drivers/gpu/pvr/pvr_pdumpfs.h | 3 ++ 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index b333344..c9aa021 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -174,6 +174,11 @@ void PDumpInit(void) NULL) != PVRSRV_OK) goto init_failed; + if (pdumpfs_init()) { + pr_err("%s: pdumpfs_init failed.\n", __func__); + goto init_failed; + } + PDumpComment("Driver Product Name: %s", VS_PRODUCT_NAME); PDumpComment("Driver Product Version: %s (%s)", PVRVERSION_STRING, PVRVERSION_FILE); @@ -204,6 +209,8 @@ void PDumpInit(void) void PDumpDeInit(void) { + pdumpfs_cleanup(); + if (gpszFile) { OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, SZ_FILENAME_SIZE_MAX, (void *)gpszFile, NULL); diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index a1a3de7..8be0dd2 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -16,11 +16,15 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <linux/mutex.h> + #include "img_defs.h" #include "services_headers.h" #include "pvr_pdump.h" #include "pvr_pdumpfs.h" +static struct mutex pdumpfs_mutex[1]; + enum pdumpfs_mode { PDUMPFS_MODE_DISABLED, PDUMPFS_MODE_STANDARD, @@ -33,40 +37,81 @@ static u32 pdumpfs_frame_number; void pdumpfs_frame_set(u32 frame) { + mutex_lock(pdumpfs_mutex); + pdumpfs_frame_number = frame; + + mutex_unlock(pdumpfs_mutex); } bool pdumpfs_capture_enabled(void) { + bool ret; + + mutex_lock(pdumpfs_mutex); + if (pdumpfs_mode == PDUMPFS_MODE_FULL) - return true; + ret = true; else - return false; + ret = false; + + mutex_unlock(pdumpfs_mutex); + + return ret; } bool pdumpfs_flags_check(u32 flags) { + bool ret; + if (flags & PDUMP_FLAGS_NEVER) return false; - else if (pdumpfs_mode == PDUMPFS_MODE_FULL) - return true; + + mutex_lock(pdumpfs_mutex); + + if (pdumpfs_mode == PDUMPFS_MODE_FULL) + ret = true; else if ((pdumpfs_mode == PDUMPFS_MODE_STANDARD) && (flags & PDUMP_FLAGS_CONTINUOUS)) - return true; + ret = true; else - return false; + ret = false; + + mutex_unlock(pdumpfs_mutex); + + return ret; } enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user) { + mutex_lock(pdumpfs_mutex); + + mutex_unlock(pdumpfs_mutex); + return PVRSRV_OK; } void pdumpfs_write_string(char *string) { + mutex_lock(pdumpfs_mutex); + + mutex_unlock(pdumpfs_mutex); +} + +int +pdumpfs_init(void) +{ + mutex_init(pdumpfs_mutex); + + return 0; +} + +void +pdumpfs_cleanup(void) +{ } diff --git a/drivers/gpu/pvr/pvr_pdumpfs.h b/drivers/gpu/pvr/pvr_pdumpfs.h index cc5c769..714f2db 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.h +++ b/drivers/gpu/pvr/pvr_pdumpfs.h @@ -25,4 +25,7 @@ bool pdumpfs_flags_check(u32 flags); enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user); void pdumpfs_write_string(char *string); +int pdumpfs_init(void); +void pdumpfs_cleanup(void); + #endif /* _PVR_PDUMPFS_H_ */ -- 1.7.5.4 From 889a11bf5ea8917d5ee041124966e31ae1326ef5 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:47 +0100 Subject: [PATCH 49/95] gpu: pvr: pdumpfs: add Kconfig and debugfs pdump mode handling This adds the pvr/pdump debugfs subdirectory, and adds two files there: mode and modes_possible. The modes_possible file is read-only and lists the different modes (disabled, standard, full). The mode file is where we read and set the current mode. Kconfig now provides an option to select the initial mode pdump is in. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Kconfig | 29 ++++++- drivers/gpu/pvr/pvr_debug.h | 4 + drivers/gpu/pvr/pvr_debugfs.c | 42 +++++----- drivers/gpu/pvr/pvr_debugfs.h | 2 + drivers/gpu/pvr/pvr_pdumpfs.c | 190 ++++++++++++++++++++++++++++++++++++++++- 5 files changed, 243 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig index 84a8c48..bcbc8a4 100644 --- a/drivers/gpu/pvr/Kconfig +++ b/drivers/gpu/pvr/Kconfig @@ -26,8 +26,35 @@ config PVR_DEBUG_EXTRA config PVR_DEBUG_PDUMP bool "PDUMP debug support" - depends on PVR + depends on PVR && DEBUG_FS && PVR_DEBUG_EXTRA default n + help + This enables Pdump logging. + +choice + prompt "Pdump initial debugging mode" + depends on PVR_DEBUG_PDUMP + default PVR_PDUMP_MODE_STANDARD + +config PVR_PDUMP_MODE_DISABLED + bool "Disabled" + help + In this pdump mode, no information will be captured. + +config PVR_PDUMP_MODE_STANDARD + bool "Standard" + help + This PDumpmode catches some of the information generated by both + kernel and pvr userspace. + +config PVR_PDUMP_MODE_FULL + bool "Full" + help + This PDumpmode catches all information generated by both kernel + and pvr userspace. This mode is needed for allowing Imagination + Technologies to run a pdump log through their simulator. + +endchoice config PVR_EDM_DEBUG depends on PVR diff --git a/drivers/gpu/pvr/pvr_debug.h b/drivers/gpu/pvr/pvr_debug.h index a886a8c..ee4e77b 100644 --- a/drivers/gpu/pvr/pvr_debug.h +++ b/drivers/gpu/pvr/pvr_debug.h @@ -114,4 +114,8 @@ static inline void pvr_dbg_cleanup(void) {}; #endif +#ifdef CONFIG_DEBUG_FS +extern struct dentry *pvr_debugfs_dir; +#endif + #endif diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 3c3b30a..81761cd 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -41,7 +41,7 @@ #include "bridged_support.h" #include "mm.h" -static struct dentry *debugfs_dir; +struct dentry *pvr_debugfs_dir; static u32 pvr_reset; /* @@ -1049,61 +1049,61 @@ int pvr_debugfs_init(void) { mutex_init(hwrec_mutex); - debugfs_dir = debugfs_create_dir("pvr", NULL); - if (!debugfs_dir) + pvr_debugfs_dir = debugfs_create_dir("pvr", NULL); + if (!pvr_debugfs_dir) return -ENODEV; - if (!debugfs_create_file("reset_sgx", S_IWUSR, debugfs_dir, &pvr_reset, - &pvr_debugfs_fops)) { - debugfs_remove(debugfs_dir); + if (!debugfs_create_file("reset_sgx", S_IWUSR, pvr_debugfs_dir, + &pvr_reset, &pvr_debugfs_fops)) { + debugfs_remove(pvr_debugfs_dir); return -ENODEV; } #ifdef PVRSRV_USSE_EDM_STATUS_DEBUG - if (!debugfs_create_file("edm_trace", S_IRUGO, debugfs_dir, NULL, + if (!debugfs_create_file("edm_trace", S_IRUGO, pvr_debugfs_dir, NULL, &pvr_debugfs_edm_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } #endif - if (!debugfs_create_file("hwrec_event", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_event", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_event_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } - if (!debugfs_create_file("hwrec_time", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_time", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_time_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } - if (!debugfs_create_file("hwrec_regs", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_regs", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_regs_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } #ifdef CONFIG_PVR_DEBUG - if (!debugfs_create_file("hwrec_mem", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_mem", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_mem_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } #endif /* CONFIG_PVR_DEBUG */ #ifdef PVRSRV_USSE_EDM_STATUS_DEBUG - if (!debugfs_create_file("hwrec_edm", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_edm", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_edm_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } #endif - if (!debugfs_create_file("hwrec_status", S_IRUSR, debugfs_dir, NULL, + if (!debugfs_create_file("hwrec_status", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_status_fops)) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); return -ENODEV; } @@ -1112,7 +1112,7 @@ int pvr_debugfs_init(void) void pvr_debugfs_cleanup(void) { - debugfs_remove_recursive(debugfs_dir); + debugfs_remove_recursive(pvr_debugfs_dir); if (hwrec_registers) free_page((u32) hwrec_registers); diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index 72bf34b..32aa38b 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -24,6 +24,8 @@ #error Error: debugfs header included but CONFIG_DEBUG_FS is not defined! #endif +extern struct dentry *pvr_debugfs_dir; + int pvr_debugfs_init(void); void pvr_debugfs_cleanup(void); diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 8be0dd2..c5400f8 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -17,6 +17,8 @@ */ #include <linux/mutex.h> +#include <linux/uaccess.h> +#include <linux/debugfs.h> #include "img_defs.h" #include "services_headers.h" @@ -31,7 +33,16 @@ enum pdumpfs_mode { PDUMPFS_MODE_FULL, }; -static enum pdumpfs_mode pdumpfs_mode = PDUMPFS_MODE_DISABLED; +static enum pdumpfs_mode pdumpfs_mode = +#if defined(CONFIG_PVR_PDUMP_MODE_STANDARD) + PDUMPFS_MODE_STANDARD +#elif defined(CONFIG_PVR_PDUMP_MODE_FULL) + PDUMPFS_MODE_FULL +#else + PDUMPFS_MODE_DISABLED +#endif + ; + static u32 pdumpfs_frame_number; void @@ -102,16 +113,191 @@ pdumpfs_write_string(char *string) mutex_unlock(pdumpfs_mutex); } +/* + * DebugFS entries. + */ +static const struct { + char *name; + enum pdumpfs_mode mode; +} pdumpfs_modes[] = { + {"disabled", PDUMPFS_MODE_DISABLED}, + {"standard", PDUMPFS_MODE_STANDARD}, + {"full", PDUMPFS_MODE_FULL}, + {NULL, PDUMPFS_MODE_DISABLED} +}; + +static ssize_t +pdumpfs_mode_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + char tmp[16]; + int i; + + tmp[0] = 0; + + mutex_lock(pdumpfs_mutex); + + for (i = 0; pdumpfs_modes[i].name; i++) + if (pdumpfs_modes[i].mode == pdumpfs_mode) + snprintf(tmp, sizeof(tmp), "%s\n", + pdumpfs_modes[i].name); + + mutex_unlock(pdumpfs_mutex); + + if (strlen(tmp) < *f_pos) + return 0; + + if ((strlen(tmp) + 1) < (*f_pos + size)) + size = strlen(tmp) + 1 - *f_pos; + + if (copy_to_user(buf, tmp + *f_pos, size)) + return -EFAULT; + + *f_pos += size; + return size; +} + +static ssize_t +pdumpfs_mode_write(struct file *filp, const char __user *buf, size_t size, + loff_t *f_pos) +{ + static char tmp[16]; + int i; + + if (*f_pos > sizeof(tmp)) + return -EINVAL; + + if (size > (sizeof(tmp) - *f_pos)) + size = sizeof(tmp) - *f_pos; + + if (copy_from_user(tmp + *f_pos, buf, size)) + return -EFAULT; + + *f_pos += size; + + mutex_lock(pdumpfs_mutex); + + for (i = 0; pdumpfs_modes[i].name; i++) + if (!strnicmp(tmp, pdumpfs_modes[i].name, + strlen(pdumpfs_modes[i].name))) { + pdumpfs_mode = pdumpfs_modes[i].mode; + mutex_unlock(pdumpfs_mutex); + return size; + } + + mutex_unlock(pdumpfs_mutex); + return -EINVAL; +} + +static const struct file_operations pdumpfs_mode_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = pdumpfs_mode_read, + .write = pdumpfs_mode_write, +}; + +static ssize_t +pdumpfs_modes_possible_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + unsigned int i, skip = *f_pos, pos = 0; + + for (i = 0; pdumpfs_modes[i].name; i++) { + if (i) { /* space */ + if (skip) + skip--; + else if (size > pos) { + if (copy_to_user(buf + pos, " ", 1)) + return -EFAULT; + pos++; + } + } + + if (size) { + int len = strlen(pdumpfs_modes[i].name); + + if (skip >= len) { + skip -= len; + } else if (size > pos) { + len = min(len - skip, size - pos); + + if (copy_to_user(buf + pos, + pdumpfs_modes[i].name + skip, + len)) + return -EFAULT; + + skip = 0; + pos += len; + } + } + } + + *f_pos += pos; + return pos; +} + +static const struct file_operations pdumpfs_modes_possible_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = pdumpfs_modes_possible_read, +}; + +static struct dentry *pdumpfs_dir; + +static void +pdumpfs_file_create(const char *name, mode_t mode, + const struct file_operations *fops) +{ + struct dentry *tmp = NULL; + + tmp = debugfs_create_file(name, mode, pdumpfs_dir, NULL, fops); + if (!tmp) + pr_err("%s: failed to create pvr/%s file.\n", __func__, name); +} + +static int +pdumpfs_fs_init(void) +{ + if (!pvr_debugfs_dir) { + pr_err("%s: debugfs pvr/ directory does not exist.\n", + __func__); + return -ENOENT; + } + + pdumpfs_dir = debugfs_create_dir("pdump", pvr_debugfs_dir); + if (!pdumpfs_dir) { + pr_err("%s: failed to create top level directory.\n", + __func__); + return -ENOENT; + } + + pdumpfs_file_create("mode", S_IRUSR | S_IWUSR, + &pdumpfs_mode_fops); + pdumpfs_file_create("modes_possible", S_IRUSR, + &pdumpfs_modes_possible_fops); + + return 0; +} + +static void +pdumpfs_fs_destroy(void) +{ + if (pdumpfs_dir) + debugfs_remove_recursive(pdumpfs_dir); +} + int pdumpfs_init(void) { mutex_init(pdumpfs_mutex); + pdumpfs_fs_init(); + return 0; } void pdumpfs_cleanup(void) { - + pdumpfs_fs_destroy(); } -- 1.7.5.4 From 0bd29835aff7bd3e80ffc34c4c022b920506e946 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:48 +0100 Subject: [PATCH 50/95] gpu: pvr: pdumpfs: add frame struct and initial frame handling code Now we are tracking frames correctly, but we are not accepting any data yet. frame_current is the last of frame_stream, and the frame that we would be writing to. New frames are created when userspace flags the start of a new frame with PDumpSetFrameKM. This is also where we deliberately change the pdump content by adding two comments. One for flagging the end of the previous frame, one for the start of the new frame. We keep at most frame_count_max frames around, older frames will be removed by frame_cull() which gets called when a new frame gets created. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 3 +- drivers/gpu/pvr/pvr_pdump.c | 6 ++- drivers/gpu/pvr/pvr_pdump.h | 2 +- drivers/gpu/pvr/pvr_pdumpfs.c | 99 ++++++++++++++++++++++++++++++++- drivers/gpu/pvr/pvr_pdumpfs.h | 2 +- 5 files changed, 103 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 1028b76..d470bcd 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -1073,9 +1073,8 @@ static int PDumpSetFrameBW(u32 ui32BridgeID, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_PDUMP_SETFRAME); - PVR_UNREFERENCED_PARAMETER(psPerProc); - PDumpSetFrameKM(psPDumpSetFrameIN->ui32Frame); + PDumpSetFrameKM(psPerProc->ui32PID, psPDumpSetFrameIN->ui32Frame); psRetOUT->eError = PVRSRV_OK; diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index c9aa021..6966d01 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -135,12 +135,14 @@ void PDumpCommentWithFlags(u32 ui32Flags, char *pszFormat, ...) PDumpCommentKM(gpszComment, ui32Flags); } -void PDumpSetFrameKM(u32 ui32Frame) +void PDumpSetFrameKM(u32 ui32PID, u32 ui32Frame) { if (PDumpSuspended()) return; - pdumpfs_frame_set(ui32Frame); + PDumpComment("Ending current Frame\r\n"); + pdumpfs_frame_set(ui32PID, ui32Frame); + PDumpComment("PID %d: Starting Frame %d\r\n", ui32PID, ui32Frame); } IMG_BOOL PDumpIsCaptureFrameKM(void) diff --git a/drivers/gpu/pvr/pvr_pdump.h b/drivers/gpu/pvr/pvr_pdump.h index 895e698..6fbf4f4 100644 --- a/drivers/gpu/pvr/pvr_pdump.h +++ b/drivers/gpu/pvr/pvr_pdump.h @@ -64,7 +64,7 @@ enum PVRSRV_ERROR PDumpPageTableKM(void *pvLinAddr, u32 ui32Bytes, void *hUniqueTag1, void *hUniqueTag2); void PDumpInit(void); void PDumpDeInit(void); -void PDumpSetFrameKM(u32 ui32Frame); +void PDumpSetFrameKM(u32 ui32PID, u32 ui32Frame); void PDumpCommentKM(char *pszComment, u32 ui32Flags); void PDumpRegWithFlagsKM(u32 ui32RegAddr, u32 ui32RegValue, u32 ui32Flags); diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index c5400f8..b642ac1 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -43,14 +43,99 @@ static enum pdumpfs_mode pdumpfs_mode = #endif ; -static u32 pdumpfs_frame_number; +struct pdumpfs_frame { + struct pdumpfs_frame *next; + + u32 pid; + u32 number; +}; + +static u32 frame_count_max = 16; +static u32 frame_count; + +static struct pdumpfs_frame *frame_stream; +static struct pdumpfs_frame *frame_current; + +static struct pdumpfs_frame * +frame_create(void) +{ + struct pdumpfs_frame *frame = + kmalloc(sizeof(struct pdumpfs_frame), GFP_KERNEL); + if (!frame) + return NULL; + + memset(frame, 0, sizeof(struct pdumpfs_frame)); + + return frame; +} + +static void +frame_destroy(struct pdumpfs_frame *frame) +{ + if (!frame) + return; + + kfree(frame); +} + +static void +frame_destroy_all(void) +{ + frame_current = NULL; + + while (frame_stream) { + struct pdumpfs_frame *frame = frame_stream; + + frame_stream = frame->next; + + frame_destroy(frame); + frame_count--; + } +} + +static void +frame_cull(void) +{ + while (frame_count > frame_count_max) { + struct pdumpfs_frame *frame = frame_stream; + + frame_stream = frame->next; + frame->next = NULL; + + frame_destroy(frame); + frame_count--; + } +} + +static int +frame_new(u32 pid, u32 number) +{ + struct pdumpfs_frame *frame = frame_create(); + + if (!frame) { + pr_err("%s: Failed to create frame.\n", __func__); + return -ENOMEM; + } + + frame->pid = pid; + frame->number = number; + + if (frame_current) + frame_current->next = frame; + frame_current = frame; + frame_count++; + + frame_cull(); + + return 0; +} void -pdumpfs_frame_set(u32 frame) +pdumpfs_frame_set(u32 pid, u32 frame) { mutex_lock(pdumpfs_mutex); - pdumpfs_frame_number = frame; + frame_new(pid, frame); mutex_unlock(pdumpfs_mutex); } @@ -289,8 +374,14 @@ pdumpfs_fs_destroy(void) int pdumpfs_init(void) { + int ret; + mutex_init(pdumpfs_mutex); + ret = frame_new(0, 0); + if (ret < 0) + return ret; + pdumpfs_fs_init(); return 0; @@ -300,4 +391,6 @@ void pdumpfs_cleanup(void) { pdumpfs_fs_destroy(); + + frame_destroy_all(); } diff --git a/drivers/gpu/pvr/pvr_pdumpfs.h b/drivers/gpu/pvr/pvr_pdumpfs.h index 714f2db..76afd43 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.h +++ b/drivers/gpu/pvr/pvr_pdumpfs.h @@ -19,7 +19,7 @@ #ifndef _PVR_PDUMPFS_H_ #define _PVR_PDUMPFS_H_ -void pdumpfs_frame_set(u32 frame); +void pdumpfs_frame_set(u32 pid, u32 frame); bool pdumpfs_capture_enabled(void); bool pdumpfs_flags_check(u32 flags); enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user); -- 1.7.5.4 From 6230a9b6c236e38686754b8610a9bc61d53fa4f6 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:49 +0100 Subject: [PATCH 51/95] gpu: pvr: pdumpfs: make frame_count_max configurable Both through a Kconfig option and through debugfs. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Kconfig | 9 +++++ drivers/gpu/pvr/pvr_pdumpfs.c | 71 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig index bcbc8a4..0da11a0 100644 --- a/drivers/gpu/pvr/Kconfig +++ b/drivers/gpu/pvr/Kconfig @@ -56,6 +56,15 @@ config PVR_PDUMP_MODE_FULL endchoice +config PVR_PDUMP_INITIAL_MAX_FRAME_COUNT + int "Pdump max frame count" + range 1 1024 + default 16 + depends on PVR_DEBUG_PDUMP + help + This value sets how many frames will be retained at any time; the oldest + frames will be removed first. This value can be set from 1 to 1024. + config PVR_EDM_DEBUG depends on PVR bool "Enable EDM trace" diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index b642ac1..e16e4f7 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -50,7 +50,7 @@ struct pdumpfs_frame { u32 number; }; -static u32 frame_count_max = 16; +static u32 frame_count_max = CONFIG_PVR_PDUMP_INITIAL_MAX_FRAME_COUNT; static u32 frame_count; static struct pdumpfs_frame *frame_stream; @@ -327,6 +327,72 @@ static const struct file_operations pdumpfs_modes_possible_fops = { .read = pdumpfs_modes_possible_read, }; +static ssize_t +pdumpfs_frame_count_max_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + char tmp[16]; + + tmp[0] = 0; + + mutex_lock(pdumpfs_mutex); + snprintf(tmp, sizeof(tmp), "%d", frame_count_max); + mutex_unlock(pdumpfs_mutex); + + if (strlen(tmp) < *f_pos) + return 0; + + if ((strlen(tmp) + 1) < (*f_pos + size)) + size = strlen(tmp) + 1 - *f_pos; + + if (copy_to_user(buf, tmp + *f_pos, size)) + return -EFAULT; + + *f_pos += size; + return size; +} + +static ssize_t +pdumpfs_frame_count_max_write(struct file *filp, const char __user *buf, + size_t size, loff_t *f_pos) +{ + static char tmp[16]; + unsigned long result = 0; + + if (*f_pos > sizeof(tmp)) + return -EINVAL; + + if (size > (sizeof(tmp) - *f_pos)) + size = sizeof(tmp) - *f_pos; + + if (copy_from_user(tmp + *f_pos, buf, size)) + return -EFAULT; + + tmp[size] = 0; + + mutex_lock(pdumpfs_mutex); + + if (!strict_strtoul(tmp, 0, &result)) { + if (result > 1024) + result = 1024; + if (!result) + result = 1; + frame_count_max = result; + } + + mutex_unlock(pdumpfs_mutex); + + *f_pos += size; + return size; +} + +static const struct file_operations pdumpfs_frame_count_max_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .read = pdumpfs_frame_count_max_read, + .write = pdumpfs_frame_count_max_write, +}; + static struct dentry *pdumpfs_dir; static void @@ -361,6 +427,9 @@ pdumpfs_fs_init(void) pdumpfs_file_create("modes_possible", S_IRUSR, &pdumpfs_modes_possible_fops); + pdumpfs_file_create("frame_count_max", S_IRUSR | S_IWUSR, + &pdumpfs_frame_count_max_fops); + return 0; } -- 1.7.5.4 From 70832e3bbb5bede6a9a077047fef35e1cebd6a44 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Date: Fri, 11 Mar 2011 15:02:50 +0100 Subject: [PATCH 52/95] gpu: pvr: pdumpfs: start storing pdump data Page based allocation, with built in copy_from_user to minimise buffer copies. Up to 2040 pages of data are kept per frame, if this amount is exceeded, an error message is printed, and a new frame is created automatically. Parameter data is stored inside the same stream as script data, but is encapsulated in "BIN %08X:"..."-- BIN END". Signed-off-by: Luc Verhaegen <Luc.Verhaegen@basyskom.de> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdump.c | 10 ++++- drivers/gpu/pvr/pvr_pdumpfs.c | 102 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdump.c b/drivers/gpu/pvr/pvr_pdump.c index 6966d01..007b9c7 100644 --- a/drivers/gpu/pvr/pvr_pdump.c +++ b/drivers/gpu/pvr/pvr_pdump.c @@ -91,13 +91,21 @@ pdump_print(u32 flags, char *format, ...) static enum PVRSRV_ERROR pdump_dump(u32 flags, void *buffer, u32 size, bool from_user) { + enum PVRSRV_ERROR eError; + if (PDumpSuspended()) return PVRSRV_OK; if (!pdumpfs_flags_check(flags)) return PVRSRV_OK; - return pdumpfs_write_data(buffer, size, from_user); + pdump_print(flags, "BIN 0x%08X:", size); + + eError = pdumpfs_write_data(buffer, size, from_user); + + pdump_print(flags, "-- BIN END\r\n"); + + return eError; } void PDumpCommentKM(char *pszComment, u32 ui32Flags) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index e16e4f7..5caca90 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -43,11 +43,17 @@ static enum pdumpfs_mode pdumpfs_mode = #endif ; +#define FRAME_PAGE_COUNT 2040 + struct pdumpfs_frame { struct pdumpfs_frame *next; u32 pid; u32 number; + + size_t offset; + int page_count; + unsigned long pages[FRAME_PAGE_COUNT]; }; static u32 frame_count_max = CONFIG_PVR_PDUMP_INITIAL_MAX_FRAME_COUNT; @@ -72,9 +78,14 @@ frame_create(void) static void frame_destroy(struct pdumpfs_frame *frame) { + int i; + if (!frame) return; + for (i = 0; i < frame->page_count; i++) + free_page(frame->pages[i]); + kfree(frame); } @@ -180,14 +191,101 @@ pdumpfs_flags_check(u32 flags) return ret; } +static size_t +pdumpfs_frame_write_low(void *buffer, size_t size, bool from_user) +{ + struct pdumpfs_frame *frame = frame_current; + size_t ret = 0; + + while (size) { + size_t count = size; + size_t offset = frame->offset & ~PAGE_MASK; + unsigned long page; + + if (!offset) { + if (frame->page_count >= FRAME_PAGE_COUNT) { + pr_err("%s: Frame size overrun.\n", __func__); + return -ENOMEM; + } + + page = __get_free_page(GFP_KERNEL); + if (!page) { + pr_err("%s: failed to get free page.\n", + __func__); + return -ENOMEM; + } + + frame->pages[frame->page_count] = page; + frame->page_count++; + } else + page = + frame->pages[frame->page_count - 1]; + + if (count > (PAGE_SIZE - offset)) + count = PAGE_SIZE - offset; + + if (from_user) { + if (copy_from_user(((u8 *) page) + offset, + (void __user __force *) buffer, + count)) + return -EINVAL; + } else + memcpy(((u8 *) page) + offset, buffer, count); + + buffer += count; + size -= count; + ret += count; + frame->offset += count; + } + return ret; +} + +static size_t +pdumpfs_frame_write(void *buffer, size_t size, bool from_user) +{ + size_t ret; + + if ((frame_current->offset + size) > (PAGE_SIZE * FRAME_PAGE_COUNT)) { + u32 pid = OSGetCurrentProcessIDKM(); + struct task_struct *task; + + pr_err("Frame overrun!!!\n"); + + ret = frame_new(pid, -1); + if (ret) + return ret; + + rcu_read_lock(); + task = pid_task(find_vpid(pid), PIDTYPE_PID); + +#define FRAME_OVERRUN_MESSAGE "-- Starting forced frame caused by " + pdumpfs_frame_write_low(FRAME_OVERRUN_MESSAGE, + sizeof(FRAME_OVERRUN_MESSAGE), false); + pdumpfs_frame_write_low(task->comm, strlen(task->comm), false); + pdumpfs_frame_write_low("\r\n", 2, false); + + pr_err("%s: Frame size overrun, caused by %d (%s)\n", + __func__, pid, task->comm); + + rcu_read_unlock(); + } + + return pdumpfs_frame_write_low(buffer, size, from_user); +} + enum PVRSRV_ERROR pdumpfs_write_data(void *buffer, size_t size, bool from_user) { mutex_lock(pdumpfs_mutex); + size = pdumpfs_frame_write(buffer, size, from_user); + mutex_unlock(pdumpfs_mutex); - return PVRSRV_OK; + if ((size >= 0) || (size == -ENOMEM)) + return PVRSRV_OK; + else + return PVRSRV_ERROR_GENERIC; } void @@ -195,6 +293,8 @@ pdumpfs_write_string(char *string) { mutex_lock(pdumpfs_mutex); + pdumpfs_frame_write(string, strlen(string), false); + mutex_unlock(pdumpfs_mutex); } -- 1.7.5.4 From 7f4e1cd9a559c99f9fa1ece02e451db9533fa66c Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:51 +0100 Subject: [PATCH 53/95] gpu: pvr: pdumpfs: add initial frame handling and debugfs support This adds the separate handling of the initial frame, and adds debugfs support for this initial frame. The initial frame is the frame started when the driver is initialised. Once userspace flags the first frame, the initial frame is ended, and a new frame started, but the initial frame is not part of the stream list. The initial frame therefor does not get culled as part of standard frame culling and is kept around for the life of the driver. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 118 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 115 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 5caca90..60cb726 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -59,6 +59,7 @@ struct pdumpfs_frame { static u32 frame_count_max = CONFIG_PVR_PDUMP_INITIAL_MAX_FRAME_COUNT; static u32 frame_count; +static struct pdumpfs_frame *frame_init; static struct pdumpfs_frame *frame_stream; static struct pdumpfs_frame *frame_current; @@ -94,6 +95,9 @@ frame_destroy_all(void) { frame_current = NULL; + frame_destroy(frame_init); + frame_init = NULL; + while (frame_stream) { struct pdumpfs_frame *frame = frame_stream; @@ -131,10 +135,17 @@ frame_new(u32 pid, u32 number) frame->pid = pid; frame->number = number; - if (frame_current) - frame_current->next = frame; + if (!frame_init) + frame_init = frame; + else { + if (frame_current != frame_init) + frame_current->next = frame; + else + frame_stream = frame; + frame_count++; + } + frame_current = frame; - frame_count++; frame_cull(); @@ -493,6 +504,104 @@ static const struct file_operations pdumpfs_frame_count_max_fops = { .write = pdumpfs_frame_count_max_write, }; +static ssize_t +pdumpfs_frame_read_single(struct pdumpfs_frame *frame, char __user *buf, + size_t size, loff_t f_pos) +{ + int page; + size_t offset; + + if (f_pos >= frame->offset) + return 0; + + if (size > (frame->offset - f_pos)) + size = frame->offset - f_pos; + + page = f_pos / PAGE_SIZE; + offset = f_pos % PAGE_SIZE; + + if (size > (PAGE_SIZE - offset)) + size = PAGE_SIZE - offset; + + if (copy_to_user(buf, ((u8 *) frame->pages[page]) + offset, size)) + return -EFAULT; + + return size; +} + +static loff_t +pdumpfs_llseek_helper(struct file *filp, loff_t offset, int whence, loff_t max) +{ + loff_t f_pos; + + switch (whence) { + case SEEK_SET: + if ((offset > max) || (offset < 0)) + f_pos = -EINVAL; + else + f_pos = offset; + break; + case SEEK_CUR: + if (((filp->f_pos + offset) > max) || + ((filp->f_pos + offset) < 0)) + f_pos = -EINVAL; + else + f_pos = filp->f_pos + offset; + break; + case SEEK_END: + if ((offset > 0) || + (offset < -max)) + f_pos = -EINVAL; + else + f_pos = max + offset; + break; + default: + f_pos = -EINVAL; + break; + } + + if (f_pos >= 0) + filp->f_pos = f_pos; + + return f_pos; +} + +static loff_t +pdumpfs_init_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(pdumpfs_mutex); + + f_pos = pdumpfs_llseek_helper(filp, offset, whence, frame_init->offset); + + mutex_unlock(pdumpfs_mutex); + + return f_pos; +} + +static ssize_t +pdumpfs_init_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + mutex_lock(pdumpfs_mutex); + + size = pdumpfs_frame_read_single(frame_init, + buf, size, *f_pos); + + mutex_unlock(pdumpfs_mutex); + + if (size > 0) + *f_pos += size; + return size; +} + +static const struct file_operations pdumpfs_init_fops = { + .owner = THIS_MODULE, + .llseek = pdumpfs_init_llseek, + .read = pdumpfs_init_read, +}; + static struct dentry *pdumpfs_dir; static void @@ -530,6 +639,9 @@ pdumpfs_fs_init(void) pdumpfs_file_create("frame_count_max", S_IRUSR | S_IWUSR, &pdumpfs_frame_count_max_fops); + pdumpfs_file_create("init_frame", S_IRUSR, + &pdumpfs_init_fops); + return 0; } -- 1.7.5.4 From 944b6adb887debb93ec2e22ea17637a37c5c46bc Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:52 +0100 Subject: [PATCH 54/95] gpu: pvr: pdumpfs: add debugfs entries for the current frame We keep another pointer to the current_frame around, so that the data in our debugfs files is predictable. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 102 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 101 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 60cb726..931319d 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -63,6 +63,9 @@ static struct pdumpfs_frame *frame_init; static struct pdumpfs_frame *frame_stream; static struct pdumpfs_frame *frame_current; +static struct pdumpfs_frame *frame_current_debugfs; +static int frame_current_open_count; + static struct pdumpfs_frame * frame_create(void) { @@ -93,11 +96,21 @@ frame_destroy(struct pdumpfs_frame *frame) static void frame_destroy_all(void) { + /* detach from possible clones */ + if (frame_current_debugfs && + ((frame_current_debugfs == frame_init) || + (frame_current_debugfs == frame_current) || + frame_current_debugfs->next)) + frame_current_debugfs = NULL; + frame_current = NULL; frame_destroy(frame_init); frame_init = NULL; + frame_destroy(frame_current_debugfs); + frame_current_debugfs = NULL; + while (frame_stream) { struct pdumpfs_frame *frame = frame_stream; @@ -117,7 +130,13 @@ frame_cull(void) frame_stream = frame->next; frame->next = NULL; - frame_destroy(frame); + /* + * we cannot have frames vanish in the middle of reading + * them through debugfs + */ + if (frame != frame_current_debugfs) + frame_destroy(frame); + frame_count--; } } @@ -602,6 +621,85 @@ static const struct file_operations pdumpfs_init_fops = { .read = pdumpfs_init_read, }; +/* + * We need to make sure that our frame doesn't vanish while we are still + * reading it: so reference this frame again. + */ +static int +pdumpfs_current_open(struct inode *inode, struct file *filp) +{ + mutex_lock(pdumpfs_mutex); + + if (!frame_current_open_count) + frame_current_debugfs = frame_current; + + frame_current_open_count++; + + mutex_unlock(pdumpfs_mutex); + return 0; +} + +static int +pdumpfs_current_release(struct inode *inode, struct file *filp) +{ + mutex_lock(pdumpfs_mutex); + + frame_current_open_count--; + + if (!frame_current_open_count) { + if ((frame_current_debugfs != frame_init) && + (frame_current_debugfs != frame_current) && + !frame_current_debugfs->next) + frame_destroy(frame_current_debugfs); + frame_current_debugfs = NULL; + } + + mutex_unlock(pdumpfs_mutex); + return 0; +} + +static loff_t +pdumpfs_current_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(pdumpfs_mutex); + + f_pos = pdumpfs_llseek_helper(filp, offset, whence, + frame_current_debugfs->offset); + + mutex_unlock(pdumpfs_mutex); + + return f_pos; +} + +static ssize_t +pdumpfs_current_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + mutex_lock(pdumpfs_mutex); + + if (frame_current_debugfs->offset) + size = pdumpfs_frame_read_single(frame_current_debugfs, + buf, size, *f_pos); + else + size = 0; + + mutex_unlock(pdumpfs_mutex); + + if (size > 0) + *f_pos += size; + return size; +} + +static const struct file_operations pdumpfs_current_fops = { + .owner = THIS_MODULE, + .llseek = pdumpfs_current_llseek, + .read = pdumpfs_current_read, + .open = pdumpfs_current_open, + .release = pdumpfs_current_release, +}; + static struct dentry *pdumpfs_dir; static void @@ -641,6 +739,8 @@ pdumpfs_fs_init(void) pdumpfs_file_create("init_frame", S_IRUSR, &pdumpfs_init_fops); + pdumpfs_file_create("current_frame", S_IRUSR, + &pdumpfs_current_fops); return 0; } -- 1.7.5.4 From 45035fd4eba6da12dcb9ed63ded27e9ad710b316 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:53 +0100 Subject: [PATCH 55/95] gpu: pvr: pdumpfs: add stream offset tracking Track the size of the stored data, this is split in start and end, so that the next commit can use the start and end to read out the stream correctly, even with vanishing frames (where the missing data can be clearly marked). Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 931319d..651f4f9 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -66,6 +66,9 @@ static struct pdumpfs_frame *frame_current; static struct pdumpfs_frame *frame_current_debugfs; static int frame_current_open_count; +static loff_t stream_start; +static loff_t stream_end; + static struct pdumpfs_frame * frame_create(void) { @@ -119,6 +122,9 @@ frame_destroy_all(void) frame_destroy(frame); frame_count--; } + + stream_start = 0; + stream_end = 0; } static void @@ -130,6 +136,8 @@ frame_cull(void) frame_stream = frame->next; frame->next = NULL; + stream_end -= frame->offset; + /* * we cannot have frames vanish in the middle of reading * them through debugfs @@ -309,6 +317,8 @@ pdumpfs_write_data(void *buffer, size_t size, bool from_user) mutex_lock(pdumpfs_mutex); size = pdumpfs_frame_write(buffer, size, from_user); + if ((size > 0) && (frame_current != frame_init)) + stream_end += size; mutex_unlock(pdumpfs_mutex); @@ -321,9 +331,13 @@ pdumpfs_write_data(void *buffer, size_t size, bool from_user) void pdumpfs_write_string(char *string) { + size_t size; + mutex_lock(pdumpfs_mutex); - pdumpfs_frame_write(string, strlen(string), false); + size = pdumpfs_frame_write(string, strlen(string), false); + if ((size > 0) && (frame_current != frame_init)) + stream_end += size; mutex_unlock(pdumpfs_mutex); } -- 1.7.5.4 From 0e2cd3641a1f61c6cef183282aae6b72cc3fb901 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:54 +0100 Subject: [PATCH 56/95] gpu: pvr: pdumpfs: add stream_frames debugfs entry A mechanism to read out this data reliably is put in place. And data is only lost when the stream is no longer being read or when a hard limit of 1024 frames has been reached when the stream is still open. In case of missing data, the buffer is padded with "..." to make up for the missing bytes and to clear mark them. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 213 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 201 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 651f4f9..23e54da 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -56,6 +56,7 @@ struct pdumpfs_frame { unsigned long pages[FRAME_PAGE_COUNT]; }; +#define MAX_FRAME_COUNT_HARD 1024 static u32 frame_count_max = CONFIG_PVR_PDUMP_INITIAL_MAX_FRAME_COUNT; static u32 frame_count; @@ -65,8 +66,10 @@ static struct pdumpfs_frame *frame_current; static struct pdumpfs_frame *frame_current_debugfs; static int frame_current_open_count; +static int frame_stream_open_count; static loff_t stream_start; +static loff_t stream_f_pos; static loff_t stream_end; static struct pdumpfs_frame * @@ -124,28 +127,44 @@ frame_destroy_all(void) } stream_start = 0; + stream_f_pos = 0; stream_end = 0; } static void -frame_cull(void) +frame_cull_first(void) { - while (frame_count > frame_count_max) { - struct pdumpfs_frame *frame = frame_stream; + struct pdumpfs_frame *frame = frame_stream; - frame_stream = frame->next; - frame->next = NULL; + frame_stream = frame->next; + frame->next = NULL; + if (frame_stream_open_count) + stream_start += frame->offset; + else stream_end -= frame->offset; - /* - * we cannot have frames vanish in the middle of reading - * them through debugfs - */ - if (frame != frame_current_debugfs) - frame_destroy(frame); + /* + * we cannot have frames vanish in the middle of reading + * them through debugfs + */ + if (frame != frame_current_debugfs) + frame_destroy(frame); - frame_count--; + frame_count--; +} + +static void +frame_cull(void) +{ + + if (!frame_stream_open_count) { + while (frame_count > frame_count_max) + frame_cull_first(); + } else { + while (((stream_start + frame_stream->offset) < stream_f_pos) || + (frame_count > MAX_FRAME_COUNT_HARD)) + frame_cull_first(); } } @@ -714,6 +733,174 @@ static const struct file_operations pdumpfs_current_fops = { .release = pdumpfs_current_release, }; +/* + * So we can track when we can alter stream offsets. + */ +static int +pdumpfs_stream_open(struct inode *inode, struct file *filp) +{ + int ret; + + mutex_lock(pdumpfs_mutex); + + if (frame_stream_open_count) + ret = -EUSERS; + else { + frame_stream_open_count++; + ret = 0; + } + + mutex_unlock(pdumpfs_mutex); + return ret; +} + +static int +pdumpfs_stream_release(struct inode *inode, struct file *filp) +{ + mutex_lock(pdumpfs_mutex); + + frame_stream_open_count--; + + /* fix the damage done while it was open */ + if (!frame_stream_open_count) { + stream_end -= stream_start; + stream_start = 0; + stream_f_pos = 0; + } + + mutex_unlock(pdumpfs_mutex); + return 0; +} + +static ssize_t +pdumpfs_stream_buffer_clear(char __user *buf, size_t size) +{ + char tmp[80]; + + memset(tmp, '.', sizeof(tmp) - 1); + tmp[sizeof(tmp) - 1] = '\n'; + + if (size >= sizeof(tmp)) { + int i; + + for (i = 0; (i + sizeof(tmp)) < size; i += sizeof(tmp)) + if (copy_to_user(buf + i, tmp, sizeof(tmp))) + return -EFAULT; + return i; + } else { + if (copy_to_user(buf, tmp + sizeof(tmp) - size, size)) + return -EFAULT; + return size; + } +} + +static ssize_t +pdumpfs_stream_buffer_fill(struct pdumpfs_frame *frame, + char __user *buf, size_t offset, size_t size) +{ + int page = offset / PAGE_SIZE; + + if (size > (frame->offset - offset)) + size = frame->offset - offset; + + offset %= PAGE_SIZE; + + if (size > (PAGE_SIZE - offset)) + size = PAGE_SIZE - offset; + + if (copy_to_user(buf, ((u8 *) frame->pages[page]) + offset, size)) + return -EFAULT; + + stream_f_pos += size; + + return size; +} + +static loff_t +pdumpfs_stream_llseek(struct file *filp, loff_t offset, int whence) +{ + loff_t f_pos; + + mutex_lock(pdumpfs_mutex); + + switch (whence) { + case SEEK_SET: + if ((offset > stream_end) || (offset < stream_start)) + f_pos = -EINVAL; + else + f_pos = offset; + break; + case SEEK_CUR: + if (((filp->f_pos + offset) > stream_end) || + ((filp->f_pos + offset) < stream_start)) + f_pos = -EINVAL; + else + f_pos = filp->f_pos + offset; + break; + case SEEK_END: + if ((offset > 0) || + (offset < (stream_start - stream_end))) + f_pos = -EINVAL; + else + f_pos = stream_end + offset; + break; + default: + f_pos = -EINVAL; + break; + } + + if (f_pos >= 0) { + filp->f_pos = f_pos; + stream_f_pos = f_pos; + } + + mutex_unlock(pdumpfs_mutex); + + return f_pos; +} + +static ssize_t +pdumpfs_stream_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + size_t ret = 0; + + mutex_lock(pdumpfs_mutex); + + if ((stream_end <= 0) || (*f_pos >= stream_end)) + ret = 0; + else if (*f_pos < stream_start) { + if (size > (stream_start - *f_pos)) + size = stream_start - *f_pos; + ret = pdumpfs_stream_buffer_clear(buf, size); + } else { + loff_t start = stream_start; + struct pdumpfs_frame *frame = frame_stream; + + /* skip frames that are before our offset */ + while ((start + frame->offset) <= *f_pos) { + start += frame->offset; + frame = frame->next; + } + + ret = pdumpfs_stream_buffer_fill(frame, buf, *f_pos - start, + size); + } + + if (ret > 0) + *f_pos += ret; + mutex_unlock(pdumpfs_mutex); + return ret; +} + +static const struct file_operations pdumpfs_stream_fops = { + .owner = THIS_MODULE, + .llseek = pdumpfs_stream_llseek, + .read = pdumpfs_stream_read, + .open = pdumpfs_stream_open, + .release = pdumpfs_stream_release, +}; + static struct dentry *pdumpfs_dir; static void @@ -755,6 +942,8 @@ pdumpfs_fs_init(void) &pdumpfs_init_fops); pdumpfs_file_create("current_frame", S_IRUSR, &pdumpfs_current_fops); + pdumpfs_file_create("stream_frames", S_IRUSR, + &pdumpfs_stream_fops); return 0; } -- 1.7.5.4 From e146f91a90a2b72c243a5462e126f9bfd5c7320b Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 11 Mar 2011 15:02:55 +0100 Subject: [PATCH 57/95] gpu: pvr: pdumpfs: fix for imgtec simulator When full dumping is enabled through init, the simulator throws in the towel on the dumped CCB wait at the end of initialisation. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 23e54da..6050fd3 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -215,7 +215,8 @@ pdumpfs_capture_enabled(void) mutex_lock(pdumpfs_mutex); - if (pdumpfs_mode == PDUMPFS_MODE_FULL) + if ((pdumpfs_mode == PDUMPFS_MODE_FULL) && + (frame_current != frame_init)) /* simulator bails otherwise */ ret = true; else ret = false; @@ -235,10 +236,12 @@ pdumpfs_flags_check(u32 flags) mutex_lock(pdumpfs_mutex); - if (pdumpfs_mode == PDUMPFS_MODE_FULL) + if (pdumpfs_mode == PDUMPFS_MODE_DISABLED) + ret = false; + else if ((pdumpfs_mode == PDUMPFS_MODE_FULL) && + (frame_current != frame_init)) /* simulator bails otherwise */ ret = true; - else if ((pdumpfs_mode == PDUMPFS_MODE_STANDARD) && - (flags & PDUMP_FLAGS_CONTINUOUS)) + else if (flags & PDUMP_FLAGS_CONTINUOUS) ret = true; else ret = false; -- 1.7.5.4 From 19d9518417e970d69eb8e056d4f96f60db54ef25 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 22 Mar 2011 16:18:20 +0200 Subject: [PATCH 58/95] gpu: pvr: change snprintf to scnprintf snprintf returns how many characters _would_ have been written if there had been enough space, whereas scnprintf returns the actual numer of written characters. The latter fits better our use case. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 81761cd..ed2c795 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -139,7 +139,7 @@ edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) buf = sdev->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; - p += snprintf(dst + p, dst_len - p, + p += scnprintf(dst + p, dst_len - p, "Last SGX microkernel status code: 0x%x\n", *buf); buf++; wr_ofs = *buf; @@ -152,7 +152,8 @@ edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) /* Dump the status values */ for (i = 0; i < SGXMK_TRACE_BUFFER_SIZE; i++) { - p += snprintf(dst + p, dst_len - p, "%3d %08X %08X %08X %08X\n", + p += scnprintf(dst + p, dst_len - p, + "%3d %08X %08X %08X %08X\n", i, buf[2], buf[3], buf[1], buf[0]); buf += 4; if (buf >= buf_end) -- 1.7.5.4 From 7af9cd25672295442a19d84c941fe11c20829075 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 22 Mar 2011 16:57:04 +0200 Subject: [PATCH 59/95] gpu: pvr: reinstate dumping EDM trace to syslog Since at the moment we don't have any other means to get the EDM trace for core-matic reports, dump the trace to syslog, which will be picked up by the core-matic report generating tool. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/Makefile | 4 ++-- drivers/gpu/pvr/pvr_debugfs.c | 20 ++++++++++++++------ drivers/gpu/pvr/pvr_debugfs.h | 7 +++---- drivers/gpu/pvr/sgxinit.c | 3 +++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 69534d6..0e5bd28 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -10,10 +10,10 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o proc.o \ sgxinit.o sgxreset.o sgxutils.o sgxkick.o \ sgxtransfer.o mmu.o pb.o perproc.o sysconfig.o \ sysutils.o osperproc.o bridged_support.o \ - bridged_sgx_bridge.o sgxpower.o pvr_events.o + bridged_sgx_bridge.o sgxpower.o pvr_events.o \ + pvr_debugfs.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o -pvrsrvkm-objs-$(CONFIG_DEBUG_FS) += pvr_debugfs.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG_PDUMP) += pvr_pdump.o pvr_pdumpfs.o diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index ed2c795..9d4fc4c 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -124,7 +124,7 @@ struct edm_buf_info { char data[1]; }; -static size_t +size_t edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) { u32 *buf_start; @@ -139,8 +139,12 @@ edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) buf = sdev->psKernelEDMStatusBufferMemInfo->pvLinAddrKM; - p += scnprintf(dst + p, dst_len - p, - "Last SGX microkernel status code: 0x%x\n", *buf); + if (dst) + p += scnprintf(dst + p, dst_len - p, + "Last SGX microkernel status code: 0x%x\n", *buf); + else + printk(KERN_DEBUG "Last SGX microkernel status code: 0x%x\n", + *buf); buf++; wr_ofs = *buf; buf++; @@ -152,9 +156,13 @@ edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, size_t dst_len) /* Dump the status values */ for (i = 0; i < SGXMK_TRACE_BUFFER_SIZE; i++) { - p += scnprintf(dst + p, dst_len - p, - "%3d %08X %08X %08X %08X\n", - i, buf[2], buf[3], buf[1], buf[0]); + if (dst) + p += scnprintf(dst + p, dst_len - p, + "%3d %08X %08X %08X %08X\n", + i, buf[2], buf[3], buf[1], buf[0]); + else + printk(KERN_DEBUG "%3d %08X %08X %08X %08X\n", + i, buf[2], buf[3], buf[1], buf[0]); buf += 4; if (buf >= buf_end) buf = buf_start; diff --git a/drivers/gpu/pvr/pvr_debugfs.h b/drivers/gpu/pvr/pvr_debugfs.h index 32aa38b..c60f3e8 100644 --- a/drivers/gpu/pvr/pvr_debugfs.h +++ b/drivers/gpu/pvr/pvr_debugfs.h @@ -20,10 +20,6 @@ #ifndef _PVR_DEBUGFS_H_ #define _PVR_DEBUGFS_H_ 1 -#ifndef CONFIG_DEBUG_FS -#error Error: debugfs header included but CONFIG_DEBUG_FS is not defined! -#endif - extern struct dentry *pvr_debugfs_dir; int pvr_debugfs_init(void); @@ -32,6 +28,9 @@ void pvr_debugfs_cleanup(void); void pvr_hwrec_dump(struct PVRSRV_PER_PROCESS_DATA *proc_data, struct PVRSRV_SGXDEV_INFO *psDevInfo); +size_t edm_trace_print(struct PVRSRV_SGXDEV_INFO *sdev, char *dst, + size_t dst_len); + #ifdef CONFIG_PVR_DEBUG /* to be used for memory dumping from mmu.c */ int hwrec_mem_write(u8 *buffer, size_t size); diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 210c66d..6170038 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -697,6 +697,9 @@ HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode, const char *caller) pr_err_process_info(proc); pr_err_sgx_registers(psDevInfo); +#ifdef PVRSRV_USSE_EDM_STATUS_DEBUG + edm_trace_print(psDevInfo, NULL, 0); +#endif #ifdef CONFIG_DEBUG_FS pvr_hwrec_dump(proc, psDevInfo); -- 1.7.5.4 From f0a0afd5659ff5d154436eec348631296fecb5a7 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:18:27 +0300 Subject: [PATCH 60/95] gpu: pvr: fix error path in PVRSRVRegisterBCDeviceKM Fixing a free with incorrect size and converting another one to use free(p, sizeof(*p)) instead of free(p, sizeof(typeof(*p)). Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index c5374e5..88dd6e8 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -355,11 +355,10 @@ ErrorExit: if (psBCInfo->psFuncTable) OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(struct PVRSRV_BC_SRV2BUFFER_KMJTABLE *), - psBCInfo->psFuncTable, NULL); + sizeof(*psBCInfo->psFuncTable), psBCInfo->psFuncTable, + NULL); - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(struct PVRSRV_BUFFERCLASS_INFO), psBCInfo, NULL); + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(*psBCInfo), psBCInfo, NULL); return PVRSRV_ERROR_OUT_OF_MEMORY; } -- 1.7.5.4 From 1d2e0e74a84db64887f27d0340bfeced8e5d813e Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 15:13:08 +0300 Subject: [PATCH 61/95] gpu: pvr: refactor error path in PVRSRVOpenBCDeviceKM Needed by the next 2 patches fixing the error path. No functional change. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index 88dd6e8..826f2a7 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -1364,7 +1364,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenBCDeviceKM: " "Failed to open external BC device"); - return eError; + goto err1; } eError = @@ -1373,7 +1373,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenBCDeviceKM : Failed to get BC Info"); - return eError; + goto err2; } psBCInfo->ui32BufferCount = sBufferInfo.ui32BufferCount; @@ -1386,7 +1386,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenBCDeviceKM: " "Failed to allocate BC buffers"); - return eError; + goto err2; } OSMemSet(psBCInfo->psBuffer, 0, sizeof(struct PVRSRV_BC_BUFFER) * @@ -1401,7 +1401,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenBCDeviceKM: " "Failed sync info alloc"); - goto ErrorExit; + goto err3; } eError = psBCInfo->psFuncTable->pfnGetBCBuffer( @@ -1414,7 +1414,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenBCDeviceKM: " "Failed to get BC buffers"); - goto ErrorExit; + goto err3; } psBCInfo->psBuffer[i].sDeviceClassBuffer. @@ -1437,8 +1437,7 @@ FoundDevice: return PVRSRV_OK; -ErrorExit: - +err3: for (i = 0; i < psBCInfo->ui32BufferCount; i++) { if (psBCInfo->psBuffer[i].sDeviceClassBuffer.psKernelSyncInfo) { PVRSRVFreeSyncInfoKM(psBCInfo->psBuffer[i]. @@ -1452,7 +1451,8 @@ ErrorExit: sizeof(struct PVRSRV_BC_BUFFER), psBCInfo->psBuffer, NULL); } - +err2: +err1: return eError; } -- 1.7.5.4 From 373a31d51fd2d7eb1480373ad2af594c31de5388 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 15:45:07 +0300 Subject: [PATCH 62/95] gpu: pvr: fix incorrect free size in PVRSRVOpenBCDeviceKM Also remove the always true condition. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index 826f2a7..cfbe18e 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -1304,6 +1304,7 @@ enum PVRSRV_ERROR PVRSRVOpenBCDeviceKM( struct PVRSRV_BUFFERCLASS_INFO *psBCInfo; struct PVRSRV_BUFFERCLASS_PERCONTEXT_INFO *psBCPerContextInfo; struct PVRSRV_DEVICE_NODE *psDeviceNode; + struct BUFFER_INFO sBufferInfo; struct SYS_DATA *psSysData; u32 i; enum PVRSRV_ERROR eError; @@ -1351,8 +1352,6 @@ FoundDevice: OSMemSet(psBCPerContextInfo, 0, sizeof(*psBCPerContextInfo)); if (psBCInfo->ui32RefCount++ == 0) { - struct BUFFER_INFO sBufferInfo; - psDeviceNode = (struct PVRSRV_DEVICE_NODE *)hDevCookie; psBCInfo->hDevMemContext = @@ -1445,12 +1444,9 @@ err3: psKernelSyncInfo); } } - - if (psBCInfo->psBuffer) { - OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, - sizeof(struct PVRSRV_BC_BUFFER), psBCInfo->psBuffer, - NULL); - } + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, + sizeof(struct PVRSRV_BC_BUFFER) * sBufferInfo.ui32BufferCount, + psBCInfo->psBuffer, NULL); err2: err1: return eError; -- 1.7.5.4 From 7e449affee516102b959238b31383baafd0d8c71 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 15:37:04 +0300 Subject: [PATCH 63/95] gpu: pvr: fix error path in PVRSRVOpenBCDeviceKM Add missing frees / ref count rollback. Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index cfbe18e..ed959d7 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -1448,7 +1448,12 @@ err3: sizeof(struct PVRSRV_BC_BUFFER) * sBufferInfo.ui32BufferCount, psBCInfo->psBuffer, NULL); err2: + psBCInfo->psFuncTable->pfnCloseBCDevice(psBCInfo->hExtDevice); err1: + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(*psBCPerContextInfo), + psBCPerContextInfo, NULL); + psBCInfo->ui32RefCount--; + return eError; } -- 1.7.5.4 From d9f51e4fec37c806ab3560bd659d5777007afd30 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:25:08 +0300 Subject: [PATCH 64/95] gpu: pvr: refactor error path in PVRSRVOpenDCDeviceKM Needed by the next patch fixing the error path. No functional change. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index ed959d7..dd3bcce 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -486,8 +486,10 @@ enum PVRSRV_ERROR PVRSRVOpenDCDeviceKM( { struct PVRSRV_DISPLAYCLASS_INFO *psDCInfo; struct PVRSRV_DISPLAYCLASS_PERCONTEXT_INFO *psDCPerContextInfo; + struct PVRSRV_DC_SRV2DISP_KMJTABLE *jtbl; struct PVRSRV_DEVICE_NODE *psDeviceNode; struct SYS_DATA *psSysData; + enum PVRSRV_ERROR eError; if (!phDeviceKM || !hDevCookie) { PVR_DPF(PVR_DBG_ERROR, @@ -531,15 +533,14 @@ FoundDevice: OSMemSet(psDCPerContextInfo, 0, sizeof(*psDCPerContextInfo)); if (psDCInfo->ui32RefCount++ == 0) { - enum PVRSRV_ERROR eError; - struct PVRSRV_DC_SRV2DISP_KMJTABLE *jtbl; - psDeviceNode = (struct PVRSRV_DEVICE_NODE *)hDevCookie; jtbl = psDCInfo->psFuncTable; if (!try_module_get(jtbl->owner)) { PVR_DPF(PVR_DBG_ERROR, "%s: can't get DC module"); - return PVRSRV_ERROR_INVALID_DEVICE; + eError = PVRSRV_ERROR_INVALID_DEVICE; + + goto err1; } psDCInfo->hDevMemContext = @@ -554,9 +555,8 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenDCDeviceKM: Failed sync info alloc"); - psDCInfo->ui32RefCount--; - module_put(jtbl->owner); - return eError; + + goto err2; } eError = jtbl->pfnOpenDCDevice(ui32DeviceID, @@ -567,11 +567,7 @@ FoundDevice: if (eError != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVOpenDCDeviceKM: " "Failed to open external DC device"); - psDCInfo->ui32RefCount--; - module_put(jtbl->owner); - PVRSRVFreeSyncInfoKM(psDCInfo->sSystemBuffer. - sDeviceClassBuffer.psKernelSyncInfo); - return eError; + goto err3; } } @@ -584,6 +580,14 @@ FoundDevice: *phDeviceKM = (void *) psDCPerContextInfo; return PVRSRV_OK; +err3: + PVRSRVFreeSyncInfoKM(psDCInfo->sSystemBuffer. + sDeviceClassBuffer.psKernelSyncInfo); +err2: + module_put(jtbl->owner); + psDCInfo->ui32RefCount--; +err1: + return eError; } enum PVRSRV_ERROR PVRSRVEnumDCFormatsKM(void *hDeviceKM, -- 1.7.5.4 From a4f14ca54c85d7711504db7d0c53c00603437bab Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:25:08 +0300 Subject: [PATCH 65/95] gpu: pvr: fix error path in PVRSRVOpenDCDeviceKM Add missing free. Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/deviceclass.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/deviceclass.c b/drivers/gpu/pvr/deviceclass.c index dd3bcce..d7f3f21 100644 --- a/drivers/gpu/pvr/deviceclass.c +++ b/drivers/gpu/pvr/deviceclass.c @@ -587,6 +587,9 @@ err2: module_put(jtbl->owner); psDCInfo->ui32RefCount--; err1: + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(*psDCPerContextInfo), + psDCPerContextInfo, NULL); + return eError; } -- 1.7.5.4 From ef3c90b8a0d66d8eaa37c8df9c250be6e2aca209 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:26:54 +0300 Subject: [PATCH 66/95] gpu: pvr: fix PVRSRVWrapExtMemoryKM for user provided physical pages Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/devicemem.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/devicemem.c b/drivers/gpu/pvr/devicemem.c index 881cf24..eb57ea3 100644 --- a/drivers/gpu/pvr/devicemem.c +++ b/drivers/gpu/pvr/devicemem.c @@ -713,7 +713,7 @@ enum PVRSRV_ERROR PVRSRVWrapExtMemoryKM(void *hDevCookie, psDeviceNode = (struct PVRSRV_DEVICE_NODE *)hDevCookie; PVR_ASSERT(psDeviceNode != NULL); - if (psDeviceNode == NULL) { + if (!psDeviceNode || (!pvLinAddr && !psExtSysPAddr)) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVWrapExtMemoryKM: invalid parameter"); return PVRSRV_ERROR_INVALID_PARAMS; -- 1.7.5.4 From 2c13845e742d4b7adcfcb95d81d1a194481b46cb Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:29:12 +0300 Subject: [PATCH 67/95] gpu: pvr: fix error path in hash _Resize Add missing free in case of _Rehash fails. Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/hash.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/hash.c b/drivers/gpu/pvr/hash.c index 56eacb7..9cbeb9e 100644 --- a/drivers/gpu/pvr/hash.c +++ b/drivers/gpu/pvr/hash.c @@ -150,13 +150,14 @@ static IMG_BOOL _Resize(struct HASH_TABLE *pHash, u32 uNewSize) if (uNewSize != pHash->uSize) { struct BUCKET **ppNewTable; u32 uIndex; + size_t table_size; PVR_DPF(PVR_DBG_MESSAGE, "HASH_Resize: oldsize=0x%x newsize=0x%x count=0x%x", pHash->uSize, uNewSize, pHash->uCount); - if (OSAllocMem(PVRSRV_PAGEABLE_SELECT, - sizeof(struct BUCKET *) * uNewSize, + table_size = sizeof(struct BUCKET *) * uNewSize; + if (OSAllocMem(PVRSRV_PAGEABLE_SELECT, table_size, (void **) &ppNewTable, NULL) != PVRSRV_OK) return IMG_FALSE; @@ -164,8 +165,11 @@ static IMG_BOOL _Resize(struct HASH_TABLE *pHash, u32 uNewSize) ppNewTable[uIndex] = NULL; if (_Rehash(pHash, pHash->ppBucketTable, pHash->uSize, - ppNewTable, uNewSize) != PVRSRV_OK) + ppNewTable, uNewSize) != PVRSRV_OK) { + OSFreeMem(PVRSRV_PAGEABLE_SELECT, table_size, + ppNewTable, NULL); return IMG_FALSE; + } OSFreeMem(PVRSRV_PAGEABLE_SELECT, sizeof(struct BUCKET *) * pHash->uSize, -- 1.7.5.4 From e60a396f645715a4ae80ebd6a2fa8ec08da0e131 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 14:33:14 +0300 Subject: [PATCH 68/95] gpu: pvr: optimize mem clear in hash _Resize Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/hash.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/pvr/hash.c b/drivers/gpu/pvr/hash.c index 9cbeb9e..bfee500 100644 --- a/drivers/gpu/pvr/hash.c +++ b/drivers/gpu/pvr/hash.c @@ -149,7 +149,6 @@ static IMG_BOOL _Resize(struct HASH_TABLE *pHash, u32 uNewSize) { if (uNewSize != pHash->uSize) { struct BUCKET **ppNewTable; - u32 uIndex; size_t table_size; PVR_DPF(PVR_DBG_MESSAGE, @@ -161,8 +160,7 @@ static IMG_BOOL _Resize(struct HASH_TABLE *pHash, u32 uNewSize) (void **) &ppNewTable, NULL) != PVRSRV_OK) return IMG_FALSE; - for (uIndex = 0; uIndex < uNewSize; uIndex++) - ppNewTable[uIndex] = NULL; + memset(ppNewTable, 0, table_size); if (_Rehash(pHash, pHash->ppBucketTable, pHash->uSize, ppNewTable, uNewSize) != PVRSRV_OK) { -- 1.7.5.4 From fa37aaf9963a7051c003f6e83ebd0c04fa6c648b Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:29:44 +0300 Subject: [PATCH 69/95] gpu: pvr: fix error path in MMU_Initialise Add missing frees / unmapping at various failure points. Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/mmu.c | 31 +++++++++++++++++++++++++------ 1 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/pvr/mmu.c b/drivers/gpu/pvr/mmu.c index 0c68876..8fec04f 100644 --- a/drivers/gpu/pvr/mmu.c +++ b/drivers/gpu/pvr/mmu.c @@ -474,6 +474,7 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, void *pvPDCpuVAddr; struct IMG_DEV_PHYADDR sPDDevPAddr; struct IMG_CPU_PHYADDR sCpuPAddr; + struct IMG_SYS_PHYADDR sSysPAddr; struct MMU_CONTEXT *psMMUContext; void *hPDOSMemHandle; struct SYS_DATA *psSysData; @@ -508,7 +509,7 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, &hPDOSMemHandle) != PVRSRV_OK) { PVR_DPF(PVR_DBG_ERROR, "MMU_Initialise: " "ERROR call to OSAllocPages failed"); - return PVRSRV_ERROR_GENERIC; + goto err1; } if (pvPDCpuVAddr) @@ -518,14 +519,13 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, sPDDevPAddr = SysCpuPAddrToDevPAddr(PVRSRV_DEVICE_TYPE_SGX, sCpuPAddr); } else { - struct IMG_SYS_PHYADDR sSysPAddr; - if (RA_Alloc(psDeviceNode->psLocalDevMemArena, SGX_MMU_PAGE_SIZE, NULL, 0, SGX_MMU_PAGE_SIZE, &(sSysPAddr.uiAddr)) != IMG_TRUE) { PVR_DPF(PVR_DBG_ERROR, "MMU_Initialise: " "ERROR call to RA_Alloc failed"); - return PVRSRV_ERROR_GENERIC; + + goto err1; } sCpuPAddr = SysSysPAddrToCpuPAddr(sSysPAddr); @@ -538,7 +538,8 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, if (!pvPDCpuVAddr) { PVR_DPF(PVR_DBG_ERROR, "MMU_Initialise: " "ERROR failed to map page tables"); - return PVRSRV_ERROR_GENERIC; + + goto err2; } } @@ -551,7 +552,7 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, } else { PVR_DPF(PVR_DBG_ERROR, "MMU_Initialise: pvPDCpuVAddr invalid"); - return PVRSRV_ERROR_GENERIC; + goto err3; } for (i = 0; i < SGX_MMU_PD_SIZE; i++) @@ -575,6 +576,24 @@ enum PVRSRV_ERROR MMU_Initialise(struct PVRSRV_DEVICE_NODE *psDeviceNode, return PVRSRV_OK; +err3: + if (psDeviceNode->psLocalDevMemArena) + OSUnMapPhysToLin((void __iomem __force *)pvPDCpuVAddr, + SGX_MMU_PAGE_SIZE, PVRSRV_HAP_WRITECOMBINE | + PVRSRV_HAP_KERNEL_ONLY, + hPDOSMemHandle); +err2: + if (!psDeviceNode->psLocalDevMemArena) + OSFreePages(PVRSRV_HAP_WRITECOMBINE | PVRSRV_HAP_KERNEL_ONLY, + SGX_MMU_PAGE_SIZE, pvPDCpuVAddr, hPDOSMemHandle); + else + RA_Free(psDeviceNode->psLocalDevMemArena, + sSysPAddr.uiAddr, IMG_FALSE); +err1: + OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP, sizeof(struct MMU_CONTEXT), + psMMUContext, NULL); + + return PVRSRV_ERROR_GENERIC; } void MMU_Finalise(struct MMU_CONTEXT *psMMUContext) -- 1.7.5.4 From 2bed85ed6faba092388d582f8be3e8a6e79221dc Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 29 Mar 2011 20:30:47 +0300 Subject: [PATCH 70/95] gpu: pvr: fix state buffer validation The incorrect comparison size could cause a corrupted buffer info to be regarded as valid. Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 9d4fc4c..4a9e068 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -413,7 +413,8 @@ static void add_uniq_items(struct render_state_buf_list *dst, for (j = 0; j < dst->cnt; j++) { if (sbinf->buf_id == dst->info[j].buf_id) { - if (memcmp(sbinf, &dst->info[j], sizeof(sbinf))) + if (memcmp(sbinf, &dst->info[j], + sizeof(*sbinf))) dst->info[j].type |= BUF_DESC_CORRUPT; break; } -- 1.7.5.4 From 6a67a6b8541a3914649e10c1b211e8365b9d86e7 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 14:36:09 +0300 Subject: [PATCH 71/95] gpu: pvr: fix error path in SysInitialise Add missing check for the mem allocation result. Fixes: NB#241787 - missing check of return value of OSReservePhys() Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/sysconfig.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/sysconfig.c b/drivers/gpu/pvr/sysconfig.c index 45b9d1f..94f18f6 100644 --- a/drivers/gpu/pvr/sysconfig.c +++ b/drivers/gpu/pvr/sysconfig.c @@ -303,10 +303,16 @@ enum PVRSRV_ERROR SysInitialise(struct platform_device *pdev) SYS_OMAP3430_GP11TIMER_PHYS_BASE + SYS_OMAP3430_GPTIMER_REGS; gpsSysData->pvSOCTimerRegisterKM = NULL; gpsSysData->hSOCTimerRegisterOSMemHandle = NULL; - OSReservePhys(TimerRegPhysBase, 4, + eError = OSReservePhys(TimerRegPhysBase, 4, PVRSRV_HAP_MULTI_PROCESS | PVRSRV_HAP_UNCACHED, (void **)&gpsSysData->pvSOCTimerRegisterKM, &gpsSysData->hSOCTimerRegisterOSMemHandle); + if (eError != PVRSRV_OK) { + PVR_DPF(PVR_DBG_ERROR, "%s: OSReservePhys failed"); + SysDeinitialise(gpsSysData); + gpsSysData = NULL; + return eError; + } gpsSysSpecificData->ui32SrcClockDiv = 3; -- 1.7.5.4 From fabcad6c1b1c9a3bf76f4d6da5440293a88ae2dd Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Wed, 30 Mar 2011 15:06:21 +0300 Subject: [PATCH 72/95] gpu: pvr: remove dead code from the PVRSRVGetFBStatsKM code path Reported-by: Coverity Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com> --- drivers/gpu/pvr/buffer_manager.c | 8 -------- drivers/gpu/pvr/pvr_bridge_km.h | 2 -- drivers/gpu/pvr/pvrsrv.c | 19 ------------------- 3 files changed, 0 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/pvr/buffer_manager.c b/drivers/gpu/pvr/buffer_manager.c index 6c4023e..ab41cf2 100644 --- a/drivers/gpu/pvr/buffer_manager.c +++ b/drivers/gpu/pvr/buffer_manager.c @@ -1078,14 +1078,6 @@ void *BM_HandleToOSMemHandle(void *hBuf) return pBuf->hOSMemHandle; } -IMG_BOOL BM_ContiguousStatistics(u32 uFlags, u32 *pTotalBytes, - u32 *pAvailableBytes) -{ - if (pAvailableBytes || pTotalBytes || uFlags) - ; - return IMG_FALSE; -} - static IMG_BOOL DevMemoryAlloc(struct BM_CONTEXT *pBMContext, struct BM_MAPPING *pMapping, u32 uFlags, u32 dev_vaddr_alignment, struct IMG_DEV_VIRTADDR *pDevVAddr) diff --git a/drivers/gpu/pvr/pvr_bridge_km.h b/drivers/gpu/pvr/pvr_bridge_km.h index 55392f2..2dfe577 100644 --- a/drivers/gpu/pvr/pvr_bridge_km.h +++ b/drivers/gpu/pvr/pvr_bridge_km.h @@ -205,8 +205,6 @@ enum PVRSRV_ERROR PVRSRVFreeSyncInfoKM( enum PVRSRV_ERROR PVRSRVGetMiscInfoKM(struct PVRSRV_MISC_INFO *psMiscInfo); -enum PVRSRV_ERROR PVRSRVGetFBStatsKM(u32 *pui32Total, u32 *pui32Available); - enum PVRSRV_ERROR PVRSRVAllocSharedSysMemoryKM( struct PVRSRV_PER_PROCESS_DATA *psPerProc, u32 ui32Flags, u32 ui32Size, struct PVRSRV_KERNEL_MEM_INFO **ppsKernelMemInfo); diff --git a/drivers/gpu/pvr/pvrsrv.c b/drivers/gpu/pvr/pvrsrv.c index 2bfb856..c0309b1 100644 --- a/drivers/gpu/pvr/pvrsrv.c +++ b/drivers/gpu/pvr/pvrsrv.c @@ -698,25 +698,6 @@ enum PVRSRV_ERROR PVRSRVGetMiscInfoKM(struct PVRSRV_MISC_INFO *psMiscInfo) return PVRSRV_OK; } -enum PVRSRV_ERROR PVRSRVGetFBStatsKM(u32 *pui32Total, u32 *pui32Available) -{ - u32 ui32Total = 0, i = 0; - u32 ui32Available = 0; - - *pui32Total = 0; - *pui32Available = 0; - - while (BM_ContiguousStatistics(i, &ui32Total, &ui32Available) == - IMG_TRUE) { - *pui32Total += ui32Total; - *pui32Available += ui32Available; - - i++; - } - - return PVRSRV_OK; -} - IMG_BOOL PVRSRVDeviceLISR(struct PVRSRV_DEVICE_NODE *psDeviceNode) { struct SYS_DATA *psSysData; -- 1.7.5.4 From a52badfdb289bd6d37ee8b3d86ea0195c2935488 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 17:59:41 +0300 Subject: [PATCH 73/95] gpu: pvr: get rid of unnecessary hash lookups for the proc object We already are passed a pointer to the process specific data, so no need to do an extra hash lookup just for this purpose. Note that this lookup overhead was incured in each IOCTL command. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/module.c | 1 + drivers/gpu/pvr/private_data.h | 1 + drivers/gpu/pvr/pvr_bridge_k.c | 25 +++++-------------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/pvr/module.c b/drivers/gpu/pvr/module.c index 7543579..da8e944 100644 --- a/drivers/gpu/pvr/module.c +++ b/drivers/gpu/pvr/module.c @@ -95,6 +95,7 @@ static int pvr_open(struct inode unref__ * inode, struct file *filp) priv->ui32OpenPID = pid; priv->hBlockAlloc = block_alloc; + priv->proc = PVRSRVPerProcessData(pid); filp->private_data = priv; INIT_LIST_HEAD(&priv->event_list); diff --git a/drivers/gpu/pvr/private_data.h b/drivers/gpu/pvr/private_data.h index b91b838..209134f 100644 --- a/drivers/gpu/pvr/private_data.h +++ b/drivers/gpu/pvr/private_data.h @@ -33,6 +33,7 @@ struct PVRSRV_FILE_PRIVATE_DATA { u32 ui32OpenPID; void *hBlockAlloc; + struct PVRSRV_PER_PROCESS_DATA *proc; wait_queue_head_t event_wait; struct list_head event_list; diff --git a/drivers/gpu/pvr/pvr_bridge_k.c b/drivers/gpu/pvr/pvr_bridge_k.c index 4cbc041..7489f65 100644 --- a/drivers/gpu/pvr/pvr_bridge_k.c +++ b/drivers/gpu/pvr/pvr_bridge_k.c @@ -173,6 +173,7 @@ long PVRSRV_BridgeDispatchKM(struct file *filp, unsigned int cmd, (struct PVRSRV_BRIDGE_PACKAGE __user *)arg; struct PVRSRV_BRIDGE_PACKAGE sBridgePackageKM; u32 ui32PID = OSGetCurrentProcessIDKM(); + struct PVRSRV_FILE_PRIVATE_DATA *priv; struct PVRSRV_PER_PROCESS_DATA *psPerProc; int err = -EFAULT; @@ -196,21 +197,12 @@ long PVRSRV_BridgeDispatchKM(struct file *filp, unsigned int cmd, sizeof(struct PVRSRV_BRIDGE_PACKAGE)) != PVRSRV_OK) goto unlock_and_return; + priv = filp->private_data; + psPerProc = priv->proc; + BUG_ON(!psPerProc); + if (ui32BridgeID != PVRSRV_GET_BRIDGE_ID(PVRSRV_BRIDGE_CONNECT_SERVICES)) { - enum PVRSRV_ERROR eError; - - eError = PVRSRVLookupHandle(KERNEL_HANDLE_BASE, - (void **)&psPerProc, - sBridgePackageKM.hKernelServices, - PVRSRV_HANDLE_TYPE_PERPROC_DATA); - if (eError != PVRSRV_OK) { - PVR_DPF(PVR_DBG_ERROR, - "%s: Invalid kernel services handle (%d)", - __func__, eError); - goto unlock_and_return; - } - if (psPerProc->ui32PID != ui32PID) { PVR_DPF(PVR_DBG_ERROR, "%s: Process %d tried to access data " @@ -218,13 +210,6 @@ long PVRSRV_BridgeDispatchKM(struct file *filp, unsigned int cmd, ui32PID, psPerProc->ui32PID); goto unlock_and_return; } - } else { - psPerProc = PVRSRVPerProcessData(ui32PID); - if (psPerProc == NULL) { - PVR_DPF(PVR_DBG_ERROR, "PVRSRV_BridgeDispatchKM: " - "Couldn't create per-process data area"); - goto unlock_and_return; - } } sBridgePackageKM.ui32BridgeID = PVRSRV_GET_BRIDGE_ID( -- 1.7.5.4 From 9a8e11cfe15db4fff5ed9977412191022d76dc8a Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:03:46 +0300 Subject: [PATCH 74/95] gpu: pvr: add missing headers to osfunc.h Headers should include all type info used within the header. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/osfunc.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/osfunc.h b/drivers/gpu/pvr/osfunc.h index 2d79af9..0419d4f 100644 --- a/drivers/gpu/pvr/osfunc.h +++ b/drivers/gpu/pvr/osfunc.h @@ -33,6 +33,9 @@ #include <linux/string.h> #endif +#include "services.h" +#include "servicesext.h" + #define PVRSRV_PAGEABLE_SELECT PVRSRV_OS_PAGEABLE_HEAP #define KERNEL_ID 0xffffffffL -- 1.7.5.4 From b680ae65c0553c640637fc25cd2125747c136f2b Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:05:39 +0300 Subject: [PATCH 75/95] gpu: pvr: get proc name during process attach time This will be needed by the upcoming patches where we need a cheap way to get to the current process name. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/osfunc.c | 10 ++++++++++ drivers/gpu/pvr/osfunc.h | 2 ++ drivers/gpu/pvr/perproc.c | 3 +++ drivers/gpu/pvr/perproc.h | 3 +++ 4 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/osfunc.c b/drivers/gpu/pvr/osfunc.c index c3c36ac..b14994c 100644 --- a/drivers/gpu/pvr/osfunc.c +++ b/drivers/gpu/pvr/osfunc.c @@ -1122,6 +1122,16 @@ enum PVRSRV_ERROR OSCopyFromUser(void *pvProcess, void *pvDest, return PVRSRV_ERROR_GENERIC; } +void get_proc_name(int pid, char *buf, size_t buf_size) +{ + struct task_struct *tsk; + + rcu_read_lock(); + tsk = pid_task(find_vpid(pid), PIDTYPE_PID); + strlcpy(buf, tsk->comm, buf_size); + rcu_read_unlock(); +} + IMG_BOOL OSAccessOK(enum IMG_VERIFY_TEST eVerification, const void __user *pvUserPtr, u32 ui32Bytes) { diff --git a/drivers/gpu/pvr/osfunc.h b/drivers/gpu/pvr/osfunc.h index 0419d4f..158034c 100644 --- a/drivers/gpu/pvr/osfunc.h +++ b/drivers/gpu/pvr/osfunc.h @@ -216,4 +216,6 @@ enum PVRSRV_ERROR OSAcquirePhysPageAddr(void *pvCPUVAddr, u32 ui32Bytes, void **phOSWrapMem); enum PVRSRV_ERROR OSReleasePhysPageAddr(void *hOSWrapMem); +void get_proc_name(int pid, char *buf, size_t buf_size); + #endif diff --git a/drivers/gpu/pvr/perproc.c b/drivers/gpu/pvr/perproc.c index d0d4f4c..1aae887 100644 --- a/drivers/gpu/pvr/perproc.c +++ b/drivers/gpu/pvr/perproc.c @@ -134,6 +134,9 @@ enum PVRSRV_ERROR PVRSRVPerProcessDataConnect(u32 ui32PID) OSMemSet(psPerProc, 0, sizeof(*psPerProc)); psPerProc->hBlockAlloc = hBlockAlloc; + get_proc_name(ui32PID, psPerProc->name, + sizeof(psPerProc->name)); + if (!HASH_Insert(psHashTab, (u32) ui32PID, (u32)psPerProc)) { PVR_DPF(PVR_DBG_ERROR, "PVRSRVPerProcessDataConnect: " "Couldn't insert per-process data into hash table"); diff --git a/drivers/gpu/pvr/perproc.h b/drivers/gpu/pvr/perproc.h index a89b0e4..3a8810c 100644 --- a/drivers/gpu/pvr/perproc.h +++ b/drivers/gpu/pvr/perproc.h @@ -27,6 +27,8 @@ #ifndef __PERPROC_H__ #define __PERPROC_H__ +#include <linux/sched.h> + #include "img_types.h" #include "resman.h" @@ -34,6 +36,7 @@ struct PVRSRV_PER_PROCESS_DATA { u32 ui32PID; + char name[TASK_COMM_LEN]; void *hBlockAlloc; struct RESMAN_CONTEXT *hResManContext; void *hPerProcData; -- 1.7.5.4 From 5d4c44e88284e8aecd03875c586937feb9570bb1 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:07:33 +0300 Subject: [PATCH 76/95] gpu: pvr: use already existing proc name in pr_err_process info Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/sgxinit.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index 6170038..d0bf38b 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -641,17 +641,10 @@ static struct PVRSRV_PER_PROCESS_DATA *find_cur_proc_data( static void pr_err_process_info(struct PVRSRV_PER_PROCESS_DATA *proc) { - struct task_struct *tsk; - int pid; - if (!proc) return; - pid = proc->ui32PID; - rcu_read_lock(); - tsk = pid_task(find_vpid(pid), PIDTYPE_PID); - pr_err("PID = %d, process name = %s\n", pid, tsk->comm); - rcu_read_unlock(); + pr_err("PID = %d, process name = %s\n", proc->ui32PID, proc->name); } static void pr_err_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) -- 1.7.5.4 From b8a08392b974069eb35545b5aef959f8bd7734a8 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:10:36 +0300 Subject: [PATCH 77/95] gpu: pvr: add command tracing support Add a lightweight tracer to track commands submitted by clients. This can help for example to debug dead-lock situations where command synchronization counters form a circular dependency. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/Kconfig | 29 ++++ drivers/gpu/pvr/Makefile | 1 + drivers/gpu/pvr/pvr_trace_cmd.c | 297 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/pvr/pvr_trace_cmd.h | 153 ++++++++++++++++++++ 4 files changed, 480 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/pvr/pvr_trace_cmd.c create mode 100644 drivers/gpu/pvr/pvr_trace_cmd.h diff --git a/drivers/gpu/pvr/Kconfig b/drivers/gpu/pvr/Kconfig index 0da11a0..c11ff83 100644 --- a/drivers/gpu/pvr/Kconfig +++ b/drivers/gpu/pvr/Kconfig @@ -74,6 +74,35 @@ config PVR_EDM_DEBUG of a HW recovery event. You also need a micro kernel that was configured to generate this trace. +config PVR_TRACE_CMD + depends on PVR + bool "Enable GPU command tracing" + default n + help + This will enable a lightweight tracer of commands submitted + to the GPU. + + Besides the command type the trace output will provide the + timestamp, id and name of the submitting process and a + a snapshots of the synchronization counters related to the + given command. + + The trace can help for example in debugging dead-lock + situations caused by circular lock dependencies. + +config PVR_TRACE_CMD_BUF_SHIFT + int "Command tracing buf size" + range 1 10 + default 3 + depends on PVR_TRACE_CMD + help + Select the number of pages (as a power of 2) set aside for + the command trace buffer. + Examples: + 1 -> 4kB + 3 -> 32kB + 10 -> 4MB + config PVR_NO_HARDWARE bool default n diff --git a/drivers/gpu/pvr/Makefile b/drivers/gpu/pvr/Makefile index 0e5bd28..f253168 100644 --- a/drivers/gpu/pvr/Makefile +++ b/drivers/gpu/pvr/Makefile @@ -16,6 +16,7 @@ pvrsrvkm-objs := osfunc.o mmap.o module.o proc.o \ pvrsrvkm-objs-$(CONFIG_PVR_DEBUG) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_PVR_TIMING) += pvr_debug.o pvrsrvkm-objs-$(CONFIG_PVR_DEBUG_PDUMP) += pvr_pdump.o pvr_pdumpfs.o +pvrsrvkm-objs-$(CONFIG_PVR_TRACE_CMD) += pvr_trace_cmd.o pvrsrvkm-objs += $(pvrsrvkm-objs-y) $(pvrsrvkm-objs-m) diff --git a/drivers/gpu/pvr/pvr_trace_cmd.c b/drivers/gpu/pvr/pvr_trace_cmd.c new file mode 100644 index 0000000..30a0d4d --- /dev/null +++ b/drivers/gpu/pvr/pvr_trace_cmd.c @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2011 Nokia Corporation + * Author: Imre Deak <imre.deak@nokia.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <linux/vmalloc.h> + +#include "img_types.h" +#include "resman.h" +#include "handle.h" +#include "pvr_trace_cmd.h" +#include "perproc.h" +#include "pvr_bridge_km.h" + +/* Need to be log2 size. */ +#define PVR_TBUF_SIZE (1 << (CONFIG_PVR_TRACE_CMD_BUF_SHIFT + PAGE_SHIFT)) + +#define PVR_TRCMD_INDENT 3 + +static struct pvr_trcmd_buf { + int read_idx; + int write_idx; + char data[PVR_TBUF_SIZE]; +} tbuf; + +DEFINE_MUTEX(pvr_trcmd_mutex); /* protects tbuf */ + +struct tbuf_frame { + unsigned short size; + unsigned short type; + unsigned long pid; + unsigned long long time; + char pname[16]; +}; + +struct trcmd_desc { + const char *name; + size_t (*print)(char *dst, size_t dst_size, const void *tbuf); +}; + +static size_t prn_syn(const char *name, char *dst, size_t dst_size, + const struct pvr_trcmd_syn *ts) +{ + size_t len; + + if (!ts->addr) + return 0; + + len = scnprintf(dst, dst_size, "%*s%s", PVR_TRCMD_INDENT, "", name); + len += scnprintf(&dst[len], dst_size - len, " addr:%08lx", ts->addr); + len += scnprintf(&dst[len], dst_size - len, + " rop/c:%8lu/%8lu wop/c:%8lu/%8lu\n", + ts->rd_pend, ts->rd_comp, ts->wr_pend, ts->wr_comp); + + return len; +} + +static size_t trcmd_prn_syn(char *dst, size_t dst_size, const void *tbuf) +{ + const struct pvr_trcmd_syn *ts = tbuf; + + return prn_syn("syn ", dst, dst_size, ts); +} + +static size_t trcmd_prn_sgxkick(char *dst, size_t dst_size, const void *tbuf) +{ + const struct pvr_trcmd_sgxkick *d = tbuf; + size_t len; + int i; + + len = prn_syn("tatq_syn", dst, dst_size, &d->tatq_syn); + len += prn_syn("3dtq_syn", &dst[len], dst_size - len, &d->_3dtq_syn); + for (i = 0; i < SGX_MAX_SRC_SYNCS; i++) { + char sname[10]; + + snprintf(sname, sizeof(sname), "src_syn%d", i); + len += prn_syn(sname, &dst[len], dst_size - len, + &d->src_syn[i]); + } + len += prn_syn("dst_syn ", &dst[len], dst_size - len, &d->dst_syn); + len += prn_syn("ta3d_syn", &dst[len], dst_size - len, &d->ta3d_syn); + len += scnprintf(&dst[len], dst_size - len, "%*sctx %08lx\n", + PVR_TRCMD_INDENT, "", d->ctx); + + return len; +} + +static size_t trcmd_prn_sgxtfer(char *dst, size_t dst_size, const void *tbuf) +{ + const struct pvr_trcmd_sgxtransfer *d = tbuf; + size_t len; + + len = prn_syn("ta_syn ", dst, dst_size, &d->ta_syn); + len += prn_syn("3d_syn ", &dst[len], dst_size - len, &d->_3d_syn); + len += prn_syn("src_syn ", &dst[len], dst_size - len, &d->src_syn); + len += prn_syn("dst_syn ", &dst[len], dst_size - len, &d->dst_syn); + len += scnprintf(&dst[len], dst_size - len, "%*sctx %08lx\n", + PVR_TRCMD_INDENT, "", d->ctx); + + return len; +} + +static struct trcmd_desc trcmd_desc_table[] = { + [PVR_TRCMD_SGX_FIRSTKICK] = { "sgx_first_kick", trcmd_prn_sgxkick }, + [PVR_TRCMD_SGX_KICK] = { "sgx_kick", trcmd_prn_sgxkick }, + [PVR_TRCMD_TFER_KICK] = { "sgx_tfer_kick", trcmd_prn_sgxtfer }, + [PVR_TRCMD_SGX_QBLT_FLPREQ] = { "sgx_qblt_flip", NULL }, + [PVR_TRCMD_SGX_QBLT_UPDREQ] = { "sgx_qblt_update", NULL }, + [PVR_TRCMD_SGX_QBLT_SYNCHK] = { "sgx_qblt_synchk", trcmd_prn_syn }, + [PVR_TRCMD_SGX_QBLT_SYNREQ] = { "sgx_qblt_synreq", trcmd_prn_syn }, + [PVR_TRCMD_SGX_QBLT_SYNCOMP] = { "sgx_qblt_syn_comp", trcmd_prn_syn }, + [PVR_TRCMD_SGX_QBLT_FLPCOMP] = { "sgx_qblt_flip_comp", NULL }, + [PVR_TRCMD_SGX_QBLT_UPDCOMP] = { "sgx_qblt_update_comp", NULL } +}; + +/* Modular add */ +static inline int tbuf_idx_add(int val, int delta) +{ + val += delta; + val &= PVR_TBUF_SIZE - 1; + + return val; +} + +static size_t prn_frame(const struct tbuf_frame *f, char *dst, size_t dst_size) +{ + const struct trcmd_desc *desc; + unsigned long long sec; + unsigned long usec_frac; + size_t len; + + desc = &trcmd_desc_table[f->type]; + + sec = f->time; + usec_frac = do_div(sec, 1000000000) / 1000; + + len = scnprintf(dst, dst_size, "[%5llu.%06lu] %s[%ld]: %s\n", + sec, usec_frac, f->pname, f->pid, desc->name); + if (desc->print) + len += desc->print(&dst[len], dst_size - len, (void *)(f + 1)); + + return len; +} + +int pvr_trcmd_create_snapshot(u8 **snapshot_ret, size_t *snapshot_size) +{ + u8 *snapshot; + int read_idx; + size_t size; + size_t tail_size; + + read_idx = tbuf.read_idx; + size = tbuf_idx_add(tbuf.write_idx, -read_idx); + snapshot = vmalloc(size); + if (!snapshot) + return -ENOMEM; + + tail_size = min_t(size_t, size, PVR_TBUF_SIZE - read_idx); + memcpy(snapshot, &tbuf.data[read_idx], tail_size); + memcpy(&snapshot[tail_size], tbuf.data, size - tail_size); + + *snapshot_ret = snapshot; + *snapshot_size = size; + + return 0; +} + +void pvr_trcmd_destroy_snapshot(void *snapshot) +{ + vfree(snapshot); +} + +size_t pvr_trcmd_print(char *dst, size_t dst_size, const u8 *snapshot, + size_t snapshot_size, loff_t *snapshot_ofs) +{ + size_t dst_len; + + if (*snapshot_ofs >= snapshot_size) + return 0; + dst_len = 0; + + snapshot_size -= *snapshot_ofs; + + while (snapshot_size) { + const struct tbuf_frame *f; + size_t this_len; + + if (WARN_ON_ONCE(snapshot_size < 4)) + break; + + f = (struct tbuf_frame *)&snapshot[*snapshot_ofs]; + if (WARN_ON_ONCE(!f->size || f->size > snapshot_size || + f->type >= ARRAY_SIZE(trcmd_desc_table))) + break; + + if (f->type != PVR_TRCMD_PAD) + this_len = prn_frame(f, &dst[dst_len], + dst_size - dst_len); + else + this_len = 0; + + if (dst_len + this_len + 1 == dst_size) { + /* drop the last printed frame */ + dst[dst_len] = '\0'; + + break; + } + + *snapshot_ofs += f->size; + dst_len += this_len; + snapshot_size -= f->size; + } + + return dst_len; +} + +static void *tbuf_get_space(size_t size) +{ + void *ret; + int buf_idx; + + while (1) { + if (tbuf_idx_add(tbuf.read_idx - 1, -tbuf.write_idx) < size) { + /* + * Trace buffer overflow, discard the frame that will + * be overwritten by the next write. + */ + struct tbuf_frame *f = + (void *)&tbuf.data[tbuf.read_idx]; + + buf_idx = tbuf.read_idx; + tbuf.read_idx = tbuf_idx_add(tbuf.read_idx, + f->size); + } else if (PVR_TBUF_SIZE - tbuf.write_idx < size) { + struct tbuf_frame *f = + (void *)&tbuf.data[tbuf.write_idx]; + /* + * Not enough space until the end of trace buffer, + * rewind to the beginning. Frames are sizeof(long) + * aligned, thus we are guaranteed to have space for + * the following two fields. + */ + f->size = PVR_TBUF_SIZE - tbuf.write_idx; + f->type = PVR_TRCMD_PAD; + tbuf.write_idx = 0; + } else { + break; + } + } + ret = &tbuf.data[tbuf.write_idx]; + tbuf.write_idx = tbuf_idx_add(tbuf.write_idx, size); + + return ret; +} + +void *pvr_trcmd_alloc(unsigned type, int pid, const char *pname, size_t size) +{ + struct tbuf_frame *f; + size_t total_size; + + size = ALIGN(size, __alignof__(*f)); + total_size = sizeof(*f) + size; + f = tbuf_get_space(total_size); + f->size = total_size; + f->type = type; + f->pid = pid; + f->time = cpu_clock(smp_processor_id()); + strlcpy(f->pname, pname, sizeof(f->pname)); + + return f + 1; +} + +void pvr_trcmd_set_syn(struct pvr_trcmd_syn *ts, + const struct PVRSRV_KERNEL_SYNC_INFO *si) +{ + struct PVRSRV_SYNC_DATA *sd = si->psSyncData; + + ts->rd_pend = sd->ui32ReadOpsPending; + ts->rd_comp = sd->ui32ReadOpsComplete; + ts->wr_pend = sd->ui32WriteOpsPending; + ts->wr_comp = sd->ui32WriteOpsComplete; + ts->addr = si->sWriteOpsCompleteDevVAddr.uiAddr - 4; +} diff --git a/drivers/gpu/pvr/pvr_trace_cmd.h b/drivers/gpu/pvr/pvr_trace_cmd.h new file mode 100644 index 0000000..9f5c212 --- /dev/null +++ b/drivers/gpu/pvr/pvr_trace_cmd.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2011 Nokia Corporation + * Author: Imre Deak <imre.deak@nokia.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PVR_TRACE_CMD_H__ +#define __PVR_TRACE_CMD_H__ + +#include <linux/mutex.h> + +#include "servicesint.h" +#include "sgxapi_km.h" + +enum pvr_trcmd_type { + PVR_TRCMD_PAD, + PVR_TRCMD_SGX_FIRSTKICK, + PVR_TRCMD_SGX_KICK, + PVR_TRCMD_TFER_KICK, + PVR_TRCMD_SGX_QBLT_SYNREQ, + PVR_TRCMD_SGX_QBLT_SYNCHK, + PVR_TRCMD_SGX_QBLT_FLPREQ, + PVR_TRCMD_SGX_QBLT_UPDREQ, + PVR_TRCMD_SGX_QBLT_SYNCOMP, + PVR_TRCMD_SGX_QBLT_FLPCOMP, + PVR_TRCMD_SGX_QBLT_UPDCOMP, +}; + +struct pvr_trcmd_buf; + +struct pvr_trcmd_syn { + unsigned long rd_pend; + unsigned long rd_comp; + unsigned long wr_pend; + unsigned long wr_comp; + unsigned long addr; +}; + +struct pvr_trcmd_sgxkick { + struct pvr_trcmd_syn tatq_syn; + struct pvr_trcmd_syn _3dtq_syn; + struct pvr_trcmd_syn src_syn[SGX_MAX_SRC_SYNCS]; + struct pvr_trcmd_syn dst_syn; + struct pvr_trcmd_syn ta3d_syn; + unsigned long ctx; +}; + +struct pvr_trcmd_sgxtransfer { + struct pvr_trcmd_syn ta_syn; + struct pvr_trcmd_syn _3d_syn; + struct pvr_trcmd_syn src_syn; + struct pvr_trcmd_syn dst_syn; + unsigned long ctx; +}; + +#ifdef CONFIG_PVR_TRACE_CMD + +void *pvr_trcmd_alloc(unsigned type, int pid, const char *pname, size_t size); + +extern struct mutex pvr_trcmd_mutex; + +static inline void pvr_trcmd_lock(void) +{ + mutex_lock(&pvr_trcmd_mutex); +} + +static inline void pvr_trcmd_unlock(void) +{ + mutex_unlock(&pvr_trcmd_mutex); +} + +int pvr_trcmd_create_snapshot(u8 **snapshot_ret, size_t *snapshot_size); +void pvr_trcmd_destroy_snapshot(void *snapshot); + +size_t pvr_trcmd_print(char *dst, size_t dst_size, const u8 *snapshot, + size_t snapshot_size, loff_t *snapshot_ofs); + +void pvr_trcmd_set_syn(struct pvr_trcmd_syn *ts, + const struct PVRSRV_KERNEL_SYNC_INFO *si); + +static inline void pvr_trcmd_set_data(unsigned long *a, unsigned long val) +{ + *a = val; +} + +static inline void pvr_trcmd_clear_syn(struct pvr_trcmd_syn *ts) +{ + memset(ts, 0, sizeof(*ts)); +} + +#else + +static inline void * +pvr_trcmd_alloc(unsigned type, int pid, const char *pname, size_t size) +{ + return NULL; +} + +static inline void pvr_trcmd_lock(void) +{ +} + +static inline void pvr_trcmd_unlock(void) +{ +} + +static inline int +pvr_trcmd_create_snapshot(u8 **snapshot_ret, size_t *snapshot_size) +{ + return 0; +} + +static inline void pvr_trcmd_destroy_snapshot(void *snapshot) +{ +} + +static inline size_t +pvr_trcmd_print(char *dst, size_t dst_size, const u8 *snapshot, + size_t snapshot_size, loff_t *snapshot_ofs) +{ + return 0; +} + +static inline void +pvr_trcmd_set_syn(struct pvr_trcmd_syn *ts, + const struct PVRSRV_KERNEL_SYNC_INFO *si) +{ +} + +static inline void pvr_trcmd_set_data(unsigned long *a, unsigned long val) +{ +} + +static inline void pvr_trcmd_clear_syn(struct pvr_trcmd_syn *ts) +{ +} + +#endif /* CONFIG_PVR_SYNC_CNT */ + +#endif -- 1.7.5.4 From d86ce13196ff2733349b134be753ce2f3c58ae0e Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:13:11 +0300 Subject: [PATCH 78/95] gpu: pvr: pass proc info to sgxkick and sgxtransfer Needed by the next patch adding tracing to these commands. Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/bridged_sgx_bridge.c | 6 ++++-- drivers/gpu/pvr/sgx_bridge_km.h | 6 ++++-- drivers/gpu/pvr/sgxkick.c | 5 +++-- drivers/gpu/pvr/sgxtransfer.c | 4 +++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index f3a24a4..70e698b 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -255,7 +255,8 @@ int SGXDoKickBW(u32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick); + psRetOUT->eError = SGXDoKickKM(hDevCookieInt, &psDoKickIN->sCCBKick, + psPerProc); return 0; } @@ -357,7 +358,8 @@ int SGXSubmitTransferBW(u32 ui32BridgeID, return 0; } - psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, psKick); + psRetOUT->eError = SGXSubmitTransferKM(hDevCookieInt, psKick, + psPerProc); return 0; } diff --git a/drivers/gpu/pvr/sgx_bridge_km.h b/drivers/gpu/pvr/sgx_bridge_km.h index fbd3379..f0613e7 100644 --- a/drivers/gpu/pvr/sgx_bridge_km.h +++ b/drivers/gpu/pvr/sgx_bridge_km.h @@ -36,11 +36,13 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, - struct PVRSRV_TRANSFER_SGX_KICK *psKick); + struct PVRSRV_TRANSFER_SGX_KICK *psKick, + struct PVRSRV_PER_PROCESS_DATA *proc); enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, - struct SGX_CCB_KICK *psCCBKick); + struct SGX_CCB_KICK *psCCBKick, + struct PVRSRV_PER_PROCESS_DATA *proc); enum PVRSRV_ERROR SGXGetPhysPageAddrKM(void *hDevMemHeap, struct IMG_DEV_VIRTADDR sDevVAddr, diff --git a/drivers/gpu/pvr/sgxkick.c b/drivers/gpu/pvr/sgxkick.c index 6678b49..ef4154b 100644 --- a/drivers/gpu/pvr/sgxkick.c +++ b/drivers/gpu/pvr/sgxkick.c @@ -36,9 +36,10 @@ #include "osfunc.h" #include "pvr_debug.h" #include "sgxutils.h" +#include "perproc.h" -enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, - struct SGX_CCB_KICK *psCCBKick) +enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, + struct PVRSRV_PER_PROCESS_DATA *proc) { enum PVRSRV_ERROR eError; struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; diff --git a/drivers/gpu/pvr/sgxtransfer.c b/drivers/gpu/pvr/sgxtransfer.c index 22d2ac8..0890921 100644 --- a/drivers/gpu/pvr/sgxtransfer.c +++ b/drivers/gpu/pvr/sgxtransfer.c @@ -40,9 +40,11 @@ #include "osfunc.h" #include "pvr_debug.h" #include "sgxutils.h" +#include "perproc.h" enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, - struct PVRSRV_TRANSFER_SGX_KICK *psKick) + struct PVRSRV_TRANSFER_SGX_KICK *psKick, + struct PVRSRV_PER_PROCESS_DATA *proc) { struct PVRSRV_KERNEL_MEM_INFO *psCCBMemInfo = (struct PVRSRV_KERNEL_MEM_INFO *)psKick->hCCBMemInfo; -- 1.7.5.4 From 137b53a735cf1dbd4b81d4ebb79802de059b43e3 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:23:30 +0300 Subject: [PATCH 79/95] gpu: pvr: add tracing to the SGX kick and transfer commands Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/sgxkick.c | 38 +++++++++++++++++++++++++++++++++++++- drivers/gpu/pvr/sgxtransfer.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/sgxkick.c b/drivers/gpu/pvr/sgxkick.c index ef4154b..0a951e0 100644 --- a/drivers/gpu/pvr/sgxkick.c +++ b/drivers/gpu/pvr/sgxkick.c @@ -37,6 +37,7 @@ #include "pvr_debug.h" #include "sgxutils.h" #include "perproc.h" +#include "pvr_trace_cmd.h" enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, struct PVRSRV_PER_PROCESS_DATA *proc) @@ -49,6 +50,8 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, u32 i; struct PVRSRV_DEVICE_NODE *psDeviceNode; struct PVRSRV_SGXDEV_INFO *psDevInfo; + struct pvr_trcmd_sgxkick *ktrace; + int trcmd_type; psDeviceNode = (struct PVRSRV_DEVICE_NODE *)hDevHandle; psDevInfo = (struct PVRSRV_SGXDEV_INFO *)psDeviceNode->pvDevice; @@ -67,6 +70,12 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, CCB_DATA_FROM_OFFSET(struct SGXMKIF_CMDTA_SHARED, psCCBMemInfo, psCCBKick, ui32CCBOffset); + trcmd_type = psCCBKick->bFirstKickOrResume ? + PVR_TRCMD_SGX_FIRSTKICK : PVR_TRCMD_SGX_KICK; + pvr_trcmd_lock(); + ktrace = pvr_trcmd_alloc(trcmd_type, proc->ui32PID, proc->name, + sizeof(*ktrace)); + if (psCCBKick->hTA3DSyncInfo) { psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick->hTA3DSyncInfo; @@ -78,6 +87,10 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, if (psCCBKick->bTADependency) psSyncInfo->psSyncData->ui32WriteOpsPending++; + + pvr_trcmd_set_syn(&ktrace->ta3d_syn, psSyncInfo); + } else { + pvr_trcmd_clear_syn(&ktrace->ta3d_syn); } if (psCCBKick->hTASyncInfo != NULL) { @@ -93,6 +106,10 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, psSyncInfo->psSyncData->ui32ReadOpsPending++; psTACmd->ui32TATQSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + + pvr_trcmd_set_syn(&ktrace->tatq_syn, psSyncInfo); + } else { + pvr_trcmd_clear_syn(&ktrace->tatq_syn); } if (psCCBKick->h3DSyncInfo != NULL) { @@ -108,6 +125,10 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, psSyncInfo->psSyncData->ui32ReadOpsPending++; psTACmd->ui323DTQSyncWriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + + pvr_trcmd_set_syn(&ktrace->_3dtq_syn, psSyncInfo); + } else { + pvr_trcmd_clear_syn(&ktrace->_3dtq_syn); } psTACmd->ui32NumTAStatusVals = psCCBKick->ui32NumTAStatusVals; @@ -140,7 +161,12 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, } psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; - for (i = 0; i < psCCBKick->ui32NumSrcSyncs; i++) { + for (i = 0; i < SGX_MAX_SRC_SYNCS; i++) { + if (i >= psCCBKick->ui32NumSrcSyncs) { + pvr_trcmd_clear_syn(&ktrace->src_syn[i]); + continue; + } + psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick-> ahSrcKernelSyncInfo[i]; @@ -156,6 +182,7 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, psTACmd->asSrcSyncs[i].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; + pvr_trcmd_set_syn(&ktrace->src_syn[i], psSyncInfo); } if (psCCBKick->bFirstKickOrResume && @@ -204,6 +231,8 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, psSyncInfo->psSyncData-> ui32WriteOpsPending++; + pvr_trcmd_set_syn(&ktrace->dst_syn, psSyncInfo); + #if defined(PDUMP) if (PDumpIsCaptureFrameKM()) { u32 ui32ModifiedValue; @@ -294,7 +323,11 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, ui32ReadOpsPendingVal = 0; psHWDeviceSyncList->asSyncData[i]. ui32WriteOpsPendingVal = 0; + + pvr_trcmd_clear_syn(&ktrace->dst_syn); } + } else { + pvr_trcmd_clear_syn(&ktrace->dst_syn); } #if defined(PDUMP) if (PDumpIsCaptureFrameKM()) { @@ -397,6 +430,9 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, } #endif + pvr_trcmd_set_data(&ktrace->ctx, psCCBKick->sCommand.ui32Data[1]); + pvr_trcmd_unlock(); + /* to aid in determining the next power down delay */ sgx_mark_new_command(psDeviceNode); diff --git a/drivers/gpu/pvr/sgxtransfer.c b/drivers/gpu/pvr/sgxtransfer.c index 0890921..7cfb829 100644 --- a/drivers/gpu/pvr/sgxtransfer.c +++ b/drivers/gpu/pvr/sgxtransfer.c @@ -41,6 +41,7 @@ #include "pvr_debug.h" #include "sgxutils.h" #include "perproc.h" +#include "pvr_trace_cmd.h" enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, struct PVRSRV_TRANSFER_SGX_KICK *psKick, @@ -51,6 +52,7 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, struct SGXMKIF_COMMAND sCommand = { 0 }; struct SGXMKIF_TRANSFERCMD_SHARED *psSharedTransferCmd; struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo; + struct pvr_trcmd_sgxtransfer *ttrace; enum PVRSRV_ERROR eError; if (!CCB_OFFSET_IS_VALID @@ -65,6 +67,10 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, CCB_DATA_FROM_OFFSET(struct SGXMKIF_TRANSFERCMD_SHARED, psCCBMemInfo, psKick, ui32SharedCmdCCBOffset); + pvr_trcmd_lock(); + ttrace = pvr_trcmd_alloc(PVR_TRCMD_TFER_KICK, proc->ui32PID, proc->name, + sizeof(*ttrace)); + if (psKick->hTASyncInfo != NULL) { psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *) psKick->hTASyncInfo; @@ -78,9 +84,13 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, psSyncInfo->sWriteOpsCompleteDevVAddr; psSharedTransferCmd->sTASyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + + pvr_trcmd_set_syn(&ttrace->ta_syn, psSyncInfo); } else { psSharedTransferCmd->sTASyncWriteOpsCompleteDevVAddr.uiAddr = 0; psSharedTransferCmd->sTASyncReadOpsCompleteDevVAddr.uiAddr = 0; + + pvr_trcmd_clear_syn(&ttrace->ta_syn); } if (psKick->h3DSyncInfo != NULL) { @@ -96,9 +106,13 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, psSyncInfo->sWriteOpsCompleteDevVAddr; psSharedTransferCmd->s3DSyncReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; + + pvr_trcmd_set_syn(&ttrace->_3d_syn, psSyncInfo); } else { psSharedTransferCmd->s3DSyncWriteOpsCompleteDevVAddr.uiAddr = 0; psSharedTransferCmd->s3DSyncReadOpsCompleteDevVAddr.uiAddr = 0; + + pvr_trcmd_clear_syn(&ttrace->_3d_syn); } if ((psKick->ui32Flags & SGXMKIF_TQFLAGS_KEEPPENDING) == 0UL) { @@ -135,13 +149,24 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, psKick->ahSrcSyncInfo[0]; psSyncInfo->psSyncData->ui32ReadOpsPending++; + pvr_trcmd_set_syn(&ttrace->src_syn, psSyncInfo); + } else { + pvr_trcmd_clear_syn(&ttrace->src_syn); } + if (psKick->ui32NumDstSync > 0) { psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *)psKick-> ahDstSyncInfo[0]; psSyncInfo->psSyncData->ui32WriteOpsPending++; + + pvr_trcmd_set_syn(&ttrace->dst_syn, psSyncInfo); + } else { + pvr_trcmd_clear_syn(&ttrace->dst_syn); } + } else { + pvr_trcmd_clear_syn(&ttrace->src_syn); + pvr_trcmd_clear_syn(&ttrace->dst_syn); } if (psKick->ui32NumDstSync > 1 || psKick->ui32NumSrcSync > 1) { @@ -243,6 +268,10 @@ enum PVRSRV_ERROR SGXSubmitTransferKM(void *hDevHandle, sCommand.ui32Data[0] = PVRSRV_CCBFLAGS_TRANSFERCMD; sCommand.ui32Data[1] = psKick->sHWTransferContextDevVAddr.uiAddr; + pvr_trcmd_set_data(&ttrace->ctx, + psKick->sHWTransferContextDevVAddr.uiAddr); + pvr_trcmd_unlock(); + /* To aid in determining the next power down delay */ sgx_mark_new_command(hDevHandle); -- 1.7.5.4 From 44f85ac626d6ea02a878c3b39348e989ec6900fb Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:16:07 +0300 Subject: [PATCH 80/95] gpu: pvr: add tracing to the SGX queryblits command Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/bridged_sgx_bridge.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index 70e698b..adb8af5 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -43,6 +43,7 @@ #include "sgxutils.h" #include "pvr_pdump.h" #include "pvr_events.h" +#include "pvr_trace_cmd.h" int SGXGetClientInfoBW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_GETCLIENTINFO *psGetClientInfoIN, @@ -995,6 +996,22 @@ int SGXFlushHWRenderTargetBW(u32 ui32BridgeID, return 0; } +static void trace_query_cmd(struct PVRSRV_PER_PROCESS_DATA *proc, int type, + struct PVRSRV_KERNEL_SYNC_INFO *si) +{ + struct pvr_trcmd_syn *ts; + size_t size; + + size = si ? sizeof(*ts) : 0; + pvr_trcmd_lock(); + + ts = pvr_trcmd_alloc(type, proc->ui32PID, proc->name, size); + if (si) + pvr_trcmd_set_syn(ts, si); + + pvr_trcmd_unlock(); +} + int SGX2DQueryBlitsCompleteBW(struct file *filp, u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_2DQUERYBLTSCOMPLETE *ps2DQueryBltsCompleteIN, struct PVRSRV_BRIDGE_RETURN *psRetOUT, @@ -1017,6 +1034,15 @@ int SGX2DQueryBlitsCompleteBW(struct file *filp, u32 ui32BridgeID, if (ps2DQueryBltsCompleteIN->type == _PVR_SYNC_WAIT_FLIP || ps2DQueryBltsCompleteIN->type == _PVR_SYNC_WAIT_UPDATE) { + int cmd_type; + + if (ps2DQueryBltsCompleteIN->type == _PVR_SYNC_WAIT_FLIP) + cmd_type = PVR_TRCMD_SGX_QBLT_FLPREQ; + else + cmd_type = PVR_TRCMD_SGX_QBLT_UPDREQ; + + trace_query_cmd(psPerProc, cmd_type, NULL); + if (pvr_flip_event_req(priv, (long)ps2DQueryBltsCompleteIN-> hKernSyncInfo, @@ -1043,6 +1069,10 @@ int SGX2DQueryBlitsCompleteBW(struct file *filp, u32 ui32BridgeID, (struct PVRSRV_KERNEL_SYNC_INFO *)pvSyncInfo, ps2DQueryBltsCompleteIN->user_data)) psRetOUT->eError = PVRSRV_ERROR_OUT_OF_MEMORY; + else + trace_query_cmd(psPerProc, + PVR_TRCMD_SGX_QBLT_SYNREQ, + pvSyncInfo); return 0; } @@ -1053,6 +1083,8 @@ int SGX2DQueryBlitsCompleteBW(struct file *filp, u32 ui32BridgeID, pvSyncInfo, ps2DQueryBltsCompleteIN->type == _PVR_SYNC_WAIT_BLOCK); + trace_query_cmd(psPerProc, PVR_TRCMD_SGX_QBLT_SYNCHK, pvSyncInfo); + return 0; } -- 1.7.5.4 From 3cb9703ca9b095a293bdff01a8e7ac26e09f65ac Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:17:42 +0300 Subject: [PATCH 81/95] gpu: pvr: add tracing for PVR events Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/pvr_events.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/pvr_events.c b/drivers/gpu/pvr/pvr_events.c index 0e3715b..e5a7b1c 100644 --- a/drivers/gpu/pvr/pvr_events.c +++ b/drivers/gpu/pvr/pvr_events.c @@ -2,6 +2,9 @@ #include "pvr_events.h" #include "servicesint.h" #include "sgx_bridge.h" +#include "perproc.h" +#include "pvr_bridge_km.h" +#include "pvr_trace_cmd.h" #include <linux/wait.h> #include <linux/sched.h> @@ -166,6 +169,40 @@ err: return ret; } +static void trace_pvr_event(struct pvr_pending_event *e) +{ + struct PVRSRV_PER_PROCESS_DATA *proc; + + proc = e->file_priv->proc; + pvr_trcmd_lock(); + + switch (e->event->type) { + case PVR_EVENT_SYNC: + { + struct pvr_event_sync *evsync; + struct pvr_trcmd_syn *ts; + + evsync = (struct pvr_event_sync *)e->event; + ts = pvr_trcmd_alloc(PVR_TRCMD_SGX_QBLT_SYNCOMP, + proc->ui32PID, proc->name, sizeof(*ts)); + pvr_trcmd_set_syn(ts, evsync->sync_info); + break; + } + case PVR_EVENT_FLIP: + pvr_trcmd_alloc(PVR_TRCMD_SGX_QBLT_FLPCOMP, + proc->ui32PID, proc->name, 0); + break; + case PVR_EVENT_UPDATE: + pvr_trcmd_alloc(PVR_TRCMD_SGX_QBLT_UPDCOMP, + proc->ui32PID, proc->name, 0); + break; + default: + __WARN(); + } + + pvr_trcmd_unlock(); +} + ssize_t pvr_read(struct file *filp, char __user *buf, size_t count, loff_t *off) { struct PVRSRV_FILE_PRIVATE_DATA *priv = filp->private_data; @@ -186,6 +223,8 @@ ssize_t pvr_read(struct file *filp, char __user *buf, size_t count, loff_t *off) break; } + trace_pvr_event(e); + total += e->event->length; e->destroy(e); } -- 1.7.5.4 From 39ba2221cd6808b54bded758f347660e7bb29f76 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:18:24 +0300 Subject: [PATCH 82/95] gpu: pvr: add debugfs interface for the command trace Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/pvr_debugfs.c | 78 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 77 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 4a9e068..40e30cf 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -40,6 +40,7 @@ #include "mmu.h" #include "bridged_support.h" #include "mm.h" +#include "pvr_trace_cmd.h" struct dentry *pvr_debugfs_dir; static u32 pvr_reset; @@ -232,6 +233,75 @@ static const struct file_operations pvr_debugfs_edm_fops = { }; #endif /* PVRSRV_USSE_EDM_STATUS_DEBUG */ +#ifdef CONFIG_PVR_TRACE_CMD + +static void *trcmd_str_buf; +static u8 *trcmd_snapshot; +static size_t trcmd_snapshot_size; +static int trcmd_open_cnt; + +static int pvr_dbg_trcmd_open(struct inode *inode, struct file *file) +{ + int r; + + if (trcmd_open_cnt) + return -EBUSY; + + trcmd_open_cnt++; + + trcmd_str_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!trcmd_str_buf) { + trcmd_open_cnt--; + + return -ENOMEM; + } + + pvr_trcmd_lock(); + + r = pvr_trcmd_create_snapshot(&trcmd_snapshot, &trcmd_snapshot_size); + if (r < 0) { + pvr_trcmd_unlock(); + kfree(trcmd_str_buf); + trcmd_open_cnt--; + + return r; + } + + pvr_trcmd_unlock(); + + return 0; +} + +static int pvr_dbg_trcmd_release(struct inode *inode, struct file *file) +{ + pvr_trcmd_destroy_snapshot(trcmd_snapshot); + kfree(trcmd_str_buf); + trcmd_open_cnt--; + + return 0; +} + +static ssize_t pvr_dbg_trcmd_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + ssize_t ret; + + ret = pvr_trcmd_print(trcmd_str_buf, max_t(size_t, PAGE_SIZE, count), + trcmd_snapshot, trcmd_snapshot_size, ppos); + if (copy_to_user(buffer, trcmd_str_buf, ret)) + return -EFAULT; + + return ret; +} + +static const struct file_operations pvr_dbg_trcmd_fops = { + .owner = THIS_MODULE, + .open = pvr_dbg_trcmd_open, + .release = pvr_dbg_trcmd_release, + .read = pvr_dbg_trcmd_read, +}; +#endif + /* * * HW Recovery dumping support. @@ -1076,7 +1146,13 @@ int pvr_debugfs_init(void) return -ENODEV; } #endif - +#ifdef CONFIG_PVR_TRACE_CMD + if (!debugfs_create_file("command_trace", S_IRUGO, pvr_debugfs_dir, + NULL, &pvr_dbg_trcmd_fops)) { + debugfs_remove_recursive(pvr_debugfs_dir); + return -ENODEV; + } +#endif if (!debugfs_create_file("hwrec_event", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_event_fops)) { debugfs_remove_recursive(pvr_debugfs_dir); -- 1.7.5.4 From 7ff53e560af99c3473106c58186cb0aacbdb94b3 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Fri, 1 Apr 2011 18:19:04 +0300 Subject: [PATCH 83/95] gpu: pvr: print the command trace to syslog during HWrec Signed-off-by: Imre Deak <imre.deak@nokia.com> Reviewed-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/sgxinit.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index d0bf38b..c1f0f53 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -58,6 +58,8 @@ #include "pvrversion.h" #include "sgx_options.h" +#include "pvr_trace_cmd.h" + #ifdef CONFIG_DEBUG_FS #include "pvr_debugfs.h" #endif @@ -665,6 +667,47 @@ static void pr_err_sgx_registers(struct PVRSRV_SGXDEV_INFO *psDevInfo) readl(psDevInfo->pvRegsBaseKM + EUR_CR_CLKGATECTL)); } +#ifdef CONFIG_PVR_TRACE_CMD +static void pr_err_cmd_trace(void) +{ + u8 *snapshot; + size_t snapshot_size; + loff_t snapshot_ofs; + char *str_buf; + size_t str_len; + int r; + + str_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!str_buf) { + pr_err("%s: out of mem\n", __func__); + return; + } + + pvr_trcmd_lock(); + + r = pvr_trcmd_create_snapshot(&snapshot, &snapshot_size); + if (r < 0) { + pvr_trcmd_unlock(); + kfree(str_buf); + pr_err("%s: can't create snapshot (%d)\n", __func__, r); + + return; + } + + pvr_trcmd_unlock(); + + snapshot_ofs = 0; + do { + str_len = pvr_trcmd_print(str_buf, PAGE_SIZE, snapshot, + snapshot_size, &snapshot_ofs); + printk(KERN_DEBUG "%s", str_buf); + } while (str_len); + + pvr_trcmd_destroy_snapshot(snapshot); + kfree(str_buf); +} +#endif + /* Should be called with pvr_lock held */ void HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode, const char *caller) @@ -693,6 +736,9 @@ HWRecoveryResetSGX(struct PVRSRV_DEVICE_NODE *psDeviceNode, const char *caller) #ifdef PVRSRV_USSE_EDM_STATUS_DEBUG edm_trace_print(psDevInfo, NULL, 0); #endif +#ifdef CONFIG_PVR_TRACE_CMD + pr_err_cmd_trace(); +#endif #ifdef CONFIG_DEBUG_FS pvr_hwrec_dump(proc, psDevInfo); -- 1.7.5.4 From a5e5ed8d1529e149b0488ba68921d7f9dcd590e8 Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Mon, 11 Apr 2011 15:36:31 +0300 Subject: [PATCH 84/95] gpu: pvr: fix memory context refcount problem leading to leaked handle Although there is an IOCTL interface for creating memory contexts, in reality processes can create only a single context. Subsequent create commands will return the same context _and_ the same handle, so this resembles more of an 'open' command, except the somewhat orthodox way of returning the same handle. In addition there can be kernel only users of the context accounted for by the current reference count of the context (ui32RefCount). Removing the user handle should happen when the last process opening (creating) the context calls the close (destroy) command on the handle. At the moment the handle is removed only if there are no kernel side or user space users of the context, which can lead to the handle being leaked in the following case: 1. create memory context -> ctx_handle created, ctx_refcount=1 2. create buffer -> ctx_refcount=2 3. destroy memory context -> ctx_refcount=1, ctx_handle not removed 4. destroy buffer -> ctx_refcount=0, ctx_handle not removed To avoid this add a counter tracking the number of opens, so we know when to remove the handle. Fixes: NB#245525 - Return value of pvr_put_ctx is not checked Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 41 +++++++++++++++++++--------------- drivers/gpu/pvr/buffer_manager.h | 1 + drivers/gpu/pvr/devicemem.c | 9 +----- drivers/gpu/pvr/pvr_bridge_km.h | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index d470bcd..1161389 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -132,7 +132,7 @@ static int PVRSRVCreateDeviceMemContextBW(u32 ui32BridgeID, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { void *hDevCookieInt; - void *hDevMemContextInt; + struct BM_CONTEXT *ctx; u32 i; IMG_BOOL bCreated; @@ -151,8 +151,7 @@ static int PVRSRVCreateDeviceMemContextBW(u32 ui32BridgeID, return 0; psCreateDevMemContextOUT->eError = PVRSRVCreateDeviceMemContextKM( - hDevCookieInt, psPerProc, - &hDevMemContextInt, + hDevCookieInt, psPerProc, (void *)&ctx, &psCreateDevMemContextOUT->ui32ClientHeapCount, &psCreateDevMemContextOUT->sHeapInfo[0], &bCreated, pbSharedDeviceMemHeap); @@ -162,18 +161,20 @@ static int PVRSRVCreateDeviceMemContextBW(u32 ui32BridgeID, if (bCreated) { PVRSRVAllocHandleNR(psPerProc->psHandleBase, - &psCreateDevMemContextOUT->hDevMemContext, - hDevMemContextInt, + &psCreateDevMemContextOUT->hDevMemContext, ctx, PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT, PVRSRV_HANDLE_ALLOC_FLAG_NONE); + ctx->open_count = 1; } else { psCreateDevMemContextOUT->eError = PVRSRVFindHandle(psPerProc->psHandleBase, - &psCreateDevMemContextOUT->hDevMemContext, - hDevMemContextInt, + &psCreateDevMemContextOUT->hDevMemContext, ctx, PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); if (psCreateDevMemContextOUT->eError != PVRSRV_OK) return 0; + + WARN_ON_ONCE(!ctx->open_count); + ctx->open_count++; } for (i = 0; i < psCreateDevMemContextOUT->ui32ClientHeapCount; i++) { @@ -225,8 +226,8 @@ static int PVRSRVDestroyDeviceMemContextBW(u32 ui32BridgeID, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { void *hDevCookieInt; - void *hDevMemContextInt; - IMG_BOOL bDestroyed; + unsigned long ctx_handle; + struct BM_CONTEXT *ctx; PVRSRV_BRIDGE_ASSERT_CMD(ui32BridgeID, PVRSRV_BRIDGE_DESTROY_DEVMEMCONTEXT); @@ -239,26 +240,30 @@ static int PVRSRVDestroyDeviceMemContextBW(u32 ui32BridgeID, if (psRetOUT->eError != PVRSRV_OK) return 0; + ctx_handle = (unsigned long)psDestroyDevMemContextIN->hDevMemContext; psRetOUT->eError = PVRSRVLookupHandle(psPerProc->psHandleBase, - &hDevMemContextInt, - psDestroyDevMemContextIN->hDevMemContext, - PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + (void *)&ctx, (void *)ctx_handle, + PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); if (psRetOUT->eError != PVRSRV_OK) return 0; - psRetOUT->eError = PVRSRVDestroyDeviceMemContextKM(hDevCookieInt, - hDevMemContextInt, &bDestroyed); + if (!ctx->open_count) { + psRetOUT->eError = PVRSRV_ERROR_INVALID_PARAMS; - if (psRetOUT->eError != PVRSRV_OK) return 0; + } - if (bDestroyed) + if (!--ctx->open_count) psRetOUT->eError = PVRSRVReleaseHandle(psPerProc->psHandleBase, - psDestroyDevMemContextIN-> - hDevMemContext, + (void *)ctx_handle, PVRSRV_HANDLE_TYPE_DEV_MEM_CONTEXT); + psRetOUT->eError = PVRSRVDestroyDeviceMemContextKM(hDevCookieInt, ctx); + + if (psRetOUT->eError != PVRSRV_OK) + return 0; + return 0; } diff --git a/drivers/gpu/pvr/buffer_manager.h b/drivers/gpu/pvr/buffer_manager.h index 39472b1..06bdb38 100644 --- a/drivers/gpu/pvr/buffer_manager.h +++ b/drivers/gpu/pvr/buffer_manager.h @@ -86,6 +86,7 @@ struct BM_CONTEXT { struct HASH_TABLE *pBufferHash; void *hResItem; u32 ui32RefCount; + int open_count; struct BM_CONTEXT *psNext; }; diff --git a/drivers/gpu/pvr/devicemem.c b/drivers/gpu/pvr/devicemem.c index eb57ea3..1cd3ef4 100644 --- a/drivers/gpu/pvr/devicemem.c +++ b/drivers/gpu/pvr/devicemem.c @@ -188,16 +188,11 @@ enum PVRSRV_ERROR PVRSRVCreateDeviceMemContextKM(void *hDevCookie, } enum PVRSRV_ERROR PVRSRVDestroyDeviceMemContextKM(void *hDevCookie, - void *hDevMemContext, - IMG_BOOL *pbDestroyed) + void *hDevMemContext) { - int destroyed; - PVR_UNREFERENCED_PARAMETER(hDevCookie); - destroyed = pvr_put_ctx(hDevMemContext); - if (pbDestroyed) - *pbDestroyed = destroyed ? IMG_TRUE : IMG_FALSE; + pvr_put_ctx(hDevMemContext); return PVRSRV_OK; } diff --git a/drivers/gpu/pvr/pvr_bridge_km.h b/drivers/gpu/pvr/pvr_bridge_km.h index 2dfe577..120c8f8 100644 --- a/drivers/gpu/pvr/pvr_bridge_km.h +++ b/drivers/gpu/pvr/pvr_bridge_km.h @@ -90,7 +90,7 @@ enum PVRSRV_ERROR PVRSRVCreateDeviceMemContextKM(void *hDevCookie, IMG_BOOL *pbShared); enum PVRSRV_ERROR PVRSRVDestroyDeviceMemContextKM(void *hDevCookie, - void *hDevMemContext, IMG_BOOL *pbCreated); + void *hDevMemContext); enum PVRSRV_ERROR PVRSRVGetDeviceMemHeapInfoKM(void *hDevCookie, void *hDevMemContext, u32 *pui32ClientHeapCount, -- 1.7.5.4 From b2659a96b7698c0937b4003f2b4a1f9679043a7a Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 12 Apr 2011 17:54:26 +0300 Subject: [PATCH 85/95] gpu: pvr: report IOCTL failures Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 39 +++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 1161389..ac976ca 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -2849,11 +2849,38 @@ static int bridged_check_cmd(u32 cmd_id) return 0; } +static void pr_ioctl_error(u32 cmd, const char *proc_name, int err, + const void *out, off_t out_err_ofs) +{ + u32 r; + + if (err) { + r = err; + } else if (out) { + r = *(u32 *)(out + out_err_ofs); + if (!r) + return; + + /* + * Don't report the following timeout failure, it's business + * as usual (unfortunately). + */ + if (PVRSRV_IOWR(cmd) == PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE && + r == PVRSRV_ERROR_CMD_NOT_PROCESSED) + return; + } else { + return; + } + + pr_warning("pvr: %s: IOCTL %d failed (%d)\n", proc_name, cmd, r); +} + static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, size_t in_size, struct PVRSRV_PER_PROCESS_DATA *per_proc) { int err = -EFAULT; + off_t out_err_ofs = 0; switch (PVRSRV_IOWR(cmd)) { case PVRSRV_BRIDGE_ENUM_DEVICES: @@ -3093,6 +3120,9 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, break; case PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR: + out_err_ofs = + offsetof(struct PVRSRV_BRIDGE_OUT_GETMMU_PD_DEVPADDR, + eError); err = MMU_GetPDDevPAddrBW(cmd, in, out, per_proc); break; @@ -3107,6 +3137,9 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = PVRSRVEventObjectWaitBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_EVENT_OBJECT_OPEN: + out_err_ofs = + offsetof(struct PVRSRV_BRIDGE_OUT_EVENT_OBJECT_OPEN, + eError); err = PVRSRVEventObjectOpenBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_EVENT_OBJECT_CLOSE: @@ -3118,6 +3151,8 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, break; case PVRSRV_BRIDGE_SGX_GETCLIENTINFO: + out_err_ofs = offsetof(struct PVRSRV_BRIDGE_OUT_GETCLIENTINFO, + eError); err = SGXGetClientInfoBW(cmd, in, out, per_proc); break; case PVRSRV_BRIDGE_SGX_RELEASECLIENTINFO: @@ -3216,7 +3251,9 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, __func__, cmd); } - return err; + pr_ioctl_error(cmd, per_proc->name, err, out, out_err_ofs); + + return err; } int BridgedDispatchKM(struct file *filp, struct PVRSRV_PER_PROCESS_DATA *pd, -- 1.7.5.4 From 86b4bda8e9ce09a0d8c7c6326234f94621a89001 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 5 Apr 2011 14:41:22 +0200 Subject: [PATCH 86/95] gpu: pvr: remove CommonBridgeInit() By dynamically assigning the function names in the BridgeDispatchTable, an extra layer of potential errors (when CommonBridgeInit or SetSGXDispatchTableEntry is not in full sync with the switch statement in bridged_ioctl()) is removed. /proc/pvr/bridge_stats now no longer shows IOCTL names and the function they are supposed to be mapped to. It now shows actual IOCTL numbers, and the functions called for them (when called at all). It can debated which is more useful, but the removal of the extra layer of potential errors wins. Crucially though, we stop caring about "holes" in IOCTL assignment, which makes it much easier for me to move pdump ioctls to their own range. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 291 +++------------------------------- drivers/gpu/pvr/bridged_pvr_bridge.h | 45 ++---- drivers/gpu/pvr/bridged_sgx_bridge.c | 66 -------- drivers/gpu/pvr/bridged_sgx_bridge.h | 2 - drivers/gpu/pvr/pvr_bridge_k.c | 11 +- 5 files changed, 44 insertions(+), 371 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index ac976ca..4621710 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -51,10 +51,9 @@ #include <linux/mm.h> #include <linux/sched.h> +#if defined(DEBUG_BRIDGE_KM) struct PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_ENTRY_COUNT]; - -#if defined(DEBUG_BRIDGE_KM) struct PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats; #endif @@ -82,7 +81,25 @@ enum PVRSRV_ERROR CopyToUserWrapper(struct PVRSRV_PER_PROCESS_DATA *pProcData, g_BridgeGlobalStats.ui32TotalCopyToUserBytes += ui32Size; return OSCopyToUser(pProcData, pvDest, pvSrc, ui32Size); } -#endif + +/* + * This is not a real sanity check. Entries cannot overlap as the compiler + * catches this in the switch statement. It does however construct a list + * of which calls are mapped to which id, as needed by /proc/pvr/bridge_stats. + */ +void +PVRSRVBridgeIDCheck(u32 id, const char *function) +{ + if (id != PVRSRV_GET_BRIDGE_ID(id)) + pr_err("PVR: IOCTL %d out of range! (%s)\n", id, function); + else if (!g_BridgeDispatchTable[id].pszFunctionName) + g_BridgeDispatchTable[id].pszFunctionName = function; + else if (g_BridgeDispatchTable[id].pszFunctionName != function) + pr_err("PVR: IOCTL %d mismatch: %s != %s\n", id, + g_BridgeDispatchTable[id].pszFunctionName, function); +} + +#endif /* DEBUG_BRIDGE_KM */ static int PVRSRVEnumerateDevicesBW(u32 ui32BridgeID, void *psBridgeIn, struct PVRSRV_BRIDGE_OUT_ENUMDEVICE *psEnumDeviceOUT, @@ -2397,93 +2414,18 @@ static int MMU_GetPDDevPAddrBW(u32 ui32BridgeID, int DummyBW(u32 ui32BridgeID, void *psBridgeIn, void *psBridgeOut, struct PVRSRV_PER_PROCESS_DATA *psPerProc) { -#if !defined(CONFIG_PVR_DEBUG_EXTRA) - PVR_UNREFERENCED_PARAMETER(ui32BridgeID); +#if defined(DEBUG_BRIDGE_KM) + PVRSRVBridgeIDCheck(ui32BridgeID, __func__); #endif PVR_UNREFERENCED_PARAMETER(psBridgeIn); PVR_UNREFERENCED_PARAMETER(psBridgeOut); PVR_UNREFERENCED_PARAMETER(psPerProc); -#if defined(DEBUG_BRIDGE_KM) - PVR_DPF(PVR_DBG_ERROR, "%s: BRIDGE ERROR: BridgeID %lu (%s) mapped to " - "Dummy Wrapper (probably not what you want!)", - __func__, ui32BridgeID, - g_BridgeDispatchTable[ui32BridgeID].pszIOCName); -#else PVR_DPF(PVR_DBG_ERROR, "%s: BRIDGE ERROR: BridgeID %lu mapped to " - "Dummy Wrapper (probably not what you want!)", - __func__, ui32BridgeID); -#endif - return -ENOTTY; -} - -void _SetDispatchTableEntry(u32 ui32Index, const char *pszIOCName, - int (*pfFunction)(u32 ui32BridgeID, - void *psBridgeIn, - void *psBridgeOut, - struct PVRSRV_PER_PROCESS_DATA - *psPerProc), - const char *pszFunctionName) -{ - static u32 ui32PrevIndex = ~0UL; -#if !defined(CONFIG_PVR_DEBUG_EXTRA) - PVR_UNREFERENCED_PARAMETER(pszIOCName); -#endif -#if !defined(DEBUG_BRIDGE_KM_DISPATCH_TABLE) && !defined(DEBUG_BRIDGE_KM) - PVR_UNREFERENCED_PARAMETER(pszFunctionName); -#endif - - - if (g_BridgeDispatchTable[ui32Index].pfFunction) { -#if defined(DEBUG_BRIDGE_KM) - PVR_DPF(PVR_DBG_ERROR, "%s: BUG!: " - "Adding dispatch table entry for %s " - "clobbers an existing entry for %s", - __func__, pszIOCName, - g_BridgeDispatchTable[ui32Index].pszIOCName); -#else - PVR_DPF(PVR_DBG_ERROR, "%s: BUG!: " - "Adding dispatch table entry for %s " - "clobbers an existing entry (index=%lu)", - __func__, pszIOCName, ui32Index); -#endif - PVR_DPF(PVR_DBG_ERROR, -"NOTE: Enabling DEBUG_BRIDGE_KM_DISPATCH_TABLE may help debug this issue.", - __func__); - } + "Dummy Wrapper (probably not what you want!)", + __func__, ui32BridgeID); - if ((ui32PrevIndex != ~0UL) && - ((ui32Index >= ui32PrevIndex + DISPATCH_TABLE_GAP_THRESHOLD) || - (ui32Index <= ui32PrevIndex))) { -#if defined(DEBUG_BRIDGE_KM) - PVR_DPF(PVR_DBG_WARNING, - "%s: There is a gap in the dispatch table " - "between indices %lu (%s) and %lu (%s)", - __func__, ui32PrevIndex, - g_BridgeDispatchTable[ui32PrevIndex].pszIOCName, - ui32Index, pszIOCName); -#else - PVR_DPF(PVR_DBG_WARNING, - "%s: There is a gap in the dispatch table " - "between indices %u and %u (%s)", - __func__, (unsigned)ui32PrevIndex, (unsigned)ui32Index, - pszIOCName); -#endif - PVR_DPF(PVR_DBG_ERROR, - "NOTE: Enabling DEBUG_BRIDGE_KM_DISPATCH_TABLE " - "may help debug this issue.", - __func__); - } - - g_BridgeDispatchTable[ui32Index].pfFunction = pfFunction; -#if defined(DEBUG_BRIDGE_KM) - g_BridgeDispatchTable[ui32Index].pszIOCName = pszIOCName; - g_BridgeDispatchTable[ui32Index].pszFunctionName = pszFunctionName; - g_BridgeDispatchTable[ui32Index].ui32CallCount = 0; - g_BridgeDispatchTable[ui32Index].ui32CopyFromUserTotalBytes = 0; -#endif - - ui32PrevIndex = ui32Index; + return -ENOTTY; } static int PVRSRVInitSrvConnectBW(u32 ui32BridgeID, void *psBridgeIn, @@ -2630,187 +2572,6 @@ static int PVRSRVEventObjectCloseBW(u32 ui32BridgeID, return 0; } -enum PVRSRV_ERROR CommonBridgeInit(void) -{ - u32 i; - - SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DEVICES, - PVRSRVEnumerateDevicesBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_ACQUIRE_DEVICEINFO, - PVRSRVAcquireDeviceDataBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_RELEASE_DEVICEINFO, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CREATE_DEVMEMCONTEXT, - PVRSRVCreateDeviceMemContextBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_DEVMEMCONTEXT, - PVRSRVDestroyDeviceMemContextBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DEVMEM_HEAPINFO, - PVRSRVGetDeviceMemHeapInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_ALLOC_DEVICEMEM, - PVRSRVAllocDeviceMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_FREE_DEVICEMEM, - PVRSRVFreeDeviceMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GETFREE_DEVICEMEM, - PVRSRVGetFreeDeviceMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CREATE_COMMANDQUEUE, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_COMMANDQUEUE, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MHANDLE_TO_MMAP_DATA, - PVRMMapOSMemHandleToMMapDataBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CONNECT_SERVICES, PVRSRVConnectBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_DISCONNECT_SERVICES, - PVRSRVDisconnectBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_WRAP_DEVICE_MEM, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DEVICEMEMINFO, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_RESERVE_DEV_VIRTMEM, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_FREE_DEV_VIRTMEM, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_EXT_MEMORY, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_EXT_MEMORY, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEV_MEMORY, - PVRSRVMapDeviceMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEV_MEMORY, - PVRSRVUnmapDeviceMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_DEVICECLASS_MEMORY, - PVRSRVMapDeviceClassMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_DEVICECLASS_MEMORY, - PVRSRVUnmapDeviceClassMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_MEM_INFO_TO_USER, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAP_MEM_INFO_FROM_USER, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_EXPORT_DEVICEMEM, - PVRSRVExportDeviceMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_RELEASE_MMAP_DATA, - PVRMMapReleaseMMapDataBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CACHE_FLUSH_DRM, - PVRSRVCacheFlushDRIBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_PROCESS_SIMISR_EVENT, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_REGISTER_SIM_PROCESS, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNREGISTER_SIM_PROCESS, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_MAPPHYSTOUSERSPACE, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNMAPPHYSTOUSERSPACE, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GETPHYSTOUSERSPACEMAP, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_FB_STATS, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_MISC_INFO, PVRSRVGetMiscInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_RELEASE_MISC_INFO, DummyBW); - - -#if defined(PDUMP) - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_INIT, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_MEMPOL, PDumpMemPolBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPMEM, PDumpMemBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_REG, PDumpRegWithFlagsBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_REGPOL, PDumpRegPolBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_COMMENT, PDumpCommentBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_SETFRAME, PDumpSetFrameBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_ISCAPTURING, - PDumpIsCaptureFrameBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPBITMAP, PDumpBitmapBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPREADREG, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_SYNCPOL, PDumpSyncPolBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPSYNC, PDumpSyncDumpBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DRIVERINFO, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_PDREG, PDumpPDRegBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR, - PDumpPDDevPAddrBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ, - PDumpCycleCountRegReadBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STARTINITPHASE, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMP_STOPINITPHASE, DummyBW); -#endif - - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_OEMJTABLE, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_CLASS, PVRSRVEnumerateDCBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_OPEN_DISPCLASS_DEVICE, - PVRSRVOpenDCDeviceBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_DISPCLASS_DEVICE, - PVRSRVCloseDCDeviceBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_FORMATS, - PVRSRVEnumDCFormatsBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_ENUM_DISPCLASS_DIMS, - PVRSRVEnumDCDimsBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_SYSBUFFER, - PVRSRVGetDCSystemBufferBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_INFO, - PVRSRVGetDCInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CREATE_DISPCLASS_SWAPCHAIN, - PVRSRVCreateDCSwapChainBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_DESTROY_DISPCLASS_SWAPCHAIN, - PVRSRVDestroyDCSwapChainBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_DSTRECT, - PVRSRVSetDCDstRectBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_SRCRECT, - PVRSRVSetDCSrcRectBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_DSTCOLOURKEY, - PVRSRVSetDCDstColourKeyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SET_DISPCLASS_SRCCOLOURKEY, - PVRSRVSetDCSrcColourKeyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_DISPCLASS_BUFFERS, - PVRSRVGetDCBuffersBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_BUFFER, - PVRSRVSwapToDCBufferBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SWAP_DISPCLASS_TO_SYSTEM, - PVRSRVSwapToDCSystemBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_OPEN_BUFFERCLASS_DEVICE, - PVRSRVOpenBCDeviceBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_CLOSE_BUFFERCLASS_DEVICE, - PVRSRVCloseBCDeviceBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_INFO, - PVRSRVGetBCInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_GET_BUFFERCLASS_BUFFER, - PVRSRVGetBCBufferBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_WRAP_EXT_MEMORY, - PVRSRVWrapExtMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_UNWRAP_EXT_MEMORY, - PVRSRVUnwrapExtMemoryBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_ALLOC_SHARED_SYS_MEM, - PVRSRVAllocSharedSysMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_FREE_SHARED_SYS_MEM, - PVRSRVFreeSharedSysMemoryBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_MAP_MEMINFO_MEM, - PVRSRVMapMemInfoMemBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_GETMMU_PD_DEVPADDR, - MMU_GetPDDevPAddrBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_INITSRV_CONNECT, - PVRSRVInitSrvConnectBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_INITSRV_DISCONNECT, - PVRSRVInitSrvDisconnectBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_EVENT_OBJECT_WAIT, - PVRSRVEventObjectWaitBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_EVENT_OBJECT_OPEN, - PVRSRVEventObjectOpenBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_EVENT_OBJECT_CLOSE, - PVRSRVEventObjectCloseBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_MODIFY_SYNC_OPS, - PVRSRVModifySyncOpsBW); - - SetSGXDispatchTableEntry(); - - for (i = 0; i < BRIDGE_DISPATCH_TABLE_ENTRY_COUNT; i++) - if (!g_BridgeDispatchTable[i].pfFunction) { - g_BridgeDispatchTable[i].pfFunction = DummyBW; -#if defined(DEBUG_BRIDGE_KM) - g_BridgeDispatchTable[i].pszIOCName = - "_PVRSRV_BRIDGE_DUMMY"; - g_BridgeDispatchTable[i].pszFunctionName = "DummyBW"; - g_BridgeDispatchTable[i].ui32CallCount = 0; - g_BridgeDispatchTable[i].ui32CopyFromUserTotalBytes = 0; - g_BridgeDispatchTable[i].ui32CopyToUserTotalBytes = 0; -#endif - } - - return PVRSRV_OK; -} - static int bridged_check_cmd(u32 cmd_id) { if (PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_RAN)) { @@ -3284,7 +3045,7 @@ int BridgedDispatchKM(struct file *filp, struct PVRSRV_PER_PROCESS_DATA *pd, pkg->ui32InBufferSize) != PVRSRV_OK) goto return_fault; - if (bid >= (BRIDGE_DISPATCH_TABLE_ENTRY_COUNT)) { + if (bid >= (PVRSRV_BRIDGE_LAST_SGX_CMD)) { PVR_DPF(PVR_DBG_ERROR, "%s: ui32BridgeID = %d is out if range!", __func__, bid); diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.h b/drivers/gpu/pvr/bridged_pvr_bridge.h index 188fded..9371df0 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.h +++ b/drivers/gpu/pvr/bridged_pvr_bridge.h @@ -99,57 +99,38 @@ static inline void ReleaseHandleBatch(struct PVRSRV_PER_PROCESS_DATA *psPerProc) int DummyBW(u32 ui32BridgeID, void *psBridgeIn, void *psBridgeOut, struct PVRSRV_PER_PROCESS_DATA *psPerProc); -struct PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY { - int (*pfFunction)(u32 ui32BridgeID, void *psBridgeIn, void *psBridgeOut, - struct PVRSRV_PER_PROCESS_DATA *psPerProc); #if defined(DEBUG_BRIDGE_KM) - const char *pszIOCName; +#define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (1 << _IOC_NRBITS) + +struct PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY { const char *pszFunctionName; u32 ui32CallCount; u32 ui32CopyFromUserTotalBytes; u32 ui32CopyToUserTotalBytes; -#endif }; -#define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT (PVRSRV_BRIDGE_LAST_SGX_CMD+1) -#define PVRSRV_BRIDGE_LAST_DEVICE_CMD PVRSRV_BRIDGE_LAST_SGX_CMD - extern struct PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_ENTRY_COUNT]; -void _SetDispatchTableEntry(u32 ui32Index, - const char *pszIOCName, - int (*pfFunction) (u32 ui32BridgeID, - void *psBridgeIn, - void *psBridgeOut, - struct PVRSRV_PER_PROCESS_DATA * - psPerProc), - const char *pszFunctionName); +void PVRSRVBridgeIDCheck(u32 id, const char *function); -#define SetDispatchTableEntry(ui32Index, pfFunction) \ - _SetDispatchTableEntry(PVRSRV_GET_BRIDGE_ID(ui32Index), #ui32Index, \ - (int (*)(u32 ui32BridgeID, void *psBridgeIn, void *psBridgeOut, \ - struct PVRSRV_PER_PROCESS_DATA *psPerProc))pfFunction, #pfFunction) +#define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) do { \ + PVR_ASSERT(X == PVRSRV_GET_BRIDGE_ID(Y)); \ + PVRSRVBridgeIDCheck((X), __func__); \ + } while (0) -#define DISPATCH_TABLE_GAP_THRESHOLD 5 - -#if defined(CONFIG_PVR_DEBUG_EXTRA) -#define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) PVR_ASSERT(X == PVRSRV_GET_BRIDGE_ID(Y)) -#else -#define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) PVR_UNREFERENCED_PARAMETER(X) -#endif - -#if defined(DEBUG_BRIDGE_KM) struct PVRSRV_BRIDGE_GLOBAL_STATS { u32 ui32IOCTLCount; u32 ui32TotalCopyFromUserBytes; u32 ui32TotalCopyToUserBytes; }; - extern struct PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats; -#endif -enum PVRSRV_ERROR CommonBridgeInit(void); +#else + +#define PVRSRV_BRIDGE_ASSERT_CMD(X, Y) PVR_UNREFERENCED_PARAMETER(X) + +#endif /* DEBUG_BRIDGE_KM */ int BridgedDispatchKM(struct file *filp, struct PVRSRV_PER_PROCESS_DATA *psPerProc, diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.c b/drivers/gpu/pvr/bridged_sgx_bridge.c index adb8af5..14f0aad 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.c +++ b/drivers/gpu/pvr/bridged_sgx_bridge.c @@ -1791,69 +1791,3 @@ int SGXPDumpHWPerfCBBW(u32 ui32BridgeID, } #endif - -void SetSGXDispatchTableEntry(void) -{ - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETCLIENTINFO, - SGXGetClientInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_RELEASECLIENTINFO, - SGXReleaseClientInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETINTERNALDEVINFO, - SGXGetInternalDevInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_DOKICK, SGXDoKickBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETPHYSPAGEADDR, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READREGISTRYDWORD, DummyBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SCHEDULECOMMAND, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_2DQUERYBLTSCOMPLETE, - SGX2DQueryBlitsCompleteBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETMMUPDADDR, DummyBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SUBMITTRANSFER, - SGXSubmitTransferBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_GETMISCINFO, SGXGetMiscInfoBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGXINFO_FOR_SRVINIT, - SGXGetInfoForSrvinitBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_DEVINITPART2, - SGXDevInitPart2BW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_FINDSHAREDPBDESC, - SGXFindSharedPBDescBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREFSHAREDPBDESC, - SGXUnrefSharedPBDescBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_ADDSHAREDPBDESC, - SGXAddSharedPBDescBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_REGISTER_HW_RENDER_CONTEXT, - SGXRegisterHWRenderContextBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_FLUSH_HW_RENDER_TARGET, - SGXFlushHWRenderTargetBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREGISTER_HW_RENDER_CONTEXT, - SGXUnregisterHWRenderContextBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_REGISTER_HW_TRANSFER_CONTEXT, - SGXRegisterHWTransferContextBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_UNREGISTER_HW_TRANSFER_CONTEXT, - SGXUnregisterHWTransferContextBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READ_DIFF_COUNTERS, - SGXReadDiffCountersBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_READ_HWPERF_CB, - SGXReadHWPerfCBBW); - - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_SCHEDULE_PROCESS_QUEUES, - SGXScheduleProcessQueuesBW); - -#if defined(PDUMP) - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY, - SGXPDumpBufferArrayBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS, - SGXPDump3DSignatureRegistersBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS, - SGXPDumpCounterRegistersBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS, - SGXPDumpTASignatureRegistersBW); - SetDispatchTableEntry(PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB, - SGXPDumpHWPerfCBBW); -#endif -} diff --git a/drivers/gpu/pvr/bridged_sgx_bridge.h b/drivers/gpu/pvr/bridged_sgx_bridge.h index 91e5b67..6c1e711 100644 --- a/drivers/gpu/pvr/bridged_sgx_bridge.h +++ b/drivers/gpu/pvr/bridged_sgx_bridge.h @@ -27,8 +27,6 @@ #ifndef __BRIDGED_SGX_BRIDGE_H__ #define __BRIDGED_SGX_BRIDGE_H__ -void SetSGXDispatchTableEntry(void); - int SGXGetClientInfoBW(u32 ui32BridgeID, struct PVRSRV_BRIDGE_IN_GETCLIENTINFO *psGetClientInfoIN, struct PVRSRV_BRIDGE_OUT_GETCLIENTINFO *psGetClientInfoOUT, diff --git a/drivers/gpu/pvr/pvr_bridge_k.c b/drivers/gpu/pvr/pvr_bridge_k.c index 7489f65..3bba80f 100644 --- a/drivers/gpu/pvr/pvr_bridge_k.c +++ b/drivers/gpu/pvr/pvr_bridge_k.c @@ -98,7 +98,7 @@ enum PVRSRV_ERROR LinuxBridgeInit(void) return PVRSRV_ERROR_OUT_OF_MEMORY; } #endif - return CommonBridgeInit(); + return PVRSRV_OK; } void LinuxBridgeDeInit(void) @@ -126,13 +126,13 @@ static off_t printLinuxBridgeStats(char *buffer, size_t count, off_t off) "Total number of bytes copied via copy_from_user = %u\n" "Total number of bytes copied via copy_to_user = %u\n" "Total number of bytes copied via copy_*_user = %u\n\n" - "%-45s | %-40s | %10s | %20s | %10s\n", + "%-2s | %-40s | %10s | %20s | %10s\n", g_BridgeGlobalStats.ui32IOCTLCount, g_BridgeGlobalStats.ui32TotalCopyFromUserBytes, g_BridgeGlobalStats.ui32TotalCopyToUserBytes, g_BridgeGlobalStats.ui32TotalCopyFromUserBytes + g_BridgeGlobalStats.ui32TotalCopyToUserBytes, - "Bridge Name", "Wrapper Function", + "ID", "Wrapper Function", "Call Count", "copy_from_user Bytes", "copy_to_user Bytes"); @@ -151,9 +151,8 @@ static off_t printLinuxBridgeStats(char *buffer, size_t count, off_t off) psEntry = &g_BridgeDispatchTable[off - 1]; Ret = printAppend(buffer, count, 0, - "%-45s %-40s %-10u %-20u %-10u\n", - psEntry->pszIOCName, - psEntry->pszFunctionName, + "%02lX %-40s %-10u %-20u %-10u\n", + off - 1, psEntry->pszFunctionName, psEntry->ui32CallCount, psEntry->ui32CopyFromUserTotalBytes, psEntry->ui32CopyToUserTotalBytes); -- 1.7.5.4 From fb0aaf0d56ed89707e0f2375ecea20adceef2679 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 5 Apr 2011 14:41:24 +0200 Subject: [PATCH 87/95] gpu: pvr: move ioctl checking error messagess to pr_err() This way, we get to actually see ioctls failing. Also, a pointless check is removed: the switch statement that follows will take care of unhandled cases for us anyway (and now complain about them verbosely). Fixes: NB#251136 - PVR: fix IOCTL command ID range checking Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 27 +++++++-------------------- 1 files changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 4621710..980781e 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -2576,16 +2576,14 @@ static int bridged_check_cmd(u32 cmd_id) { if (PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_RAN)) { if (!PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_SUCCESSFUL)) { - PVR_DPF(PVR_DBG_ERROR, - "%s: Initialisation failed. Driver unusable.", - __func__); + pr_err("PVR: ERROR: Initialisation failed. " + "Driver unusable.\n"); return 1; } } else { if (PVRSRVGetInitServerState(PVRSRV_INIT_SERVER_RUNNING)) { - PVR_DPF(PVR_DBG_ERROR, - "%s: Initialisation is in progress", - __func__); + pr_err("PVR: ERROR: Initialisation still in " + "progress.\n"); return 1; } else { switch (cmd_id) { @@ -2599,9 +2597,8 @@ static int bridged_check_cmd(u32 cmd_id) PVRSRV_BRIDGE_INITSRV_DISCONNECT): break; default: - PVR_DPF(PVR_DBG_ERROR, - "%s: Driver initialisation not completed yet.", - __func__); + pr_err("PVR: ERROR: initialisation not " + "completed yet.\n"); return 1; } } @@ -3008,8 +3005,7 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, #endif default: - PVR_DPF(PVR_DBG_ERROR, "%s: cmd = %d is out if range!", - __func__, cmd); + pr_err("PVR: Error: Unhandled IOCTL %d.\n", cmd); } pr_ioctl_error(cmd, per_proc->name, err, out, out_err_ofs); @@ -3020,7 +3016,6 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, int BridgedDispatchKM(struct file *filp, struct PVRSRV_PER_PROCESS_DATA *pd, struct PVRSRV_BRIDGE_PACKAGE *pkg) { - void *in; void *out; u32 bid = pkg->ui32BridgeID; @@ -3045,15 +3040,7 @@ int BridgedDispatchKM(struct file *filp, struct PVRSRV_PER_PROCESS_DATA *pd, pkg->ui32InBufferSize) != PVRSRV_OK) goto return_fault; - if (bid >= (PVRSRV_BRIDGE_LAST_SGX_CMD)) { - PVR_DPF(PVR_DBG_ERROR, - "%s: ui32BridgeID = %d is out if range!", __func__, - bid); - goto return_fault; - } - err = bridged_ioctl(filp, bid, in, out, pkg->ui32InBufferSize, pd); - if (err < 0) goto return_fault; -- 1.7.5.4 From 667558a26400137fd9c13f158814921ecf40dcfd Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 5 Apr 2011 14:41:25 +0200 Subject: [PATCH 88/95] gpu: pvr: fix init script handling for pdump/non-pdump A PDUMP enabled build has SGX_INIT_OP_HALT shift one up in the enum, as its former position is replaced with SGX_INIT_OP_PDUMP_HW_REG. When kernel and userspace are out of sync, this leads to rather interesting results since the init script is run _before_ userspace build options are compared with the kernel build options. By moving SGX_INIT_OP_PDUMP_HW_REG, and not masking it behind #ifdef PDUMP, we get around this issue for good, without in anyway altering the behavior of a current non-pdump build. Some extra checking of the init script is now also included to catch and warn about all possible cases of kernel and userspace being out of sync, with respect to pdump support (and the new difference in OP_PDUMP_HW_REG). This way, even if we do not make it to the build option checking, we still know what went wrong. This patch requires matching userspace, but only when pdump is enabled. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/sgxinit.c | 60 +++++++++++++++++++++++++----------------- drivers/gpu/pvr/sgxscript.h | 5 +-- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/pvr/sgxinit.c b/drivers/gpu/pvr/sgxinit.c index c1f0f53..3cd70ec 100644 --- a/drivers/gpu/pvr/sgxinit.c +++ b/drivers/gpu/pvr/sgxinit.c @@ -192,35 +192,47 @@ static enum PVRSRV_ERROR SGXRunScript(struct PVRSRV_SGXDEV_INFO *psDevInfo, ui32PC < ui32NumInitCommands; ui32PC++, psComm++) { switch (psComm->eOp) { case SGX_INIT_OP_WRITE_HW_REG: - { - OSWriteHWReg(psDevInfo->pvRegsBaseKM, - psComm->sWriteHWReg.ui32Offset, - psComm->sWriteHWReg.ui32Value); - PDUMPREG(psComm->sWriteHWReg.ui32Offset, - psComm->sWriteHWReg.ui32Value); - break; + OSWriteHWReg(psDevInfo->pvRegsBaseKM, + psComm->sWriteHWReg.ui32Offset, + psComm->sWriteHWReg.ui32Value); + PDUMPREG(psComm->sWriteHWReg.ui32Offset, + psComm->sWriteHWReg.ui32Value); + break; + case SGX_INIT_OP_HALT: + /* Old OP_PDUMP_HW_REG masked OP_HALT */ + if (psComm->sWriteHWReg.ui32Offset) { + pr_warning("%s: Init Script HALT command " + "contains data!\n", __func__); + pr_warning("PVR: Is userspace built with " + "incompatible PDUMP support?\n"); } -#if defined(PDUMP) + return PVRSRV_OK; case SGX_INIT_OP_PDUMP_HW_REG: - { - PDUMPREG(psComm->sPDumpHWReg.ui32Offset, - psComm->sPDumpHWReg.ui32Value); - break; - } -#endif - case SGX_INIT_OP_HALT: - { - return PVRSRV_OK; +#if defined(PDUMP) + if (!psComm->sPDumpHWReg.ui32Offset && + !psComm->sPDumpHWReg.ui32Value) { + pr_warning("%s: Init Script PDUMP command " + "contains no offset/value!\n", + __func__); + pr_warning("PVR: Is userspace built without " + "PDUMP support?\n"); } - case SGX_INIT_OP_ILLEGAL: + PDUMPREG(psComm->sPDumpHWReg.ui32Offset, + psComm->sPDumpHWReg.ui32Value); + break; +#else + pr_err("%s: Init Script contains PDUMP writes!\n", + __func__); + pr_err("PVR: ERROR: Userspace built with PDUMP " + "support!\n"); + return PVRSRV_ERROR_GENERIC; +#endif /* PDUMP */ + case SGX_INIT_OP_ILLEGAL: default: - { - PVR_DPF(PVR_DBG_ERROR, - "SGXRunScript: PC %d: Illegal command: %d", - ui32PC, psComm->eOp); - return PVRSRV_ERROR_GENERIC; - } + pr_err("PVR: ERROR: %s: PC %d: Illegal operation: " + "0x%02X\n", __func__, ui32PC, psComm->eOp); + return PVRSRV_ERROR_GENERIC; } } diff --git a/drivers/gpu/pvr/sgxscript.h b/drivers/gpu/pvr/sgxscript.h index 2bbb0ba..5e02216 100644 --- a/drivers/gpu/pvr/sgxscript.h +++ b/drivers/gpu/pvr/sgxscript.h @@ -34,10 +34,9 @@ enum SGX_INIT_OPERATION { SGX_INIT_OP_ILLEGAL = 0, SGX_INIT_OP_WRITE_HW_REG, -#if defined(PDUMP) + /* Do not move this halt, especially not for something like PDUMP. */ + SGX_INIT_OP_HALT, SGX_INIT_OP_PDUMP_HW_REG, -#endif - SGX_INIT_OP_HALT }; union SGX_INIT_COMMAND { -- 1.7.5.4 From d50498dedf6b38197bab0d684b88f3445dbba3c6 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Tue, 5 Apr 2011 14:41:26 +0200 Subject: [PATCH 89/95] gpu: pvr: move pdump ioctls to its own range at 192 This removes the shifting of ioctls when enabling pdump builds. Fixes: NB#247418 - PVR kernel driver IOCTL IDs depend on build configuration Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/bridged_pvr_bridge.c | 110 +++++++++++++++++----------------- drivers/gpu/pvr/pvr_bridge.h | 95 +++++++++++++++-------------- drivers/gpu/pvr/sgx_bridge.h | 23 +++++-- 3 files changed, 120 insertions(+), 108 deletions(-) diff --git a/drivers/gpu/pvr/bridged_pvr_bridge.c b/drivers/gpu/pvr/bridged_pvr_bridge.c index 980781e..49f39c0 100644 --- a/drivers/gpu/pvr/bridged_pvr_bridge.c +++ b/drivers/gpu/pvr/bridged_pvr_bridge.c @@ -2738,61 +2738,6 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, err = DummyBW(cmd, in, out, per_proc); break; -#if defined(PDUMP) - case PVRSRV_BRIDGE_PDUMP_INIT: - err = DummyBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_MEMPOL: - err = PDumpMemPolBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DUMPMEM: - err = PDumpMemBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_REG: - err = PDumpRegWithFlagsBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_REGPOL: - err = PDumpRegPolBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_COMMENT: - err = PDumpCommentBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_SETFRAME: - err = PDumpSetFrameBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_ISCAPTURING: - err = PDumpIsCaptureFrameBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DUMPBITMAP: - err = PDumpBitmapBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DUMPREADREG: - err = DummyBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_SYNCPOL: - err = PDumpSyncPolBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DUMPSYNC: - err = PDumpSyncDumpBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DRIVERINFO: - err = DummyBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_PDREG: - err = PDumpPDRegBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR: - err = PDumpPDDevPAddrBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ: - err = PDumpCycleCountRegReadBW(cmd, in, out, per_proc); - break; - case PVRSRV_BRIDGE_PDUMP_STARTINITPHASE: - case PVRSRV_BRIDGE_PDUMP_STOPINITPHASE: - err = DummyBW(cmd, in, out, per_proc); - break; -#endif - case PVRSRV_BRIDGE_GET_OEMJTABLE: err = DummyBW(cmd, in, out, per_proc); break; @@ -2987,6 +2932,61 @@ static int bridged_ioctl(struct file *filp, u32 cmd, void *in, void *out, break; #if defined(PDUMP) + /* PDUMP IOCTLs live in a separate range */ + case PVRSRV_BRIDGE_PDUMP_INIT: + err = DummyBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_MEMPOL: + err = PDumpMemPolBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DUMPMEM: + err = PDumpMemBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_REG: + err = PDumpRegWithFlagsBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_REGPOL: + err = PDumpRegPolBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_COMMENT: + err = PDumpCommentBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_SETFRAME: + err = PDumpSetFrameBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_ISCAPTURING: + err = PDumpIsCaptureFrameBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DUMPBITMAP: + err = PDumpBitmapBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DUMPREADREG: + err = DummyBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_SYNCPOL: + err = PDumpSyncPolBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DUMPSYNC: + err = PDumpSyncDumpBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DRIVERINFO: + err = DummyBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_PDREG: + err = PDumpPDRegBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR: + err = PDumpPDDevPAddrBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ: + err = PDumpCycleCountRegReadBW(cmd, in, out, per_proc); + break; + case PVRSRV_BRIDGE_PDUMP_STARTINITPHASE: + case PVRSRV_BRIDGE_PDUMP_STOPINITPHASE: + err = DummyBW(cmd, in, out, per_proc); + break; + + /* bridged_sgx_bridge */ case PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY: err = SGXPDumpBufferArrayBW(cmd, in, out, per_proc); break; diff --git a/drivers/gpu/pvr/pvr_bridge.h b/drivers/gpu/pvr/pvr_bridge.h index d41e73d..22dd20f 100644 --- a/drivers/gpu/pvr/pvr_bridge.h +++ b/drivers/gpu/pvr/pvr_bridge.h @@ -149,55 +149,10 @@ #define PVRSRV_BRIDGE_OVERLAY_CMD_LAST \ (PVRSRV_BRIDGE_OVERLAY_CMD_FIRST+1) -#if defined(PDUMP) -#define PVRSRV_BRIDGE_PDUMP_CMD_FIRST \ - (PVRSRV_BRIDGE_OVERLAY_CMD_FIRST+1) -#define PVRSRV_BRIDGE_PDUMP_INIT \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+0) -#define PVRSRV_BRIDGE_PDUMP_MEMPOL \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+1) -#define PVRSRV_BRIDGE_PDUMP_DUMPMEM \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+2) -#define PVRSRV_BRIDGE_PDUMP_REG \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+3) -#define PVRSRV_BRIDGE_PDUMP_REGPOL \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+4) -#define PVRSRV_BRIDGE_PDUMP_COMMENT \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+5) -#define PVRSRV_BRIDGE_PDUMP_SETFRAME \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+6) -#define PVRSRV_BRIDGE_PDUMP_ISCAPTURING \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+7) -#define PVRSRV_BRIDGE_PDUMP_DUMPBITMAP \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+8) -#define PVRSRV_BRIDGE_PDUMP_DUMPREADREG \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+9) -#define PVRSRV_BRIDGE_PDUMP_SYNCPOL \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+10) -#define PVRSRV_BRIDGE_PDUMP_DUMPSYNC \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+11) -#define PVRSRV_BRIDGE_PDUMP_MEMPAGES \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+12) -#define PVRSRV_BRIDGE_PDUMP_DRIVERINFO \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+13) -#define PVRSRV_BRIDGE_PDUMP_PDREG \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+14) -#define PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+15) -#define PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+16) -#define PVRSRV_BRIDGE_PDUMP_STARTINITPHASE \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+17) -#define PVRSRV_BRIDGE_PDUMP_STOPINITPHASE \ - PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+18) -#define PVRSRV_BRIDGE_PDUMP_CMD_LAST \ - (PVRSRV_BRIDGE_PDUMP_CMD_FIRST+18) -#else -#define PVRSRV_BRIDGE_PDUMP_CMD_LAST PVRSRV_BRIDGE_OVERLAY_CMD_LAST -#endif +/* PDUMP was here */ #define PVRSRV_BRIDGE_OEM_CMD_FIRST \ - (PVRSRV_BRIDGE_PDUMP_CMD_LAST+1) + (PVRSRV_BRIDGE_OVERLAY_CMD_LAST+1) #define PVRSRV_BRIDGE_GET_OEMJTABLE \ PVRSRV_IOWR(PVRSRV_BRIDGE_OEM_CMD_FIRST+0) #define PVRSRV_BRIDGE_OEM_CMD_LAST \ @@ -317,6 +272,52 @@ #define PVRSRV_BRIDGE_LAST_NON_DEVICE_CMD \ (PVRSRV_BRIDGE_SYNC_OPS_CMD_LAST+1) + +#if defined(PDUMP) +#define PVRSRV_BRIDGE_PDUMP_CMD_FIRST 192 +#define PVRSRV_BRIDGE_PDUMP_INIT \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+0) +#define PVRSRV_BRIDGE_PDUMP_MEMPOL \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+1) +#define PVRSRV_BRIDGE_PDUMP_DUMPMEM \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+2) +#define PVRSRV_BRIDGE_PDUMP_REG \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+3) +#define PVRSRV_BRIDGE_PDUMP_REGPOL \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+4) +#define PVRSRV_BRIDGE_PDUMP_COMMENT \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+5) +#define PVRSRV_BRIDGE_PDUMP_SETFRAME \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+6) +#define PVRSRV_BRIDGE_PDUMP_ISCAPTURING \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+7) +#define PVRSRV_BRIDGE_PDUMP_DUMPBITMAP \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+8) +#define PVRSRV_BRIDGE_PDUMP_DUMPREADREG \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+9) +#define PVRSRV_BRIDGE_PDUMP_SYNCPOL \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+10) +#define PVRSRV_BRIDGE_PDUMP_DUMPSYNC \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+11) +#define PVRSRV_BRIDGE_PDUMP_MEMPAGES \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+12) +#define PVRSRV_BRIDGE_PDUMP_DRIVERINFO \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+13) +#define PVRSRV_BRIDGE_PDUMP_PDREG \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+14) +#define PVRSRV_BRIDGE_PDUMP_DUMPPDDEVPADDR \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+15) +#define PVRSRV_BRIDGE_PDUMP_CYCLE_COUNT_REG_READ \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+16) +#define PVRSRV_BRIDGE_PDUMP_STARTINITPHASE \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+17) +#define PVRSRV_BRIDGE_PDUMP_STOPINITPHASE \ + PVRSRV_IOWR(PVRSRV_BRIDGE_PDUMP_CMD_FIRST+18) +#define PVRSRV_BRIDGE_PDUMP_CMD_LAST \ + (PVRSRV_BRIDGE_PDUMP_CMD_FIRST+18) +#endif /* PDUMP */ + + #define PVRSRV_KERNEL_MODE_CLIENT 1 struct PVRSRV_BRIDGE_RETURN { diff --git a/drivers/gpu/pvr/sgx_bridge.h b/drivers/gpu/pvr/sgx_bridge.h index dab97c7f..1bb3209 100644 --- a/drivers/gpu/pvr/sgx_bridge.h +++ b/drivers/gpu/pvr/sgx_bridge.h @@ -87,20 +87,31 @@ #define PVRSRV_BRIDGE_SGX_READ_HWPERF_CB \ PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+30) +#define PVRSRV_BRIDGE_LAST_SGX_CMD (PVRSRV_BRIDGE_SGX_CMD_BASE+30) + + #if defined(PDUMP) +#define PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE \ + (PVRSRV_BRIDGE_PDUMP_CMD_LAST+1) + #define PVRSRV_BRIDGE_SGX_PDUMP_BUFFER_ARRAY \ - PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+31) + PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE+0) #define PVRSRV_BRIDGE_SGX_PDUMP_3D_SIGNATURE_REGISTERS \ - PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+32) + PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE+1) #define PVRSRV_BRIDGE_SGX_PDUMP_COUNTER_REGISTERS \ - PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+33) + PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE+2) #define PVRSRV_BRIDGE_SGX_PDUMP_TA_SIGNATURE_REGISTERS \ - PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+34) + PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE+3) #define PVRSRV_BRIDGE_SGX_PDUMP_HWPERFCB \ - PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_CMD_BASE+35) + PVRSRV_IOWR(PVRSRV_BRIDGE_SGX_PDUMP_CMD_BASE+4) #endif -#define PVRSRV_BRIDGE_LAST_SGX_CMD (PVRSRV_BRIDGE_SGX_CMD_BASE+35) +/* sanity check */ +#if defined(PDUMP) +#if PVRSRV_BRIDGE_PDUMP_CMD_FIRST <= PVRSRV_BRIDGE_LAST_SGX_CMD +# error Standard and PDUMP IOCTLs overlap!!! +#endif +#endif struct PVRSRV_BRIDGE_IN_GETPHYSPAGEADDR { u32 ui32BridgeFlags; -- 1.7.5.4 From 30fec4f482c6bab3b45db3542ab5930f888db454 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 1 Apr 2011 13:45:08 +0200 Subject: [PATCH 90/95] gpu: pvr: debugfs: add registers file Switches to power state D0 before capturing all registers on open. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 223 +++++++++++++++++++++++++++++++---------- 1 files changed, 171 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 40e30cf..78987c7 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -101,7 +101,7 @@ exit: return r; } -static int pvr_debugfs_set(void *data, u64 val) +static int pvr_debugfs_reset_wrapper(void *data, u64 val) { u32 *var = data; @@ -111,7 +111,8 @@ static int pvr_debugfs_set(void *data, u64 val) BUG(); } -DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_fops, NULL, pvr_debugfs_set, "%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_reset_fops, NULL, + pvr_debugfs_reset_wrapper, "%llu\n"); #ifdef PVRSRV_USSE_EDM_STATUS_DEBUG /* @@ -303,6 +304,156 @@ static const struct file_operations pvr_dbg_trcmd_fops = { #endif /* + * llseek helper. + */ +static loff_t +pvr_debugfs_llseek_helper(struct file *filp, loff_t offset, int whence, + loff_t max) +{ + loff_t f_pos; + + switch (whence) { + case SEEK_SET: + if ((offset > max) || (offset < 0)) + f_pos = -EINVAL; + else + f_pos = offset; + break; + case SEEK_CUR: + if (((filp->f_pos + offset) > max) || + ((filp->f_pos + offset) < 0)) + f_pos = -EINVAL; + else + f_pos = filp->f_pos + offset; + break; + case SEEK_END: + if ((offset > 0) || + (offset < -max)) + f_pos = -EINVAL; + else + f_pos = max + offset; + break; + default: + f_pos = -EINVAL; + break; + } + + if (f_pos >= 0) + filp->f_pos = f_pos; + + return f_pos; +} + +/* + * One shot register dump. + * + * Only in D0 can we read all registers. Our driver currently only does either + * D0 or D3. In D3 any register read results in a SIGBUS. There is a possibility + * that in D1 or possibly D2 all registers apart from [0xA08:0xA4C] can be read. + */ +static int +pvr_debugfs_regs_open(struct inode *inode, struct file *filp) +{ + struct PVRSRV_DEVICE_NODE *node; + struct PVRSRV_SGXDEV_INFO *dev; + enum PVRSRV_ERROR error; + u32 *regs; + int i, ret = 0; + + regs = (u32 *) __get_free_page(GFP_KERNEL); + if (!regs) + return -ENOMEM; + + pvr_lock(); + + if (pvr_is_disabled()) { + ret = -ENODEV; + goto exit; + } + + node = get_sgx_node(); + if (!node) { + ret = -ENODEV; + goto exit; + } + dev = node->pvDevice; + + error = PVRSRVSetDevicePowerStateKM(node->sDevId.ui32DeviceIndex, + PVRSRV_POWER_STATE_D0); + if (error != PVRSRV_OK) { + ret = -EIO; + goto exit; + } + + for (i = 0; i < 1024; i++) + regs[i] = readl(dev->pvRegsBaseKM + 4 * i); + + filp->private_data = regs; + + SGXTestActivePowerEvent(node); + + exit: + pvr_unlock(); + + return ret; +} + +static int +pvr_debugfs_regs_release(struct inode *inode, struct file *filp) +{ + free_page((unsigned long) filp->private_data); + + return 0; +} + +#define REGS_DUMP_LINE_SIZE 17 +#define REGS_DUMP_FORMAT "0x%03X 0x%08X\n" + +static loff_t +pvr_debugfs_regs_llseek(struct file *filp, loff_t offset, int whence) +{ + return pvr_debugfs_llseek_helper(filp, offset, whence, + 1024 * REGS_DUMP_LINE_SIZE); +} + +static ssize_t +pvr_debugfs_regs_read(struct file *filp, char __user *buf, size_t size, + loff_t *f_pos) +{ + char tmp[REGS_DUMP_LINE_SIZE + 1]; + u32 *regs = filp->private_data; + int i; + + if ((*f_pos < 0) || (size < (sizeof(tmp) - 1))) + return 0; + + i = ((int) *f_pos) / (sizeof(tmp) - 1); + if (i >= 1024) + return 0; + + size = snprintf(tmp, sizeof(tmp), REGS_DUMP_FORMAT, i * 4, regs[i]); + + if (size > 0) { + if (copy_to_user(buf, tmp + *f_pos - (i * (sizeof(tmp) - 1)), + size)) + return -EFAULT; + + *f_pos += size; + return size; + } else + return 0; +} + +static const struct file_operations pvr_debugfs_regs_fops = { + .owner = THIS_MODULE, + .llseek = pvr_debugfs_regs_llseek, + .read = pvr_debugfs_regs_read, + .open = pvr_debugfs_regs_open, + .release = pvr_debugfs_regs_release, +}; + + +/* * * HW Recovery dumping support. * @@ -752,43 +903,6 @@ hwrec_file_release(struct inode *inode, struct file *filp) return 0; } -static loff_t -hwrec_llseek_helper(struct file *filp, loff_t offset, int whence, loff_t max) -{ - loff_t f_pos; - - switch (whence) { - case SEEK_SET: - if ((offset > max) || (offset < 0)) - f_pos = -EINVAL; - else - f_pos = offset; - break; - case SEEK_CUR: - if (((filp->f_pos + offset) > max) || - ((filp->f_pos + offset) < 0)) - f_pos = -EINVAL; - else - f_pos = filp->f_pos + offset; - break; - case SEEK_END: - if ((offset > 0) || - (offset < -max)) - f_pos = -EINVAL; - else - f_pos = max + offset; - break; - default: - f_pos = -EINVAL; - break; - } - - if (f_pos >= 0) - filp->f_pos = f_pos; - - return f_pos; -} - /* * Provides a hwrec timestamp for unique dumping. */ @@ -885,8 +999,6 @@ static const struct file_operations hwrec_event_fops = { /* * Reads out all readable registers. */ -#define HWREC_REGS_LINE_SIZE 17 - static loff_t hwrec_regs_llseek(struct file *filp, loff_t offset, int whence) { @@ -895,8 +1007,8 @@ hwrec_regs_llseek(struct file *filp, loff_t offset, int whence) mutex_lock(hwrec_mutex); if (hwrec_registers) - f_pos = hwrec_llseek_helper(filp, offset, whence, - 1024 * HWREC_REGS_LINE_SIZE); + f_pos = pvr_debugfs_llseek_helper(filp, offset, whence, + 1024 * REGS_DUMP_LINE_SIZE); else f_pos = 0; @@ -909,7 +1021,7 @@ static ssize_t hwrec_regs_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) { - char tmp[HWREC_REGS_LINE_SIZE + 1]; + char tmp[REGS_DUMP_LINE_SIZE + 1]; int i; if ((*f_pos < 0) || (size < (sizeof(tmp) - 1))) @@ -924,7 +1036,7 @@ hwrec_regs_read(struct file *filp, char __user *buf, size_t size, if (!hwrec_registers) size = 0; else - size = snprintf(tmp, sizeof(tmp), "0x%03X 0x%08X\n", i * 4, + size = snprintf(tmp, sizeof(tmp), REGS_DUMP_FORMAT, i * 4, hwrec_registers[i]); mutex_unlock(hwrec_mutex); @@ -961,8 +1073,8 @@ hwrec_mem_llseek(struct file *filp, loff_t offset, int whence) mutex_lock(hwrec_mutex); if (hwrec_mem_size) - f_pos = hwrec_llseek_helper(filp, offset, whence, - hwrec_mem_size); + f_pos = pvr_debugfs_llseek_helper(filp, offset, whence, + hwrec_mem_size); else f_pos = 0; @@ -1023,8 +1135,8 @@ hwrec_edm_llseek(struct file *filp, loff_t offset, int whence) mutex_lock(hwrec_mutex); if (hwrec_edm_buf) - f_pos = hwrec_llseek_helper(filp, offset, whence, - hwrec_edm_buf->len); + f_pos = pvr_debugfs_llseek_helper(filp, offset, whence, + hwrec_edm_buf->len); else f_pos = 0; @@ -1073,8 +1185,8 @@ hwrec_status_llseek(struct file *filp, loff_t offset, int whence) mutex_lock(hwrec_mutex); if (hwrec_status_size) - f_pos = hwrec_llseek_helper(filp, offset, whence, - hwrec_status_size); + f_pos = pvr_debugfs_llseek_helper(filp, offset, whence, + hwrec_status_size); else f_pos = 0; @@ -1134,7 +1246,7 @@ int pvr_debugfs_init(void) return -ENODEV; if (!debugfs_create_file("reset_sgx", S_IWUSR, pvr_debugfs_dir, - &pvr_reset, &pvr_debugfs_fops)) { + &pvr_reset, &pvr_debugfs_reset_fops)) { debugfs_remove(pvr_debugfs_dir); return -ENODEV; } @@ -1153,6 +1265,13 @@ int pvr_debugfs_init(void) return -ENODEV; } #endif + + if (!debugfs_create_file("registers", S_IRUSR, pvr_debugfs_dir, NULL, + &pvr_debugfs_regs_fops)) { + debugfs_remove(pvr_debugfs_dir); + return -ENODEV; + } + if (!debugfs_create_file("hwrec_event", S_IRUSR, pvr_debugfs_dir, NULL, &hwrec_event_fops)) { debugfs_remove_recursive(pvr_debugfs_dir); -- 1.7.5.4 From 126b14cdc8bfb3ee6f34ba797df9b36421af36cb Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 1 Apr 2011 13:47:59 +0200 Subject: [PATCH 91/95] gpu: pvr: hwrec: fix hwrec_mem_pages type change warnings Last minute change of hwrec_mem_pages, from u32 to unsigned long, was not build tested due to hwrec_mem dumping now only happening inside CONFIG_PVR_DEBUG, which was not given a spin before submission. Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 78987c7..9636d02 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -504,7 +504,7 @@ hwrec_registers_dump(struct PVRSRV_SGXDEV_INFO *psDevInfo) } static void -hwrec_pages_free(size_t *size, u32 *pages) +hwrec_pages_free(size_t *size, unsigned long *pages) { int i; @@ -520,8 +520,8 @@ hwrec_pages_free(size_t *size, u32 *pages) } static int -hwrec_pages_write(u8 *buffer, size_t size, size_t *current_size, u32 *pages, - int array_size) +hwrec_pages_write(u8 *buffer, size_t size, size_t *current_size, + unsigned long *pages, int array_size) { size_t ret = 0; @@ -591,7 +591,7 @@ hwrec_mem_print(char *format, ...) * Render status buffer dumping. */ static size_t hwrec_status_size; -static u32 hwrec_status_pages[1024]; +static unsigned long hwrec_status_pages[1024]; static int hwrec_status_write(char *buffer, size_t size) -- 1.7.5.4 From a8424d61ea3b16a68a9a50b7f56acd9ac21787dc Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Fri, 1 Apr 2011 13:50:10 +0200 Subject: [PATCH 92/95] gpu: pvr: fix pdumpfs_stream_buffer_clear Fix tmp[] filling loop so that size == sizeof(tmp) also functions correctly. Spotted-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_pdumpfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/pvr/pvr_pdumpfs.c b/drivers/gpu/pvr/pvr_pdumpfs.c index 6050fd3..c1b7df5 100644 --- a/drivers/gpu/pvr/pvr_pdumpfs.c +++ b/drivers/gpu/pvr/pvr_pdumpfs.c @@ -786,7 +786,7 @@ pdumpfs_stream_buffer_clear(char __user *buf, size_t size) if (size >= sizeof(tmp)) { int i; - for (i = 0; (i + sizeof(tmp)) < size; i += sizeof(tmp)) + for (i = 0; (i + sizeof(tmp)) <= size; i += sizeof(tmp)) if (copy_to_user(buf + i, tmp, sizeof(tmp))) return -EFAULT; return i; -- 1.7.5.4 From 4a7b5b04007cfa7fdabf1c7fb517bc97fbdfbcbc Mon Sep 17 00:00:00 2001 From: Imre Deak <imre.deak@nokia.com> Date: Tue, 19 Apr 2011 19:57:42 +0300 Subject: [PATCH 93/95] gpu: pvr: fix missing return value warning when CONFIG_BUG=n Although the behaviour after these functions return in a BUG() condition is undefined, we could still make things somewhat more predictable by returning the same value every time. Also this way we get rid of the warning. Signed-off-by: Imre Deak <imre.deak@nokia.com> --- drivers/gpu/pvr/pvr_debugfs.c | 2 ++ drivers/gpu/pvr/sysconfig.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/pvr/pvr_debugfs.c b/drivers/gpu/pvr/pvr_debugfs.c index 9636d02..32ca6c3 100644 --- a/drivers/gpu/pvr/pvr_debugfs.c +++ b/drivers/gpu/pvr/pvr_debugfs.c @@ -109,6 +109,8 @@ static int pvr_debugfs_reset_wrapper(void *data, u64 val) return pvr_debugfs_reset(data, val); BUG(); + + return -EFAULT; } DEFINE_SIMPLE_ATTRIBUTE(pvr_debugfs_reset_fops, NULL, diff --git a/drivers/gpu/pvr/sysconfig.c b/drivers/gpu/pvr/sysconfig.c index 94f18f6..2a31b70 100644 --- a/drivers/gpu/pvr/sysconfig.c +++ b/drivers/gpu/pvr/sysconfig.c @@ -160,6 +160,8 @@ unsigned long sgx_get_max_freq(void) } } BUG(); + + return 0; } #else -- 1.7.5.4 From 16300cd429324c964e33e5bbf2ad346a44b05f87 Mon Sep 17 00:00:00 2001 From: Alex Crowther <alex.crowther@imgtec.com> Date: Mon, 23 May 2011 12:46:17 +0100 Subject: [PATCH 94/95] gpu: pvr: V2: Find and fix all incorrect sync counter completion checks Bugfix for a very rare buffer wrap issue on sync counters though the use of the wrap safe sync_cnt_after_eq function Fixes: NB#233069 Signed-off-by: Alex Crowther <alex.crowther@imgtec.com> --- drivers/gpu/pvr/sgxutils.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/pvr/sgxutils.c b/drivers/gpu/pvr/sgxutils.c index 860cbb6..b5e5b7d 100644 --- a/drivers/gpu/pvr/sgxutils.c +++ b/drivers/gpu/pvr/sgxutils.c @@ -644,16 +644,26 @@ enum PVRSRV_ERROR SGXUnregisterHWTransferContextKM(void *hHWTransferContext) return PVRSRV_OK; } + + +static inline int sync_cnt_after_eq(u32 c1, u32 c2) +{ + return (int)(c1 - c2) >= 0; +} + + + static inline IMG_BOOL SGX2DQuerySyncOpsComplete( struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo, u32 ui32ReadOpsPending, u32 ui32WriteOpsPending) { struct PVRSRV_SYNC_DATA *psSyncData = psSyncInfo->psSyncData; - return (IMG_BOOL)((psSyncData->ui32ReadOpsComplete >= - ui32ReadOpsPending) && - (psSyncData->ui32WriteOpsComplete >= - ui32WriteOpsPending)); + return (IMG_BOOL)( + sync_cnt_after_eq( + psSyncData->ui32ReadOpsComplete, ui32ReadOpsPending) && + sync_cnt_after_eq( + psSyncData->ui32WriteOpsComplete, ui32WriteOpsPending)); } enum PVRSRV_ERROR SGX2DQueryBlitsCompleteKM( -- 1.7.5.4 From 24128cdbb5fb8581b2ecbcff6c4e3ae6954fdab8 Mon Sep 17 00:00:00 2001 From: Luc Verhaegen <libv@codethink.co.uk> Date: Wed, 18 May 2011 10:01:40 +0200 Subject: [PATCH 95/95] gpu: pvr: kick: check for duplicate src syncs When duplicate syncs are present, we deadlock; so check and throw an error message. Was already fixed in userspace as part of #253237, this now shores up the kernel too. Fixes: NB#254225 Signed-off-by: Luc Verhaegen <libv@codethink.co.uk> --- drivers/gpu/pvr/sgxkick.c | 45 ++++++++++++++++++++++++++++++++------------- 1 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/pvr/sgxkick.c b/drivers/gpu/pvr/sgxkick.c index 0a951e0..c3891a6 100644 --- a/drivers/gpu/pvr/sgxkick.c +++ b/drivers/gpu/pvr/sgxkick.c @@ -160,31 +160,50 @@ enum PVRSRV_ERROR SGXDoKickKM(void *hDevHandle, struct SGX_CCB_KICK *psCCBKick, } } - psTACmd->ui32NumSrcSyncs = psCCBKick->ui32NumSrcSyncs; - for (i = 0; i < SGX_MAX_SRC_SYNCS; i++) { - if (i >= psCCBKick->ui32NumSrcSyncs) { - pvr_trcmd_clear_syn(&ktrace->src_syn[i]); - continue; + /* check for duplicates while creating the new list */ + psTACmd->ui32NumSrcSyncs = 0; + for (i = 0; ((i < SGX_MAX_SRC_SYNCS) && + (i < psCCBKick->ui32NumSrcSyncs)); i++) { + int j; + + psSyncInfo = (struct PVRSRV_KERNEL_SYNC_INFO *) + psCCBKick->ahSrcKernelSyncInfo[i]; + + for (j = 0; j < i; j++) { + struct PVRSRV_KERNEL_SYNC_INFO *tmp = + psCCBKick->ahSrcKernelSyncInfo[j]; + if (tmp->psSyncData == psSyncInfo->psSyncData) { + pr_err("%s: Duplicate SRC Sync detected: %p\n", + __func__, tmp->psSyncData); + break; + } } + if (j != i) + continue; - psSyncInfo = - (struct PVRSRV_KERNEL_SYNC_INFO *)psCCBKick-> - ahSrcKernelSyncInfo[i]; + /* beat the 80 char limit. */ + j = psTACmd->ui32NumSrcSyncs; - psTACmd->asSrcSyncs[i].sWriteOpsCompleteDevVAddr = + psTACmd->asSrcSyncs[j].sWriteOpsCompleteDevVAddr = psSyncInfo->sWriteOpsCompleteDevVAddr; - psTACmd->asSrcSyncs[i].sReadOpsCompleteDevVAddr = + psTACmd->asSrcSyncs[j].sReadOpsCompleteDevVAddr = psSyncInfo->sReadOpsCompleteDevVAddr; - psTACmd->asSrcSyncs[i].ui32ReadOpsPendingVal = + psTACmd->asSrcSyncs[j].ui32ReadOpsPendingVal = psSyncInfo->psSyncData->ui32ReadOpsPending++; - psTACmd->asSrcSyncs[i].ui32WriteOpsPendingVal = + psTACmd->asSrcSyncs[j].ui32WriteOpsPendingVal = psSyncInfo->psSyncData->ui32WriteOpsPending; - pvr_trcmd_set_syn(&ktrace->src_syn[i], psSyncInfo); + pvr_trcmd_set_syn(&ktrace->src_syn[j], psSyncInfo); + + psTACmd->ui32NumSrcSyncs++; } + /* clear the remaining src syncs */ + for (i = psTACmd->ui32NumSrcSyncs; i < SGX_MAX_SRC_SYNCS; i++) + pvr_trcmd_clear_syn(&ktrace->src_syn[i]); + if (psCCBKick->bFirstKickOrResume && psCCBKick->ui32NumDstSyncObjects > 0) { struct PVRSRV_KERNEL_MEM_INFO *psHWDstSyncListMemInfo = -- 1.7.5.4