From patchwork Sat Feb 11 15:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 652697 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1537376wrr; Sat, 11 Feb 2023 07:30:44 -0800 (PST) X-Google-Smtp-Source: AK7set/m73bot4KsxFs2d/VtdJ3YIzPUhnBOCdyHX+Lm5iWrVltbG4d8pN6OpBkx3mx4rHW/Kyec X-Received: by 2002:a05:6808:278a:b0:378:8f21:3ded with SMTP id es10-20020a056808278a00b003788f213dedmr7844959oib.37.1676129444110; Sat, 11 Feb 2023 07:30:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676129444; cv=none; d=google.com; s=arc-20160816; b=dnZdemEiV5x99Bch19u8K3ke3jJ81dRwxUPsplvGviq35ky4I9bcQZo+9RwgWRV37p e4iWILM8Y3U1SeFO4htqE7FMaXz7tXQsqsYjzw73XfefBKbUoH9Hx5piiaDptp365/kL jKdgz3M9vvtFUUhoD8vKnw8jvI+gQSGsZNuIz+dat/LK/2n2Q5np2Rz/PK6H/D3X7HQS 34PHFL2q/zmWdTFTjOH1uGo9fZOJ5j/6GD1hMGlpQaybTAqBNVoOQiLWZmrIHTCTRqD5 vtzmdfVHYlMYZvLL/1MaUieiB6uTgaePM5VmQ/T4Yv+4Mkvec3qZr7E8uTFpiIqEAG+B VfUg== 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=bLzh5w5TLq1Gd/bmSc41Qw+cz9MWQYAi7R/5+7ILTmw=; b=Q574BGbxewFoLsBj6slpvQA4GNU+Px9rGqRxrbXitE/AMcKFjqLEoJ4KpQXF2xDbBq JKhIoKEOOv/HMk5EticORbfLwPUGcJoDbHd5icNzcwmEPhNek62jZxTIwvTV3SRiCea8 lcRendrx54j/2/OEd2i6E7xftdpVr5JOK7CjMiwkHqqMz7SrBypXx1Lq8VvjtepUqS9H dGFAHY+9Htp8z/FiipZBk9Kcje0ZxPhyDD7ipx0wRDTEJN9O7kdbIcMvvBwUJlF4nmbg c3gDOE0xIKHj19G0sWOmTUGj4hBJH5HjwiVs0pGMOqbcmdWTMb0ai6KO92sB3FUjE9BG OmeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mPUkMqsi; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id dl14-20020a056808614e00b0037d88bd0e5dsi261408oib.129.2023.02.11.07.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Feb 2023 07:30:44 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mPUkMqsi; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 AE3878577F; Sat, 11 Feb 2023 16:29:38 +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="mPUkMqsi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79A8985785; Sat, 11 Feb 2023 16:29:28 +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-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 6F7478576F for ; Sat, 11 Feb 2023 16:29:25 +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-ej1-x62a.google.com with SMTP id qb15so20393926ejc.1 for ; Sat, 11 Feb 2023 07:29:25 -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=bLzh5w5TLq1Gd/bmSc41Qw+cz9MWQYAi7R/5+7ILTmw=; b=mPUkMqsinQJBdl9pRcfJkHXJqP21STOXECluPZmo+0WPrpWP8VzXssSR/M/3v/azEh gKljD5GoBRTchM/JQLbFqO5YIy7JQM+8j5z07VgDlyOaW5TymxpGqsvbGmAvDcx/kFFb tpoKlEk2rL87L4XS69SeuDlZYkmhG6EqlSyBWb33N5Eyi1DmTqwvmTxWmJRgWpojh0by mW8PB72+uIb2RPfHPcZbbMaq1w02FY5oExcgiaCxgLTAu0E2t2pT7AI7Y07O5SNWmSOX sQRJYNAxiJT0GapcS+zFZVGZPlrym/++7woSVYXZUqb+14g71/tkUslLehhmy7uIb/MM Dheg== 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=bLzh5w5TLq1Gd/bmSc41Qw+cz9MWQYAi7R/5+7ILTmw=; b=PwaQ0970PtYn95KmbBM3L+ltsESqha9MY5l1ea96+f8SwTiDvR5cHUWgbHkU97rwtQ szRl1BIsd96zifetsyA3bD8LxOxwx9cVZyOzGQJCuk3Zr+KhSTTcSRbSdyt4MBNUtNFu i5j6wSAVHWEoSpBw5qckk1LxcT0lODbTli73wZwGP7bkJbLp+HE+xyEmKYgbNjmqQ15Z 2PIK3wzTnbetTcyKTMdwaJeZ3kSGXEVqk/h8AfDF1D19UNka0+EGhAVHa1/huGZixBI6 37KVgkteVexErDt1qTBua7C7ExdL80KcBEpqpeN3Nz65oMkvr0SfwTK+G+LQm2ciOPGh XsvA== X-Gm-Message-State: AO0yUKWbDlNyhMfM8OppFfPxPnGtBwyu82lrhLpT2Va6YTMYI52Ym49k 2OQQK0NuNow8xazw8UcJCTqvtpwhRIruNCVY X-Received: by 2002:a17:906:1691:b0:8a4:e093:9bdb with SMTP id s17-20020a170906169100b008a4e0939bdbmr19324117ejd.19.1676129364971; Sat, 11 Feb 2023 07:29:24 -0800 (PST) Received: from Fecusia.lan (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id f26-20020a170906825a00b0084c4b87aa18sm3977768ejx.37.2023.02.11.07.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Feb 2023 07:29:24 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini , Michael Nazzareno Trimarchi Cc: Anand Gore , William Zhang , Kursad Oney , Joel Peshkin , Philippe Reynes , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , =?utf-8?q?=C3=81lvaro_Fern=C3=A1nd?= =?utf-8?q?ez_Rojas?= , Miquel Raynal , Linus Walleij Subject: [PATCH v2 05/10] mtd: rawnand: brcmnand: correctly verify erased pages Date: Sat, 11 Feb 2023 16:29:04 +0100 Message-Id: <20230211152909.1436133-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230211152909.1436133-1-linus.walleij@linaro.org> References: <20230211152909.1436133-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 Acked-by: William Zhang --- 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 a934373a2992..5d3fb460d89a 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1777,11 +1777,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) { @@ -1794,18 +1795,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;