From patchwork Mon May 14 15:59:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 913066 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40l5B668tGz9rxs for ; Tue, 15 May 2018 02:04:46 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n7ZSHuqQ"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40l5B647pdzF347 for ; Tue, 15 May 2018 02:04:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n7ZSHuqQ"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n7ZSHuqQ"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40l54z3WCwzF3Dy for ; Tue, 15 May 2018 02:00:19 +1000 (AEST) Received: by mail-pf0-x242.google.com with SMTP id w129-v6so6236384pfd.3 for ; Mon, 14 May 2018 09:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GKltKDryHPk2eNSEXoAX7o9vileBXd27A1VlnSzbZjs=; b=n7ZSHuqQ7cpNh/pMyqjsC+IGgfUX5JjKOylbG5aN/PnbaxTkic/j8r9wkyzyUf8DiI PN1Lqc9ZxPFkJNo51RzKZs1ensr6JcK9y9ty0mXtt+HBM2O2+e5mB7qvOeGLNfGVq0AU U1VGQ7qYTztKNiBCd+PnpkYYWmqc77WpEhZZE3Hj9IZ27VcmkrqZo50ZAsQ5rPdIiYSw HfUT6ZwY5RcIplG+1/XW/lJfaA3G/mc0FLCwcdcG39NdvKjFSltgKXt4t4/vOPn9osRs Qux3t7DQXhRfLCghjwYADzKioaAWuiS7MsKkRHT64bYfIVFbiiqId5f8SGXl0EATBhqf 7LPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GKltKDryHPk2eNSEXoAX7o9vileBXd27A1VlnSzbZjs=; b=LWQItNlprXcKqxBzpeiA5BZpqC0poWuXnR3bdzDDIPJW3WNNm/l8RLhDtyHso8bJpt O3MpbfsmXhhkN6DmXiPwSzCmri46DUJ0JqyUjsWFNjoDsjKM6VYYGJoCOduumcMvuKZ8 +Gf5sBDg5I/crzpgLtapo6XktXE5F0VnaCkwTGF36diwgOUfjmS9KtfwUkhdd/XUHBuj oyZpFPFcvaTyOHYgaXFTvhG2xHX6khFK7FcrVE1+fk8GCU2cwsIQqimOCeOCzWi9DYVP c0LjFu3x/HSqh9OpYl+7ZAZoVK5s182wVkMXgvr/mEOzoycrpfZC5TDIOZVDM+6qd2FW w3/Q== X-Gm-Message-State: ALKqPwf05zAZf9DqKouNbIbBYUXFzETPaIdndIRatdx3ggiYqwzknhP2 dIbkunhU+8H0HbVghNrQjCsysA== X-Google-Smtp-Source: AB8JxZpoKbjecgFyRqkLaAKtCZr0fAgcJYUTxyOzSpX7ZoiU6n8+EUq57DTFdLwseLjrxXsk5dAabw== X-Received: by 2002:a65:484c:: with SMTP id i12-v6mr8511922pgs.162.1526313617379; Mon, 14 May 2018 09:00:17 -0700 (PDT) Received: from roar.au.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id r90-v6sm24138529pfg.122.2018.05.14.09.00.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 09:00:16 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/2] powerpc/powernv: Fix opal_event_shutdown() called with interrupts disabled Date: Tue, 15 May 2018 01:59:46 +1000 Message-Id: <20180514155947.22753-2-npiggin@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514155947.22753-1-npiggin@gmail.com> References: <20180514155947.22753-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" A kernel crash in process context that calls emergency_restart from panic will end up calling opal_event_shutdown with interrupts disabled but not in interrupt. This causes a sleeping function to be called which gives the following warning with sysrq+c: Rebooting in 10 seconds.. BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238 in_atomic(): 0, irqs_disabled(): 1, pid: 7669, name: bash CPU: 20 PID: 7669 Comm: bash Tainted: G D W 4.17.0-rc5+ #3 Call Trace: dump_stack+0xb0/0xf4 (unreliable) ___might_sleep+0x174/0x1a0 mutex_lock+0x38/0xb0 __free_irq+0x68/0x460 free_irq+0x70/0xc0 opal_event_shutdown+0xb4/0xf0 opal_shutdown+0x24/0xa0 pnv_shutdown+0x28/0x40 machine_shutdown+0x44/0x60 machine_restart+0x28/0x80 emergency_restart+0x30/0x50 panic+0x2a0/0x328 oops_end+0x1ec/0x1f0 bad_page_fault+0xe8/0x154 handle_page_fault+0x34/0x38 --- interrupt: 300 at sysrq_handle_crash+0x44/0x60 LR = __handle_sysrq+0xfc/0x260 flag_spec.62335+0x12b844/0x1e8db4 (unreliable) __handle_sysrq+0xfc/0x260 write_sysrq_trigger+0xa8/0xb0 proc_reg_write+0xac/0x110 __vfs_write+0x6c/0x240 vfs_write+0xd0/0x240 ksys_write+0x6c/0x110 Fixes: 9f0fd0499d30 ("powerpc/powernv: Add a virtual irqchip for opal events") Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/opal-irqchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/opal-irqchip.c b/arch/powerpc/platforms/powernv/opal-irqchip.c index 9d1b8c0aaf93..05ffe05f0fdc 100644 --- a/arch/powerpc/platforms/powernv/opal-irqchip.c +++ b/arch/powerpc/platforms/powernv/opal-irqchip.c @@ -177,7 +177,7 @@ void opal_event_shutdown(void) if (!opal_irqs[i]) continue; - if (in_interrupt()) + if (in_interrupt() || irqs_disabled()) disable_irq_nosync(opal_irqs[i]); else free_irq(opal_irqs[i], NULL);