[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221001163946.534067-9-dakr@redhat.com>
Date: Sat, 1 Oct 2022 18:39:45 +0200
From: Danilo Krummrich <dakr@...hat.com>
To: daniel@...ll.ch, airlied@...ux.ie, tzimmermann@...e.de,
mripard@...nel.org, liviu.dudau@....com, brian.starkey@....com
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Danilo Krummrich <dakr@...hat.com>
Subject: [PATCH drm-misc-next v2 8/9] drm/arm/malidp: drv: protect device resources after removal
(Hardware) resources which are bound to the driver and device lifecycle
must not be accessed after the device and driver are unbound.
However, the DRM device isn't freed as long as the last user didn't
close it, hence userspace can still call into the driver.
Therefore protect the critical sections which are accessing those
resources with drm_dev_enter() and drm_dev_exit().
Signed-off-by: Danilo Krummrich <dakr@...hat.com>
---
drivers/gpu/drm/arm/malidp_drv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index aedd30f5f451..8bb8e8d14461 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -234,9 +234,12 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)
struct malidp_drm *malidp = drm_to_malidp(drm);
struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state;
- int i;
+ int i, idx;
bool fence_cookie = dma_fence_begin_signalling();
+ if (!drm_dev_enter(drm, &idx))
+ return;
+
pm_runtime_get_sync(drm->dev);
/*
@@ -267,6 +270,8 @@ static void malidp_atomic_commit_tail(struct drm_atomic_state *state)
pm_runtime_put(drm->dev);
drm_atomic_helper_cleanup_planes(drm, state);
+
+ drm_dev_exit(idx);
}
static const struct drm_mode_config_helper_funcs malidp_mode_config_helpers = {
--
2.37.3
Powered by blists - more mailing lists