Message ID | 20230627193738.19596-4-william.zhang@broadcom.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8434447vqr; Tue, 27 Jun 2023 12:50:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5stodIDURXb+94qJBGwjtqKinrkOVkdK7fTL8ksVSzUM3BZpRTHeqrPt5wuZ0j8KJZwmIw X-Received: by 2002:a17:907:970f:b0:990:27e2:7f81 with SMTP id jg15-20020a170907970f00b0099027e27f81mr7834570ejc.31.1687895449754; Tue, 27 Jun 2023 12:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687895449; cv=none; d=google.com; s=arc-20160816; b=V3XMCxMDauGcWUW7vXCCsehDqSo4/ZtvApbGFr6N5wX8sATpPGDhN14nCLAYPp/s1q MPefdRwLMhGOL0awMqb45G6cjueo7SSi08cOiLxoCo9bDL7V3H/QzXVwEvWIDUgz5czO w9FDX9CFhh4klMsJ4+rtbVwfTL9O3FHgYNQzQipTquA+0ty89fZoGMnQO5dml3xqtetK MMAN3xRadt3f4nFZRUv/ASYMYwzA94TNmdJ0W+gXvKkhs7+QWad6EJI9khxwKoSNbHDI JG0ffpUVuWvRafuV+nBgoKZgfCw380qrN6OhWjN+GwntRV10zZ5y5DQF1YiH2NSl2KaL MAOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=U6jLGJe+JGGax79XpISkVnPfy+abCUUfWZOAyTcMVmw=; fh=V5lgikJFjYeJdRk3kd9fIKVcjyByg7w8p+LYJYgJQFE=; b=t9W/g0MwHp3F+Nil5fT8CSS9q6ghZhYs9c6FqT9gR6bX+pO7hGAicmjyuh+JqtGxiB Nmbr5qSZ9JCoV0hmCHkrdt6WLZVxpJ+5mvZayucaqtDANblLPTzo1D8Bh1mLf4QFUGL9 AsJ2aCDNrGKgkhY/nXWz/pnbQ7PuO+sTgCfgju3izs9qsJqQqLHQq+gbgp4RRhZX+fsh LUAjnwXQlKwgn1xIoOtvtKxDDL0uig2LYntzz4ZCANNgJJvZhh6ETpmetYfXpb8kTHdf 2sy38oPcD1ET217TQDSSAX8GyYLHKIkIli0PX47wNqYtJQWJLK05dQBdq8N2QKEVCASk T0kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=U99bkglA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a170906590f00b0098dcabba1f7si5061062ejq.452.2023.06.27.12.50.25; Tue, 27 Jun 2023 12:50:49 -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=@broadcom.com header.s=google header.b=U99bkglA; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjF0Tie (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Tue, 27 Jun 2023 15:38:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230214AbjF0TiY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 27 Jun 2023 15:38:24 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD6DF19B5 for <linux-kernel@vger.kernel.org>; Tue, 27 Jun 2023 12:38:19 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b7ffab9454so16173675ad.3 for <linux-kernel@vger.kernel.org>; Tue, 27 Jun 2023 12:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1687894699; x=1690486699; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=U6jLGJe+JGGax79XpISkVnPfy+abCUUfWZOAyTcMVmw=; b=U99bkglAeCfTB8XBCbyv+1GpA24LQHN18Dr/1J1QVs2vNq+OalPPbftDGNGLRKnFhb wFQeGQhr6tDjGXSkdPSdMeR5jkEFB3KClqzzAevNOARbxhlhPATBSPGKQtHV5knQQiCw aJpYNbt44YRnA9BMz6hstAzsD71hEhFRPHFi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687894699; x=1690486699; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U6jLGJe+JGGax79XpISkVnPfy+abCUUfWZOAyTcMVmw=; b=SV8TZtOxh3F+ZvCSfPV8TrXMGWgqhq8N/jm9Er6g/e/XWIa6vtPesuIgz9aiEJ9nZo QOeCbNkBR30EheQMdI/dQkNyWMQH82j98z4Ssn5ztUgrBcKQdXwtR4v22Civz78aNCJ6 n5LBpvxHqMvfHWsyNJPyTVBOU48MP89ddXqMN1lIX7QcAQNUdINlMqygj0Ggl7z467bQ NUR8EmYO1tY3S+v0/f+NLolXsdML8rK9Zrm9KXm+cZ0aqE7p7bnAy5RSD7i2UVfJpgSz XVZG/Ua98jxmZC+vN2HRpnVSphAa+1jT8hIvBkWy/Qt4h9q3jlgqxLBoeYH1WOMCiLMq Mfiw== X-Gm-Message-State: AC+VfDxhqNqMFaPhykDjqoeNoaC8SjSkvfndPb8zNAguoVF2p/n2qkwk n5owbXhw3lKeaq/px4Nfp86ZTQ== X-Received: by 2002:a17:902:dace:b0:1b6:7b75:60f with SMTP id q14-20020a170902dace00b001b67b75060fmr7687704plx.41.1687894699322; Tue, 27 Jun 2023 12:38:19 -0700 (PDT) Received: from ubuntu-22.localdomain ([192.19.222.250]) by smtp.gmail.com with ESMTPSA id g7-20020a1709026b4700b001b7f40a8959sm4986919plt.76.2023.06.27.12.38.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 12:38:18 -0700 (PDT) From: William Zhang <william.zhang@broadcom.com> To: Broadcom Kernel List <bcm-kernel-feedback-list@broadcom.com>, Linux MTD List <linux-mtd@lists.infradead.org> Cc: 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, William Zhang <william.zhang@broadcom.com>, Florian Fainelli <florian.fainelli@broadcom.com>, Miquel Raynal <miquel.raynal@bootlin.com>, linux-kernel@vger.kernel.org, Vignesh Raghavendra <vigneshr@ti.com>, Richard Weinberger <richard@nod.at>, Kamal Dasu <kdasu.kdev@gmail.com> Subject: [PATCH v3 3/5] mtd: rawnand: brcmnand: Fix crash during the panic_write Date: Tue, 27 Jun 2023 12:37:36 -0700 Message-Id: <20230627193738.19596-4-william.zhang@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627193738.19596-1-william.zhang@broadcom.com> References: <20230627193738.19596-1-william.zhang@broadcom.com> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000fdbd6205ff219b35" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769886659467841908?= X-GMAIL-MSGID: =?utf-8?q?1769886659467841908?= |
Series |
mtd: rawnand: brcmnand: driver and doc updates
|
|
Commit Message
William Zhang
June 27, 2023, 7:37 p.m. UTC
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. Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") Signed-off-by: William Zhang <william.zhang@broadcom.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Kursad Oney <kursad.oney@broadcom.com> Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com> --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Comments
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. > > Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") > Signed-off-by: William Zhang <william.zhang@broadcom.com> > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > Reviewed-by: Kursad Oney <kursad.oney@broadcom.com> > Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com> > --- > > Changes in v3: None > Changes in v2: None > > drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > 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) > > dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); > > - BUG_ON(ctrl->cmd_pending != 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 != 0); > ctrl->cmd_pending = cmd; > > ret = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); LGTM otherwise. Thanks, Miquèl
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. > > Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") The Fixes tag looks wrong. > Signed-off-by: William Zhang <william.zhang@broadcom.com> > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > Reviewed-by: Kursad Oney <kursad.oney@broadcom.com> > Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com> > --- > > Changes in v3: None > Changes in v2: None > > drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > 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) > > dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); > > - BUG_ON(ctrl->cmd_pending != 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 != 0); > ctrl->cmd_pending = cmd; > > ret = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); Thanks, Miquèl
Hi Miquel, On 07/04/2023 08:26 AM, Miquel Raynal wrote: > 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. >> >> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") > > The Fixes tag looks wrong. > The brcmnand_send_cmd function and BUG_ON line were added by this commit and the function didn't changed much since then. Not sure why you think it is wrong? >> Signed-off-by: William Zhang <william.zhang@broadcom.com> >> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> >> Reviewed-by: Kursad Oney <kursad.oney@broadcom.com> >> Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com> >> --- >> >> Changes in v3: None >> Changes in v2: None >> >> drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> 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) >> >> dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); >> >> - BUG_ON(ctrl->cmd_pending != 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 != 0); >> ctrl->cmd_pending = cmd; >> >> ret = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); > > > Thanks, > Miquèl >
Hi William, william.zhang@broadcom.com wrote on Tue, 4 Jul 2023 17:40:03 -0700: > Hi Miquel, > > On 07/04/2023 08:26 AM, Miquel Raynal wrote: > > 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. > >> > >> Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") > > > > The Fixes tag looks wrong. > > > The brcmnand_send_cmd function and BUG_ON line were added by this commit and the function didn't changed much since then. Not sure why you think it is wrong? Ok, the title of that commit let me think it was moving code rather than adding it. Alright. > >> Signed-off-by: William Zhang <william.zhang@broadcom.com> > >> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > >> Reviewed-by: Kursad Oney <kursad.oney@broadcom.com> > >> Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com> > >> --- > >> > >> Changes in v3: None > >> Changes in v2: None > >> > >> drivers/mtd/nand/raw/brcmnand/brcmnand.c | 12 +++++++++++- > >> 1 file changed, 11 insertions(+), 1 deletion(-) > >> > >> 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) > >> >> dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); > >> >> - BUG_ON(ctrl->cmd_pending != 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 != 0); > >> ctrl->cmd_pending = cmd; > >> >> ret = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0); > > > > > > Thanks, > > Miquèl > > Thanks, Miquèl
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) dev_dbg(ctrl->dev, "send native cmd %d addr 0x%llx\n", cmd, cmd_addr); - BUG_ON(ctrl->cmd_pending != 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 != 0); ctrl->cmd_pending = cmd; ret = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY, NAND_CTRL_RDY, 0);