From bbf470202d697b7d57cc3febad578ec77fd7bded Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Mon, 13 Jul 2015 08:22:22 +0200 Subject: drm/i915: fix oops in primary_check_plane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sun, Jul 12, 2015 at 09:52:51AM -0700, Linus Torvalds wrote: > On Sun, Jul 12, 2015 at 1:03 AM, Jörg Otte wrote: > > BUG: unable to handle kernel NULL pointer dereference at 0000000000000009 > > IP: [] 0xffffffffbd3447bb > > Ugh. Please enable KALLSYMS to get sane symbols. > > But yes, "crtc_state->base.active" is at offset 9 from "crtc_state", > so it's pretty clearly just that change frm > > - if (intel_crtc->active) { > + if (crtc_state->base.active) { > > and "crtc_state" is NULL. > > And the code very much knows that crtc_state can be NULL, since it's > initialized with > > crtc_state = state->base.state ? > intel_atomic_get_crtc_state(state->base.state, > intel_crtc) : NULL; > > Tssk. Daniel? Should I just revert that commit dec4f799d0a4 > ("drm/i915: Use crtc_state->active in primary check_plane func") for > now, or is there a better fix? Like just checking crtc_state for NULL? Indeed embarrassing. I've missed that we still have 1 caller left that's using the transitional helpers, and those don't fill out plane_state->state backpointers to the global atomic update since there is no global atomic update for transitional helpers. Below diff should fix this - we need to preferentially check crts_state->active and if that's not set intel_crtc->active should yield the right result for the one remaining caller (it's in the crtc_disable paths). This fixes a regression introduced in commit dec4f799d0a4c9edae20512fa60b0a36f3299ca2 Author: Daniel Vetter Date: Tue Jul 7 11:15:47 2015 +0200 drm/i915: Use crtc_state->active in primary check_plane func which was quickly reverted in commit 01e2d0627a9a6edb24c37db45db5ecb31e9de808 Author: Linus Torvalds Date: Sun Jul 12 15:00:20 2015 -0700 Revert "drm/i915: Use crtc_state->active in primary check_plane func" Cc: Linus Torvalds Cc: Jörg Otte Reported-and-tested-by: Jörg Otte Reviewed-by: Maarten Lankhorst Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/i915/intel_display.c') diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 647b1404c441..85ac6d85dc39 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -13276,7 +13276,7 @@ intel_check_primary_plane(struct drm_plane *plane, if (ret) return ret; - if (intel_crtc->active) { + if (crtc_state ? crtc_state->base.active : intel_crtc->active) { struct intel_plane_state *old_state = to_intel_plane_state(plane->state); -- cgit v1.2.3 From ccfb8b2ed4d4e12c3c35de3db5fbbbaa11277736 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 14 Jul 2015 13:00:39 +0200 Subject: drm/i915: Do not call intel_crtc_disable if the crtc is already disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When resuming with dpms off, the following warn can happen: [ 118.334082] ------------[ cut here ]------------ [ 118.334105] WARNING: CPU: 2 PID: 2274 at drivers/gpu/drm/i915/intel_display.c:6319 __intel_set_mode+0xae5/0xb90 [i915]() [ 118.334106] WARN_ON(!crtc->state->enable) [ 118.334137] Modules linked in: i915 [ 118.334139] CPU: 2 PID: 2274 Comm: kworker/u16:117 Not tainted 4.2.0-rc2-fixes+ #4148 [ 118.334140] Hardware name: LENOVO 2349AV8/2349AV8, BIOS G1ETA5WW (2.65 ) 04/15/2014 [ 118.334144] Workqueue: events_unbound async_run_entry_fn [ 118.334147] ffffffffc017eef0 ffff8800ada93998 ffffffff817aa62a 0000000080000001 [ 118.334149] ffff8800ada939e8 ffff8800ada939d8 ffffffff810807e1 ffff8800ada939c8 [ 118.334151] ffff8800cea3b3d8 0000000000000000 ffff8800ad86b008 ffff880117705668 [ 118.334151] Call Trace: [ 118.334155] [] dump_stack+0x4f/0x7b [ 118.334157] [] warn_slowpath_common+0x81/0xc0 [ 118.334158] [] warn_slowpath_fmt+0x41/0x50 [ 118.334173] [] __intel_set_mode+0xae5/0xb90 [i915] [ 118.334188] [] ? intel_modeset_compute_config+0x52/0xb40 [i915] [ 118.334191] [] ? drm_atomic_set_fb_for_plane+0x63/0x80 [ 118.334205] [] intel_set_mode+0x29/0x60 [i915] [ 118.334219] [] intel_crtc_restore_mode+0x13a/0x1f0 [i915] [ 118.334232] [] ? gen6_write16+0x250/0x250 [i915] [ 118.334246] [] intel_modeset_setup_hw_state+0x89c/0xcd0 [i915] [ 118.334248] [] ? pci_pm_thaw+0x90/0x90 [ 118.334255] [] i915_drm_resume+0xcb/0x160 [i915] [ 118.334262] [] i915_pm_resume+0x22/0x30 [i915] [ 118.334263] [] pci_pm_resume+0x63/0xa0 [ 118.334266] [] dpm_run_callback+0x70/0x420 [ 118.334267] [] device_resume+0x9d/0x1c0 [ 118.334269] [] ? initcall_debug_start+0x60/0x60 [ 118.334270] [] async_resume+0x1c/0x50 [ 118.334271] [] async_run_entry_fn+0x34/0xd0 [ 118.334273] [] process_one_work+0x1dd/0x7e0 [ 118.334275] [] ? process_one_work+0x14a/0x7e0 [ 118.334276] [] worker_thread+0x49/0x450 [ 118.334278] [] ? process_one_work+0x7e0/0x7e0 [ 118.334280] [] kthread+0xf9/0x110 [ 118.334282] [] ? insert_kthread_work+0x90/0x90 [ 118.334284] [] ret_from_fork+0x3f/0x70 [ 118.334286] [] ? insert_kthread_work+0x90/0x90 [ 118.334287] ---[ end trace 01f2cf6371b82d7a ]--- This warn is harmless, and can be fixed by not calling intel_crtc_disable when the crtc is already disabled. Reported-and-Tested-by: Jörg Otte Signed-off-by: Maarten Lankhorst Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/gpu/drm/i915/intel_display.c') diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 85ac6d85dc39..30e0f54ba19d 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -6315,9 +6315,6 @@ static void intel_crtc_disable(struct drm_crtc *crtc) struct drm_connector *connector; struct drm_i915_private *dev_priv = dev->dev_private; - /* crtc should still be enabled when we disable it. */ - WARN_ON(!crtc->state->enable); - intel_crtc_disable_planes(crtc); dev_priv->display.crtc_disable(crtc); dev_priv->display.off(crtc); @@ -12591,7 +12588,8 @@ static int __intel_set_mode(struct drm_crtc *modeset_crtc, continue; if (!crtc_state->enable) { - intel_crtc_disable(crtc); + if (crtc->state->enable) + intel_crtc_disable(crtc); } else if (crtc->state->enable) { intel_crtc_disable_planes(crtc); dev_priv->display.crtc_disable(crtc); -- cgit v1.2.3