linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/msm: Protect the RPTR shadow
@ 2020-09-04  2:03 Jordan Crouse
  2020-09-04  2:03 ` [PATCH 1/4] drm/msm: Split the a5xx preemption record Jordan Crouse
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jordan Crouse @ 2020-09-04  2:03 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: Akhil P Oommen, AngeloGioacchino Del Regno, Ben Dooks,
	Bjorn Andersson, Brian Masney, Daniel Vetter, David Airlie,
	Emil Velikov, Eric Anholt, Greg Kroah-Hartman, Jonathan Marek,
	Rob Clark, Sam Ravnborg, Sean Paul, Sharat Masetty, Shawn Guo,
	Wambui Karuga, dri-devel, freedreno, linux-kernel

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(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] drm/msm: Split the a5xx preemption record
  2020-09-04  2:03 [PATCH 0/4] drm/msm: Protect the RPTR shadow Jordan Crouse
@ 2020-09-04  2:03 ` Jordan Crouse
  2020-09-06  3:16   ` Sasha Levin
  2020-09-04  2:03 ` [PATCH 2/4] drm/msm: Enable expanded apriv support for a650 Jordan Crouse
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Jordan Crouse @ 2020-09-04  2:03 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: stable, Daniel Vetter, David Airlie, Greg Kroah-Hartman,
	Rob Clark, Sean Paul, Wambui Karuga, dri-devel, freedreno,
	linux-kernel

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.

Cc: stable@vger.kernel.org
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 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(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
index 54868d4e3958..1e5b1a15a70f 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.h
@@ -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];
 
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
index 9cf9353a7ff1..9f3fe177b00e 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] drm/msm: Enable expanded apriv support for a650
  2020-09-04  2:03 [PATCH 0/4] drm/msm: Protect the RPTR shadow Jordan Crouse
  2020-09-04  2:03 ` [PATCH 1/4] drm/msm: Split the a5xx preemption record Jordan Crouse
@ 2020-09-04  2:03 ` Jordan Crouse
  2020-09-04  2:03 ` [PATCH 3/4] drm/msm: Disable preemption on all 5xx targets Jordan Crouse
  2020-09-04  2:03 ` [PATCH 4/4] drm/msm: Disable the RPTR shadow Jordan Crouse
  3 siblings, 0 replies; 7+ messages in thread
From: Jordan Crouse @ 2020-09-04  2:03 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: Akhil P Oommen, Daniel Vetter, David Airlie, Emil Velikov,
	Eric Anholt, Jonathan Marek, Rob Clark, Sean Paul,
	Sharat Masetty, dri-devel, freedreno, linux-kernel

a650 supports expanded apriv support that allows us to map critical buffers
(ringbuffer and memstore) as as privileged to protect them from corruption.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 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(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index c5a3e4d4c007..406efaac95a7 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -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));
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index d5645472b25d..57ddc9438351 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -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)) {
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 0db117a7339b..37cffac4cbe3 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -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__ */
diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.c b/drivers/gpu/drm/msm/msm_ringbuffer.c
index 39ecb5a18431..935bf9b1d941 100644
--- a/drivers/gpu/drm/msm/msm_ringbuffer.c
+++ b/drivers/gpu/drm/msm/msm_ringbuffer.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] drm/msm: Disable preemption on all 5xx targets
  2020-09-04  2:03 [PATCH 0/4] drm/msm: Protect the RPTR shadow Jordan Crouse
  2020-09-04  2:03 ` [PATCH 1/4] drm/msm: Split the a5xx preemption record Jordan Crouse
  2020-09-04  2:03 ` [PATCH 2/4] drm/msm: Enable expanded apriv support for a650 Jordan Crouse
@ 2020-09-04  2:03 ` Jordan Crouse
  2020-09-04  2:03 ` [PATCH 4/4] drm/msm: Disable the RPTR shadow Jordan Crouse
  3 siblings, 0 replies; 7+ messages in thread
From: Jordan Crouse @ 2020-09-04  2:03 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: AngeloGioacchino Del Regno, Ben Dooks, Daniel Vetter,
	David Airlie, Emil Velikov, Eric Anholt, Rob Clark, Sam Ravnborg,
	Sean Paul, dri-devel, freedreno, linux-kernel

Temporarily disable preemption on a5xx targets pending some improvements
to protect the RPTR shadow from being corrupted.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 9e63a190642c..e718f964d590 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] drm/msm: Disable the RPTR shadow
  2020-09-04  2:03 [PATCH 0/4] drm/msm: Protect the RPTR shadow Jordan Crouse
                   ` (2 preceding siblings ...)
  2020-09-04  2:03 ` [PATCH 3/4] drm/msm: Disable preemption on all 5xx targets Jordan Crouse
@ 2020-09-04  2:03 ` Jordan Crouse
  3 siblings, 0 replies; 7+ messages in thread
From: Jordan Crouse @ 2020-09-04  2:03 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: AngeloGioacchino Del Regno, Ben Dooks, Bjorn Andersson,
	Brian Masney, Daniel Vetter, David Airlie, Emil Velikov,
	Eric Anholt, Jonathan Marek, Rob Clark, Sean Paul,
	Sharat Masetty, Shawn Guo, dri-devel, freedreno, linux-kernel

Disable the RPTR shadow across all targets. It will be selectively
re-enabled later for targets that need it.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
---

 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(-)

diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index 6021f8d9efd1..48fa49f69d6d 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -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
diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index 0a5ea9f56cb8..f6471145a7a6 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -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);
 
diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index b9b26b2bf9c5..954753600625 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -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;
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index e718f964d590..ce3c0b5c167b 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -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);
 
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 406efaac95a7..74bc27eb4203 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -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];
 
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index d2dbb6968cba..459f10a3710b 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] drm/msm: Split the a5xx preemption record
  2020-09-04  2:03 ` [PATCH 1/4] drm/msm: Split the a5xx preemption record Jordan Crouse
@ 2020-09-06  3:16   ` Sasha Levin
  2020-09-08 18:13     ` Jordan Crouse
  0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2020-09-06  3:16 UTC (permalink / raw)
  To: Sasha Levin, Jordan Crouse, linux-arm-msm
  Cc: stable, Daniel Vetter, stable, stable

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?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] drm/msm: Split the a5xx preemption record
  2020-09-06  3:16   ` Sasha Levin
@ 2020-09-08 18:13     ` Jordan Crouse
  0 siblings, 0 replies; 7+ messages in thread
From: Jordan Crouse @ 2020-09-08 18:13 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-arm-msm, stable, Daniel Vetter

On Sun, Sep 06, 2020 at 03:16:10AM +0000, Sasha Levin wrote:
> 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?

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
> 
> -- 
> Thanks
> Sasha

-- 
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-08 18:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04  2:03 [PATCH 0/4] drm/msm: Protect the RPTR shadow Jordan Crouse
2020-09-04  2:03 ` [PATCH 1/4] drm/msm: Split the a5xx preemption record Jordan Crouse
2020-09-06  3:16   ` Sasha Levin
2020-09-08 18:13     ` Jordan Crouse
2020-09-04  2:03 ` [PATCH 2/4] drm/msm: Enable expanded apriv support for a650 Jordan Crouse
2020-09-04  2:03 ` [PATCH 3/4] drm/msm: Disable preemption on all 5xx targets Jordan Crouse
2020-09-04  2:03 ` [PATCH 4/4] drm/msm: Disable the RPTR shadow Jordan Crouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).