From patchwork Sun Jan 15 19:53:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 642957 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp251215pvb; Sun, 15 Jan 2023 11:55:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXv2mlQNl3fU4XYX28Kj6CYgvtqsZhsMljnEM/9FOqj3QQce5AR4qvkd/BCeT8bQwPhR7TQw X-Received: by 2002:a05:6808:140e:b0:35c:4e7c:2f34 with SMTP id w14-20020a056808140e00b0035c4e7c2f34mr10938685oiv.14.1673812536791; Sun, 15 Jan 2023 11:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673812536; cv=none; d=google.com; s=arc-20160816; b=jceslU+q5OT7jHSKAUnDbTPJ6qvTBYdH1TekDVHY6PD6cNTnU+xccou6uZwSAAiUU0 GBxM8pSm9WnBsbcW0nqwPScKUhhy2ZzTA9slnzVngdo0Vj6tUiu7k8n72UGpQpmfOEUG dnc7Uqzsy30eHly03QNKhdWIpiF++lirr+Jj+pq+Ilceak+noqBDFEt5+5ghrdA+zq1R phjSAuvyzvZZYjP2P8Nlp5h+prdlcbz3+StAaBpPhDxPMKn92zBFlz8eK0prW+UnxpkK EL5XZvZWeVtDc+c1PoPbp6w1hAhu/K6dRYIhfyijyxXNWpWlrY/utVBkzklkwe2MdiaK BihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0qaV2ff9CshiUpEVx0ph6Uaa6oOCJaBDnnOn5q7s9MI=; b=ZSmDNJzhQB6Vw37wFPQWHX72UTRFweDJa07b4dOSZVQJVLcal/ibp0755p+93Ghulr 9GhTI9cUcvWskNalnPHSkcbzdpOWaSavxEO/LXD9oKe9b3kLONpT4alaDG/Bvi2PeJ2f nwKzR/Slx81pJJ0W5NIKo4EjcKRdqpMU6QQ6Mva6SwWL2oD1Paos8hId/QbfwenFFMUs sGHLF5+dianRINijlQt9GA0pw8gOHhzau6nUgGv6jjfy/I+uJox2XW5Jx5fqwv1VjuLb r7B9rD6+wu922vRhw2R7illscfAqVXw3eA5O0GvsC6cKQJby0jmfL7aHT15YHxNFKpHT KtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QS4vRPjZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u22-20020a056808115600b00363a990bfe9si30070957oiu.295.2023.01.15.11.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QS4vRPjZ; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F465855DD; Sun, 15 Jan 2023 20:54:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QS4vRPjZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4DFD88557C; Sun, 15 Jan 2023 20:53:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 33A848557C for ; Sun, 15 Jan 2023 20:53:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linus.walleij@linaro.org Received: by mail-lf1-x129.google.com with SMTP id g13so40110869lfv.7 for ; Sun, 15 Jan 2023 11:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0qaV2ff9CshiUpEVx0ph6Uaa6oOCJaBDnnOn5q7s9MI=; b=QS4vRPjZ8pjhTd8I/tAnV4+LmGk634bqHjJiSNaNpWXJdWmGDK9yzNopkuGNBm9syp NbcBBP5E2/bec1I1tov8npMh1wVbMQoD2MKO3SQdSGBObD7sf6Jtyyt9ummfOlWVoDJ4 avWYujjx0PkbbgWuUQH5O4Iujl0JWRflmgLPo/Z1aCKGrMh7mHwXK8Y02S4QIvJaFgWE W1B/hnQxihRE8+btJymA6UuPZjzwnnbMiRU9kVDbvLtHzafX0HjA7G9/z8Jj8f18ioHF FL2JfxlaU/Zkkmq/QdqGQUlHNRO1vYXMn9LRBwunRYqn46Xlh+zSxHO/VnlS/2mrtULS EsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=0qaV2ff9CshiUpEVx0ph6Uaa6oOCJaBDnnOn5q7s9MI=; b=IqsoXgpw/NqP8m8i16uGvxpKtoeOW3mO03HiWLcXRoHrgsvLyuHeONyQYDZX2kEZFD R6079LGUEkGfTdIv0k96oyuG2LctTUr11zSUmhPyRjSYjdhxSTvI27RNCy1NbhJKxKrW SgrGBBylBkSfVg2eUmR0319kh/R1zh1RdMjqhhBzXPr5S1cj0/Utd+l+bxHKbtuSTeln zYA7cLg8AZLzGhYKprQe3SE4gyUmHAOpNoPwC7BZMrvPgqOMLJAPHVwsOQmICHElaeLT joq6AUm+QWAp9LPEcIiawjBR4BI1XG0e3L0ZJKlJboZ13EaNNZxcQqdenRnbh2dHWesC mMiw== X-Gm-Message-State: AFqh2kqVhuSEUwYgj392eaaPobikrpulFN2x5rjsbkYMsMkf9Fswk2le J/WXKa8QbnPWRBJ+Xa2gg9uStUxcOVUbYjve X-Received: by 2002:a05:6512:3b2a:b0:4b5:5efb:7d26 with SMTP id f42-20020a0565123b2a00b004b55efb7d26mr31759978lfv.37.1673812424012; Sun, 15 Jan 2023 11:53:44 -0800 (PST) Received: from localhost.localdomain (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id r12-20020ac252ac000000b004aab0ca795csm4780439lfm.211.2023.01.15.11.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:53:43 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini Cc: Anand Gore , William Zhang , Kursad Oney , Joel Peshkin , Philippe Reynes , =?utf-8?q?=C3=81lvaro_Fer?= =?utf-8?q?n=C3=A1ndez_Rojas?= , Miquel Raynal , Linus Walleij Subject: [PATCH 09/14] mtd: rawnand: brcmnand: correctly verify erased pages Date: Sun, 15 Jan 2023 20:53:07 +0100 Message-Id: <20230115195312.1477845-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230115195312.1477845-1-linus.walleij@linaro.org> References: <20230115195312.1477845-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Álvaro Fernández Rojas The current code checks that the whole OOB area is erased. This is a problem when JFFS2 cleanmarkers are added to the OOB, since it will fail due to the usable OOB bytes not being 0xff. Correct this by only checking that data and ECC bytes aren't 0xff. Fixes: 02b88eea9f9c ("mtd: brcmnand: Add check for erased page bitflips") Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200512082451.771212-1-noltari@gmail.com [Ported to U-Boot from the Linux kernel] Signed-off-by: Linus Walleij --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index d082801b8306..b87e3e0656df 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1829,11 +1829,12 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, struct nand_chip *chip, void *buf, u64 addr) { - int i, sas; - void *oob = chip->oob_poi; + struct mtd_oob_region ecc; + int i; int bitflips = 0; int page = addr >> chip->page_shift; int ret; + void *ecc_bytes; void *ecc_chunk; if (!buf) { @@ -1846,18 +1847,20 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd, chip->pagebuf = -1; } - sas = mtd->oobsize / chip->ecc.steps; - /* read without ecc for verification */ ret = chip->ecc.read_page_raw(mtd, chip, buf, true, page); if (ret) return ret; - for (i = 0; i < chip->ecc.steps; i++, oob += sas) { + for (i = 0; i < chip->ecc.steps; i++) { ecc_chunk = buf + chip->ecc.size * i; - ret = nand_check_erased_ecc_chunk(ecc_chunk, - chip->ecc.size, - oob, sas, NULL, 0, + + mtd_ooblayout_ecc(mtd, i, &ecc); + ecc_bytes = chip->oob_poi + ecc.offset; + + ret = nand_check_erased_ecc_chunk(ecc_chunk, chip->ecc.size, + ecc_bytes, ecc.length, + NULL, 0, chip->ecc.strength); if (ret < 0) return ret;