drm/msm/a6xx: Serialize GMU communication
Subsystems (4)
RFC 1/1 drm/msm/a6xx: Serialize GMU communication
From: Rob Clark <[email protected]>
I've seen some crashes in our crash reporting that *look* like multiple threads stomping on each other while communicating with GMU. So wrap all those paths in a lock.
---
Are we allowed to use c99/gnu99 yet?
drivers/gpu/drm/msm/Makefile | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 9 +++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 50 ++++++++++++++++++++------- 4 files changed, 54 insertions(+), 13 deletions(-)
drivers/gpu/drm/msm/Makefile +1 -1
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -I $(srctree)/$(src) +ccflags-y := -I $(srctree)/$(src) -std=gnu99 ccflags-y += -I $(srctree)/$(src)/disp/dpu1 ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dp
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +6 -0
@@ -296,6 +296,8 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)u32 val;int request, ack; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return -EINVAL ;
@@ -337,6 +339,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) {int bit; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return ;
@@ -1482,6 +1486,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (!pdev)return -ENODEV ; +mutex_init (&gmu->lock); + gmu->dev = &pdev->dev;of_dma_configure (gmu->dev, node, true);
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +9 -0
@@ -44,6 +44,9 @@ struct a6xx_gmu_bo {struct a6xx_gmu {struct device *dev; +/* For serializing communication with the GMU: */ +struct mutex lock; +struct msm_gem_address_space *aspace;void *__iomem mmio;
@@ -88,6 +91,12 @@ struct a6xx_gmu {bool legacy;/* a618 or a630 */ }; +/* Helper macro for serializing GMU access: */ +#define with_gmu_lock (gmu) \ + for (bool done = ({ mutex_lock(&(gmu)->lock); false; }); \ + !done; \ + done = ({ mutex_unlock(&(gmu)->lock); true; })) +static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) {return msm_readl (gmu->mmio + (offset <<2 ));
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +38 -12
96 lines not on this page · raw message
Signature · 1 line
2.31.1
Quoted 73 lines · Rob Clark
From: Rob Clark <[email protected]>
I've seen some crashes in our crash reporting that *look* like multiple threads stomping on each other while communicating with GMU. So wrap all those paths in a lock.
Signed-off-by Rob Clark <[email protected]>---
Are we allowed to use c99/gnu99 yet?drivers/gpu/drm/msm/Makefile | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 9 +++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 50 ++++++++++++++++++++------- 4 files changed, 54 insertions(+), 13 deletions(-)drivers/gpu/drm/msm/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -I $(srctree)/$(src) +ccflags-y := -I $(srctree)/$(src) -std=gnu99 ccflags-y += -I $(srctree)/$(src)/disp/dpu1 ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dpdrivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0@@ -296,6 +296,8 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)u32 val;int request, ack; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return -EINVAL ;@@ -337,6 +339,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) {int bit; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return ;@@ -1482,6 +1486,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (!pdev)return -ENODEV ; +mutex_init (&gmu->lock); + gmu->dev = &pdev->dev;of_dma_configure (gmu->dev, node, true);drivers/gpu/drm/msm/adreno/a6xx_gmu.h +3
-0@@ -44,6 +44,9 @@ struct a6xx_gmu_bo {struct a6xx_gmu {struct device *dev; +/* For serializing communication with the GMU: */ +struct mutex lock; +struct msm_gem_address_space *aspace;void *__iomem mmio;
drivers/gpu/drm/msm/adreno/a6xx_gmu.h struct a6xx_gmu { · line 98
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +5
-0@@ -88,6 +91,12 @@ struct a6xx_gmu {bool legacy;/* a618 or a630 */ }; +/* Helper macro for serializing GMU access: */ +#define with_gmu_lock (gmu) \ + for (bool done = ({ mutex_lock(&(gmu)->lock); false; }); \ + !done; \ + done = ({ mutex_unlock(&(gmu)->lock); true; }))
The intent is good, but I'm not sure this kind of syntax sugar would be a good approach. What about calling lock/unlock explicitly, like we typically do? Then we won't have to use c99.
Quoted 112 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1
-0+static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) {return msm_readl (gmu->mmio + (offset <<2 ));drivers/gpu/drm/msm/adreno/a6xx_gpu.c +38
-12@@ -881,7 +881,7 @@ static int a6xx_zap_shader_init(struct msm_gpu *gpu) A6XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS | \ A6XX_RBBM_INT_0_MASK_UCHE_TRAP_INTR) -static int a6xx_hw_init (struct msm_gpu *gpu) +static int hw_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);@@ -1135,6 +1135,19 @@ static int a6xx_hw_init(struct msm_gpu *gpu)return ret; } +static int a6xx_hw_init (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +int ret; + + with_gmu_lock(&a6xx_gpu->gmu) { + ret =hw_init (gpu); + } + +return ret; +} +static void a6xx_dump (struct msm_gpu *gpu) { DRM_DEV_INFO(&gpu->pdev->dev, "status: %08x\n",@@ -1509,7 +1522,9 @@ static int a6xx_pm_resume(struct msm_gpu *gpu)trace_msm_gpu_resume (0 ); - ret =a6xx_gmu_resume (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_resume (a6xx_gpu); + }if (ret)return ret;@@ -1532,7 +1547,9 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)msm_devfreq_suspend (gpu); - ret =a6xx_gmu_stop (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_stop (a6xx_gpu); + }if (ret)return ret;@@ -1547,18 +1564,17 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); -static DEFINE_MUTEX (perfcounter_oob); -mutex_lock (&perfcounter_oob); + with_gmu_lock(&a6xx_gpu->gmu) { +/* Force the GPU power on so we can read this register */ +a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -/* Force the GPU power on so we can read this register */ -a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); + *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER_LO , +REG_A6XX_CP_ALWAYS_ON_COUNTER_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_PERFCOUNTER_SET ); + } -a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -mutex_unlock (&perfcounter_oob);return 0 ; }@@ -1622,6 +1638,16 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)return (unsigned long )busy_time; } +void a6xx_gpu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + + with_gmu_lock(&a6xx_gpu->gmu) { +a6xx_gmu_set_freq (gpu, opp); + } +} +static struct msm_gem_address_space *a6xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) {@@ -1766,7 +1792,7 @@ static const struct adreno_gpu_funcs funcs = {#endif .gpu_busy = a6xx_gpu_busy, .gpu_get_freq = a6xx_gmu_get_freq, - .gpu_set_freq = a6xx_gmu_set_freq, + .gpu_set_freq = a6xx_gpu_set_freq,#if defined(CONFIG_DRM_MSM_GPU_STATE ) .gpu_state_get = a6xx_gpu_state_get, .gpu_state_put = a6xx_gpu_state_put,
Signature · 2 lines
With best wishes Dmitry
Quoted 78 lines · Dmitry Baryshkov
Quoted 76 lines · Rob Clark
From: Rob Clark <[email protected]>
I've seen some crashes in our crash reporting that *look* like multiple threads stomping on each other while communicating with GMU. So wrap all those paths in a lock.
Signed-off-by Rob Clark <[email protected]>---
Are we allowed to use c99/gnu99 yet?drivers/gpu/drm/msm/Makefile | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 9 +++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 50 ++++++++++++++++++++------- 4 files changed, 54 insertions(+), 13 deletions(-)drivers/gpu/drm/msm/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -I $(srctree)/$(src) +ccflags-y := -I $(srctree)/$(src) -std=gnu99 ccflags-y += -I $(srctree)/$(src)/disp/dpu1 ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dpdrivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0@@ -296,6 +296,8 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)u32 val;int request, ack; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return -EINVAL ;@@ -337,6 +339,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) {int bit; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return ;@@ -1482,6 +1486,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (!pdev)return -ENODEV ; +mutex_init (&gmu->lock); + gmu->dev = &pdev->dev;of_dma_configure (gmu->dev, node, true);drivers/gpu/drm/msm/adreno/a6xx_gmu.h +3
-0@@ -44,6 +44,9 @@ struct a6xx_gmu_bo {struct a6xx_gmu {struct device *dev; +/* For serializing communication with the GMU: */ +struct mutex lock; +struct msm_gem_address_space *aspace;void *__iomem mmio;@@ -88,6 +91,12 @@ struct a6xx_gmu {bool legacy;/* a618 or a630 */ };
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h struct a6xx_gmu { · line 98
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +5
-0+/* Helper macro for serializing GMU access: */ +#define with_gmu_lock (gmu) \ + for (bool done = ({ mutex_lock(&(gmu)->lock); false; }); \ + !done; \ + done = ({ mutex_unlock(&(gmu)->lock); true; }))The intent is good, but I'm not sure this kind of syntax sugar would be a good approach. What about calling lock/unlock explicitly, like we typically do? Then we won't have to use c99.
Yeah, I was planning to resend without the sugar.. but it was a good excuse to bring up c99. Ie. I want c99 regardless ;-)
(The sugar was useful initially before I'd sorted thru all the code paths and settled on using a mutex vs spinlock)
BR,
-R
Quoted 117 lines
Quoted 104 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1
-0+static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) {return msm_readl (gmu->mmio + (offset <<2 ));drivers/gpu/drm/msm/adreno/a6xx_gpu.c +37
-11@@ -881,7 +881,7 @@ static int a6xx_zap_shader_init(struct msm_gpu *gpu) A6XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS | \ A6XX_RBBM_INT_0_MASK_UCHE_TRAP_INTR) -static int a6xx_hw_init (struct msm_gpu *gpu) +static int hw_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);@@ -1135,6 +1135,19 @@ static int a6xx_hw_init(struct msm_gpu *gpu)return ret; } +static int a6xx_hw_init (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +int ret; + + with_gmu_lock(&a6xx_gpu->gmu) { + ret =hw_init (gpu); + } + +return ret; +} +static void a6xx_dump (struct msm_gpu *gpu) { DRM_DEV_INFO(&gpu->pdev->dev, "status: %08x\n",@@ -1509,7 +1522,9 @@ static int a6xx_pm_resume(struct msm_gpu *gpu)trace_msm_gpu_resume (0 ); - ret =a6xx_gmu_resume (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_resume (a6xx_gpu); + }if (ret)return ret;@@ -1532,7 +1547,9 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)msm_devfreq_suspend (gpu); - ret =a6xx_gmu_stop (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_stop (a6xx_gpu); + }if (ret)return ret;@@ -1547,18 +1564,17 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); -static DEFINE_MUTEX (perfcounter_oob); -mutex_lock (&perfcounter_oob); + with_gmu_lock(&a6xx_gpu->gmu) { +/* Force the GPU power on so we can read this register */ +a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -/* Force the GPU power on so we can read this register */ -a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); + *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER_LO , +REG_A6XX_CP_ALWAYS_ON_COUNTER_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_PERFCOUNTER_SET ); + } -a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -mutex_unlock (&perfcounter_oob);return 0 ; }@@ -1622,6 +1638,16 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)return (unsigned long )busy_time; } +void a6xx_gpu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + + with_gmu_lock(&a6xx_gpu->gmu) { +a6xx_gmu_set_freq (gpu, opp); + } +} +static struct msm_gem_address_space *a6xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) {drivers/gpu/drm/msm/adreno/a6xx_gpu.c static const struct adreno_gpu_funcs funcs = { · line 1798
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-1@@ -1766,7 +1792,7 @@ static const struct adreno_gpu_funcs funcs = {#endif .gpu_busy = a6xx_gpu_busy, .gpu_get_freq = a6xx_gmu_get_freq, - .gpu_set_freq = a6xx_gmu_set_freq, + .gpu_set_freq = a6xx_gpu_set_freq,#if defined(CONFIG_DRM_MSM_GPU_STATE ) .gpu_state_get = a6xx_gpu_state_get, .gpu_state_put = a6xx_gpu_state_put,--
With best wishes
Dmitry
Quoted 90 lines · Rob Clark
Quoted 78 lines · Dmitry Baryshkov
Quoted 76 lines · Rob Clark
From: Rob Clark <[email protected]>
I've seen some crashes in our crash reporting that *look* like multiple threads stomping on each other while communicating with GMU. So wrap all those paths in a lock.
Signed-off-by Rob Clark <[email protected]>---
Are we allowed to use c99/gnu99 yet?drivers/gpu/drm/msm/Makefile | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 9 +++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 50 ++++++++++++++++++++------- 4 files changed, 54 insertions(+), 13 deletions(-)drivers/gpu/drm/msm/Makefile +1
-1@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -I $(srctree)/$(src) +ccflags-y := -I $(srctree)/$(src) -std=gnu99 ccflags-y += -I $(srctree)/$(src)/disp/dpu1 ccflags-$(CONFIG_DRM_MSM_DSI) += -I $(srctree)/$(src)/dsi ccflags-$(CONFIG_DRM_MSM_DP) += -I $(srctree)/$(src)/dpdrivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0@@ -296,6 +296,8 @@ int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state)u32 val;int request, ack; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return -EINVAL ;@@ -337,6 +339,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state) {int bit; +WARN_ON_ONCE (!mutex_is_locked (&gmu->lock)); +if (state >=ARRAY_SIZE (a6xx_gmu_oob_bits))return ;@@ -1482,6 +1486,8 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (!pdev)return -ENODEV ; +mutex_init (&gmu->lock); + gmu->dev = &pdev->dev;of_dma_configure (gmu->dev, node, true);drivers/gpu/drm/msm/adreno/a6xx_gmu.h +3
-0@@ -44,6 +44,9 @@ struct a6xx_gmu_bo {struct a6xx_gmu {struct device *dev; +/* For serializing communication with the GMU: */ +struct mutex lock; +struct msm_gem_address_space *aspace;void *__iomem mmio;@@ -88,6 +91,12 @@ struct a6xx_gmu {bool legacy;/* a618 or a630 */ };Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h struct a6xx_gmu { · line 98
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +5
-0+/* Helper macro for serializing GMU access: */ +#define with_gmu_lock (gmu) \ + for (bool done = ({ mutex_lock(&(gmu)->lock); false; }); \ + !done; \ + done = ({ mutex_unlock(&(gmu)->lock); true; }))The intent is good, but I'm not sure this kind of syntax sugar would be a good approach. What about calling lock/unlock explicitly, like we typically do? Then we won't have to use c99.
Quoted 5 lines
Yeah, I was planning to resend without the sugar.. but it was a good excuse to bring up c99. Ie. I want c99 regardless ;-)
(The sugar was useful initially before I'd sorted thru all the code paths and settled on using a mutex vs spinlock)
We can always have GMU_LOCK/GMU_UNLOCK macros.
Quoted 121 lines
BR,
-RQuoted 117 lines
Quoted 104 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1
-0+static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) {return msm_readl (gmu->mmio + (offset <<2 ));drivers/gpu/drm/msm/adreno/a6xx_gpu.c +37
-11@@ -881,7 +881,7 @@ static int a6xx_zap_shader_init(struct msm_gpu *gpu) A6XX_RBBM_INT_0_MASK_UCHE_OOB_ACCESS | \ A6XX_RBBM_INT_0_MASK_UCHE_TRAP_INTR) -static int a6xx_hw_init (struct msm_gpu *gpu) +static int hw_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);@@ -1135,6 +1135,19 @@ static int a6xx_hw_init(struct msm_gpu *gpu)return ret; } +static int a6xx_hw_init (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +int ret; + + with_gmu_lock(&a6xx_gpu->gmu) { + ret =hw_init (gpu); + } + +return ret; +} +static void a6xx_dump (struct msm_gpu *gpu) { DRM_DEV_INFO(&gpu->pdev->dev, "status: %08x\n",@@ -1509,7 +1522,9 @@ static int a6xx_pm_resume(struct msm_gpu *gpu)trace_msm_gpu_resume (0 ); - ret =a6xx_gmu_resume (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_resume (a6xx_gpu); + }if (ret)return ret;@@ -1532,7 +1547,9 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)msm_devfreq_suspend (gpu); - ret =a6xx_gmu_stop (a6xx_gpu); + with_gmu_lock(&a6xx_gpu->gmu) { + ret =a6xx_gmu_stop (a6xx_gpu); + }if (ret)return ret;@@ -1547,18 +1564,17 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); -static DEFINE_MUTEX (perfcounter_oob); -mutex_lock (&perfcounter_oob); + with_gmu_lock(&a6xx_gpu->gmu) { +/* Force the GPU power on so we can read this register */ +a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -/* Force the GPU power on so we can read this register */ -a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); + *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER_LO , +REG_A6XX_CP_ALWAYS_ON_COUNTER_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_PERFCOUNTER_SET ); + } -a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); -mutex_unlock (&perfcounter_oob);return 0 ; }@@ -1622,6 +1638,16 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)return (unsigned long )busy_time; } +void a6xx_gpu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + + with_gmu_lock(&a6xx_gpu->gmu) { +a6xx_gmu_set_freq (gpu, opp); + } +} +static struct msm_gem_address_space *a6xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) {drivers/gpu/drm/msm/adreno/a6xx_gpu.c static const struct adreno_gpu_funcs funcs = { · line 1798
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-1@@ -1766,7 +1792,7 @@ static const struct adreno_gpu_funcs funcs = {#endif .gpu_busy = a6xx_gpu_busy, .gpu_get_freq = a6xx_gmu_get_freq, - .gpu_set_freq = a6xx_gmu_set_freq, + .gpu_set_freq = a6xx_gpu_set_freq,#if defined(CONFIG_DRM_MSM_GPU_STATE ) .gpu_state_get = a6xx_gpu_state_get, .gpu_state_put = a6xx_gpu_state_put,--
With best wishes
Dmitry
Signature · 2 lines
With best wishes Dmitry