drm/msm: Protect the RPTR shadow
Subsystems (5)
cover drm/msm: Protect the RPTR shadow
On Adreno GPUs there is an option to shadow the RPTR register in GPU accessible memory. The shadow memory allows the kernel driver to query the value of the RPTR for each ringbuffer even if it is preempted out or if the GPU is turned off during aggressive power management.
There are risks to using the RPTR shadow. If it is in GPU accessible memory it could be read or written by any GPU operation. All versions of the GPU hardware except A650 requires the shadow to be in unprivileged memory which opens it to risk.
This series does two things. First, it marks as many buffers as possible as privileged. For a5xx these are some preemption buffers and on a650 this includes all global buffers (such as the ringbuffer and memstore). I've sent these patches before but they tie in well with this series so I've included them.
Then we disable the RPTR shadow across all targets. For all targets except for a5xx the RPTR shadow isn't needed so there isn't a loss of functionality. a5xx does need it for preemption so that has to be temporarily disabled.
Later changes will re-enable the shadow for those targets that can safely mitigate the risks.
Jordan Crouse (4):
drm/msm: Split the a5xx preemption record
drm/msm: Enable expanded apriv support for a650
drm/msm: Disable premption on all 5xx targets
drm/msm: Disable the RPTR shadow
drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 5 +++++ drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 10 +++++++++ drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 10 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 14 +++++++++--- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 25 ++++++++++++++++----- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 13 ++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 27 ++--------------------- drivers/gpu/drm/msm/msm_gpu.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 11 +++++++++ drivers/gpu/drm/msm/msm_ringbuffer.c | 4 ++-- 11 files changed, 85 insertions(+), 37 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/4 drm/msm: Split the a5xx preemption record
The main a5xx preemption record can be marked as privileged to protect it from user access but the counters storage needs to be remain unprivileged. Split the buffers and mark the critical memory as privileged.
---
drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 25 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.h +1 -0
@@ -31,6 +31,7 @@ struct a5xx_gpu {struct msm_ringbuffer *next_ring;struct drm_gem_object *preempt_bo[MSM_GPU_MAX_RINGS ]; +struct drm_gem_object *preempt_counters_bo[MSM_GPU_MAX_RINGS ];struct a5xx_preempt_record *preempt[MSM_GPU_MAX_RINGS ];uint64_t preempt_iova[MSM_GPU_MAX_RINGS ];
drivers/gpu/drm/msm/adreno/a5xx_preempt.c +20 -5
@@ -226,19 +226,31 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,struct adreno_gpu *adreno_gpu = &a5xx_gpu->base;struct msm_gpu *gpu = &adreno_gpu->base;struct a5xx_preempt_record *ptr; -struct drm_gem_object *bo =NULL ; -u64 iova =0 ; +void *counters; +struct drm_gem_object *bo =NULL , *counters_bo =NULL ; +u64 iova =0 , counters_iova =0 ; ptr =msm_gem_kernel_new (gpu->dev,A5XX_PREEMPT_RECORD_SIZE +A5XX_PREEMPT_COUNTER_SIZE , -MSM_BO_UNCACHED , gpu->aspace, &bo, &iova); +MSM_BO_UNCACHED |MSM_BO_MAP_PRIV , gpu->aspace, &bo, &iova);if (IS_ERR (ptr))return PTR_ERR (ptr); +/* The buffer to store counters needs to be unprivileged */ + counters =msm_gem_kernel_new (gpu->dev, +A5XX_PREEMPT_COUNTER_SIZE , +MSM_BO_UNCACHED , gpu->aspace, &counters_bo, &counters_iova); +if (IS_ERR (counters)) { +msm_gem_kernel_put (bo, gpu->aspace, true); +return PTR_ERR (counters); + } +msm_gem_object_set_name (bo,"preempt" ); +msm_gem_object_set_name (counters_bo,"preempt_counters" ); a5xx_gpu->preempt_bo[ring->id] = bo; + a5xx_gpu->preempt_counters_bo[ring->id] = counters_bo; a5xx_gpu->preempt_iova[ring->id] = iova; a5xx_gpu->preempt[ring->id] = ptr;
@@ -249,7 +261,7 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu, ptr->data =0 ; ptr->cntl =MSM_GPU_RB_CNTL_DEFAULT ; ptr->rptr_addr =rbmemptr (ring, rptr); - ptr->counter = iova +A5XX_PREEMPT_RECORD_SIZE ; + ptr->counter = counters_iova;return 0 ; }
@@ -260,8 +272,11 @@ void a5xx_preempt_fini(struct msm_gpu *gpu)struct a5xx_gpu *a5xx_gpu =to_a5xx_gpu (adreno_gpu);int i; -for (i =0 ; i < gpu->nr_rings; i++) +for (i =0 ; i < gpu->nr_rings; i++) {msm_gem_kernel_put (a5xx_gpu->preempt_bo[i], gpu->aspace, true); +msm_gem_kernel_put (a5xx_gpu->preempt_counters_bo[i], + gpu->aspace, true); + } }void a5xx_preempt_init (struct msm_gpu *gpu)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerRe: [PATCH 1/4] drm/msm: Split the a5xx preemption record
Hi
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.8.6, v5.4.62, v4.19.143, v4.14.196, v4.9.235, v4.4.235.
v5.8.6: Build OK!
v5.4.62: Build failed! Errors:
drivers/gpu/drm/msm/adreno/a5xx_preempt.c:235:21: error: 'MSM_BO_MAP_PRIV' undeclared (first use in this function); did you mean 'MSM_BO_CACHED'?
v4.19.143: Failed to apply! Possible dependencies:
0815d7749a68 ("drm/msm: Add a name field for gem objects")
1e29dff00400 ("drm/msm: Add a common function to free kernel buffer objects") 64686886bbff ("drm/msm: Replace drm_gem_object_{un/reference} with put, get functions") 6a41da17e87d ("drm: msm: Use DRM_DEV_* instead of dev_*")
c97ea6a61b5e ("drm: msm: adreno: Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) +PTR_ERR") df0dff132905 ("drm/msm/a6xx: Poll for HFI responses")
f384d7d514d1 ("drm: Convert to using %pOFn instead of device_node.name") feb085ec8a3d ("drm/msm: dsi: Return errors whan dt parsing fails")
v4.14.196: Failed to apply! Possible dependencies:
b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets") cd414f3d9316 ("drm/msm: Move memptrs to msm_gpu") e8f3de96a9d3 ("drm/msm/adreno: split out helper to load fw") eec874ce5ff1 ("drm/msm/adreno: load gpu at probe/bind time") f7de15450e90 ("drm/msm: Add per-instance submit queues") f97decac5f4c ("drm/msm: Support multiple ringbuffers")
v4.9.235: Failed to apply! Possible dependencies:
1cec20f0ea0e ("dma-buf: Restart reservation_object_wait_timeout_rcu() after writes")
667ce33e57d0 ("drm/msm: support multiple address spaces")
78010cd9736e ("dma-buf/fence: add an lockdep_assert_held()")
89d777a57245 ("drm/msm: Remove 'src_clk' from adreno configuration")
b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets")
b5f103ab98c7 ("drm/msm: gpu: Add A5XX target support")
f54d1867005c ("dma-buf: Rename struct fence to dma_fence")
fb0399819239 ("drm/msm: Add adreno_gpu_write64()")
fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes")v4.4.235: Failed to apply! Possible dependencies:
01c8f1c44b83 ("mm, dax, gpu: convert vm_insert_mixed to pfn_t") 0caeef63e6d2 ("libnvdimm: Add a poison list and export badblocks") 0e749e54244e ("dax: increase granularity of dax_clear_blocks() operations") 34c0fd540e79 ("mm, dax, pmem: introduce pfn_t")
357ff00b08d6 ("drm/msm/adreno: support for adreno 430.")
52db400fcd50 ("pmem, dax: clean up clear_pmem()")
667ce33e57d0 ("drm/msm: support multiple address spaces") 68209390f116 ("drm/msm: shrinker support")
7d0c5ee9f077 ("drm/msm/adreno: get CP_RPTR from register instead of shadow memory") 87ba05dff351 ("libnvdimm: don't fail init for full badblocks list") 89d777a57245 ("drm/msm: Remove 'src_clk' from adreno configuration") a5725ab0497a ("drm/msm/adreno: move function declarations to header file") b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets") b2e0d1625e19 ("dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()") b5f103ab98c7 ("drm/msm: gpu: Add A5XX target support")
b95f5f4391fa ("libnvdimm: convert to statically allocated badblocks") edcd60ce243d ("drm/msm: move debugfs code to it's own file") fb0399819239 ("drm/msm: Add adreno_gpu_write64()")
fde5de6cb461 ("drm/msm: move fence code to it's own file") fe683adabfe6 ("dax: guarantee page aligned results from bdev_direct_access()")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
Signature · 2 lines
Thanks Sasha
Re: [PATCH 1/4] drm/msm: Split the a5xx preemption record
Quoted 65 lines · Sasha Levin
Hi
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.8.6, v5.4.62, v4.19.143, v4.14.196, v4.9.235, v4.4.235.
v5.8.6: Build OK!
v5.4.62: Build failed! Errors:
drivers/gpu/drm/msm/adreno/a5xx_preempt.c:235:21: error: 'MSM_BO_MAP_PRIV' undeclared (first use in this function); did you mean 'MSM_BO_CACHED'?v4.19.143: Failed to apply! Possible dependencies:
0815d7749a68("drm/msm: Add a name field for gem objects")
1e29dff00400("drm/msm: Add a common function to free kernel buffer objects")64686886bbff("drm/msm: Replace drm_gem_object_{un/reference} with put, get functions")6a41da17e87d("drm: msm: Use DRM_DEV_* instead of dev_*")
c97ea6a61b5e("drm: msm: adreno: UsePTR_ERR_OR_ZEROrather than if(IS_ERR(...)) +PTR_ERR")df0dff132905("drm/msm/a6xx: Poll for HFI responses")
f384d7d514d1("drm: Convert to using %pOFn instead of device_node.name")feb085ec8a3d("drm/msm: dsi: Return errors whan dt parsing fails")v4.14.196: Failed to apply! Possible dependencies:
b1fc2839d2f9("drm/msm: Implement preemption for A5XX targets")cd414f3d9316("drm/msm: Move memptrs tomsm_gpu")e8f3de96a9d3("drm/msm/adreno: split out helper to load fw")eec874ce5ff1("drm/msm/adreno: load gpu at probe/bind time")f7de15450e90("drm/msm: Add per-instance submit queues")f97decac5f4c("drm/msm: Support multiple ringbuffers")v4.9.235: Failed to apply! Possible dependencies:
1cec20f0ea0e ("dma-buf: Restart reservation_object_wait_timeout_rcu() after writes") 667ce33e57d0 ("drm/msm: support multiple address spaces") 78010cd9736e ("dma-buf/fence: add an lockdep_assert_held()") 89d777a57245 ("drm/msm: Remove 'src_clk' from adreno configuration") b1fc2839d2f9 ("drm/msm: Implement preemption for A5XX targets") b5f103ab98c7 ("drm/msm: gpu: Add A5XX target support") f54d1867005c ("dma-buf: Rename struct fence to dma_fence") fb0399819239 ("drm/msm: Add adreno_gpu_write64()") fedf54132d24 ("dma-buf: Restart reservation_object_get_fences_rcu() after writes")v4.4.235: Failed to apply! Possible dependencies:
01c8f1c44b83("mm, dax, gpu: convertvm_insert_mixedtopfn_t")0caeef63e6d2("libnvdimm: Add a poison list and export badblocks")0e749e54244e("dax: increase granularity ofdax_clear_blocks()operations")34c0fd540e79("mm, dax, pmem: introducepfn_t")
357ff00b08d6("drm/msm/adreno: support for adreno 430.")
52db400fcd50("pmem, dax: clean upclear_pmem()")
667ce33e57d0("drm/msm: support multiple address spaces")68209390f116("drm/msm: shrinker support")
7d0c5ee9f077("drm/msm/adreno: getCP_RPTRfrom register instead of shadow memory")87ba05dff351("libnvdimm: don't fail init for full badblocks list")89d777a57245("drm/msm: Remove 'src_clk' from adreno configuration")a5725ab0497a("drm/msm/adreno: move function declarations to header file")b1fc2839d2f9("drm/msm: Implement preemption for A5XX targets")b2e0d1625e19("dax: fix lifetime of in-kernel dax mappings withdax_map_atomic()")b5f103ab98c7("drm/msm: gpu: Add A5XX target support")
b95f5f4391fa("libnvdimm: convert to statically allocated badblocks")edcd60ce243d("drm/msm: move debugfs code to it's own file")fb0399819239("drm/msm: Addadreno_gpu_write64()")
fde5de6cb461("drm/msm: move fence code to it's own file")fe683adabfe6("dax: guarantee page aligned results frombdev_direct_access()")
Quoted 3 lines
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
For 5.4 it looks like all you need is:
0b462d7a71c07e96b ("drm/msm: add internal MSM_BO_MAP_PRIV flag")
For 4.19 it looks a bit more complicated. I can try to build a stack that would work.
This patch isn't needed before 4.19 because preemption isn't available (as far as I can tell from the dependencies list).
Jordan
Quoted 4 lines
Signature · 3 lines
-- Thanks Sasha
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/4 drm/msm: Enable expanded apriv support for a650
In reply to Jordan Crousea650 supports expanded apriv support that allows us to map critical buffers (ringbuffer and memstore) as as privileged to protect them from corruption.
---
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++++- drivers/gpu/drm/msm/msm_gpu.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 11 +++++++++++ drivers/gpu/drm/msm/msm_ringbuffer.c | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5 -1
@@ -678,7 +678,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu) A6XX_PROTECT_RDONLY(0x980, 0x4));gpu_write (gpu,REG_A6XX_CP_PROTECT (25 ),A6XX_PROTECT_RW (0xa630 ,0x0 )); -if (adreno_is_a650 (adreno_gpu)) { +/* Enable expanded apriv for targets that support it */ +if (gpu->hw_apriv) {gpu_write (gpu,REG_A6XX_CP_APRIV_CNTL , (1 <<6 ) | (1 <<5 ) | (1 <<3 ) | (1 <<2 ) | (1 <<1 )); }
@@ -1056,6 +1057,9 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->registers =NULL ; adreno_gpu->reg_offsets = a6xx_register_offsets; +if (adreno_is_a650 (adreno_gpu)) + adreno_gpu->base.hw_apriv = true; + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) {a6xx_destroy (&(a6xx_gpu->base.base));
drivers/gpu/drm/msm/msm_gpu.c +1 -1
@@ -908,7 +908,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev, memptrs =msm_gem_kernel_new (drm,sizeof (struct msm_rbmemptrs ) * nr_rings, -MSM_BO_UNCACHED , gpu->aspace, &gpu->memptrs_bo, +check_apriv (gpu,MSM_BO_UNCACHED ), gpu->aspace, &gpu->memptrs_bo, &memptrs_iova);if (IS_ERR (memptrs)) {
drivers/gpu/drm/msm/msm_gpu.h +11 -0
@@ -15,6 +15,7 @@#include "msm_drv.h" #include "msm_fence.h" #include "msm_ringbuffer.h" +#include "msm_gem.h" struct msm_gem_submit ;struct msm_gpu_perfcntr ;
@@ -139,6 +140,8 @@ struct msm_gpu { } devfreq;struct msm_gpu_state *crashstate; +/* True if the hardware supports expanded apriv (a650 and newer) */ +bool hw_apriv; };/* It turns out that all targets use the same ringbuffer size */
@@ -327,4 +330,12 @@ static inline void msm_gpu_crashstate_put(struct msm_gpu *gpu) mutex_unlock(&gpu->dev->struct_mutex); } +/* +* Simple macro to semi-cleanly add the MAP_PRIV flag for targets that can +* support expanded privileges +*/ +#define check_apriv (gpu, flags) \ + (((gpu)->hw_apriv ? MSM_BO_MAP_PRIV : 0) | (flags)) + +#endif /* __MSM_GPU_H__ */
drivers/gpu/drm/msm/msm_ringbuffer.c +2 -2
@@ -27,8 +27,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id, ring->id = id; ring->start =msm_gem_kernel_new (gpu->dev,MSM_GPU_RINGBUFFER_SZ , -MSM_BO_WC |MSM_BO_GPU_READONLY , gpu->aspace, &ring->bo, - &ring->iova); +check_apriv (gpu,MSM_BO_WC |MSM_BO_GPU_READONLY ), + gpu->aspace, &ring->bo, &ring->iova);if (IS_ERR (ring->start)) { ret =PTR_ERR (ring->start);
Signature · 1 line
2.25.1
PATCH 3/4 drm/msm: Disable preemption on all 5xx targets
In reply to Jordan CrouseTemporarily disable preemption on a5xx targets pending some improvements to protect the RPTR shadow from being corrupted.
---
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -1
@@ -1511,7 +1511,8 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)check_speed_bin (&pdev->dev); - ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,4 ); +/* Restricting nr_rings to 1 to temporarily disable preemption */ + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) {a5xx_destroy (&(a5xx_gpu->base.base));return ERR_PTR (ret);
Signature · 1 line
2.25.1
PATCH 4/4 drm/msm: Disable the RPTR shadow
In reply to Jordan CrouseDisable the RPTR shadow across all targets. It will be selectively re-enabled later for targets that need it.
---
drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 5 +++++ drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 10 +++++++++ drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 10 +++++++++ drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 11 ++++++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 7 +++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 27 ++----------------------- 6 files changed, 43 insertions(+), 27 deletions(-)
drivers/gpu/drm/msm/adreno/a2xx_gpu.c +5 -0
@@ -164,6 +164,11 @@ static int a2xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; +gpu_write (gpu,REG_AXXX_CP_RB_CNTL , +MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ); + +gpu_write (gpu,REG_AXXX_CP_RB_BASE ,lower_32_bits (gpu->rb[0 ]->iova)); +/* NOTE: PM4/micro-engine firmware registers look to be the same * for a2xx and a3xx.. we could possibly push that part down to * adreno_gpu base class. Or push both PM4 and PFP but
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +10 -0
@@ -211,6 +211,16 @@ static int a3xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; +/* +* Use the default ringbuffer size and block size but disable the RPTR +* shadow +*/ +gpu_write (gpu,REG_AXXX_CP_RB_CNTL , +MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ); + +/* Set the ringbuffer address */ +gpu_write (gpu,REG_AXXX_CP_RB_BASE ,lower_32_bits (gpu->rb[0 ]->iova)); +/* setup access protection: */ gpu_write (gpu,REG_A3XX_CP_PROTECT_CTRL ,0x00000007 );
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +10 -0
@@ -267,6 +267,16 @@ static int a4xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; +/* +* Use the default ringbuffer size and block size but disable the RPTR +* shadow +*/ +gpu_write (gpu,REG_A4XX_CP_RB_CNTL , +MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ); + +/* Set the ringbuffer address */ +gpu_write (gpu,REG_A4XX_CP_RB_BASE ,lower_32_bits (gpu->rb[0 ]->iova)); +/* Load PM4: */ ptr = (uint32_t *)(adreno_gpu->fw[ADRENO_FW_PM4 ]->data); len = adreno_gpu->fw[ADRENO_FW_PM4 ]->size /4 ;
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +9 -2
@@ -703,8 +703,6 @@ static int a5xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; -a5xx_preempt_hw_init (gpu); -if (!adreno_is_a510 (adreno_gpu))a5xx_gpmu_ucode_init (gpu);
@@ -712,6 +710,15 @@ static int a5xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; +/* Set the ringbuffer address */ +gpu_write64 (gpu,REG_A5XX_CP_RB_BASE ,REG_A5XX_CP_RB_BASE_HI , + gpu->rb[0 ]->iova); + +gpu_write (gpu,REG_A5XX_CP_RB_CNTL , +MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ); + +a5xx_preempt_hw_init (gpu); +/* Disable the interrupts through the initial bringup stage */ gpu_write (gpu,REG_A5XX_RBBM_INT_0_MASK ,A5XX_INT_MASK );
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7 -0
@@ -695,6 +695,13 @@ static int a6xx_hw_init(struct msm_gpu *gpu)if (ret) goto out; +/* Set the ringbuffer address */ +gpu_write64 (gpu,REG_A6XX_CP_RB_BASE ,REG_A6XX_CP_RB_BASE_HI , + gpu->rb[0 ]->iova); + +gpu_write (gpu,REG_A6XX_CP_RB_CNTL , +MSM_GPU_RB_CNTL_DEFAULT |AXXX_CP_RB_CNTL_NO_UPDATE ); +/* Always come up on rb 0 */ a6xx_gpu->cur_ring = gpu->rb[0 ];
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -25
@@ -400,26 +400,6 @@ int adreno_hw_init(struct msm_gpu *gpu) ring->memptrs->rptr =0 ; } -/* -* Setup REG_CP_RB_CNTL. The same value is used across targets (with -* the excpetion of A430 that disables the RPTR shadow) - the cacluation -* for the ringbuffer size and block size is moved to msm_gpu.h for the -* pre-processor to deal with and the A430 variant is ORed in here -*/ -adreno_gpu_write (adreno_gpu,REG_ADRENO_CP_RB_CNTL , -MSM_GPU_RB_CNTL_DEFAULT | - (adreno_is_a430 (adreno_gpu) ?AXXX_CP_RB_CNTL_NO_UPDATE :0 )); - -/* Setup ringbuffer address - use ringbuffer[0] for GPU init */ -adreno_gpu_write64 (adreno_gpu,REG_ADRENO_CP_RB_BASE , -REG_ADRENO_CP_RB_BASE_HI , gpu->rb[0 ]->iova); - -if (!adreno_is_a430 (adreno_gpu)) { -adreno_gpu_write64 (adreno_gpu,REG_ADRENO_CP_RB_RPTR_ADDR , -REG_ADRENO_CP_RB_RPTR_ADDR_HI , -rbmemptr (gpu->rb[0 ], rptr)); - } -return 0 ; }
@@ -427,11 +407,8 @@ int adreno_hw_init(struct msm_gpu *gpu)static uint32_t get_rptr (struct adreno_gpu *adreno_gpu,struct msm_ringbuffer *ring) { -if (adreno_is_a430 (adreno_gpu)) -return ring->memptrs->rptr =adreno_gpu_read ( - adreno_gpu,REG_ADRENO_CP_RB_RPTR ); -else -return ring->memptrs->rptr; +return ring->memptrs->rptr =adreno_gpu_read ( + adreno_gpu,REG_ADRENO_CP_RB_RPTR ); }struct msm_ringbuffer *adreno_active_ring (struct msm_gpu *gpu)
Signature · 6 lines
2.25.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel