From patchwork Wed Sep 11 07:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 827368 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp663884wrc; Wed, 11 Sep 2024 00:12:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3nXt2CLhf6vAE8EAfjdBWBRTpBbnXMnzTsjdyGxW6g9GqcaB0gn103zxI0oQA9Z5OpxYOOg==@linaro.org X-Google-Smtp-Source: AGHT+IH0juNMCOAxgfBNTjwvMcLCJtpoRpgmVj6Yuv+WzCgzXuAJZBP0Y0W+KkXjXqos/SYTGz3f X-Received: by 2002:a05:6000:781:b0:374:c56c:fbc7 with SMTP id ffacd0b85a97d-378895ca924mr11454652f8f.15.1726038737048; Wed, 11 Sep 2024 00:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726038737; cv=none; d=google.com; s=arc-20240605; b=b41T28ddBCyMTac8Fc34AL6OCRdWdVHyAspMG4RhiIovARV9dCTHgFRjKfLWb5fBUI h3VqDRfw/mp3b8pgBJy+G6MjV+AEJlrkgE4BL4C5CPktZh+i58c5/tRf8x0Mmskh038j IGDyJE8CS4hgh742cliBGpqb0PjMXZlzPcunWZEJDCDB9yUuY7F13g4LB29gYWE3Q4Q2 N7uyt/EDh1aQtp/Z28IMuR0DEtXfqro97W9QkdyOf3N/CIaadcJgVkBswnm5SOp+WCm9 aPDeR+XYV+a0L1nIBJgVazrR3rOretFKQv5op4nmpQQqsq7LKS+dUb6lc+afQSzf0IIM e9rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=yKuLdsLuyes8mnBA3MrU0R/rfIaNO+BeT5q0k2EEnh0=; fh=h9O78uwswjRVdW8Id1esrMzZoEr+njK1me6t0mcjnS0=; b=bADc/+QQUXpEh9nKcURQcm/Nhcjx+UsSb5b74uqLGZoY6gIdMAYXcbwuqCjOb1zgYX G8mlfrgcj/31Bcnx2oKND42v0nprVKE5D4Ju/buRx3Hv+P3+RJFl98LHN3lEiPNaTZtC 8TrKWq4ESHWIci0/wpnorcV2ze9cWRxLb1+URi8jbulr/rhZRHGC9XmOlZq2R4IgGMq/ sSeKjfRTNm3/c4gYWjt+oeZKJJL2ef2nt8ZVoIP6U2yta+Lky1RHGrqSmuGFc0z+wmD3 9vt2tBXCXwwhXW93naJr38ttS78kfUAHN5johM0Uc6GQ5mq+/hDHjABZOKTvZ5PrqDdh qaKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ILQTihuw; 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; dara=neutral header.i=@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 ffacd0b85a97d-3789562372dsi3657349f8f.243.2024.09.11.00.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:12:17 -0700 (PDT) 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=ILQTihuw; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3107A891FB; Wed, 11 Sep 2024 09:11:40 +0200 (CEST) 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="ILQTihuw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 040D7891FB; Wed, 11 Sep 2024 09:11:39 +0200 (CEST) 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-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (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 BFD18891E2 for ; Wed, 11 Sep 2024 09:11:36 +0200 (CEST) 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-x635.google.com with SMTP id a640c23a62f3a-a8d60e23b33so391669366b.0 for ; Wed, 11 Sep 2024 00:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726038696; x=1726643496; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yKuLdsLuyes8mnBA3MrU0R/rfIaNO+BeT5q0k2EEnh0=; b=ILQTihuwa8IQUynIW//yvkpd15O4t/2DiCXVa8r46qHP9qEArEnvrgH9PZM48VSkyS 3qdl0kxa8tcGQkj375pGAUdNJUUupWC5NL8dX1iLUaROieiZQWkS45zlNRVPfv042x1z Ne8iiXvVLZUQxA97+qyQFFCWAapLwAbByznEZl3JhxoV9D2Te4dA9H15MOUh3+/v2sOH 8dYrmnF+8PHX5/qxR/IjiEkMAOL/hZ8g4DuGWzIqAzQfOzEF94xx3fgHEdHOlAZCRre4 IU+SypNFm3AUkuKLOoGLhWLlCLlZctCtyt64YnyrA2dDPoZhdAU5jiwzL+sfxmzjmhuV 6krg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726038696; x=1726643496; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yKuLdsLuyes8mnBA3MrU0R/rfIaNO+BeT5q0k2EEnh0=; b=SjohcjekVJw8h3CC2oC8Rnwf9dzBewZtzEVjPtehBzo/B2difp+kci/Vf7scQoVt/E 4LORl5IalsYvSG8OfVZuwVbm05Pj8ND62ofIlpqsl0NZXRlUpkJkld2hub6+OWZut8bj lLe1/Pae/XRfjuROQxU72ZY7qAqbfkWbhPmWZ+kALQIWGQ4zguxXJ9ITXh+8rZ0v9kP3 l+VfL4haUz/t5/lCn/F6J1nEYe+gqfy1Xz96gJILjiWQ/+CxGLlYIRYwV3ezoRGSl6r9 kuQfmtfFrvz2VmNLgBS1ox+lBKB3wanT8qX+IE9arIw0dWVOTnODtNFdwjsjr4bqaSDT TE1g== X-Gm-Message-State: AOJu0Yxl/fk5JFoZIZRpJLO0c/yh90YCL1RjwYcJtW8qkBg/u6fq10Pc 5A6SPXMpP6sRw05qAEWnG2HpaBT0DOhHFB3InvLb27r5liujeRgDnG+UXGnfMsGLDeOPY3W3Sm+ F X-Received: by 2002:a17:907:6d27:b0:a8a:7549:2a25 with SMTP id a640c23a62f3a-a8ffab83e3fmr338426966b.36.1726038695966; Wed, 11 Sep 2024 00:11:35 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25926ee8sm580523866b.50.2024.09.11.00.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 00:11:34 -0700 (PDT) From: Linus Walleij Date: Wed, 11 Sep 2024 09:11:15 +0200 Subject: [PATCH 4/7] mtd: rawnand: brcmnand: Fix mtd oobsize MIME-Version: 1.0 Message-Id: <20240911-brcmnand-fixes-v1-4-be112a20aaf1@linaro.org> References: <20240911-brcmnand-fixes-v1-0-be112a20aaf1@linaro.org> In-Reply-To: <20240911-brcmnand-fixes-v1-0-be112a20aaf1@linaro.org> To: u-boot@lists.denx.de, Dario Binacchi , Michael Trimarchi , Anand Gore , William Zhang , Kursad Oney , Philippe Reynes Cc: Linus Walleij , Miquel Raynal X-Mailer: b4 0.14.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.8 at phobos.denx.de X-Virus-Status: Clean From: William Zhang Backport from upstream Linux commit 60177390fa061c62d156f4a546e3efd90df3c183 "mtd: rawnand: brcmnand: Fix mtd oobsize" brcmnand controller can only access the flash spare area up to certain bytes based on the ECC level. It can be less than the actual flash spare area size. For example, for many NAND chip supporting ECC BCH-8, it has 226 bytes spare area. But controller can only uses 218 bytes. So brcmand driver overrides the mtd oobsize with the controller's accessible spare area size. When the nand base driver utilizes the nand_device object, it resets the oobsize back to the actual flash spare aprea size from nand_memory_organization structure and controller may not able to access all the oob area as mtd advises. This change fixes the issue by overriding the oobsize in the nand_memory_organization structure to the controller's accessible spare area size. Fixes: a7ab085d7c16 ("mtd: rawnand: Initialize the nand_device object") Signed-off-by: William Zhang Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20230706182909.79151-6-william.zhang@broadcom.com Signed-off-by: Linus Walleij --- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c index 60d34bd21f53..552b239b95ae 100644 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -2304,6 +2305,8 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) { struct mtd_info *mtd = nand_to_mtd(&host->chip); struct nand_chip *chip = &host->chip; + struct nand_device *nanddev = mtd_to_nanddev(mtd); + struct nand_memory_organization *memorg = nanddev_get_memorg(nanddev); struct brcmnand_controller *ctrl = host->ctrl; struct brcmnand_cfg *cfg = &host->hwcfg; char msg[128]; @@ -2331,10 +2334,11 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) if (cfg->spare_area_size > ctrl->max_oob) cfg->spare_area_size = ctrl->max_oob; /* - * Set oobsize to be consistent with controller's spare_area_size, as - * the rest is inaccessible. + * Set mtd and memorg oobsize to be consistent with controller's + * spare_area_size, as the rest is inaccessible. */ mtd->oobsize = cfg->spare_area_size * (mtd->writesize >> FC_SHIFT); + memorg->oobsize = mtd->oobsize; cfg->device_size = mtd->size; cfg->block_size = mtd->erasesize;