Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1942706lqa; Tue, 30 Apr 2024 04:12:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSvxAFMuppYfdo+l7mjpoJmMcFyuIEr2UNwNdVW1x3FQu0LlTOY2uyWkoSymDiYRB31TT3gScf+GCRGy0/v+u7nhmq1e7n6heVPk+WUA== X-Google-Smtp-Source: AGHT+IGYRhRPY8Lsys4LmeZjMKvvpIZgKft2PWFnin7+vGgUkhE8GSx/yr8ITZyZUz5P5GmO00rA X-Received: by 2002:a05:622a:5b0d:b0:439:bb04:f3b8 with SMTP id ea13-20020a05622a5b0d00b00439bb04f3b8mr12024461qtb.65.1714475544482; Tue, 30 Apr 2024 04:12:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714475544; cv=pass; d=google.com; s=arc-20160816; b=luAqzGw+A6JKkYrvzFlKMcuRtcODCNlgLN4TaaFo8hIcNamMRRKgHJimt2xhp1XHl1 UGRGgsojLat6jgeLQERqnPYQioGWBJX/ksegFQJGCcXrwS8sQIkc6oqA+iDFL3+p/pAg t3NmcPB+6+0OZtbUeZR0FJQznK7IYWYviedw1HReuuezNrdRiSa85Ii91xfrF2oLoQk2 BbKXIDjbk7WSCdA776Mbnfw1xg+GDDtRvxdjnlRjVKE7yMcSJnUSEZV4NJmpgEPRQSHY b42QsZaYXneDqsiRJ99kdQ5X3TnWKSPYHVn0psuTHuAqSusVWuiiqD+G2PU2utMcfZD2 wMvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=r/2e9251esAgYfJxA3MmCFz5TgoEYdsJ8t5nrcFII78=; fh=MAc09QjDjSik4AuDyYjfNYzf5L/MMPnuXYvjGiHigzc=; b=giOImficxtpMuN1X9khYLGzfHSuW+38K3EEcI6O+8wFv0z+94xT7YynT5QtBC7TMnw Z8ewDhN8GCCSxHeRndNzmudR8zc10Uq9FUuhGpNYoaQSFr6SiLxdCgWIqmU25Ss1JXOI /7QTwlcAaVPDy3J8ay0aLBFLxjJ209H+TMVKof60ceEOJUw1zTDiQ7vuRDt8BuTwRTuI BdgnwrJLcdnSw6mhDjBIeS+V7vZ24Vsu44P0IsLAqSb49uaAhxQsR/MfHkGt358OHHj5 ufvnDd7aq6WZta6k9wyIBk+CzgSVzpvghbOh0YjEt4CTT7haHpk46FewFlMYW2EsWsKh 3oBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eKuhx1K+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h14-20020ac8584e000000b0043ab64f612dsi6848662qth.202.2024.04.30.04.12.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 04:12:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eKuhx1K+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3D35F1C224D6 for ; Tue, 30 Apr 2024 11:11:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE9DB12DD99; Tue, 30 Apr 2024 11:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eKuhx1K+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07E2912D74F; Tue, 30 Apr 2024 11:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714475494; cv=none; b=Op9XRxX6+mIxcGrVQLuN5GpRxJpJr8WCKcIfgDNP7M5QfxZRPaQxT/hDF/jHJIr5O8/kfukTOqV9qh+t8aDqNiN+b2qiHM8F2DvjOflw7Z5kElUUTccfBRNiMC7yVeRFIMA21yNmLx+QSzP2rOT5+bCJjgXh8lS07eu4e6l6G/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714475494; c=relaxed/simple; bh=2n6RKhZ6Alf/wZaO1MKOWwaDevD0k3b+5zSEVw4UWKs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZtemA7mA/nCPiamVq15942YQt3wHKS4dp62xf9/I8/Ibtr2m+sD0ST/vRb4Uw9xXBDXPK5k3DbVfbxTFQTTpKVyVFVfNgG7MTQovwvH085pg2cc/EukTCfhhoINiRkP0iYjFcE7cEk4ibxhUzt+ZrMTcvV/H3YULGMENcrJHnhM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eKuhx1K+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id A6393C4AF1A; Tue, 30 Apr 2024 11:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714475493; bh=2n6RKhZ6Alf/wZaO1MKOWwaDevD0k3b+5zSEVw4UWKs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eKuhx1K+SwtgMP71K/LghjaKXGuYS90nfXBjhKShGHvmuGy54dtW31bs4aznwXVR8 +Xq3Ts6cFAtynwNPEjMa/cxE0Ieql0KT+Mz0A6Q2H8ZJivSQy9CgnMy95/6AkC2101 2Q0CLoHSinF6U5aoP6Lvei/5WkCoZqob+tf+B+7h/xdqAf/g9kBNsg0eP8V6IdxbuK NwWAE/QeISov9QZlHSnPn6SY4SkzlY8CAuoJFo+iq9/6QJHydHNYeEq4VhlbtdXgWx Jbgj7JphcSX7ZKcszIA0CgCPRKI3Anpr41p6ywaBsem4nPoJ7I9qHFc/4hIezW16zZ l8g04i9weF70w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D70C4345F; Tue, 30 Apr 2024 11:11:33 +0000 (UTC) From: Keguang Zhang via B4 Relay Date: Tue, 30 Apr 2024 19:11:11 +0800 Subject: [PATCH v7 2/3] mtd: rawnand: Enable monolithic read when reading subpages Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240430-loongson1-nand-v7-2-60787c314fa4@gmail.com> References: <20240430-loongson1-nand-v7-0-60787c314fa4@gmail.com> In-Reply-To: <20240430-loongson1-nand-v7-0-60787c314fa4@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, devicetree@vger.kernel.org, Keguang Zhang X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714475491; l=2188; i=keguang.zhang@gmail.com; s=20231129; h=from:subject:message-id; bh=wxQD1HBRVqdAYZRkfcNz/OdgGE3Cin/b3Ag8hRQf9EE=; b=qDOtiX5d4aKcQL2FPn2OyNayDTvIp5rLphjmsU/ftUr6P5kvU+uapKzBtmSJ/WRUiabEBChwh aCMaYeMxjLVBrdMF8NlJVpvxvgOeSPpm4aw4cFeheZOOjofdE3W3IPl X-Developer-Key: i=keguang.zhang@gmail.com; a=ed25519; pk=FMKGj/JgKll/MgClpNZ3frIIogsh5e5r8CeW2mr+WLs= X-Endpoint-Received: by B4 Relay for keguang.zhang@gmail.com/20231129 with auth_id=102 X-Original-From: Keguang Zhang Reply-To: keguang.zhang@gmail.com From: Keguang Zhang nand_read_subpage() reads data and ECC data by two separate operations. This patch allows the NAND controllers who support monolithic page read to do subpage read by a single operation, which is more effective than nand_read_subpage(). --- Changes in v7: - None Changes in v6: - A newly added patch Signed-off-by: Keguang Zhang --- drivers/mtd/nand/raw/nand_base.c | 5 +++-- include/linux/mtd/rawnand.h | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index d7dbbd469b89..eeb654c6b4fc 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3630,7 +3630,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, oob_required, page); else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) && - !oob) + !NAND_HAS_MONOLITHIC_READ(chip) && !oob) ret = chip->ecc.read_subpage(chip, col, bytes, bufpoi, page); else @@ -3648,7 +3648,8 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, * partial pages or when a bounce buffer is required. */ if (use_bounce_buf) { - if (!NAND_HAS_SUBPAGE_READ(chip) && !oob && + if ((!NAND_HAS_SUBPAGE_READ(chip) || + NAND_HAS_MONOLITHIC_READ(chip)) && !oob && !(mtd->ecc_stats.failed - ecc_stats.failed) && (ops->mode != MTD_OPS_RAW)) { chip->pagecache.page = realpage; diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index e84522e31301..92d3ab491c9c 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -150,6 +150,11 @@ struct gpio_desc; /* Device needs 3rd row address cycle */ #define NAND_ROW_ADDR_3 BIT(14) +/* Device supports monolithic reads */ +#define NAND_MONOLITHIC_READ BIT(15) +/* Macros to identify the above */ +#define NAND_HAS_MONOLITHIC_READ(chip) ((chip->options & NAND_MONOLITHIC_READ)) + /* Non chip related options */ /* This option skips the bbt scan during initialization. */ #define NAND_SKIP_BBTSCAN BIT(16) -- 2.40.1