From patchwork Sat Feb 11 15:29:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 652702 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1537824wrr; Sat, 11 Feb 2023 07:31:40 -0800 (PST) X-Google-Smtp-Source: AK7set8ODuYljCID9k7UOOWC2Ttwdemn5mImHAT6ieWzqbYxVR4EikKZe4u0kmEwAmplxUOR1yZ4 X-Received: by 2002:a05:6870:d62b:b0:16d:b5cb:9d39 with SMTP id a43-20020a056870d62b00b0016db5cb9d39mr3908455oaq.22.1676129500458; Sat, 11 Feb 2023 07:31:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676129500; cv=none; d=google.com; s=arc-20160816; b=Z3fd26X5lpgnBc95YmgyUafRPm1LLncadWohU3pyuWP9tTmF02WdQ5/yfQOFMQJc+k g96oa/fwIsByV+TFrDRHd3toUYysMlI2CUREDwnqTPSu/s2ktgBW5Yf8+J6a+Ea6+VhO HS2dz7YuznIhmNhE7OOLzWT1jzVwpc3WHug+hDTXJSF8y4vxEN1FLM5JX57pF+/SHwoh ujZ8ge73l7Qv9xWu05Q7fz1V3ftIeZaWD9IObOmpaT9b8yOisSORl5n+b99ZSQPgZOTZ jivUOZ9Z8UArPFJBWysmjDhl1zPp2FyAhqCOlC1g3NjI+5yz4nRB8j2tp5Zo95AezyOe EUEA== 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=tkkG9VXWoJMZNzfgk3Mj0C9VT5VtAUjlIC+7R01alf4=; b=NUJgRO/YPU/KIcDtEaF70UgKLdzGhWZZF5UTKRv2UT7ijjAvKMjx8WmU3lctokjx2j SVFeSMmVhYyrskZhVV9SABilnuRgZE1XuVKjJObYhzalxJoA/I9EE0IIB6lePgoPpGAQ 3Wp+dF57vW32DyP97CyvqM1zt3s4cn8Sewyq9GgQqjhhN9FIK/5WiTQgaLVaWKvtfNdQ qlgJzO8W/DSDzRoVAdK/DlkYzVt8aFMoQmKJ2B26wRqMWp+kglIECSfSZAdz+G/LKHA0 ngfsOmKA/tQiPOc5VzvnKkkgI7tlKMA/VAtq4ANOfh4ltcUpN1jtJKJjiOJ5gab/aEV1 tpdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nPVILmdz; 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 x11-20020a056870a78b00b001508c8f4da2si7119711oao.107.2023.02.11.07.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Feb 2023 07:31:40 -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=nPVILmdz; 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 4E94785800; Sat, 11 Feb 2023 16:29:54 +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="nPVILmdz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D540C857A3; Sat, 11 Feb 2023 16:29:40 +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-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 5972C857A9 for ; Sat, 11 Feb 2023 16:29:36 +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-x634.google.com with SMTP id ml19so22626314ejb.0 for ; Sat, 11 Feb 2023 07:29:36 -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=tkkG9VXWoJMZNzfgk3Mj0C9VT5VtAUjlIC+7R01alf4=; b=nPVILmdzT2EWVQu6BTl051U3e2ycptM5eFJzZIm5M0a8YwtUPvXA0SIvt0eRTzFGVU tIQqPd89shw4q57kLD2hf8Mqv1cQeHq7D1EhxGfB8tsMVcCH19s2qmK7Qc2DoIhyV0gR gFLrVvJ5BKcYCMzklUIjklyJQ+4AXV4TFtzDttke+WJYtVmGpoSRhLzXzki+QK3/JZvf cQFIBNeqrb/mNsOUTGiiesgOzocT9zXhMi1P04B1BEqsADH851ZcVjmZol+d4IpNBhd8 ypruSv3H//jMKcsa6u4fCF8vuRHWnogl3vpqqROQUOv3AzG855NvqvjpRxSnMgdk6eYM 6A5Q== 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=tkkG9VXWoJMZNzfgk3Mj0C9VT5VtAUjlIC+7R01alf4=; b=4bXWFn9vBm0s9SMQvnpJvsDowg7P7QdNRk5mRhZFAemNWNFxcfX34VylSKfkSYuzKj kRwHpv4NhmlJia1xgiOY4KQxhBxW7aQbB84XkeUbCT/ZNk3AIubhyOJlLXK2+oQmniba XatXCNpdBj2pUybCSVbtbWVM5byQAqeV2J6LNDV7wza+3ZG8Z22udQ90chpcBvzfq01X TtkVaoKgY8iEQn5jWHy6rPDLk2IJZslrK/57PxncT/UhvrbVWipZrqSihnWVYrWT/5NN KVgTjMXfdHw0SmaBlrsEDRKwtAU4RHrqvK9X4pvgS7PFn1OpbpTWZClv3QRxcq8lMMy2 WZmA== X-Gm-Message-State: AO0yUKUmKGHc3HQhlNiGfUzu8qnC2vJsG0o/Yv6cee47XF5V+Fqhy49c Z2RAs2qpF7gsVVva4dmQmS98xRYlGtWzzoJ2 X-Received: by 2002:a17:907:20b7:b0:889:1480:d908 with SMTP id pw23-20020a17090720b700b008891480d908mr13654917ejb.17.1676129375713; Sat, 11 Feb 2023 07:29:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Feb 2023 07:29:34 -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?= , Brian Norris , Miquel Raynal , Linus Walleij Subject: [PATCH v2 10/10] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC Date: Sat, 11 Feb 2023 16:29:09 +0100 Message-Id: <20230211152909.1436133-11-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 Hamming ECC doesn't cover the OOB data, so reading or writing OOB shall always be done without ECC enabled. This is a problem when adding JFFS2 cleanmarkers to erased blocks. If JFFS2 clenmarkers are added to the OOB with ECC enabled, OOB bytes will be changed from ff ff ff to 00 00 00, reporting incorrect ECC errors. Fixes: 27c5b17cd1b1 ("mtd: nand: add NAND driver "library" for Broadcom STB NAND controller") Signed-off-by: Álvaro Fernández Rojas Acked-by: Brian Norris Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210224080210.23686-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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index b2ebcaf7a5bf..efbf9a3120a4 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2515,6 +2515,12 @@ static int brcmnand_init_cs(struct brcmnand_host *host, ofnode dn) ret = nand_register(0, mtd); #endif /* __UBOOT__ */ + /* If OOB is written with ECC enabled it will cause ECC errors */ + if (is_hamming_ecc(host->ctrl, &host->hwcfg)) { + chip->ecc.write_oob = brcmnand_write_oob_raw; + chip->ecc.read_oob = brcmnand_read_oob_raw; + } + return ret; }