From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@redhat.com, sean@poorly.run, daniel@ffwll.ch
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 09/16] drm/udl: Support DRM hot-unplugging
Date: Mon, 19 Sep 2022 15:04:01 +0200 [thread overview]
Message-ID: <20220919130408.21486-10-tzimmermann@suse.de> (raw)
In-Reply-To: <20220919130408.21486-1-tzimmermann@suse.de>
Add drm_dev_enter() and drm_dev_exit() to the various modesetting
functions that interact with the device. After hot-unplugging the
device, these functions will return early. So far, the udl driver
relied on USB interfaces to handle unplugging of the device.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/udl/udl_modeset.c | 43 ++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 97d68cf88bd8..aaa828034a04 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -12,6 +12,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_damage_helper.h>
+#include <drm/drm_drv.h>
#include <drm/drm_edid.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_gem_atomic_helper.h>
@@ -295,14 +296,21 @@ static const uint64_t udl_primary_plane_fmtmods[] = {
static void udl_primary_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_atomic_state *state)
{
+ struct drm_device *dev = plane->dev;
struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, plane);
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
struct drm_framebuffer *fb = plane_state->fb;
struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
struct drm_rect rect;
+ int idx;
+
+ if (!drm_dev_enter(dev, &idx))
+ return;
if (drm_atomic_helper_damage_merged(old_plane_state, plane_state, &rect))
udl_handle_damage(fb, &shadow_plane_state->data[0], &rect);
+
+ drm_dev_exit(idx);
}
static void udl_primary_plane_helper_atomic_disable(struct drm_plane *plane,
@@ -348,10 +356,14 @@ static void udl_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atom
struct drm_display_mode *mode = &crtc_state->mode;
struct urb *urb;
char *buf;
+ int idx;
+
+ if (!drm_dev_enter(dev, &idx))
+ return;
urb = udl_get_urb(dev);
if (!urb)
- return;
+ goto out;
buf = (char *)urb->transfer_buffer;
buf = udl_vidreg_lock(buf);
@@ -366,6 +378,9 @@ static void udl_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atom
buf = udl_dummy_render(buf);
udl_submit_urb(dev, urb, buf - (char *)urb->transfer_buffer);
+
+out:
+ drm_dev_exit(idx);
}
static void udl_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_atomic_state *state)
@@ -373,10 +388,14 @@ static void udl_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_ato
struct drm_device *dev = crtc->dev;
struct urb *urb;
char *buf;
+ int idx;
+
+ if (!drm_dev_enter(dev, &idx))
+ return;
urb = udl_get_urb(dev);
if (!urb)
- return;
+ goto out;
buf = (char *)urb->transfer_buffer;
buf = udl_vidreg_lock(buf);
@@ -385,6 +404,9 @@ static void udl_crtc_helper_atomic_disable(struct drm_crtc *crtc, struct drm_ato
buf = udl_dummy_render(buf);
udl_submit_urb(dev, urb, buf - (char *)urb->transfer_buffer);
+
+out:
+ drm_dev_exit(idx);
}
static const struct drm_crtc_helper_funcs udl_crtc_helper_funcs = {
@@ -471,17 +493,26 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block, size_t le
static enum drm_connector_status udl_connector_detect(struct drm_connector *connector, bool force)
{
- struct udl_device *udl = to_udl(connector->dev);
+ struct drm_device *dev = connector->dev;
+ struct udl_device *udl = to_udl(dev);
struct udl_connector *udl_connector = to_udl_connector(connector);
+ enum drm_connector_status status = connector_status_disconnected;
+ int idx;
/* cleanup previous EDID */
kfree(udl_connector->edid);
+ udl_connector->edid = NULL;
- udl_connector->edid = drm_do_get_edid(connector, udl_get_edid_block, udl);
- if (!udl_connector->edid)
+ if (!drm_dev_enter(dev, &idx))
return connector_status_disconnected;
- return connector_status_connected;
+ udl_connector->edid = drm_do_get_edid(connector, udl_get_edid_block, udl);
+ if (udl_connector->edid)
+ status = connector_status_connected;
+
+ drm_dev_exit(idx);
+
+ return status;
}
static void udl_connector_destroy(struct drm_connector *connector)
--
2.37.3
next prev parent reply other threads:[~2022-09-19 13:06 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 13:03 [PATCH 00/16] drm/udl: Better modesetting, hot-unplug, protocol Thomas Zimmermann
2022-09-19 13:03 ` [PATCH 01/16] drm/udl: Rename struct udl_drm_connector to struct udl_connector Thomas Zimmermann
2022-09-29 12:51 ` Javier Martinez Canillas
2022-09-19 13:03 ` [PATCH 02/16] drm/udl: Test pixel limit in mode-config's mode-valid function Thomas Zimmermann
2022-09-29 13:20 ` Javier Martinez Canillas
2022-09-29 13:53 ` Thomas Zimmermann
2022-09-19 13:03 ` [PATCH 03/16] drm/udl: Use USB timeout constant when reading EDID Thomas Zimmermann
2022-09-29 13:23 ` Javier Martinez Canillas
2022-09-19 13:03 ` [PATCH 04/16] drm/udl: Various improvements to the connector Thomas Zimmermann
2022-09-29 13:44 ` Javier Martinez Canillas
2022-09-19 13:03 ` [PATCH 05/16] drm/udl: Move connector to modesetting code Thomas Zimmermann
2022-09-29 13:47 ` Javier Martinez Canillas
2022-09-19 13:03 ` [PATCH 06/16] drm/udl: Remove udl_simple_display_pipe_mode_valid() Thomas Zimmermann
2022-09-29 13:49 ` Javier Martinez Canillas
2022-09-19 13:03 ` [PATCH 07/16] drm/udl: Convert to atomic-modesetting helpers Thomas Zimmermann
2022-09-29 14:21 ` Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 08/16] drm/udl: Simplify modesetting in CRTC's enable function Thomas Zimmermann
2022-09-29 14:28 ` Javier Martinez Canillas
2022-09-19 13:04 ` Thomas Zimmermann [this message]
2022-10-04 22:17 ` [PATCH 09/16] drm/udl: Support DRM hot-unplugging Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 10/16] drm/udl: Use damage iterator Thomas Zimmermann
2022-10-04 22:28 ` Javier Martinez Canillas
2022-10-05 15:26 ` Thomas Zimmermann
2022-09-19 13:04 ` [PATCH 11/16] drm/udl: Move register constants to udl_proto.h Thomas Zimmermann
2022-10-04 22:39 ` Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 12/16] drm/udl: Add constants for display-mode registers Thomas Zimmermann
2022-10-04 22:50 ` Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 13/16] drm/udl: Add register constants for color depth Thomas Zimmermann
2022-10-04 22:51 ` Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 14/16] drm/udl: Add register constants for video locks Thomas Zimmermann
2022-10-04 22:52 ` Javier Martinez Canillas
2022-09-19 13:04 ` [PATCH 15/16] drm/udl: Add register constants for framebuffer scanout addresses Thomas Zimmermann
2022-10-04 22:59 ` Javier Martinez Canillas
2022-10-05 14:56 ` Thomas Zimmermann
2022-09-19 13:04 ` [PATCH 16/16] drm/udl: Add constants for commands Thomas Zimmermann
2022-10-04 23:00 ` Javier Martinez Canillas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220919130408.21486-10-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=sean@poorly.run \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox