From patchwork Sun Jan 15 19:53:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 642961 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp251391pvb; Sun, 15 Jan 2023 11:56:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJEggQPOlCj6CzL1cDjQlD0kcPrNe+A5KQF4mcdWt8MSGGt98c3b314xmX+wajn96NBNdx X-Received: by 2002:a05:6870:5b83:b0:150:f2df:cf2 with SMTP id em3-20020a0568705b8300b00150f2df0cf2mr22895915oab.49.1673812583368; Sun, 15 Jan 2023 11:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673812583; cv=none; d=google.com; s=arc-20160816; b=VoS56B7AQjlfVczr73xhxxli7dXePvRhpzxK5CPbk7HKj40+n+P9sxTaCN9HtxsnPt 8Gn0EacVsz1aNiOIokbN8I43WqX9lzD+Zc1UtVXDWii7Gv1CBVUjPg3Nu6/BgtKNlEtJ rW/0Jr/UHC11POzcXv9U2HIN/pWduWIocP75mylsvwAs2ZXgNUbzy8wpQVGHkMMHC6WF MuQ9WywuZsFcrsEjWXBVs3e/tig7VPRM8Nt3Plnl3httZcIgEWoMmbI4q+Yo1hVB9Fxs zDOHk2RbB0m5EwuzstMEd+y21B4UEXLonhHbO8vUfCgEFkuNqOMGDFafPR5+efhPuE6B ACWw== 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=PMILEsthxdRKzrFrV/LMxMD1j7CUc2sFkhGwrgLXK8s=; b=UhXmLfRHMlzbYtmQeJyaCIKLy0zM25KFr7xT9PRO1+3OaSn/+iH+ZsnZSi+3/ptf0u yB4IYfALLGPHhsPn+5F985eySnoCSYRosAyATVsoVKwm37s05LzUCt/SC+3N0s0Q7kqy 60Ps0iNR5dZdxcEDyRC2cbJL9mjyc40x2+WkLQbMmBS6ak55fn60N4BuANuDjiMe+fDi 8O0f5ifZamk0i026a6jqsXCxifyB2GkVbn1UyjemhKBRa0wFOavDpxrt4kWJ7aRfUJjq lzWq3BHNPPwmI1AhnB8PFHeGKiVF98V1ErvOCIGCKScg7KI5PAMgVVkpQALel+ZSMkTs Ar+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gq9sDh/3"; 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 n38-20020a056870972600b00131b0b627bcsi22358022oaq.247.2023.01.15.11.56.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:56:23 -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="gq9sDh/3"; 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 9A338855EB; Sun, 15 Jan 2023 20:54:42 +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="gq9sDh/3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0622185592; Sun, 15 Jan 2023 20:53:57 +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-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (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 B41FB855B5 for ; Sun, 15 Jan 2023 20:53:53 +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-x12e.google.com with SMTP id f34so40081564lfv.10 for ; Sun, 15 Jan 2023 11:53:53 -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=PMILEsthxdRKzrFrV/LMxMD1j7CUc2sFkhGwrgLXK8s=; b=gq9sDh/3qcHVMtEdlOAC1LbA7KkasLr38BaMm0G3rQyFXwoIXo6ImmNschDMo+ssrz GrfG4yGe8+RI+WtztpNNTWj2CVtMbKf73b0bAo0vKXBy8+tylouY5zXlymNMz8/Snr+C +U3rspPamf5QvwDkPa7LU7O4jxcLycCXQOA9yoZ71gi2gkRSwbmRx+GSJWBDBSDpPPEd Cj50jEUW8WmTTFrPpNXcoIFQy0BdC4kDx3W2aDRxDuMlyuiHuxucJRPgONyZqysyrhBr kJWbjYi+bTnlmiajsWkI7yWfZW+4UBFrNbA3L4o5275sN5j+FMnA4a4H18HNmdGJITc9 gjgA== 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=PMILEsthxdRKzrFrV/LMxMD1j7CUc2sFkhGwrgLXK8s=; b=3hgDkK2RREQgaH7U0GVBxwjj/YDV6fPfRP9oe4+Zv76l1mJLzR0TynhD3Hm5zcvruu lhOmc+5+vIFsztTWuaUSdB73WOSAWdQzaSso0bCeUvY869bGcJnFLupzL0riuI47kG94 7fQT4Z4CCCa7z9KeMZhJl+s9bVQrG28FPXIh9U7HBxoRMXFq9Ny65lmmsGoIC2jGC43v NI3xpYBrBqrbUMzLC75wPg4lDTGTGlKEOqksv3eS7rbDny2rPpdWoIF5tTCPHplZVRLk TtQ7hFKuryJnaDmyBcBa28tTlWbYZKJ7PFBcJc9Qf6r2MEbic3giHkJN+Zfvx0rknWWO dHDA== X-Gm-Message-State: AFqh2ko3rhK/yhJsnhhAJ0pup4wL7TL3ICnTNlcKOMAGzlm3RAYHoo64 yMa4YnzPM/kitAc4ARdF1yIIwOzn77J+SzcV X-Received: by 2002:ac2:4474:0:b0:4c3:35b3:9a0e with SMTP id y20-20020ac24474000000b004c335b39a0emr1960331lfl.56.1673812433208; Sun, 15 Jan 2023 11:53:53 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:53:52 -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?= , Brian Norris , Miquel Raynal , Linus Walleij Subject: [PATCH 14/14] mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC Date: Sun, 15 Jan 2023 20:53:12 +0100 Message-Id: <20230115195312.1477845-15-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 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 --- 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 2cca897ab3c9..ee3ff372b863 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -2567,6 +2567,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; }