From patchwork Tue May 3 14:03:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cpaul@redhat.com X-Patchwork-Id: 9004001 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A87D9F1D3 for ; Tue, 3 May 2016 14:05:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE5E12026F for ; Tue, 3 May 2016 14:05:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 827A720123 for ; Tue, 3 May 2016 14:05:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 016586E861; Tue, 3 May 2016 14:05:03 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3D25A6E862; Tue, 3 May 2016 14:05:01 +0000 (UTC) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7079D486D3; Tue, 3 May 2016 14:05:00 +0000 (UTC) Received: from ecstaticemu.bos.redhat.com (dhcp-25-142.bos.redhat.com [10.18.25.142]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u43E4xHf003270; Tue, 3 May 2016 10:04:59 -0400 From: Lyude To: intel-gfx@lists.freedesktop.org Date: Tue, 3 May 2016 10:03:40 -0400 Message-Id: <1462284220-14930-1-git-send-email-cpaul@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Cc: David Airlie , stable@vger.kernel.org, "open list:INTEL DRM DRIVERS excluding Poulsbo, Moorestow..., linux-kernel@vger.kernel.org open list" , Daniel Vetter Subject: [Intel-gfx] [PATCH] drm/i915: Discard previous atomic state on resume if connectors change X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If an MST device is disconnected while the machine is suspended, the number of connectors will change as well after we call intel_dp_mst_resume(). This means that any previous atomic state we had before suspending is no longer valid, since it'll still be pointing to missing connectors. We need to check for this before committing the state, otherwise we'll kernel panic on resume whenever if any MST display was disconnected before we started resuming: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [] drm_atomic_helper_check_modeset+0x29f/0xb40 [drm_kms_helper] Call Trace: [] intel_atomic_check+0x34/0x1180 [i915] [] ? mark_held_locks+0x6f/0xa0 [] ? trace_hardirqs_on_caller+0x129/0x1b0 [] drm_atomic_check_only+0x192/0x620 [drm] [] ? pci_pm_thaw+0x21/0x90 [] drm_atomic_commit+0x17/0x60 [drm] [] intel_display_resume+0xbd/0x160 [i915] [] ? pci_pm_thaw+0x90/0x90 [] i915_drm_resume+0xd8/0x160 [i915] [] i915_pm_resume+0x25/0x30 [i915] [] pci_pm_resume+0x64/0xa0 [] dpm_run_callback+0x90/0x190 [] device_resume+0xd5/0x1f0 [] async_resume+0x1d/0x50 [] async_run_entry_fn+0x48/0x150 [] process_one_work+0x1e9/0x5c0 [] ? process_one_work+0x166/0x5c0 [] worker_thread+0x48/0x4e0 [] ? process_one_work+0x5c0/0x5c0 [] kthread+0xe4/0x100 [] ret_from_fork+0x22/0x50 [] ? kthread_create_on_node+0x200/0x200 Cc: stable@vger.kernel.org Signed-off-by: Lyude --- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 6e0d828..252c06c 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -15945,6 +15945,17 @@ void intel_display_resume(struct drm_device *dev) dev_priv->modeset_restore_state = NULL; /* + * With MST, the number of connectors can change between suspend and + * resume, which means that the state we want to restore might now be + * impossible to use since it'll be pointing to non-existant + * connectors. + */ + if (state->num_connector != dev->mode_config.num_connector) { + drm_atomic_state_free(state); + state = NULL; + } + + /* * This is a cludge because with real atomic modeset mode_config.mutex * won't be taken. Unfortunately some probed state like * audio_codec_enable is still protected by mode_config.mutex, so lock