<div dir="ltr"><div>This still crashes for me:<br><br>kernel: ------------[ cut here ]------------<br>kernel: WARNING: at drivers/gpu/drm/drm_modeset_lock.c:219 drm_modeset_legacy_acquire_ctx+0x38/0x40()<br>kernel: Modules linked in:<br>kernel: CPU: 0 PID: 586 Comm: Xorg Not tainted 3.10.33-02454-g1c4eeb3-dirty #196<br>kernel: [<c0014c9c>] (unwind_backtrace+0x0/0xec) from [<c0011d34>] (show_stack+0x10/0x14)<br>kernel: [<c0011d34>] (show_stack+0x10/0x14) from [<c002d2d0>] (warn_slowpath_common+0x54/0x6c)<br>kernel: [<c002d2d0>] (warn_slowpath_common+0x54/0x6c) from [<c002d384>] (warn_slowpath_null+0x1c/0x24)<br>kernel: [<c002d384>] (warn_slowpath_null+0x1c/0x24) from [<c02ce818>] (drm_modeset_legacy_acquire_ctx+0x38/0x40)<br>kernel: [<c02ce818>] (drm_modeset_legacy_acquire_ctx+0x38/0x40) from [<c02afa9c>] (drm_atomic_helper_disable_plane+0x24/0xd0)<br>kernel: [<c02afa9c>] (drm_atomic_helper_disable_plane+0x24/0xd0) from [<c02c19a4>] (__setplane_internal+0x28/0x2cc)<br>kernel: [<c02c19a4>] (__setplane_internal+0x28/0x2cc) from [<c02c287c>] (drm_mode_cursor_common+0x1cc/0x2f8)<br>kernel: [<c02c287c>] (drm_mode_cursor_common+0x1cc/0x2f8) from [<c02c53d4>] (drm_mode_cursor_ioctl+0x58/0x60)<br>kernel: [<c02c53d4>] (drm_mode_cursor_ioctl+0x58/0x60) from [<c02b917c>] (drm_ioctl+0x318/0x510)<br>kernel: [<c02b917c>] (drm_ioctl+0x318/0x510) from [<c00e2d9c>] (do_vfs_ioctl+0x55c/0x5b0)<br>kernel: [<c00e2d9c>] (do_vfs_ioctl+0x55c/0x5b0) from [<c00e2e40>] (SyS_ioctl+0x50/0x7c)<br>kernel: [<c00e2e40>] (SyS_ioctl+0x50/0x7c) from [<c000e000>] (ret_fast_syscall+0x0/0x30)<br><br></div>This seems to try to acquire the global device lock as instantiated by drm_modeset_lock_all, but nothing in this path calls that. I'm not sure what lock we can acquire when we don't have a CRTC.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 21, 2014 at 8:55 AM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel.vetter@ffwll.ch" target="_blank">daniel.vetter@ffwll.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">I've missed checking this and so didn't notice that there's a NULL<br>
check missing. Since depending upon calling context the crtc might not<br>
even be there (disable-me-harder does happen around planes, especially<br>
in cleanup code) we need to dodge the oops and look at the global<br>
acquire ctx.<br>
<br>
</span>v2: Actually fix the oops for real and don't just move it two lines<br>
down. That requires that we pass a drm_device pointer for the cases<br>
where crtc could be NULL.<br>
<span class=""><br>
Reported-by: "Jasper St. Pierre" <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>><br>
Cc: "Jasper St. Pierre" <<a href="mailto:jstpierre@mecheye.net">jstpierre@mecheye.net</a>><br>
Cc: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>><br>
Signed-off-by: Daniel Vetter <<a href="mailto:daniel.vetter@intel.com">daniel.vetter@intel.com</a>><br>
---<br>
</span> drivers/gpu/drm/drm_atomic_helper.c | 12 ++++++++----<br>
 drivers/gpu/drm/drm_modeset_lock.c  | 12 ++++++++----<br>
 include/drm/drm_modeset_lock.h      |  3 ++-<br>
 3 files changed, 18 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c<br>
