From patchwork Fri Dec 14 11:01:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 1878171 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 03D0040079 for ; Fri, 14 Dec 2012 11:01:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4017E68EF for ; Fri, 14 Dec 2012 03:01:19 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D741E5E55 for ; Fri, 14 Dec 2012 03:01:06 -0800 (PST) Received: by mail-la0-f49.google.com with SMTP id r15so2640376lag.36 for ; Fri, 14 Dec 2012 03:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:from:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=so8IAqA4/ZbJHCXscfw5AuILl9s5LEPXjLS5FWnpgAA=; b=oYxoZQ4kZ1UHLwO+Od1xmold1EF68ayT1lAYTMQoP7p5+jDkzWtC7d8tYHojYrzD+W ZR+8EUBkIzdKXkiBXUHrWrvPJXYY+l8PqU217OBmShcKdCA2bsirRVQdJ8CL2N8NJ+jc Kp0YIRc1EahRDQOAUbxGjQ2Y8WAo0IdoZpQhoFcA8q7YxkOlPl2DOv1eNtJJ5DtKRoXs 4WnbagbjKt9haXYRl5ibVZKcIknbDmzOLapt3OkwC1W3dIX8jjdHfSwYcqUPTt8OMUhN AMUG5fmDG8Dql2iZxdzyQS+5BFxe9qupLHrlTWzL1QxYGHF+n2Y4w8cetftcgz3J9Kar Zi0Q== Received: by 10.112.16.207 with SMTP id i15mr2221398lbd.114.1355482865437; Fri, 14 Dec 2012 03:01:05 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id lr20sm1682135lab.17.2012.12.14.03.01.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 03:01:04 -0800 (PST) Subject: [PATCH] drm/fb: avoid sleeping in unblank_screen() if oops in progress To: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Date: Fri, 14 Dec 2012 15:01:00 +0400 Message-ID: <20121214110100.7836.65250.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: Andrew Morton , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org unblank_screen() can be called from interrupt context during oops. thus all ->fb_blank handlers should avoid sleeping in this situation. callstack: panic() bust_spinlocks(1) unblank_screen() vc->vc_sw->con_blank() fbcon_blank() fb_blank() info->fbops->fb_blank() drm_fb_helper_blank() drm_fb_helper_dpms() mutex_lock(&dev->mode_config.mutex) Signed-off-by: Konstantin Khlebnikov Cc: Andrew Morton Cc: David Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_fb_helper.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 954d175..2c9f49f 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -326,7 +326,7 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { }; #endif -static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) +static int drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) { struct drm_fb_helper *fb_helper = info->par; struct drm_device *dev = fb_helper->dev; @@ -334,10 +334,15 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) struct drm_connector *connector; int i, j; + if (oops_in_progress) { + if (!mutex_trylock(&dev->mode_config.mutex)) + return -EBUSY; + } else + mutex_lock(&dev->mode_config.mutex); + /* * For each CRTC in this fb, turn the connectors on/off. */ - mutex_lock(&dev->mode_config.mutex); for (i = 0; i < fb_helper->crtc_count; i++) { crtc = fb_helper->crtc_info[i].mode_set.crtc; @@ -353,6 +358,7 @@ static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode) } } mutex_unlock(&dev->mode_config.mutex); + return 0; } int drm_fb_helper_blank(int blank, struct fb_info *info) @@ -360,24 +366,19 @@ int drm_fb_helper_blank(int blank, struct fb_info *info) switch (blank) { /* Display: On; HSync: On, VSync: On */ case FB_BLANK_UNBLANK: - drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON); - break; + return drm_fb_helper_dpms(info, DRM_MODE_DPMS_ON); /* Display: Off; HSync: On, VSync: On */ case FB_BLANK_NORMAL: - drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); - break; + return drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); /* Display: Off; HSync: Off, VSync: On */ case FB_BLANK_HSYNC_SUSPEND: - drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); - break; + return drm_fb_helper_dpms(info, DRM_MODE_DPMS_STANDBY); /* Display: Off; HSync: On, VSync: Off */ case FB_BLANK_VSYNC_SUSPEND: - drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND); - break; + return drm_fb_helper_dpms(info, DRM_MODE_DPMS_SUSPEND); /* Display: Off; HSync: Off, VSync: Off */ case FB_BLANK_POWERDOWN: - drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF); - break; + return drm_fb_helper_dpms(info, DRM_MODE_DPMS_OFF); } return 0; }