drm/msm cleanups
Subsystems (4)
cover drm/msm cleanups
Here are a few foundational patches to clean up some of the MSM code and get ready for new and awesome things down the line.
Jordan Crouse (3):
drm/msm: gpu: Cut down the list of "generic" registers to the ones we use drm/msm: gpu: Return error on hw_init failure
drm/msm: gpu Add new gpu register read/write functions
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): 1479829657-23698-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
PATCH 1/3 drm/msm: gpu: Cut down the list of "generic" registers to the ones we use
There are very few register accesses in the common code. Cut down the list of common registers to just those that are used. This saves const space and saves us the effort of maintaining registers for A3XX and A4XX that don't exist or are unused.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 80 --------------------------------- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 76 ------------------------------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 59 ------------------------ 3 files changed, 215 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +0 -80
@@ -419,91 +419,11 @@ static void a3xx_dump(struct msm_gpu *gpu) }/* Register offset defines for A3XX */ static const unsigned int a3xx_register_offsets[REG_ADRENO_REGISTER_MAX ] = { -REG_ADRENO_DEFINE (REG_ADRENO_CP_DEBUG ,REG_AXXX_CP_DEBUG ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ME_RAM_WADDR ,REG_AXXX_CP_ME_RAM_WADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ME_RAM_DATA ,REG_AXXX_CP_ME_RAM_DATA ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_PFP_UCODE_DATA , -REG_A3XX_CP_PFP_UCODE_DATA ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_PFP_UCODE_ADDR , -REG_A3XX_CP_PFP_UCODE_ADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_WFI_PEND_CTR ,REG_A3XX_CP_WFI_PEND_CTR ),REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_BASE ,REG_AXXX_CP_RB_BASE ),REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_RPTR_ADDR ,REG_AXXX_CP_RB_RPTR_ADDR ),REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_RPTR ,REG_AXXX_CP_RB_RPTR ),REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_WPTR ,REG_AXXX_CP_RB_WPTR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_PROTECT_CTRL ,REG_A3XX_CP_PROTECT_CTRL ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ME_CNTL ,REG_AXXX_CP_ME_CNTL ),REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_CNTL ,REG_AXXX_CP_RB_CNTL ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_IB1_BASE ,REG_AXXX_CP_IB1_BASE ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_IB1_BUFSZ ,REG_AXXX_CP_IB1_BUFSZ ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_IB2_BASE ,REG_AXXX_CP_IB2_BASE ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_IB2_BUFSZ ,REG_AXXX_CP_IB2_BUFSZ ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_TIMESTAMP ,REG_AXXX_CP_SCRATCH_REG0 ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ME_RAM_RADDR ,REG_AXXX_CP_ME_RAM_RADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_SCRATCH_ADDR ,REG_AXXX_SCRATCH_ADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_SCRATCH_UMSK ,REG_AXXX_SCRATCH_UMSK ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ROQ_ADDR ,REG_A3XX_CP_ROQ_ADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_ROQ_DATA ,REG_A3XX_CP_ROQ_DATA ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_MERCIU_ADDR ,REG_A3XX_CP_MERCIU_ADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_MERCIU_DATA ,REG_A3XX_CP_MERCIU_DATA ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_MERCIU_DATA2 ,REG_A3XX_CP_MERCIU_DATA2 ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_MEQ_ADDR ,REG_A3XX_CP_MEQ_ADDR ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_MEQ_DATA ,REG_A3XX_CP_MEQ_DATA ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_HW_FAULT ,REG_A3XX_CP_HW_FAULT ), -REG_ADRENO_DEFINE (REG_ADRENO_CP_PROTECT_STATUS , -REG_A3XX_CP_PROTECT_STATUS ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_STATUS ,REG_A3XX_RBBM_STATUS ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_CTL , -REG_A3XX_RBBM_PERFCTR_CTL ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_LOAD_CMD0 , -REG_A3XX_RBBM_PERFCTR_LOAD_CMD0 ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_LOAD_CMD1 , -REG_A3XX_RBBM_PERFCTR_LOAD_CMD1 ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_PWR_1_LO , -REG_A3XX_RBBM_PERFCTR_PWR_1_LO ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_INT_0_MASK ,REG_A3XX_RBBM_INT_0_MASK ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_INT_0_STATUS , -REG_A3XX_RBBM_INT_0_STATUS ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_AHB_ERROR_STATUS , -REG_A3XX_RBBM_AHB_ERROR_STATUS ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_AHB_CMD ,REG_A3XX_RBBM_AHB_CMD ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_INT_CLEAR_CMD , -REG_A3XX_RBBM_INT_CLEAR_CMD ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_CLOCK_CTL ,REG_A3XX_RBBM_CLOCK_CTL ), -REG_ADRENO_DEFINE (REG_ADRENO_VPC_DEBUG_RAM_SEL , -REG_A3XX_VPC_VPC_DEBUG_RAM_SEL ), -REG_ADRENO_DEFINE (REG_ADRENO_VPC_DEBUG_RAM_READ , -REG_A3XX_VPC_VPC_DEBUG_RAM_READ ), -REG_ADRENO_DEFINE (REG_ADRENO_VSC_SIZE_ADDRESS , -REG_A3XX_VSC_SIZE_ADDRESS ), -REG_ADRENO_DEFINE (REG_ADRENO_VFD_CONTROL_0 ,REG_A3XX_VFD_CONTROL_0 ), -REG_ADRENO_DEFINE (REG_ADRENO_VFD_INDEX_MAX ,REG_A3XX_VFD_INDEX_MAX ), -REG_ADRENO_DEFINE (REG_ADRENO_SP_VS_PVT_MEM_ADDR_REG , -REG_A3XX_SP_VS_PVT_MEM_ADDR_REG ), -REG_ADRENO_DEFINE (REG_ADRENO_SP_FS_PVT_MEM_ADDR_REG , -REG_A3XX_SP_FS_PVT_MEM_ADDR_REG ), -REG_ADRENO_DEFINE (REG_ADRENO_SP_VS_OBJ_START_REG , -REG_A3XX_SP_VS_OBJ_START_REG ), -REG_ADRENO_DEFINE (REG_ADRENO_SP_FS_OBJ_START_REG , -REG_A3XX_SP_FS_OBJ_START_REG ), -REG_ADRENO_DEFINE (REG_ADRENO_PA_SC_AA_CONFIG ,REG_A3XX_PA_SC_AA_CONFIG ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PM_OVERRIDE2 , -REG_A3XX_RBBM_PM_OVERRIDE2 ), -REG_ADRENO_DEFINE (REG_ADRENO_SCRATCH_REG2 ,REG_AXXX_CP_SCRATCH_REG2 ), -REG_ADRENO_DEFINE (REG_ADRENO_SQ_GPR_MANAGEMENT , -REG_A3XX_SQ_GPR_MANAGEMENT ), -REG_ADRENO_DEFINE (REG_ADRENO_SQ_INST_STORE_MANAGMENT , -REG_A3XX_SQ_INST_STORE_MANAGMENT ), -REG_ADRENO_DEFINE (REG_ADRENO_TP0_CHICKEN ,REG_A3XX_TP0_CHICKEN ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_RBBM_CTL ,REG_A3XX_RBBM_RBBM_CTL ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_SW_RESET_CMD , -REG_A3XX_RBBM_SW_RESET_CMD ), -REG_ADRENO_DEFINE (REG_ADRENO_UCHE_INVALIDATE0 , -REG_A3XX_UCHE_CACHE_INVALIDATE0_REG ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_LOAD_VALUE_LO , -REG_A3XX_RBBM_PERFCTR_LOAD_VALUE_LO ), -REG_ADRENO_DEFINE (REG_ADRENO_RBBM_PERFCTR_LOAD_VALUE_HI , -REG_A3XX_RBBM_PERFCTR_LOAD_VALUE_HI ), };static const struct adreno_gpu_funcs funcs = {
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +0 -76
87 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -59
70 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 2/3 drm/msm: gpu: Return error on hw_init failure
In reply to a message not in the archiveWhen the GPU hardware init function fails (like say, ME_INIT timed out) return error instead of blindly continuing on. This gives us a small chance of saving the system before it goes boom.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 21 ++++++++++++--------- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 20 +++++++++++--------- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 11 +++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 2 +- 5 files changed, 30 insertions(+), 26 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +12 -9
@@ -41,7 +41,7 @@ extern bool hang_debug;static void a3xx_dump (struct msm_gpu *gpu); -static void a3xx_me_init (struct msm_gpu *gpu) +static bool a3xx_me_init (struct msm_gpu *gpu) {struct msm_ringbuffer *ring = gpu->rb;
@@ -65,7 +65,7 @@ static void a3xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); - gpu->funcs->idle (gpu); +return gpu->funcs->idle (gpu); }static int a3xx_hw_init (struct msm_gpu *gpu)
@@ -294,9 +294,7 @@ static int a3xx_hw_init(struct msm_gpu *gpu)/* clear ME_HALT to start micro engine */ gpu_write (gpu,REG_AXXX_CP_ME_CNTL ,0 ); -a3xx_me_init (gpu); - -return 0 ; +return a3xx_me_init (gpu) ?0 : -EINVAL ; }static void a3xx_recover (struct msm_gpu *gpu)
@@ -330,17 +328,22 @@ static void a3xx_destroy(struct msm_gpu *gpu)kfree (a3xx_gpu); } -static void a3xx_idle (struct msm_gpu *gpu) +static bool a3xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -adreno_idle (gpu); +if (!adreno_idle (gpu)) +return false;/* then wait for GPU to finish: */ if (spin_until (!(gpu_read (gpu,REG_A3XX_RBBM_STATUS ) & -A3XX_RBBM_STATUS_GPU_BUSY ))) +A3XX_RBBM_STATUS_GPU_BUSY ))) {DRM_ERROR ("%s: timeout waiting for GPU to idle!\n" , gpu->name); -/* TODO maybe we need to reset GPU here to recover from hang? */ +/* TODO maybe we need to reset GPU here to recover from hang? */ +return false; + } + +return true; }static irqreturn_t a3xx_irq (struct msm_gpu *gpu)
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +11 -9
@@ -113,7 +113,7 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu) } -static void a4xx_me_init (struct msm_gpu *gpu) +static bool a4xx_me_init (struct msm_gpu *gpu) {struct msm_ringbuffer *ring = gpu->rb;
@@ -137,7 +137,7 @@ static void a4xx_me_init(struct msm_gpu *gpu)OUT_RING (ring,0x00000000 ); gpu->funcs->flush (gpu); - gpu->funcs->idle (gpu); +return gpu->funcs->idle (gpu); }static int a4xx_hw_init (struct msm_gpu *gpu)
@@ -292,9 +292,7 @@ static int a4xx_hw_init(struct msm_gpu *gpu)/* clear ME_HALT to start micro engine */ gpu_write (gpu,REG_A4XX_CP_ME_CNTL ,0 ); -a4xx_me_init (gpu); - -return 0 ; +return a4xx_me_init (gpu) ?0 : -EINVAL ; }static void a4xx_recover (struct msm_gpu *gpu)
@@ -328,17 +326,21 @@ static void a4xx_destroy(struct msm_gpu *gpu)kfree (a4xx_gpu); } -static void a4xx_idle (struct msm_gpu *gpu) +static bool a4xx_idle (struct msm_gpu *gpu) {/* wait for ringbuffer to drain: */ -adreno_idle (gpu); +if (!adreno_idle (gpu)) +return false;/* then wait for GPU to finish: */ if (spin_until (!(gpu_read (gpu,REG_A4XX_RBBM_STATUS ) & -A4XX_RBBM_STATUS_GPU_BUSY ))) +A4XX_RBBM_STATUS_GPU_BUSY ))) {DRM_ERROR ("%s: timeout waiting for GPU to idle!\n" , gpu->name); +/* TODO maybe we need to reset GPU here to recover from hang? */ +return false; + } -/* TODO maybe we need to reset GPU here to recover from hang? */ +return true; }static irqreturn_t a4xx_irq (struct msm_gpu *gpu)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +5 -6
@@ -218,19 +218,18 @@ void adreno_flush(struct msm_gpu *gpu)adreno_gpu_write (adreno_gpu,REG_ADRENO_CP_RB_WPTR , wptr); } -void adreno_idle (struct msm_gpu *gpu) +bool adreno_idle (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);uint32_t wptr =get_wptr (gpu->rb); -int ret;/* wait for CP to drain ringbuffer: */ - ret =spin_until (get_rptr (adreno_gpu) == wptr); - -if (ret) -DRM_ERROR ("%s: timeout waiting to drain ringbuffer!\n" , gpu->name); +if (!spin_until (get_rptr (adreno_gpu) == wptr)) +return true;/* TODO maybe we need to reset GPU here to recover from hang? */ +DRM_ERROR ("%s: timeout waiting to drain ringbuffer!\n" , gpu->name); +return false; }#ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1 -1
@@ -182,7 +182,7 @@ void adreno_recover(struct msm_gpu *gpu);void adreno_submit (struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx);void adreno_flush (struct msm_gpu *gpu); -void adreno_idle (struct msm_gpu *gpu); +bool adreno_idle (struct msm_gpu *gpu);#ifdef CONFIG_DEBUG_FS void adreno_show (struct msm_gpu *gpu,struct seq_file *m);#endif
drivers/gpu/drm/msm/msm_gpu.h +1 -1
@@ -50,7 +50,7 @@ struct msm_gpu_funcs {void (*submit)(struct msm_gpu *gpu,struct msm_gem_submit *submit,struct msm_file_private *ctx);void (*flush)(struct msm_gpu *gpu); -void (*idle)(struct msm_gpu *gpu); +bool (*idle)(struct msm_gpu *gpu);irqreturn_t (*irq)(struct msm_gpu *irq);uint32_t (*last_fence)(struct msm_gpu *gpu);void (*recover)(struct msm_gpu *gpu);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 3/3 drm/msm: gpu Add new gpu register read/write functions
In reply to a message not in the archiveAdd some new functions to manipulate GPU registers. gpu_read64 and gpu_write64 can read/write a 64 bit value to two 32 bit registers. For 4XX and older these are normally perfcounter registers, but future targets will use 64 bit addressing so there will be many more spots where a 64 bit read and write are needed.
gpu_rmw() does a read/modify/write on a 32 bit register given a mask and bits to OR in.
--- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 12 ++--------- drivers/gpu/drm/msm/msm_gpu.h | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-)
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2 -10
@@ -513,16 +513,8 @@ static int a4xx_pm_suspend(struct msm_gpu *gpu) {static int a4xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { -uint32_t hi, lo, tmp; - - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); -do { - hi = tmp; - lo =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO ); - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); - }while (tmp != hi); - - *value = (((uint64_t )hi) <<32 ) | lo; + *value =gpu_read64 (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO , +REG_A4XX_RBBM_PERFCTR_CP_0_HI );return 0 ; }
drivers/gpu/drm/msm/msm_gpu.h +39 -0
@@ -154,6 +154,45 @@ static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg)return msm_readl (gpu->mmio + (reg <<2 )); } +static inline void gpu_rmw (struct msm_gpu *gpu,u32 reg,u32 mask,u32 or) +{ +uint32_t val =gpu_read (gpu, reg); + + val &= ~mask; +gpu_write (gpu, reg, val | or); +} + +static inline u64 gpu_read64 (struct msm_gpu *gpu,u32 lo,u32 hi) +{ +u64 val; + +/* +* Why not a readq here? Two reasons: 1) many of the LO registers are +* not quad word aligned and 2) the GPU hardware designers have a bit +* of a history of putting registers where they fit, especially in +* spins. The longer a GPU family goes the higher the chance that +* we'll get burned. We could do a series of validity checks if we +* wanted to, but really is a readq() that much better? Nah. +*/ + +/* +* For some lo/hi registers (like perfcounters), the hi value is latched +* when the lo is read, so make sure to read the lo first to trigger +* that +*/ + val = (u64 )msm_readl (gpu->mmio + (lo <<2 )); + val |= ((u64 )msm_readl (gpu->mmio + (hi <<2 )) <<32 ); + +return val; +} + +static inline void gpu_write64 (struct msm_gpu *gpu,u32 lo,u32 hi,u64 val) +{ +/* Why not a writeq here? Read the screed above */ +msm_writel (lower_32_bits (val), gpu->mmio + (lo <<2 )); +msm_writel (upper_32_bits (val), gpu->mmio + (hi <<2 )); +} +int msm_gpu_pm_suspend (struct msm_gpu *gpu);int msm_gpu_pm_resume (struct msm_gpu *gpu);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
Re: [PATCH 3/3] drm/msm: gpu Add new gpu register read/write functions
Quoted 25 lines · Jordan Crouse
Add some new functions to manipulate GPU registers.
gpu_read64andgpu_write64can read/write a 64 bit value to two 32 bit registers. For 4XX and older these are normally perfcounter registers, but future targets will use 64 bit addressing so there will be many more spots where a 64 bit read and write are needed.
gpu_rmw()does a read/modify/write on a 32 bit register given a mask and bits to OR in.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 12 ++--------- drivers/gpu/drm/msm/msm_gpu.h | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-)drivers/gpu/drm/msm/adreno/a4xx_gpu.c +0
-2@@ -513,16 +513,8 @@ static int a4xx_pm_suspend(struct msm_gpu *gpu) {static int a4xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { -uint32_t hi, lo, tmp; -
drivers/gpu/drm/msm/adreno/a4xx_gpu.c static int a4xx_pm_suspend(struct msm_gpu *gpu) { · line 517
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2
-8- tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); -do { - hi = tmp; - lo =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO ); - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); - }while (tmp != hi); - - *value = (((uint64_t )hi) <<32 ) | lo; + *value =gpu_read64 (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO , +REG_A4XX_RBBM_PERFCTR_CP_0_HI );
Did we stop caring about the case where the high bits changed while the low bits were read? gpu_read64 (pretty poor name by the way considering how many GPUs there are supported in the kernel) doesn't look to check for or handle that case.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
A message that is not in the archive (sent off-list or not yet received): f456dc94-7ae2-1b64-c90b-bfb8311be592-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Re: [PATCH 3/3] drm/msm: gpu Add new gpu register read/write functions
Quoted 33 lines · Stephen Boyd
Quoted 32 lines · Jordan Crouse
Add some new functions to manipulate GPU registers.
gpu_read64andgpu_write64can read/write a 64 bit value to two 32 bit registers. For 4XX and older these are normally perfcounter registers, but future targets will use 64 bit addressing so there will be many more spots where a 64 bit read and write are needed.
gpu_rmw()does a read/modify/write on a 32 bit register given a mask and bits to OR in.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 12 ++--------- drivers/gpu/drm/msm/msm_gpu.h | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-)drivers/gpu/drm/msm/adreno/a4xx_gpu.c +0
-9@@ -513,16 +513,8 @@ static int a4xx_pm_suspend(struct msm_gpu *gpu) {static int a4xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { -uint32_t hi, lo, tmp; - - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); -do { - hi = tmp; - lo =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO ); - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); - }while (tmp != hi); -
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a4xx_gpu.c static int a4xx_pm_suspend(struct msm_gpu *gpu) { · line 517
Quoted 3 lines
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2
-1- *value = (((uint64_t )hi) <<32 ) | lo; + *value =gpu_read64 (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO , +REG_A4XX_RBBM_PERFCTR_CP_0_HI );Did we stop caring about the case where the high bits changed while the low bits were read?
gpu_read64(pretty poor name by the way considering how many GPUs there are supported in the kernel) doesn't look to check for or handle that case.
fancy hw is fancy ;-)
seems like for the perf ctrs reading _LO latches _HI so the loop was overkill (and only worked in the first place because I happened to read _LO first)
I was planning to smash in a comment to that effect when I merged this patch
BR,
-R
Quoted 8 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
A message that is not in the archive (sent off-list or not yet received): CAF6AEGvwZ9NAwfd40SsvS1C8av1n2rGmULtmHjSYurR7-JEwCg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/3] drm/msm: gpu Add new gpu register read/write functions
Quoted 41 lines · Rob Clark
Quoted 32 lines · Stephen Boyd
Quoted 31 lines · Jordan Crouse
Add some new functions to manipulate GPU registers.
gpu_read64andgpu_write64can read/write a 64 bit value to two 32 bit registers. For 4XX and older these are normally perfcounter registers, but future targets will use 64 bit addressing so there will be many more spots where a 64 bit read and write are needed.
gpu_rmw()does a read/modify/write on a 32 bit register given a mask and bits to OR in.Signed-off-by Jordan Crouse <[email protected]>--- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 12 ++--------- drivers/gpu/drm/msm/msm_gpu.h | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-)drivers/gpu/drm/msm/adreno/a4xx_gpu.c +0
-8@@ -513,16 +513,8 @@ static int a4xx_pm_suspend(struct msm_gpu *gpu) {static int a4xx_get_timestamp (struct msm_gpu *gpu,uint64_t *value) { -uint32_t hi, lo, tmp; - - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); -do { - hi = tmp; - lo =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO ); - tmp =gpu_read (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_HI ); - }while (tmp != hi);Quoted 8 lines
drivers/gpu/drm/msm/adreno/a4xx_gpu.c static int a4xx_pm_suspend(struct msm_gpu *gpu) { · line 517
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +2
-2- - *value = (((uint64_t )hi) <<32 ) | lo; + *value =gpu_read64 (gpu,REG_A4XX_RBBM_PERFCTR_CP_0_LO , +REG_A4XX_RBBM_PERFCTR_CP_0_HI );Did we stop caring about the case where the high bits changed while the low bits were read?
gpu_read64(pretty poor name by the way considering how many GPUs there are supported in the kernel) doesn't look to check for or handle that case.
Quoted 9 lines
fancy hw is fancy ;-)
seems like for the perf ctrs reading
_LOlatches_HIso the loop was overkill (and only worked in the first place because I happened to read_LOfirst)I was planning to smash in a comment to that effect when I merged this patch
Ah ok. There's already a comment in the newly introduced function to that effect but no mention in the commit text hence the confusion.
Signature · 7 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno