Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2 drm: Work around client modeset mutex ...



details:   https://anonhg.NetBSD.org/src/rev/5fd887410d5f
branches:  trunk
changeset: 1028807:5fd887410d5f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 12:04:59 2021 +0000

description:
drm: Work around client modeset mutex for entering ddb.

Linux introduced a wait lock (`mutex') around access to the drm
client modesets, even for drm_fb_helper_debug_enter/leave -- which
happen when we're crashing and can't wait for the scheduler to let
whatever thread might hold a mutex continue to run.

This really shouldn't be a wait lock, but disentangling the lock
order and sleeping allocations is difficult, so let's just hope that
it's safe to access unlocked in ddb for now.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_fb_helper.c |  12 ++++--------
 sys/external/bsd/drm2/include/drm/drm_client.h |   5 ++++-
 2 files changed, 8 insertions(+), 9 deletions(-)

diffs (73 lines):

diff -r 3dac12b78856 -r 5fd887410d5f sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
--- a/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c    Sun Dec 19 12:04:51 2021 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c    Sun Dec 19 12:04:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_fb_helper.c,v 1.24 2021/12/19 10:46:43 riastradh Exp $     */
+/*     $NetBSD: drm_fb_helper.c,v 1.25 2021/12/19 12:04:59 riastradh Exp $     */
 
 /*
  * Copyright (c) 2006-2009 Red Hat Inc.
@@ -30,7 +30,7 @@
  *      Jesse Barnes <jesse.barnes%intel.com@localhost>
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.24 2021/12/19 10:46:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_fb_helper.c,v 1.25 2021/12/19 12:04:59 riastradh Exp $");
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
@@ -171,8 +171,7 @@
        struct drm_mode_set *mode_set;
 
        list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
-               mutex_lock(&helper->client.modeset_mutex);
-               drm_client_for_each_modeset(mode_set, &helper->client) {
+               drm_client_for_each_modeset_unlocked(mode_set, &helper->client) {
                        if (!mode_set->crtc->enabled)
                                continue;
 
@@ -189,7 +188,6 @@
                                                    mode_set->y,
                                                    ENTER_ATOMIC_MODE_SET);
                }
-               mutex_unlock(&helper->client.modeset_mutex);
        }
 
        return 0;
@@ -209,8 +207,7 @@
        struct drm_mode_set *mode_set;
        struct drm_framebuffer *fb;
 
-       mutex_lock(&client->modeset_mutex);
-       drm_client_for_each_modeset(mode_set, client) {
+       drm_client_for_each_modeset_unlocked(mode_set, client) {
                crtc = mode_set->crtc;
                if (drm_drv_uses_atomic_modeset(crtc->dev))
                        continue;
@@ -233,7 +230,6 @@
                funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x,
                                            crtc->y, LEAVE_ATOMIC_MODE_SET);
        }
-       mutex_unlock(&client->modeset_mutex);
 
        return 0;
 }
diff -r 3dac12b78856 -r 5fd887410d5f sys/external/bsd/drm2/include/drm/drm_client.h
--- a/sys/external/bsd/drm2/include/drm/drm_client.h    Sun Dec 19 12:04:51 2021 +0000
+++ b/sys/external/bsd/drm2/include/drm/drm_client.h    Sun Dec 19 12:04:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_client.h,v 1.1 2021/12/19 10:36:32 riastradh Exp $ */
+/*     $NetBSD: drm_client.h,v 1.2 2021/12/19 12:04:59 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -81,6 +81,9 @@
 
 #define drm_client_for_each_modeset(MODESET, CLIENT)              \
        KASSERT(mutex_is_locked(&(CLIENT)->modeset_mutex));        \
+       drm_client_for_each_modeset_unlocked(MODESET, CLIENT)
+
+#define drm_client_for_each_modeset_unlocked(MODESET, CLIENT)     \
        for ((MODESET) = (CLIENT)->modesets; (MODESET)->crtc; (MODESET)++)
 
 #define drm_client_for_each_connector_iter(CONNECTOR, ITER)                  \



Home | Main Index | Thread Index | Old Index