Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27854734rwd; Tue, 4 Jul 2023 08:46:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VYUuGgpMp4S6VOmGdcbfjcX4Znv4B7ml69w0TfuKeJzE49CmlV9P31GF5CjbLV3lhPXKw X-Received: by 2002:a05:6808:2202:b0:3a1:cb5c:44fd with SMTP id bd2-20020a056808220200b003a1cb5c44fdmr17870516oib.57.1688485598871; Tue, 04 Jul 2023 08:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688485598; cv=none; d=google.com; s=arc-20160816; b=BN1hQc0kZNEzj67PM5I/hOptl9e6lEHZLrOikxOGyBKTiuAMkFXLqmvGq34trBIAR4 NGNCo7lw7ryrVQKtIhjtbOVDBplF09meQDGDCjC9e/HMACUEB1jLwQCy9oNWx6bYYq2M x2qiMmB/Na7Rxz5SDfzExD/qv2NGUDa7U89FULcjF1QLFUcXBwtuY+6YMiZQQHX4f/py 1WMT9tGEoW8vLjsVSyQ814Ge987jJAawgDimANJujsDJ4BtE9V51IAeFSbAGOyeJokY+ lwzuxZlhYnA6n3VvE8wkPpGbhGfaeL1wu6/lbxygxFsWVinxQGIpud67JTYBEyFtsKa7 z7hg== 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=O5qqU0Kxcet4KnwRLYAfKVI4AV4hzg5i/RVgRnzmxGo=; fh=WDeTRLgWlMibEvAwYVhEMnXZGZusDGDqhsVNfkO91RM=; b=UfMUMNNhHBRcy2AkmGc2F9P5Q2thvJZaD5H5A/edBaDCRu5wDw95GHtzpNdQaoeVSk ioANkDJfqYhBgWqps+B6jEOLdtJ+HL+TMSKm5uv8L5yEuUgQGFVrNvOUs6aFIa9ivj47 sU1lJoyWTCTV0ihu09BWp6zeBcqGh7MsprE/1BvLJ7Kl7Y5ap4QzNI7H2UNdoBgW14Ng RjUMWIGVQsKpzoNt/McL6t84f8LxebY/xGhf9000NqaLKAYPhFCVD8i2DYQNdWSB5PFI iigMXwzHwuxtbieq8HiVDj/z9kgSY7RcrfSpGh0wkjlQ7PZ8wDryadCr9uCiy6oWaw93 NMag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DTuSkRut; 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 s23-20020a17090aad9700b00263aff4ccf0si6402381pjq.3.2023.07.04.08.46.25; Tue, 04 Jul 2023 08:46:38 -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=DTuSkRut; 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 S231162AbjGDP0V (ORCPT + 99 others); Tue, 4 Jul 2023 11:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231679AbjGDP0K (ORCPT ); Tue, 4 Jul 2023 11:26:10 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F8FCBD for ; Tue, 4 Jul 2023 08:26:08 -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=1688484367; 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=O5qqU0Kxcet4KnwRLYAfKVI4AV4hzg5i/RVgRnzmxGo=; b=DTuSkRut6d2zmR+QLC356DceKemf8eFqnjdqrLQjyKbT5Y1e+DeqXx0oTqytEN6A8HYcDJ bK6nwL9BwtfIK4bayKvc6tFGZJmHH4j/vM4WY9Nb01SPL9SeZ1fqb9bGY8kBwPmnxic1Ij wJCItyIbgdBfHhSMxEti1k8WMY58DpmkUR+o2hZwc0weZx7ZPVoAZ6IEM73xRn9Mh2UMPc LEhyLh10p5bojoP9RFZsG5M3GFB2Txq1kLQIp62UowGfjnipDGJ6ZVN6f6pG2iMuHgk15a rxphBspFw/6E76rN3KxNWYQPpmv9Ry8N2xbkI8APSjdy5bqd5Ww1O8l2s1cNMw== 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 E673B1BF206; Tue, 4 Jul 2023 15:26:05 +0000 (UTC) Date: Tue, 4 Jul 2023 17:26:04 +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: <20230704172604.6924d2af@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_H4,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 > 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") The Fixes tag looks wrong. > 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); Thanks, Miqu=C3=A8l