Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2043597imm; Thu, 24 May 2018 05:01:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoZcrtzdY52URcEqzmimkghbe7+CsWCDmC9GCmjliTdvKrw96OfquqpHk07p/b1Npu5/xx8 X-Received: by 2002:a63:6285:: with SMTP id w127-v6mr5719025pgb.164.1527163305276; Thu, 24 May 2018 05:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163305; cv=none; d=google.com; s=arc-20160816; b=TrDcceBMAk54zPBjDRCKjLIjgmKmfJ4tj4Sb8mQvmhAO6DuXYfIo2WHKxh3TKxl8N1 DSOtsaOp/Dtgro2ise8lk4t7rFPG/Veqrvokn3k395q3FwMSex5mdVfX5pdo/Y/HShji O0jsrkpMUtEFLcIfCW6BhjFcis50zgdd5SwAOoJ/zsq79gZ16rPBX38UREnH0yTStMw9 gk4BJIPvgXXKfoc3QlKdBaboAa5FoLv/1MKUcrGdT7HtVEoC1iINPMstEZlr8vIeRHOK aPqiOn8kD33HZ2sWcuGt/q4IYfedjrAfUxYiROrHOxDH6I7BWt1d2jtUT1xGRFbnGoGY W20w== 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=Cs9pt71wZX4ooE/LmbHZ0up6ISc12NUqBfcQYwi8F4o=; b=g+rtG+7rOzuYdqtLtnxaF/18bIDztGGyF8LxA3eYiKUbrJlroi6Wmbj0UpVMGIjg6F 7CJzKfiZ9ViEb32DMt50i4upzx9yBLzapT9UTScn4y62hglQSdGQFWunwCjerhBHk9x2 HOWPHyzBHDj8sCe+GUF/0RvSQbccRbbEyD8prLRv99Rwk4/+mxTAwr8VRAacO92xqCus qDCvZOeLmPegWJf/5bcxPn+uhEtpAm1DyQCrG4x5LxeSo077C68U4U49WYrpLiTW0/38 FucLS/5egCTWBPg4b9tygiaa9YtWeB1i7617+CTy7brJNC4HX5SOLWDKGoj13FFcWUM2 5HxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eEnlN6+b; 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 v24-v6si21753905pfj.292.2018.05.24.05.01.24; Thu, 24 May 2018 05:01:45 -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=eEnlN6+b; 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 S969560AbeEXMAe (ORCPT + 99 others); Thu, 24 May 2018 08:00:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:56226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966717AbeEXJpC (ORCPT ); Thu, 24 May 2018 05:45:02 -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 4BB29208CD; Thu, 24 May 2018 09:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155101; bh=1RrxgN3O/CT/Bn+1aeT3RB4nrVbuVL5DFg2o/HZnzao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEnlN6+bGg2eopzoxGQDETg+pjabzLy/ihGgruH4+iIFrrkZWycnMfD+FH5a941cC 5U9rO1X0LnlP6M7BAkNdES42fWe86b5vCiVEGhE/AgFwtdiQg7rQq43038twQGpZX+ uO+nyFg6bKTbxRSUVl+wjzX9tKqhR8sJyrzQnXD0= 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.4 56/92] powerpc/powernv: Fix NVRAM sleep in invalid context when crashing Date: Thu, 24 May 2018 11:38:33 +0200 Message-Id: <20180524093204.697899221@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-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); } }