From patchwork Tue Aug 21 22:34:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1358221 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A8562DFB34 for ; Tue, 21 Aug 2012 22:35:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317Ab2HUWfK (ORCPT ); Tue, 21 Aug 2012 18:35:10 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:60519 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754737Ab2HUWes (ORCPT ); Tue, 21 Aug 2012 18:34:48 -0400 Received: by wibhr14 with SMTP id hr14so266316wib.1 for ; Tue, 21 Aug 2012 15:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=y+qPBUHZaevYV/+dZBug+Xul5MXq/Ed56W5Km9WrN0o=; b=QhfinG3KecyHjQNo7mcs9eQ/dmE10U47FelewZheTmClBJ3MzVgcR0WPDiY8xaU0sp tENkVMedGCQEo77PyKJKj4XgLewwKz1hl/UF1SuR5E2wi6eyK2/bmm/b/rm8tRsnHbzz aWccrK+D0axLZ8FilCjp4ncooorfipb99dKx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=y+qPBUHZaevYV/+dZBug+Xul5MXq/Ed56W5Km9WrN0o=; b=OGnAxpk3ckS/KVZBW8n5FSgVhWGRcZnUNyOAELbQzDVs4BEp7MK+mpn0JdDM9Qz5on oNAo4oJKqz0abxRAgy8Z/4izyb/zCVx+pKPFCjN0GDng4CwWrEKX4G0ZKO7oRAl7UjMd CVEJMHzdxv2ZRwSaPgYEDqH5bZdj8FWkQCrOJVpvEtEUx+UGt1hePgCtdO6j4yQOv+Ri aQkkullMkqzUZ6rHju8qDIeHg2im0lJX3BCrJRhVtMbzVfxbFFV6z/Adg8ErVUiDujk1 bRZRcIPbtfqFVQ0SHiCCVH6HRVVkYDAm2tGJ5F972NO4X0+c4fps80y4hJhIQC1gxM4D 8MXw== Received: by 10.180.81.133 with SMTP id a5mr394018wiy.17.1345588487540; Tue, 21 Aug 2012 15:34:47 -0700 (PDT) Received: from aaron.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id k20sm36045620wiv.11.2012.08.21.15.34.45 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Aug 2012 15:34:46 -0700 (PDT) From: Daniel Vetter To: LKML Cc: DRI Development , linux-fbdev@vger.kernel.org, Alan Cox , Daniel Vetter , Dave Airlie , Thomas Gleixner Subject: [PATCH 1/2] console: use might_sleep in console_lock Date: Wed, 22 Aug 2012 00:34:31 +0200 Message-Id: <1345588472-4055-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1345588472-4055-1-git-send-email-daniel.vetter@ffwll.ch> References: <1345588472-4055-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQn8iFgG8/NvUm+fEn/JuIMuDYClT4va/JjrfotWD07a4V7FXkmrmj5RG9Crm8RTDn3D5jkE Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Instead of BUG_ON(in_interrupt()), since that doesn't check for all the newfangled stuff like preempt. Note that this is valid since the console_sem is essentially used like a real mutex with only two twists: - we allow trylock from hardirq context - across suspend/resume we lock the logical console_lock, but drop the semaphore protecting the locking state. Now that doesn't guarantee that no one is playing tricks in single-thread atomic contexts at suspend/resume/boot time, but - I couldn't find anything suspicious with some grepping, - might_sleep shouldn't die, - and I think the upside of catching more potential issues is worth the risk of getting a might_sleep backtrace that would have been save (and then dealing with that fallout). Cc: Dave Airlie Cc: Thomas Gleixner Signed-off-by: Daniel Vetter --- kernel/printk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/printk.c b/kernel/printk.c index 66a2ea3..ed9af6a 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -1909,7 +1909,8 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self, */ void console_lock(void) { - BUG_ON(in_interrupt()); + might_sleep(); + down(&console_sem); if (console_suspended) return;