Module Name: src
Committed By: riastradh
Date: Sun Dec 19 12:04:59 UTC 2021
Modified Files:
src/sys/external/bsd/drm2/dist/drm: drm_fb_helper.c
src/sys/external/bsd/drm2/include/drm: drm_client.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
cvs rdiff -u -r1.1 -r1.2 src/sys/external/bsd/drm2/include/drm/drm_client.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.24 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.25
--- src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.24 Sun Dec 19 10:46:43 2021
+++ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c Sun Dec 19 12:04:59 2021
@@ -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 <[email protected]>
*/
#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 @@ int drm_fb_helper_debug_enter_fb(struct
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 @@ int drm_fb_helper_debug_enter_fb(struct
mode_set->y,
ENTER_ATOMIC_MODE_SET);
}
- mutex_unlock(&helper->client.modeset_mutex);
}
return 0;
@@ -209,8 +207,7 @@ int drm_fb_helper_debug_leave_fb(struct
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 @@ int drm_fb_helper_debug_leave_fb(struct
funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x,
crtc->y, LEAVE_ATOMIC_MODE_SET);
}
- mutex_unlock(&client->modeset_mutex);
return 0;
}
Index: src/sys/external/bsd/drm2/include/drm/drm_client.h
diff -u src/sys/external/bsd/drm2/include/drm/drm_client.h:1.1 src/sys/external/bsd/drm2/include/drm/drm_client.h:1.2
--- src/sys/external/bsd/drm2/include/drm/drm_client.h:1.1 Sun Dec 19 10:36:32 2021
+++ src/sys/external/bsd/drm2/include/drm/drm_client.h Sun Dec 19 12:04:59 2021
@@ -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 @@ void drm_client_modeset_free(struct drm_
#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) \