]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 13:03:49 +0000 (15:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 13:03:49 +0000 (15:03 +0200)
added patches:
drm-etnaviv-add-missing-mmu-context-put-when-reaping-mmu-mapping.patch
drm-etnaviv-exec-and-mmu-state-is-lost-when-resetting-the-gpu.patch
drm-etnaviv-fix-mmu-context-leak-on-gpu-reset.patch
drm-etnaviv-keep-mmu-context-across-runtime-suspend-resume.patch
drm-etnaviv-put-submit-prev-mmu-context-when-it-exists.patch
drm-etnaviv-reference-mmu-context-when-setting-up-hardware-state.patch
drm-etnaviv-return-context-from-etnaviv_iommu_context_get.patch
drm-etnaviv-stop-abusing-mmu_context-as-fe-running-marker.patch

queue-5.10/drm-etnaviv-add-missing-mmu-context-put-when-reaping-mmu-mapping.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-exec-and-mmu-state-is-lost-when-resetting-the-gpu.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-fix-mmu-context-leak-on-gpu-reset.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-keep-mmu-context-across-runtime-suspend-resume.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-put-submit-prev-mmu-context-when-it-exists.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-reference-mmu-context-when-setting-up-hardware-state.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-return-context-from-etnaviv_iommu_context_get.patch [new file with mode: 0644]
queue-5.10/drm-etnaviv-stop-abusing-mmu_context-as-fe-running-marker.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/drm-etnaviv-add-missing-mmu-context-put-when-reaping-mmu-mapping.patch b/queue-5.10/drm-etnaviv-add-missing-mmu-context-put-when-reaping-mmu-mapping.patch
new file mode 100644 (file)
index 0000000..f7a3b80
--- /dev/null
@@ -0,0 +1,34 @@
+From f2faea8b64125852fa9acc6771c07fc0311a039b Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:30 +0200
+Subject: drm/etnaviv: add missing MMU context put when reaping MMU mapping
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit f2faea8b64125852fa9acc6771c07fc0311a039b upstream.
+
+When we forcefully evict a mapping from the the address space and thus the
+MMU context, the MMU context is leaked, as the mapping no longer points to
+it, so it doesn't get freed when the GEM object is destroyed. Add the
+mssing context put to fix the leak.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_mmu.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.c
+@@ -197,6 +197,7 @@ static int etnaviv_iommu_find_iova(struc
+                */
+               list_for_each_entry_safe(m, n, &list, scan_node) {
+                       etnaviv_iommu_remove_mapping(context, m);
++                      etnaviv_iommu_context_put(m->context);
+                       m->context = NULL;
+                       list_del_init(&m->mmu_node);
+                       list_del_init(&m->scan_node);
diff --git a/queue-5.10/drm-etnaviv-exec-and-mmu-state-is-lost-when-resetting-the-gpu.patch b/queue-5.10/drm-etnaviv-exec-and-mmu-state-is-lost-when-resetting-the-gpu.patch
new file mode 100644 (file)
index 0000000..69c3aa1
--- /dev/null
@@ -0,0 +1,51 @@
+From 725cbc7884c37f3b4f1777bc1aea6432cded8ca5 Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:27 +0200
+Subject: drm/etnaviv: exec and MMU state is lost when resetting the GPU
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit 725cbc7884c37f3b4f1777bc1aea6432cded8ca5 upstream.
+
+When the GPU is reset both the current exec state, as well as all MMU
+state is lost. Move the driver side state tracking into the reset function
+to keep hardware and software state from diverging.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c |    5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -562,6 +562,8 @@ static int etnaviv_hw_reset(struct etnav
+       etnaviv_gpu_update_clock(gpu);
+       gpu->fe_running = false;
++      gpu->exec_state = -1;
++      gpu->mmu_context = NULL;
+       return 0;
+ }
+@@ -818,7 +820,6 @@ int etnaviv_gpu_init(struct etnaviv_gpu
+       /* Now program the hardware */
+       mutex_lock(&gpu->lock);
+       etnaviv_gpu_hw_init(gpu);
+-      gpu->exec_state = -1;
+       mutex_unlock(&gpu->lock);
+       pm_runtime_mark_last_busy(gpu->dev);
+@@ -1043,8 +1044,6 @@ void etnaviv_gpu_recover_hang(struct etn
+       spin_unlock(&gpu->event_spinlock);
+       etnaviv_gpu_hw_init(gpu);
+-      gpu->exec_state = -1;
+-      gpu->mmu_context = NULL;
+       mutex_unlock(&gpu->lock);
+       pm_runtime_mark_last_busy(gpu->dev);
diff --git a/queue-5.10/drm-etnaviv-fix-mmu-context-leak-on-gpu-reset.patch b/queue-5.10/drm-etnaviv-fix-mmu-context-leak-on-gpu-reset.patch
new file mode 100644 (file)
index 0000000..8260792
--- /dev/null
@@ -0,0 +1,35 @@
+From f978a5302f5566480c58ffae64a16d34456801bd Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:28 +0200
+Subject: drm/etnaviv: fix MMU context leak on GPU reset
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit f978a5302f5566480c58ffae64a16d34456801bd upstream.
+
+After a reset the GPU is no longer using the MMU context and may be
+restarted with a different context. While the mmu_state proeprly was
+cleared, the context wasn't unreferenced, leading to a memory leak.
+
+Cc: stable@vger.kernel.org # 5.4
+Reported-by: Michael Walle <michael@walle.cc>
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -563,6 +563,8 @@ static int etnaviv_hw_reset(struct etnav
+       gpu->fe_running = false;
+       gpu->exec_state = -1;
++      if (gpu->mmu_context)
++              etnaviv_iommu_context_put(gpu->mmu_context);
+       gpu->mmu_context = NULL;
+       return 0;
diff --git a/queue-5.10/drm-etnaviv-keep-mmu-context-across-runtime-suspend-resume.patch b/queue-5.10/drm-etnaviv-keep-mmu-context-across-runtime-suspend-resume.patch
new file mode 100644 (file)
index 0000000..4600f48
--- /dev/null
@@ -0,0 +1,50 @@
+From 8f3eea9d01d7b0f95b0fe04187c0059019ada85b Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:26 +0200
+Subject: drm/etnaviv: keep MMU context across runtime suspend/resume
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit 8f3eea9d01d7b0f95b0fe04187c0059019ada85b upstream.
+
+The MMU state may be kept across a runtime suspend/resume cycle, as we
+avoid a full hardware reset to keep the latency of the runtime PM small.
+
+Don't pretend that the MMU state is lost in driver state. The MMU
+context is pushed out when new HW jobs with a different context are
+coming in. The only exception to this is when the GPU is unbound, in
+which case we need to make sure to also free the last active context.
+
+Cc: stable@vger.kernel.org # 5.4
+Reported-by: Michael Walle <michael@walle.cc>
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -1578,9 +1578,6 @@ static int etnaviv_gpu_hw_suspend(struct
+                */
+               etnaviv_gpu_wait_idle(gpu, 100);
+-              etnaviv_iommu_context_put(gpu->mmu_context);
+-              gpu->mmu_context = NULL;
+-
+               gpu->fe_running = false;
+       }
+@@ -1729,6 +1726,9 @@ static void etnaviv_gpu_unbind(struct de
+       etnaviv_gpu_hw_suspend(gpu);
+ #endif
++      if (gpu->mmu_context)
++              etnaviv_iommu_context_put(gpu->mmu_context);
++
+       if (gpu->initialized) {
+               etnaviv_cmdbuf_free(&gpu->buffer);
+               etnaviv_iommu_global_fini(gpu);
diff --git a/queue-5.10/drm-etnaviv-put-submit-prev-mmu-context-when-it-exists.patch b/queue-5.10/drm-etnaviv-put-submit-prev-mmu-context-when-it-exists.patch
new file mode 100644 (file)
index 0000000..fc1328f
--- /dev/null
@@ -0,0 +1,36 @@
+From cda7532916f7bc860b36a1806cb8352e6f63dacb Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:24 +0200
+Subject: drm/etnaviv: put submit prev MMU context when it exists
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit cda7532916f7bc860b36a1806cb8352e6f63dacb upstream.
+
+The prev context is the MMU context at the time of the job
+queueing in hardware. As a job might be queued multiple times
+due to recovery after a GPU hang, we need to make sure to put
+the stale prev MMU context from a prior queuing, to avoid the
+reference and thus the MMU context leaking.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -1356,6 +1356,8 @@ struct dma_fence *etnaviv_gpu_submit(str
+               gpu->mmu_context = etnaviv_iommu_context_get(submit->mmu_context);
+               etnaviv_gpu_start_fe_idleloop(gpu);
+       } else {
++              if (submit->prev_mmu_context)
++                      etnaviv_iommu_context_put(submit->prev_mmu_context);
+               submit->prev_mmu_context = etnaviv_iommu_context_get(gpu->mmu_context);
+       }
diff --git a/queue-5.10/drm-etnaviv-reference-mmu-context-when-setting-up-hardware-state.patch b/queue-5.10/drm-etnaviv-reference-mmu-context-when-setting-up-hardware-state.patch
new file mode 100644 (file)
index 0000000..79da13d
--- /dev/null
@@ -0,0 +1,110 @@
+From d6408538f091fb22d47f792d4efa58143d56c3fb Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:29 +0200
+Subject: drm/etnaviv: reference MMU context when setting up hardware state
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit d6408538f091fb22d47f792d4efa58143d56c3fb upstream.
+
+Move the refcount manipulation of the MMU context to the point where the
+hardware state is programmed. At that point it is also known if a previous
+MMU state is still there, or the state needs to be reprogrammed with a
+potentially different context.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c      |   24 ++++++++++++------------
+ drivers/gpu/drm/etnaviv/etnaviv_iommu.c    |    4 ++++
+ drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c |    8 ++++++++
+ 3 files changed, 24 insertions(+), 12 deletions(-)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -633,17 +633,19 @@ void etnaviv_gpu_start_fe(struct etnaviv
+       gpu->fe_running = true;
+ }
+-static void etnaviv_gpu_start_fe_idleloop(struct etnaviv_gpu *gpu)
++static void etnaviv_gpu_start_fe_idleloop(struct etnaviv_gpu *gpu,
++                                        struct etnaviv_iommu_context *context)
+ {
+-      u32 address = etnaviv_cmdbuf_get_va(&gpu->buffer,
+-                              &gpu->mmu_context->cmdbuf_mapping);
+       u16 prefetch;
++      u32 address;
+       /* setup the MMU */
+-      etnaviv_iommu_restore(gpu, gpu->mmu_context);
++      etnaviv_iommu_restore(gpu, context);
+       /* Start command processor */
+       prefetch = etnaviv_buffer_init(gpu);
++      address = etnaviv_cmdbuf_get_va(&gpu->buffer,
++                                      &gpu->mmu_context->cmdbuf_mapping);
+       etnaviv_gpu_start_fe(gpu, address, prefetch);
+ }
+@@ -1357,14 +1359,12 @@ struct dma_fence *etnaviv_gpu_submit(str
+               goto out_unlock;
+       }
+-      if (!gpu->fe_running) {
+-              gpu->mmu_context = etnaviv_iommu_context_get(submit->mmu_context);
+-              etnaviv_gpu_start_fe_idleloop(gpu);
+-      } else {
+-              if (submit->prev_mmu_context)
+-                      etnaviv_iommu_context_put(submit->prev_mmu_context);
+-              submit->prev_mmu_context = etnaviv_iommu_context_get(gpu->mmu_context);
+-      }
++      if (!gpu->fe_running)
++              etnaviv_gpu_start_fe_idleloop(gpu, submit->mmu_context);
++
++      if (submit->prev_mmu_context)
++              etnaviv_iommu_context_put(submit->prev_mmu_context);
++      submit->prev_mmu_context = etnaviv_iommu_context_get(gpu->mmu_context);
+       if (submit->nr_pmrs) {
+               gpu->event[event[1]].sync_point = &sync_point_perfmon_sample_pre;
+--- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c
+@@ -92,6 +92,10 @@ static void etnaviv_iommuv1_restore(stru
+       struct etnaviv_iommuv1_context *v1_context = to_v1_context(context);
+       u32 pgtable;
++      if (gpu->mmu_context)
++              etnaviv_iommu_context_put(gpu->mmu_context);
++      gpu->mmu_context = etnaviv_iommu_context_get(context);
++
+       /* set base addresses */
+       gpu_write(gpu, VIVS_MC_MEMORY_BASE_ADDR_RA, context->global->memory_base);
+       gpu_write(gpu, VIVS_MC_MEMORY_BASE_ADDR_FE, context->global->memory_base);
+--- a/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu_v2.c
+@@ -172,6 +172,10 @@ static void etnaviv_iommuv2_restore_nons
+       if (gpu_read(gpu, VIVS_MMUv2_CONTROL) & VIVS_MMUv2_CONTROL_ENABLE)
+               return;
++      if (gpu->mmu_context)
++              etnaviv_iommu_context_put(gpu->mmu_context);
++      gpu->mmu_context = etnaviv_iommu_context_get(context);
++
+       prefetch = etnaviv_buffer_config_mmuv2(gpu,
+                               (u32)v2_context->mtlb_dma,
+                               (u32)context->global->bad_page_dma);
+@@ -192,6 +196,10 @@ static void etnaviv_iommuv2_restore_sec(
+       if (gpu_read(gpu, VIVS_MMUv2_SEC_CONTROL) & VIVS_MMUv2_SEC_CONTROL_ENABLE)
+               return;
++      if (gpu->mmu_context)
++              etnaviv_iommu_context_put(gpu->mmu_context);
++      gpu->mmu_context = etnaviv_iommu_context_get(context);
++
+       gpu_write(gpu, VIVS_MMUv2_PTA_ADDRESS_LOW,
+                 lower_32_bits(context->global->v2.pta_dma));
+       gpu_write(gpu, VIVS_MMUv2_PTA_ADDRESS_HIGH,
diff --git a/queue-5.10/drm-etnaviv-return-context-from-etnaviv_iommu_context_get.patch b/queue-5.10/drm-etnaviv-return-context-from-etnaviv_iommu_context_get.patch
new file mode 100644 (file)
index 0000000..7e68934
--- /dev/null
@@ -0,0 +1,94 @@
+From 78edefc05e41352099ffb8f06f8d9b2d091e29cd Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:23 +0200
+Subject: drm/etnaviv: return context from etnaviv_iommu_context_get
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit 78edefc05e41352099ffb8f06f8d9b2d091e29cd upstream.
+
+Being able to have the refcount manipulation in an assignment makes
+it much easier to parse the code.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_buffer.c     |    3 +--
+ drivers/gpu/drm/etnaviv/etnaviv_gem.c        |    3 +--
+ drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c |    3 +--
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c        |    6 ++----
+ drivers/gpu/drm/etnaviv/etnaviv_mmu.h        |    4 +++-
+ 5 files changed, 8 insertions(+), 11 deletions(-)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
+@@ -397,8 +397,7 @@ void etnaviv_buffer_queue(struct etnaviv
+               if (switch_mmu_context) {
+                       struct etnaviv_iommu_context *old_context = gpu->mmu_context;
+-                      etnaviv_iommu_context_get(mmu_context);
+-                      gpu->mmu_context = mmu_context;
++                      gpu->mmu_context = etnaviv_iommu_context_get(mmu_context);
+                       etnaviv_iommu_context_put(old_context);
+               }
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+@@ -305,8 +305,7 @@ struct etnaviv_vram_mapping *etnaviv_gem
+               list_del(&mapping->obj_node);
+       }
+-      etnaviv_iommu_context_get(mmu_context);
+-      mapping->context = mmu_context;
++      mapping->context = etnaviv_iommu_context_get(mmu_context);
+       mapping->use = 1;
+       ret = etnaviv_iommu_map_gem(mmu_context, etnaviv_obj,
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+@@ -532,8 +532,7 @@ int etnaviv_ioctl_gem_submit(struct drm_
+               goto err_submit_objects;
+       submit->ctx = file->driver_priv;
+-      etnaviv_iommu_context_get(submit->ctx->mmu);
+-      submit->mmu_context = submit->ctx->mmu;
++      submit->mmu_context = etnaviv_iommu_context_get(submit->ctx->mmu);
+       submit->exec_state = args->exec_state;
+       submit->flags = args->flags;
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -1353,12 +1353,10 @@ struct dma_fence *etnaviv_gpu_submit(str
+       }
+       if (!gpu->mmu_context) {
+-              etnaviv_iommu_context_get(submit->mmu_context);
+-              gpu->mmu_context = submit->mmu_context;
++              gpu->mmu_context = etnaviv_iommu_context_get(submit->mmu_context);
+               etnaviv_gpu_start_fe_idleloop(gpu);
+       } else {
+-              etnaviv_iommu_context_get(gpu->mmu_context);
+-              submit->prev_mmu_context = gpu->mmu_context;
++              submit->prev_mmu_context = etnaviv_iommu_context_get(gpu->mmu_context);
+       }
+       if (submit->nr_pmrs) {
+--- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h
++++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h
+@@ -105,9 +105,11 @@ void etnaviv_iommu_dump(struct etnaviv_i
+ struct etnaviv_iommu_context *
+ etnaviv_iommu_context_init(struct etnaviv_iommu_global *global,
+                          struct etnaviv_cmdbuf_suballoc *suballoc);
+-static inline void etnaviv_iommu_context_get(struct etnaviv_iommu_context *ctx)
++static inline struct etnaviv_iommu_context *
++etnaviv_iommu_context_get(struct etnaviv_iommu_context *ctx)
+ {
+       kref_get(&ctx->refcount);
++      return ctx;
+ }
+ void etnaviv_iommu_context_put(struct etnaviv_iommu_context *ctx);
+ void etnaviv_iommu_restore(struct etnaviv_gpu *gpu,
diff --git a/queue-5.10/drm-etnaviv-stop-abusing-mmu_context-as-fe-running-marker.patch b/queue-5.10/drm-etnaviv-stop-abusing-mmu_context-as-fe-running-marker.patch
new file mode 100644 (file)
index 0000000..ec43584
--- /dev/null
@@ -0,0 +1,82 @@
+From 23e0f5a57d0ecec86e1fc82194acd94aede21a46 Mon Sep 17 00:00:00 2001
+From: Lucas Stach <l.stach@pengutronix.de>
+Date: Fri, 20 Aug 2021 22:18:25 +0200
+Subject: drm/etnaviv: stop abusing mmu_context as FE running marker
+
+From: Lucas Stach <l.stach@pengutronix.de>
+
+commit 23e0f5a57d0ecec86e1fc82194acd94aede21a46 upstream.
+
+While the DMA frontend can only be active when the MMU context is set, the
+reverse isn't necessarily true, as the frontend can be stopped while the
+MMU state is kept. Stop treating mmu_context being set as a indication that
+the frontend is running and instead add a explicit property.
+
+Cc: stable@vger.kernel.org # 5.4
+Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
+Tested-by: Michael Walle <michael@walle.cc>
+Tested-by: Marek Vasut <marex@denx.de>
+Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.c |   10 ++++++++--
+ drivers/gpu/drm/etnaviv/etnaviv_gpu.h |    1 +
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+@@ -561,6 +561,8 @@ static int etnaviv_hw_reset(struct etnav
+       /* We rely on the GPU running, so program the clock */
+       etnaviv_gpu_update_clock(gpu);
++      gpu->fe_running = false;
++
+       return 0;
+ }
+@@ -623,6 +625,8 @@ void etnaviv_gpu_start_fe(struct etnaviv
+                         VIVS_MMUv2_SEC_COMMAND_CONTROL_ENABLE |
+                         VIVS_MMUv2_SEC_COMMAND_CONTROL_PREFETCH(prefetch));
+       }
++
++      gpu->fe_running = true;
+ }
+ static void etnaviv_gpu_start_fe_idleloop(struct etnaviv_gpu *gpu)
+@@ -1352,7 +1356,7 @@ struct dma_fence *etnaviv_gpu_submit(str
+               goto out_unlock;
+       }
+-      if (!gpu->mmu_context) {
++      if (!gpu->fe_running) {
+               gpu->mmu_context = etnaviv_iommu_context_get(submit->mmu_context);
+               etnaviv_gpu_start_fe_idleloop(gpu);
+       } else {
+@@ -1561,7 +1565,7 @@ int etnaviv_gpu_wait_idle(struct etnaviv
+ static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
+ {
+-      if (gpu->initialized && gpu->mmu_context) {
++      if (gpu->initialized && gpu->fe_running) {
+               /* Replace the last WAIT with END */
+               mutex_lock(&gpu->lock);
+               etnaviv_buffer_end(gpu);
+@@ -1576,6 +1580,8 @@ static int etnaviv_gpu_hw_suspend(struct
+               etnaviv_iommu_context_put(gpu->mmu_context);
+               gpu->mmu_context = NULL;
++
++              gpu->fe_running = false;
+       }
+       gpu->exec_state = -1;
+--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
++++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.h
+@@ -101,6 +101,7 @@ struct etnaviv_gpu {
+       struct workqueue_struct *wq;
+       struct drm_gpu_scheduler sched;
+       bool initialized;
++      bool fe_running;
+       /* 'ring'-buffer: */
+       struct etnaviv_cmdbuf buffer;
index 387f7efd73f501dd604060aeefbf56f0315b789f..7c9046b2f0daea468a8d35531b40fdc321396a65 100644 (file)
@@ -7,3 +7,11 @@ arm64-sve-use-correct-size-when-reinitialising-sve-state.patch
 pm-base-power-don-t-try-to-use-non-existing-rtc-for-storing-data.patch
 pci-add-amd-gpu-multi-function-power-dependencies.patch
 drm-amd-amdgpu-increase-hwip_max_instance-to-10.patch
+drm-etnaviv-return-context-from-etnaviv_iommu_context_get.patch
+drm-etnaviv-put-submit-prev-mmu-context-when-it-exists.patch
+drm-etnaviv-stop-abusing-mmu_context-as-fe-running-marker.patch
+drm-etnaviv-keep-mmu-context-across-runtime-suspend-resume.patch
+drm-etnaviv-exec-and-mmu-state-is-lost-when-resetting-the-gpu.patch
+drm-etnaviv-fix-mmu-context-leak-on-gpu-reset.patch
+drm-etnaviv-reference-mmu-context-when-setting-up-hardware-state.patch
+drm-etnaviv-add-missing-mmu-context-put-when-reaping-mmu-mapping.patch