Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp797712imm; Mon, 21 May 2018 14:40:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqWd/gglmDUM6sxBz+veMcumJWs1tvMaJBuhaJHEQbo90C+10JThBKLLQvxvzeWt+fl1792 X-Received: by 2002:a62:4651:: with SMTP id t78-v6mr21580877pfa.46.1526938806031; Mon, 21 May 2018 14:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938806; cv=none; d=google.com; s=arc-20160816; b=riTIx2LrJLqPT58kMb2NOqWiKw7oGNgXonCsROWk+0G/Y3Nfe/Lmc3p/UqfIWmit7Q WaZf554tFgao0fsoxGbwJiCoC7sNI0eY9BoDonhtDian3gfq6UHEUn8aU6HwxC5h5h8n RkCR1SAe53ZJPAF2EMSdvZ/+Kfr7ac1hpcRaXpWrfoXTZ7PdjEO0PTbEuYE9RgN2k2gu Af4u1cyFcbv8SY/cbqtHPBvO+EwINwKejpDZz5c6LiwvKsF5o2qrqR6GH/vduOWAroyM 3l+Dcpl6h2sIKzOVbeBREfJcpc3PETHPuFzDf2fWhsXa6AmlHDUD2KjKNJDBCDK/r0td gCmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HoKl4VRKR6zQBzNSV2hVjA7vuo6CvBZhC59zsgmNMIs=; b=AtXl4j4jhP9AuZN1IdUf6btus02r9fO+9lJTp4gAmRF4A/xgm8N1yd56twB5aMKv+G 82cF1Uo+S+pyDoTMKHxGO2v/vKJZcmmg8mwRmQk4Ms8s7RXTLUHdKnB8f1g3KPg5ivk7 H4npRwxHMbROODakYE7Rtrnm/1V8OegN7/iqCpHjYy4vOB76/QSHIbBqPDHFZoTpnRvZ 84XuY/AhVV6VjbvrDQ7Iw0s7pNDjyrm8Ymtp1pFvX8cWGcl0EQN1JrDNGQZAIx8nGdUh oAsVHRJuYHMAMAa2IftSk5jBrUo7Mn72JlT16pFNuP9eZvm7+oR4Z9LLnri52rtPU+tq KUCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ng9xRY+k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8-v6si14986356pfj.138.2018.05.21.14.39.51; Mon, 21 May 2018 14:40:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ng9xRY+k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754632AbeEUVjq (ORCPT + 99 others); Mon, 21 May 2018 17:39:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932138AbeEUVY4 (ORCPT ); Mon, 21 May 2018 17:24:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE2E220871; Mon, 21 May 2018 21:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937896; bh=POlo+4nWdwfaxppi7p5uRl9lX295N69C1zn4Wt5CaCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ng9xRY+kbMIzph0nvO718BSi0ys0QBXuFUZo4IEnu1Jmd26YJhAzEBX5IQ0JdugcN AKDFpXP+YxhlzkJedmAg81v3v4NgYwkf4DAr7kiOHwjF/A5voNFYaaybGT7zZwKFrn SlqNdnHFDiYXpNYdEP3YZqQrsWHgnAp3DCw2YQtU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Michael Ellerman Subject: [PATCH 4.16 033/110] powerpc/powernv: Fix NVRAM sleep in invalid context when crashing Date: Mon, 21 May 2018 23:11:30 +0200 Message-Id: <20180521210506.681631570@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nicholas Piggin commit c1d2a31397ec51f0370f6bd17b19b39152c263cb upstream. Similarly to opal_event_shutdown, opal_nvram_write can be called in the crash path with irqs disabled. Special case the delay to avoid sleeping in invalid context. Fixes: 3b8070335f75 ("powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops") Cc: stable@vger.kernel.org # v3.2 Signed-off-by: Nicholas Piggin Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/powernv/opal-nvram.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/arch/powerpc/platforms/powernv/opal-nvram.c +++ b/arch/powerpc/platforms/powernv/opal-nvram.c @@ -44,6 +44,10 @@ static ssize_t opal_nvram_read(char *buf return count; } +/* + * This can be called in the panic path with interrupts off, so use + * mdelay in that case. + */ static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index) { s64 rc = OPAL_BUSY; @@ -58,10 +62,16 @@ static ssize_t opal_nvram_write(char *bu while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { rc = opal_write_nvram(__pa(buf), count, off); if (rc == OPAL_BUSY_EVENT) { - msleep(OPAL_BUSY_DELAY_MS); + if (in_interrupt() || irqs_disabled()) + mdelay(OPAL_BUSY_DELAY_MS); + else + msleep(OPAL_BUSY_DELAY_MS); opal_poll_events(NULL); } else if (rc == OPAL_BUSY) { - msleep(OPAL_BUSY_DELAY_MS); + if (in_interrupt() || irqs_disabled()) + mdelay(OPAL_BUSY_DELAY_MS); + else + msleep(OPAL_BUSY_DELAY_MS); } }