drm/msm: Fixes/updates for perfetto profiling
Subsystems (5)
cover drm/msm: Fixes/updates for perfetto profiling
From: Rob Clark <[email protected]>
A couple kernel side things I realized I needed in the process of implementing performance-counter and render-stage support for perfetto, the first patch fixes the MSM_PARAM_TIMESTAMP query which was just wrong on a5xx/a6xx (ALWAYS_COUNT vs ALWAYS_ON). The second adds a way for userspace to determine whether the device has suspended since the last sampling period (which means counters have lost their state and configuration).
I am a bit tempted to add a way that a CAP_SYS_ADMIN user could ask the GPU to not suspend (until the drm_file is closed), but so far I've managed to avoid needing this.
Rob Clark (2):
drm/msm: Fix a5xx/a6xx timestamps
drm/msm: Add param for userspace to query suspend count
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++ drivers/gpu/drm/msm/msm_drv.c | 1 + drivers/gpu/drm/msm/msm_gpu.c | 2 ++ drivers/gpu/drm/msm/msm_gpu.h | 2 ++ include/uapi/drm/msm_drm.h | 1 + 7 files changed, 13 insertions(+), 4 deletions(-)
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/2 drm/msm: Fix a5xx/a6xx timestamps
From: Rob Clark <[email protected]>
They were reading a counter that was configured to ALWAYS_COUNT (ie. cycles that the GPU is doing something) rather than ALWAYS_ON. This isn't the thing that userspace is looking for.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -2
@@ -1241,8 +1241,8 @@ static int a5xx_pm_suspend(struct msm_gpu *gpu)static int a5xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { - *value =gpu_read64 (gpu,REG_A5XX_RBBM_PERFCTR_CP_0_LO , -REG_A5XX_RBBM_PERFCTR_CP_0_HI ); + *value =gpu_read64 (gpu,REG_A5XX_RBBM_ALWAYSON_COUNTER_LO , +REG_A5XX_RBBM_ALWAYSON_COUNTER_HI );return 0 ; }
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -2
@@ -1173,8 +1173,8 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)/* Force the GPU power on so we can read this register */ a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); - *value =gpu_read64 (gpu,REG_A6XX_RBBM_PERFCTR_CP_0_LO , -REG_A6XX_RBBM_PERFCTR_CP_0_HI ); + *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER_LO , +REG_A6XX_CP_ALWAYS_ON_COUNTER_HI );a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET );return 0 ;
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/msm: Add param for userspace to query suspend count
In reply to Rob ClarkFrom: Rob Clark <[email protected]>
Performance counts, and ALWAYS_ON counters used for capturing GPU timestamps, lose their state across suspend/resume cycles. Userspace tooling for performance monitoring needs to be aware of this. For example, after a suspend userspace needs to recalibrate it's offset between CPU and GPU time.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++ drivers/gpu/drm/msm/msm_drv.c | 1 + drivers/gpu/drm/msm/msm_gpu.c | 2 ++ drivers/gpu/drm/msm/msm_gpu.h | 2 ++ include/uapi/drm/msm_drm.h | 1 + 5 files changed, 9 insertions(+)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -0
@@ -280,6 +280,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)case MSM_PARAM_FAULTS : *value = gpu->global_faults;return 0 ; +case MSM_PARAM_SUSPENDS : + *value = gpu->suspend_count; +return 0 ;default :DBG ("%s: invalid param: %u" , gpu->name, param);return -EINVAL ;
drivers/gpu/drm/msm/msm_drv.c +1 -0
@@ -39,6 +39,7 @@* GEM object's debug name * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl * - 1.6.0 - Syncobj support +* - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count */ #define MSM_VERSION_MAJOR 1#define MSM_VERSION_MINOR 6
drivers/gpu/drm/msm/msm_gpu.c +2 -0
@@ -256,6 +256,8 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu)if (ret)return ret; + gpu->suspend_count++; +return 0 ; }
drivers/gpu/drm/msm/msm_gpu.h +2 -0
@@ -152,6 +152,8 @@ struct msm_gpu {ktime_t time; } devfreq; +uint32_t suspend_count; +struct msm_gpu_state *crashstate;/* True if the hardware supports expanded apriv (a650 and newer) */ bool hw_apriv;
include/uapi/drm/msm_drm.h +1 -0
@@ -76,6 +76,7 @@ struct drm_msm_timespec {#define MSM_PARAM_NR_RINGS 0x07#define MSM_PARAM_PP_PGTABLE 0x08/* => 1 for per-process pagetables, else 0 */ #define MSM_PARAM_FAULTS 0x09 +#define MSM_PARAM_SUSPENDS 0x0astruct drm_msm_param {__u32 pipe;/* in, MSM_PIPE_x */
Signature · 6 lines
2.29.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Freedreno] [PATCH 1/2] drm/msm: Fix a5xx/a6xx timestamps
In reply to Rob ClarkQuoted 5 lines · Rob Clark
From: Rob Clark <[email protected]>
They were reading a counter that was configured to
ALWAYS_COUNT(ie. cycles that the GPU is doing something) rather thanALWAYS_ON. This isn't the thing that userspace is looking for.
Quoted 43 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2
-2@@ -1241,8 +1241,8 @@ static int a5xx_pm_suspend(struct msm_gpu *gpu)static int a5xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { - *value =gpu_read64 (gpu,REG_A5XX_RBBM_PERFCTR_CP_0_LO , -REG_A5XX_RBBM_PERFCTR_CP_0_HI ); + *value =gpu_read64 (gpu,REG_A5XX_RBBM_ALWAYSON_COUNTER_LO , +REG_A5XX_RBBM_ALWAYSON_COUNTER_HI );return 0 ; }drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2
-2@@ -1173,8 +1173,8 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)/* Force the GPU power on so we can read this register */ a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); - *value =gpu_read64 (gpu,REG_A6XX_RBBM_PERFCTR_CP_0_LO , -REG_A6XX_RBBM_PERFCTR_CP_0_HI ); + *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER_LO , +REG_A6XX_CP_ALWAYS_ON_COUNTER_HI );a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET );return 0 ;Signature · 6 lines
2.29.2 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [Freedreno] [PATCH 2/2] drm/msm: Add param for userspace to query suspend count
In reply to Rob ClarkQuoted 8 lines · Rob Clark
From: Rob Clark <[email protected]>
Performance counts, and
ALWAYS_ONcounters used for capturing GPU timestamps, lose their state across suspend/resume cycles. Userspace tooling for performance monitoring needs to be aware of this. For example, after a suspend userspace needs to recalibrate it's offset between CPU and GPU time.
Quoted 80 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++ drivers/gpu/drm/msm/msm_drv.c | 1 + drivers/gpu/drm/msm/msm_gpu.c | 2 ++ drivers/gpu/drm/msm/msm_gpu.h | 2 ++ include/uapi/drm/msm_drm.h | 1 + 5 files changed, 9 insertions(+)drivers/gpu/drm/msm/adreno/adreno_gpu.c +3
-0@@ -280,6 +280,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)case MSM_PARAM_FAULTS : *value = gpu->global_faults;return 0 ; +case MSM_PARAM_SUSPENDS : + *value = gpu->suspend_count; +return 0 ;default :DBG ("%s: invalid param: %u" , gpu->name, param);return -EINVAL ;drivers/gpu/drm/msm/msm_drv.c +1
-0@@ -39,6 +39,7 @@* GEM object's debug name * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl * - 1.6.0 - Syncobj support +* - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count */ #define MSM_VERSION_MAJOR 1#define MSM_VERSION_MINOR 6drivers/gpu/drm/msm/msm_gpu.c +2
-0@@ -256,6 +256,8 @@ int msm_gpu_pm_suspend(struct msm_gpu *gpu)if (ret)return ret; + gpu->suspend_count++; +return 0 ; }drivers/gpu/drm/msm/msm_gpu.h +2
-0@@ -152,6 +152,8 @@ struct msm_gpu {ktime_t time; } devfreq; +uint32_t suspend_count; +struct msm_gpu_state *crashstate;/* True if the hardware supports expanded apriv (a650 and newer) */ bool hw_apriv;include/uapi/drm/msm_drm.h +1
-0@@ -76,6 +76,7 @@ struct drm_msm_timespec {#define MSM_PARAM_NR_RINGS 0x07#define MSM_PARAM_PP_PGTABLE 0x08/* => 1 for per-process pagetables, else 0 */ #define MSM_PARAM_FAULTS 0x09 +#define MSM_PARAM_SUSPENDS 0x0astruct drm_msm_param {__u32 pipe;/* in, MSM_PIPE_x */ Signature · 6 lines
2.29.2 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel