From patchwork Sun Jan 15 19:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 642955 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp251108pvb; Sun, 15 Jan 2023 11:55:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXuzw9j3zpK606x16D4zapzPh3Zrc8iCXedaItrRm2RId8YF9rymWiiXesvufEjmqKib1Dzu X-Received: by 2002:a05:6871:4307:b0:15f:193d:37f1 with SMTP id lu7-20020a056871430700b0015f193d37f1mr2389697oab.5.1673812513699; Sun, 15 Jan 2023 11:55:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673812513; cv=none; d=google.com; s=arc-20160816; b=iPUCfESrCtEYNZ8s+yesGhTPWDKN+nnRJ+SmKsmKxTuKUecUySgU4BANUBAGv+z+fz R9sivETnhxNYx+0M9WVNkdeg8EYvst04B3SG0Dem+YmdVSe33GjPeFxILj+onW1nND8O UD3VSmsXJn/qMCnvho4JmdCEnmG1PwM9SFTOK4Cy32yMip2SWv6fRi4+aKEo9tbhAYMr YCWOrmZ/x9uxodMPOOKQoi1VFfCciDSyO47bQia99OgOkj4MyA5tEhAvLAu1B5i3SQKP jPiVnGNN24PL7ZlPUuylvMcnhXCQW/DgTh/L5VpsN6tUPQPCcILjSMj+7ZEdgk6dZSjL MrQQ== 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=NbBdtYS7ES3bn+CKQckBE4ZAU2uZNNmorTZjk223ioc=; b=NYSGJILOp9OT2uBEDsAnzlPeSP1XQGQ45WXemrhOHl9BrM3E8P46T+1eST5685XsYv tiOUr/yKVT5+MkVjMf6PexW94qM4UneHLT6G0HBsVPvW6CDT7P0538otq6c/yT383MIk QpltGHQyhld5zf1eXVls/kepspIVPl/iDoLAeC2su4UfRSzbFrJDQFm/KXSCAaTlaWhA IWDXtNlTiL1CvOp7gXDrDqBy44vDMVx6cmQTk4C+j/WzgEBpCSUep+Drw9emAtZGRMIi zYeRIIRmoVvjGrAVzE4Gh6cyc60INbQkEQIcScvaWHfmGvEg/4yfvYN8zH/ur4tuA5kX P3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L3fEv/c+"; 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 w35-20020a05687033a300b0015ed5dc0f1bsi8863262oae.309.2023.01.15.11.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:55:13 -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="L3fEv/c+"; 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 5B320855B5; Sun, 15 Jan 2023 20:54:00 +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="L3fEv/c+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 350CD855B3; Sun, 15 Jan 2023 20:53:49 +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-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) (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 C87908551E for ; Sun, 15 Jan 2023 20:53: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=linus.walleij@linaro.org Received: by mail-lf1-x131.google.com with SMTP id bp15so40083312lfb.13 for ; Sun, 15 Jan 2023 11:53:42 -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=NbBdtYS7ES3bn+CKQckBE4ZAU2uZNNmorTZjk223ioc=; b=L3fEv/c+OtAJcg4Ovs80DwipQ1hls+Jare5B4db8yl6YFhLGRNVe0i3XAIhY73i8wB 5DxWHQpiVhtjQw4i/cT489+DJ55dAHry/g9cZJ6HEkdF8fSL1SwwgcAPTpJxPoHBUSOo 9JcV7MozoEp5oqwUPhpro3VGiaI+RMnsQLDMRrqd7102X1EomUpprKQx/mJmmPMaBYYz FENIPh+5gpWiB4Asgi5OPtVPsYca8BRYnll7XiKOAtgYEmCfCZqPTxXVgUOAaOw+TUVn ky7CfrPAT2uin3uK7Gma/nl4uXieOOwbNIk24yiAqybjYDw7a8jOH9qiSmLraDbmhBKc 3PXg== 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=NbBdtYS7ES3bn+CKQckBE4ZAU2uZNNmorTZjk223ioc=; b=Aktrsukyfq20r855P5yALF3OsD74fTfm4+adtoNsPckZmbrd+v8USaCKjup9B8gJKS o6qzuw1ZwP5p6+VessGUQQjIIGpDh3vnNnqxedC8nNm7a8r+u/6vzg34O3Del8SRSeyG KF4JJYN0AeM1IBMrZTiqFJ7vxEuFzxna5DwO6qdq+QYiDbTOMKsowsa4OQtHL3ldn41S G8qknPNw+6k1qXk9fbaDVhuL+yi4CuTqiNLHM5LbREGXe+CRuZpOL+f0ZxGw+eh84sha R21ZN1wg2+mtomWc97bmMAR4/L2wMc2nL2NdmfjPjSRg3hPLWQfhC8cbGbhwYslaIn1F rxMA== X-Gm-Message-State: AFqh2kpsD7e0KziGqXeqbDIhrsmjO8DFwp3M6QB29kttUdacuHs0tlIg stPH4kSR5k2vmqVcAWIdUxPlBK/PlckRcCR9 X-Received: by 2002:a05:6512:3f1a:b0:4cd:f051:940a with SMTP id y26-20020a0565123f1a00b004cdf051940amr2837468lfa.32.1673812422263; Sun, 15 Jan 2023 11:53:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Jan 2023 11:53:41 -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 08/14] mtd: rawnand: brcmnand: improve hamming oob layout Date: Sun, 15 Jan 2023 20:53:06 +0100 Message-Id: <20230115195312.1477845-9-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 generates 8 oob sections: S1 1-5 ECC 6-8 S2 9-15 S3 16-21 ECC 22-24 S4 25-31 S5 32-37 ECC 38-40 S6 41-47 S7 48-53 ECC 54-56 S8 57-63 Change it by merging continuous sections: S1 1-5 ECC 6-8 S2 9-21 ECC 22-24 S3 25-37 ECC 38-40 S4 41-53 ECC 54-56 S5 57-63 Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200512075733.745374-3-noltari@gmail.com [Ported to U-Boot from the Linux kernel] Signed-off-by: Linus Walleij --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 35 +++++++++++------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 7cb6f2651250..d082801b8306 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -1043,33 +1043,30 @@ static int brcmnand_hamming_ooblayout_free(struct mtd_info *mtd, int section, struct brcmnand_cfg *cfg = &host->hwcfg; int sas = cfg->spare_area_size << cfg->sector_size_1k; int sectors = cfg->page_size / (512 << cfg->sector_size_1k); + u32 next; - if (section >= sectors * 2) + if (section > sectors) return -ERANGE; - oobregion->offset = (section / 2) * sas; + next = (section * sas); + if (section < sectors) + next += 6; - if (section & 1) { - oobregion->offset += 9; - oobregion->length = 7; + if (section) { + oobregion->offset = ((section - 1) * sas) + 9; } else { - oobregion->length = 6; - - /* First sector of each page may have BBI */ - if (!section) { - /* - * Small-page NAND use byte 6 for BBI while large-page - * NAND use bytes 0 and 1. - */ - if (cfg->page_size > 512) { - oobregion->offset += 2; - oobregion->length -= 2; - } else { - oobregion->length--; - } + if (cfg->page_size > 512) { + /* Large page NAND uses first 2 bytes for BBI */ + oobregion->offset = 2; + } else { + /* Small page NAND uses last byte before ECC for BBI */ + oobregion->offset = 0; + next--; } } + oobregion->length = next - oobregion->offset; + return 0; }