[PATCH 5/6] drm/vc4: Hold a runtime PM reference in the binner overflow work
Maíra Canal <[email protected]>
| Newsgroups | org.freedesktop.lists.dri-devel |
|---|---|
| Message-ID | <[email protected]> |
The out-of-memory interrupt only queues vc4_overflow_mem_work(), so the
V3D block can be runtime suspended before the work runs. It then hands the
binner a new overflow slot through V3D_BPOA and V3D_BPOS, registers that
are unreachable once the block is down.
Take a runtime PM reference in the work and give up when the block is no
longer active. Nothing is lost by giving up: the interrupt mask is rebuilt
on resume, and the binner can ask again as soon as it is short of memory.
Fixes: 001bdb55d9eb ("drm/vc4: Enable runtime PM.")
Signed-off-by: Maíra Canal <[email protected]>
---
drivers/gpu/drm/vc4/vc4_irq.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
index 2efed552c08a..999010381da1 100644
--- a/drivers/gpu/drm/vc4/vc4_irq.c
+++ b/drivers/gpu/drm/vc4/vc4_irq.c
@@ -46,6 +46,7 @@
*/
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <drm/drm_print.h>
@@ -65,6 +66,9 @@ vc4_overflow_mem_work(struct work_struct *work)
struct vc4_exec_info *exec;
unsigned long irqflags;
+ if (pm_runtime_get_if_active(&vc4->v3d->pdev->dev) <= 0)
+ return;
+
mutex_lock(&vc4->bin_bo_lock);
if (!vc4->bin_bo)
@@ -109,6 +113,7 @@ vc4_overflow_mem_work(struct work_struct *work)
complete:
mutex_unlock(&vc4->bin_bo_lock);
+ pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
}
static void
--
2.55.0