index ca839bd9bb0d..32c34b5d5f68 100644<br>
--- a/drivers/gpu/drm/drm_atomic_helper.c<br>
+++ b/drivers/gpu/drm/drm_atomic_helper.c<br>
@@ -1171,7 +1171,8 @@ int drm_atomic_helper_update_plane(struct drm_plane *plane,<br>
        if (!state)<br>
                return -ENOMEM;<br>
<br>
-       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);<br>
+       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc,<br>
+                                                           plane->dev);<br>
 retry:<br>
        plane_state = drm_atomic_get_plane_state(state, plane);<br>
        if (IS_ERR(plane_state)) {<br>
@@ -1239,7 +1240,8 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane)<br>
        if (!state)<br>
                return -ENOMEM;<br>
<br>
-       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(plane->crtc);<br>
+       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(plane->crtc,<br>
+                                                           plane->dev);<br>
 retry:<br>
        plane_state = drm_atomic_get_plane_state(state, plane);<br>
        if (IS_ERR(plane_state)) {<br>
@@ -1391,7 +1393,8 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)<br>
        if (!state)<br>
                return -ENOMEM;<br>
<br>
-       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);<br>
+       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc,<br>
+                                                           crtc->dev);<br>
 retry:<br>
        crtc_state = drm_atomic_get_crtc_state(state, crtc);<br>
        if (IS_ERR(crtc_state)) {<br>
@@ -1676,7 +1679,8 @@ int drm_atomic_helper_page_flip(struct drm_crtc *crtc,<br>
        if (!state)<br>
                return -ENOMEM;<br>
<br>
-       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);<br>
+       state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc,<br>
+                                                           crtc->dev);<br>
 retry:<br>
        crtc_state = drm_atomic_get_crtc_state(state, crtc);<br>
        if (IS_ERR(crtc_state)) {<br>
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c<br>
index 474e4d12a2d8..655958d4f23e 100644<br>
--- a/drivers/gpu/drm/drm_modeset_lock.c<br>
+++ b/drivers/gpu/drm/drm_modeset_lock.c<br>
@@ -200,21 +200,25 @@ EXPORT_SYMBOL(drm_modeset_lock_crtc);<br>
 /**<br>
  * drm_modeset_legacy_acquire_ctx - find acquire ctx for legacy ioctls<br>
  * @crtc: drm crtc<br>
+ * @dev: device<br>
  *<br>
  * Legacy ioctl operations like cursor updates or page flips only have per-crtc<br>
  * locking, and store the acquire ctx in the corresponding crtc. All other<br>
  * legacy operations take all locks and use a global acquire context. This<br>
  * function grabs the right one.<br>
+ *<br>
+ * Note that either @crtc or @dev can be NULL, but not both.<br>
  */<br>
 struct drm_modeset_acquire_ctx *<br>
-drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc)<br>
+drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc,<br>
+                              struct drm_device *dev)<br>
<span class=""> {<br>
-       if (crtc->acquire_ctx)<br>
+       if (crtc && crtc->acquire_ctx)<br>
                return crtc->acquire_ctx;<br>
<br>
</span>-       WARN_ON(!crtc->dev->mode_config.acquire_ctx);<br>
+       WARN_ON(!dev->mode_config.acquire_ctx);<br>
<br>
-       return crtc->dev->mode_config.acquire_ctx;<br>
+       return dev->mode_config.acquire_ctx;<br>
 }<br>
 EXPORT_SYMBOL(drm_modeset_legacy_acquire_ctx);<br>
<br>
diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h<br>
index 28931a23d96c..cdbfd822e52f 100644<br>
--- a/include/drm/drm_modeset_lock.h<br>
+++ b/include/drm/drm_modeset_lock.h<br>
@@ -135,7 +135,8 @@ void drm_modeset_lock_crtc(struct drm_crtc *crtc);<br>
 void drm_modeset_unlock_crtc(struct drm_crtc *crtc);<br>
 void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);<br>
 struct drm_modeset_acquire_ctx *<br>
-drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc);<br>
+drm_modeset_legacy_acquire_ctx(struct drm_crtc *crtc,<br>
+                              struct drm_device *dev);<br>
<br>
 int drm_modeset_lock_all_crtcs(struct drm_device *dev,<br>
                struct drm_modeset_acquire_ctx *ctx);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.1<br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">  Jasper<br></div>
</div>