Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27841372rwd; Tue, 4 Jul 2023 08:34:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlHt7VQMuy3olZcw6gJqRkr4SSsKNQ2qs+rJqoG5LuIMSMNPB3SP5dSyCjoIuVz2FnJX/X/q X-Received: by 2002:a05:6359:2e94:b0:134:c650:cc0a with SMTP id rp20-20020a0563592e9400b00134c650cc0amr7865972rwb.15.1688484843049; Tue, 04 Jul 2023 08:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688484843; cv=none; d=google.com; s=arc-20160816; b=vH1vj9nJDpdu0/+giJHwmSyWCHb3XdZsuOESe7cVG6KZrH7fm9EJ7lYCjUIxy7Zk5G Q856A63ZI5rede8pW105xsXVitWnuZIm42wVSvRsHzROBcDcuUNmOe6RtKsdeUJpJwU6 xWKZ3MVFVHfn6xykdc45kMojnBgAaB6b29DowhQZiQC0JCFGf8acGHvo3Nxrv8xUewPq 7m9O9WMNYSGdklypmnHa57qQBZiYx3akDht1ciK5Frsv3/UU27bso4iTVrTrQ0QrR7Yt geoGWiagGoRQ1zbcGB8BwyAwPwFMsZb26i/UbEfQHgPEw4mQkP5jwryrMcJenSja3e4x Yx0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=btwb9fDGkDZ7jnV3QokEO1LHIFVROBuBltSAKFFlyfU=; fh=WDeTRLgWlMibEvAwYVhEMnXZGZusDGDqhsVNfkO91RM=; b=VlAqgA8gACshVyCl6PRzSJPlCmwCsvSDaTEbGXOt7E3Gobpl6Kaq6uXc/XOJiHieYn kFbhns57DmaA6i734bn/pWdeA/JgycVlftumVbXgO6mrKsCw8zml1FWXL/fdbVtCvIHw DlXOcmIz4HqDfbKka4MDb2U15Z6KGPT87zWM6Mmq3e6VFOid6LoOji3ojEwNyU9Wed7B O5DoIG84C/afqeUwM3LA2fXhT6IBFSF/GSeEF5ldSPXySizRBl/x7sAIVcKdt/e3c2km /ouws2Ig8qMsJ/lZ7l3PsrbUpkc7hkA8JeDatJ7yDX5aZg5tmVDIfA4GScHf6xn5R4eS 8qIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="m/bJrBdi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r20-20020a6560d4000000b0055b0e39eed2si14363826pgv.107.2023.07.04.08.33.48; Tue, 04 Jul 2023 08:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="m/bJrBdi"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbjGDPXj (ORCPT + 99 others); Tue, 4 Jul 2023 11:23:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjGDPXi (ORCPT ); Tue, 4 Jul 2023 11:23:38 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB3B10E2 for ; Tue, 4 Jul 2023 08:23:26 -0700 (PDT) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1688484205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=btwb9fDGkDZ7jnV3QokEO1LHIFVROBuBltSAKFFlyfU=; b=m/bJrBdiQ4r3dm4fK/+8HHJvPBn/jW8CbISsWJhd6smsSEnAyu39fJ4EvX/BJSWTX773ml twRyOvqQBaJbbZyEety5YOKrkg3b4+ZfX1LjVEoBwOHQyHT+6DT+WE7fEdEk4SZfytJN3Y Z5k/mkUthbn2bEyUw3McmYKjaTiUTA9lvc5/Rj9PbYblTk5tBDwUbpbUTqf7+jC068UPvQ qoy1d6RlDRf1obobZNfiIEgJAmtEj2RYloXeuGtU2yD0EoYWzZFm7FAUbhjLuESlVQwkQA zT2bSFYjA8IRwCmXMkQwB1Ds8mL2TngPNtoTFF+Ar4plMPY2H+MoG64a3urs+Q== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 5BDFC240010; Tue, 4 Jul 2023 15:23:24 +0000 (UTC) Date: Tue, 4 Jul 2023 17:23:23 +0200 From: Miquel Raynal To: William Zhang Cc: Broadcom Kernel List , Linux MTD List , f.fainelli@gmail.com, rafal@milecki.pl, kursad.oney@broadcom.com, joel.peshkin@broadcom.com, computersforpeace@gmail.com, anand.gore@broadcom.com, dregan@mail.com, kamal.dasu@broadcom.com, tomer.yacoby@broadcom.com, dan.beygelman@broadcom.com, Florian Fainelli , linux-kernel@vger.kernel.org, Vignesh Raghavendra , Richard Weinberger , Kamal Dasu Subject: Re: [PATCH v3 3/5] mtd: rawnand: brcmnand: Fix crash during the panic_write Message-ID: <20230704172323.2cfe5a89@xps-13> In-Reply-To: <20230627193738.19596-4-william.zhang@broadcom.com> References: <20230627193738.19596-1-william.zhang@broadcom.com> <20230627193738.19596-4-william.zhang@broadcom.com> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi William, william.zhang@broadcom.com wrote on Tue, 27 Jun 2023 12:37:36 -0700: > During the panic write path to execute another nand command, if "When executing a NAND command within the panic write path, wait for any pending command instead of calling BUG_ON to avoid crashing while (already) crashing." > there is a pending command, we should wait for the command instead of > calling BUG_ON so we don't crash while crashing. >=20 > Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom S= TB NAND controller") > Signed-off-by: William Zhang > Reviewed-by: Florian Fainelli > Reviewed-by: Kursad Oney > Reviewed-by: Kamal Dasu > --- >=20 > Changes in v3: None > Changes in v2: None >=20 > drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/= raw/brcmnand/brcmnand.c > index 37c2c7cfa00e..ea03104692bf 100644 > --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c > +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c > @@ -1608,7 +1608,17 @@ static void brcmnand_send_cmd(struct brcmnand_host= *host, int cmd) > =20 > dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); > =20 > - BUG_ON(ctrl->cmd_pending !=3D 0); > + /* > + * If we came here through _panic_write and there is a pending > + * command, try to wait for it. If it times out, rather than > + * hitting BUG_ON, just return so we don't crash while crashing. > + */ > + if (oops_in_progress) { > + if (ctrl->cmd_pending && > + bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0)) > + return; > + } else > + BUG_ON(ctrl->cmd_pending !=3D 0); > ctrl->cmd_pending =3D cmd; > =20 > ret =3D bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); LGTM otherwise. Thanks, Miqu=C3=A8l