From patchwork Tue Mar 25 12:25:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3887431 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 319929F2E8 for ; Tue, 25 Mar 2014 12:25:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65DB3202B4 for ; Tue, 25 Mar 2014 12:25:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8736020270 for ; Tue, 25 Mar 2014 12:25:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F12F36E1C7; Tue, 25 Mar 2014 05:25:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f49.google.com (mail-bk0-f49.google.com [209.85.214.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 598666E1C7 for ; Tue, 25 Mar 2014 05:25:31 -0700 (PDT) Received: by mail-bk0-f49.google.com with SMTP id my13so161756bkb.36 for ; Tue, 25 Mar 2014 05:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ug+kT5YQR26UlKHcAmZkj49DMX2GQd0tMf3DA4mP8TA=; b=YsaX2wgS+unQlJqvXGuokEo3KBKdIWt2EgxA17/8mkeWzi+nbXRIZwcWBYnk5k4RIx T9VwaW8xslOnRQb6elF77BIp6qEyiXKoHkjY4lqsc9ndWkiSaL6ULfboLU4AbpVuKKAz DQhNM0RoVAbAlyhsY49cjAyMxAYoUq5ymZOVSSrBS7PLAaXWraRtmQatm99SFdylbHyu L6PgGH70OmOHbtNhZknNNBbMPzMPrMuH0bKuJXf1ZIQlQVcgMUdQVh8xI6GkH6flrDVf GBqJljUN2KWiERg+6XBNGX6BneESfHyQ2TmRE9WE9HcLOCEGUMeK0/xH2ha6OJ43kiPt qNuQ== X-Received: by 10.204.165.207 with SMTP id j15mr1065636bky.45.1395750330271; Tue, 25 Mar 2014 05:25:30 -0700 (PDT) Received: from localhost (port-21158.pppoe.wtnet.de. [46.59.144.79]) by mx.google.com with ESMTPSA id ew15sm11204925bkb.1.2014.03.25.05.25.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 05:25:29 -0700 (PDT) From: Thierry Reding To: David Airlie Subject: [PATCH] drm: Try to acquire modeset lock on panic or sysrq Date: Tue, 25 Mar 2014 13:25:15 +0100 Message-Id: <1395750315-22269-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Thierry Reding Commit 62ff94a54921 "drm/crtc-helper: remove LOCKING from kerneldoc" causes drm_helper_crtc_in_use() and drm_helper_encoder_in_use() to complain loudly during a kernel panic or sysrq processing. This is caused by nobody acquiring the modeset lock in these code paths. This patch fixes this by trying to acquire the modeset lock for each FB helper that's forced to kernel mode. If the lock can't be acquired, it's likely that somebody else is performing a modeset. However, doing another modeset concurrently might make things even worse, so the safe option is to simply bail out in that case. Signed-off-by: Thierry Reding Reviewed-by: Daniel Vetter Reviewed-by: David Herrmann --- drivers/gpu/drm/drm_fb_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 9580393628a0..afce7cbd5149 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -325,12 +325,21 @@ static bool drm_fb_helper_force_kernel_mode(void) return false; list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) { - if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF) + struct drm_device *dev = helper->dev; + + if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) + continue; + + if (!mutex_trylock(&dev->mode_config.mutex)) { + error = true; continue; + } ret = drm_fb_helper_restore_fbdev_mode(helper); if (ret) error = true; + + mutex_unlock(&dev->mode_config.mutex); } return error; }