From patchwork Tue Jun 27 19:37:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 113568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8435841vqr; Tue, 27 Jun 2023 12:53:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UQLDw0D49IwAn7kbsmYvhOWUES7m+lC23j5u4l+x3jC30dggvrsiS8sDN4++qJ5jYuQBF X-Received: by 2002:a05:6a20:7f99:b0:10e:d4fb:b031 with SMTP id d25-20020a056a207f9900b0010ed4fbb031mr25299981pzj.61.1687895637365; Tue, 27 Jun 2023 12:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687895637; cv=none; d=google.com; s=arc-20160816; b=HQWUsfpTe9jL8rtoH1hY3Ab3HYmt8ZcC/cHekICvZvr57Gh/iEr0+vR/P7GXak+WZK k8y21leozX7x3+WyfieDN5Aty64m9y9UNVzkgF/UnAZQ0+VIVAmzPu1r835/MX09tbgY yQCuP0V5XN1P0ZgP6LCoL2hZln1CvGgwy7HYVB22tgnZ0D55K+Ce+jqAbqVyQVCDLHRj BVADrmej9/Cc0gtt9kKMyjsd5cPOu1yQX9fnm9Hb4WBMHycoqsbD5LldRMojhuczXbFU 19aLjfho23qnCo67HROKikypH2xf+GPukEKtj0XH/AwSE0lMOkxScScY5chnzJvdailL uWUg== 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=raC0c8lD4uoqTKZzJVWvaIfqfutPouqXSyepzVVGY8A=; fh=I9qq4GK33V5F8z/ulbIoIJANM2w6qIjwqLIeYG6B9Xc=; b=hKepzLTmDT1AXQhkVwfIeniIgWrLSw9hf3845y5LK16l/Uxw6Jmr+LoJ7L+VceEJZy A98TkGAnD5JqE2P0u3CaFS3wYRIm0qeTLGG5ySLSzv5jOSdsmoGZL5ctprGy9qQ2Mb9p 2RWlGeEpim2AZf5OkPsI76nBYCj1XPpxZ1GTFjNP6zm/HD2krU9WDrRhq21NtGfZ9q/3 WW5OG8Z9ZD31WmZCzTZAc4vVPNPyGY41FRUqPos1h76xwr4otihMoMdEHjJCOXKAXBNY SEjJMANF2gv098hmlQKl1d19UghLHqI04LLQqFBRS+2fjraGJIZXTc3cUV7suUw+X38r c67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=gqA+TP3Y; 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 x64-20020a638643000000b00553c6af75d5si7667496pgd.315.2023.06.27.12.53.43; Tue, 27 Jun 2023 12:53:56 -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=gqA+TP3Y; 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 S230283AbjF0Ti2 (ORCPT + 99 others); Tue, 27 Jun 2023 15:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjF0TiX (ORCPT ); Tue, 27 Jun 2023 15:38:23 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D54E26A3 for ; Tue, 27 Jun 2023 12:38:17 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b7fef01fe4so16950235ad.0 for ; Tue, 27 Jun 2023 12:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1687894697; x=1690486697; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=raC0c8lD4uoqTKZzJVWvaIfqfutPouqXSyepzVVGY8A=; b=gqA+TP3YY8Bl42FSOl7N8s9551FBx53d9n7BcJB/NshVW6qKv3gzGsbr/Yvw9EhSn5 DShp2MgQHwsKElHNAi3yNl/U3ZEysBfM7dqpABSsiWrGBlLV/KpbB441dENxrryCjXCp ScHefLEQlZi8TYlHitKQlBMUf9RMKiZT3nR6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687894697; x=1690486697; 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=raC0c8lD4uoqTKZzJVWvaIfqfutPouqXSyepzVVGY8A=; b=Jx3aQfUZsQ1zLFoNe7lk2SIfn+JNItmGMFCQGBMY9pxxRfJA/2AAjSEFI9CoxtWd0O jhB2VyjkwE5ZUXMdx3Xl4WNJYf15xnuAtfWCgfIbXnx8da2EQqnbkFKZJNFdEX2LOYp9 0/WiH4pTJLPKRXhPse1H+TEeAlHDOK5/o+kZ+WxZ+sCoFPM1xD0dgZFLP7g7XkZcozVP FICDtrXrS+C4cJVhnsffTJ9Fsxd7FaOwbMIqj5JU+oUDP8e9nKLN7RLeoUYoNIzSlcEZ ljKnBp7uyXKgn+CxEBTTjJwRX38vfv3IX4B9bZxt45z37sLOfoEi7G8zku91EBkF1OMe /tHQ== X-Gm-Message-State: AC+VfDwibxtzjGxqfAmsw8OeJK2nRTMDB5Z/7FBoEnWJwJQYOXUh1jUX 5a8h0VJhLOGO/vVRMimLQ8ksBQ== X-Received: by 2002:a17:902:c40d:b0:1b5:5bf2:b7e2 with SMTP id k13-20020a170902c40d00b001b55bf2b7e2mr8453541plk.6.1687894696915; Tue, 27 Jun 2023 12:38:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 12:38:16 -0700 (PDT) From: William Zhang To: Broadcom Kernel List , Linux MTD List 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 , Florian Fainelli , Miquel Raynal , linux-kernel@vger.kernel.org, Vignesh Raghavendra , Richard Weinberger , Boris Brezillon , Kamal Dasu Subject: [PATCH v3 2/5] mtd: rawnand: brcmnand: Fix potential false time out warning Date: Tue, 27 Jun 2023 12:37:35 -0700 Message-Id: <20230627193738.19596-3-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769886855692020534?= X-GMAIL-MSGID: =?utf-8?q?1769886855692020534?= If system is busy during the command status polling function, the driver may not get the chance to poll the status register till the end of time out and return the premature status. Do a final check after time out happens to ensure reading the correct status. Fixes: 9d2ee0a60b8b ("mtd: nand: brcmnand: Check flash #WP pin status before nand erase/program") Signed-off-by: William Zhang Reviewed-by: Florian Fainelli --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 69709419516a..37c2c7cfa00e 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1080,6 +1080,14 @@ static int bcmnand_ctrl_poll_status(struct brcmnand_controller *ctrl, cpu_relax(); } while (time_after(limit, jiffies)); + /* + * do a final check after time out in case CPU is busy and driver does + * not get the enough time to poll to avoid false alarm + */ + val = brcmnand_read_reg(ctrl, BRCMNAND_INTFC_STATUS); + if ((val & mask) == expected_val) + return 0; + dev_warn(ctrl->dev, "timeout on status poll (expected %x got %x)\n", expected_val, val & mask);