Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp214006lqe; Wed, 27 Mar 2024 03:47:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyyPnRntxmbwQXvWmzU3PyoDSFZFBhEPbF2vpMM0mKU6KA+jmdTifAZnSxCBiW0tRUiWhd1dADiEjO/t6ba7hI0c9sc9bGrt6h5XioRw== X-Google-Smtp-Source: AGHT+IEA17JU0q6R/dGxiphK1LAnjj9EheAiejYS7oJ9250hh4ZlplYecwQU+NBCYvOci5DgEh1V X-Received: by 2002:a17:902:e54f:b0:1e0:d09d:ea59 with SMTP id n15-20020a170902e54f00b001e0d09dea59mr5162684plf.31.1711536427340; Wed, 27 Mar 2024 03:47:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711536427; cv=pass; d=google.com; s=arc-20160816; b=Y8PrkzvIvPt3ml4ExXl064rEnpdlLF2s0cv/4loeUCPkjvrre/H9L9IJike/5yWoKx WUu4njspvKZ9seYH1yy8CQ+f1SEcfj2SCHsW0Q9EjpHBBVOLAHB/7OvbSr2t2flWQttD +q5xTe+cI+0ubfuTwNjAgqkNdZT9K+YW4KvgwmPVRStel0mQkgTALAVqnTmciBemqssq j2ZbTUQjSRS5gZy3JJGPRQ3l9iKPdllLpMr5KFl9TIYIw+/hvGnxSUhexWwrZbm4UFCQ yREFK4pm4qcWbxd4Qc6v7rzUkWvA1X3kBAOAVDm5G9RkADEyY4UX6NbAOcYATDSdqn1P CyYA== 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=apaPzwDK2Seu68gfZPpbdrn3nZ0SeMjp1IwLbL3YNmY=; fh=MAc09QjDjSik4AuDyYjfNYzf5L/MMPnuXYvjGiHigzc=; b=LDk6PP0BoXO40A7PBLurH3Hg3PQBd+4hL6F1vLtNpEYr+BZ38T10avCq8xsIIxVEFx OVTchzqryDLcsGmg0rzhzs0Pn8a0M9QLP1Q3o4Ut1gfJPHVcvkjzBi4erdD7V5S1+DDX w3m7JlXZ5dsogqXmInPUrfSfXpWm6aC+8F5u2wodmxyBmLYT+cZJfyTvThxFa8ePEfkK YMTOB+dD5/EbLA4h8H1OLamWkSmyxKrwyyC9dAwXAwAhY3/dXUBGgq3cASETAB+9UJTm Gf7gDzRe6cje/zRDUDdb6Ay5nFdwF6mXAcqRLpAP12ILzPAe0HOIJkmxfYUcxqVjqOu9 yayA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EaSyHLv0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120689-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q5-20020a170902a3c500b001e0c54819a9si5123238plb.165.2024.03.27.03.47.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 03:47:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EaSyHLv0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120689-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120689-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D74629B47F for ; Wed, 27 Mar 2024 10:45:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 062655339C; Wed, 27 Mar 2024 10:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EaSyHLv0" 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 1C88A524CE; Wed, 27 Mar 2024 10:44:51 +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=1711536292; cv=none; b=LmkqdmCkk6j/NGIJCXsz7DA9jd0ex+m9rS6uLVQD0cFjEszApEna8TgFVOpBQs8vLsmvMxmh4hBvnvtE9C1K39C6fWtOHmJ5X/QPcUe9W8fz78My8x6wGUmeIdLl0ranepkUeynaehyZ2fif5YDN8d6hBknbQUqVn9+1Z7KvLFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711536292; c=relaxed/simple; bh=rpDdqi9H/9+yY97geGXJz7EymWFNjuM/TNqVLXbS7jY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uwarIf68AuDwPbhKtqhZWOV9OskLwXXpreK6o3mIE1eVEcmbdqL+zs3CRlOIcx2MhtKq3ns0fSK3FEbFzwG1kZHx1NB8UGxrA10ECAwcpLeUCuc4zBoEYFEVOH9r4couzuUYNYdgl+0gAKQfZPUZ+Xq2jABP0eHeQGfjiWFn4dg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EaSyHLv0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id BFD69C433A6; Wed, 27 Mar 2024 10:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711536291; bh=rpDdqi9H/9+yY97geGXJz7EymWFNjuM/TNqVLXbS7jY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EaSyHLv0YBqbe9fVrkSH3v+BogorJ/tul+/vfmFQyBVy3K0z0BQAWZ/UxkgWyRd+U 9w4TUes1a6QzbMSN3J6WAruOwCVl9JKQVFxg1PDj+bey/nteHCS2eEfDHpI3z0kVz4 ZuOTg66TvPaDncMlAenMyQ+riPGyUl7v4dTv6wIk92PBISpgDQRBFW196PRqX/3vau 2HtNGHROfvFrVgGgi0Jl5sODTE16XQsoehOGpJBPzVl11JWi3l/N9hqdZTeICQe3Eh /HbkaVxgE/WvjQhL0QTAvgN2YihiYJKfirwK5rY0OmcDuf9pw2NljXfolGjtpaPHNd 3K6H/U1JZHi3A== 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 ADE9DCD1283; Wed, 27 Mar 2024 10:44:51 +0000 (UTC) From: Keguang Zhang via B4 Relay Date: Wed, 27 Mar 2024 18:44:00 +0800 Subject: [PATCH v6 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: <20240327-loongson1-nand-v6-2-7f9311cef020@gmail.com> References: <20240327-loongson1-nand-v6-0-7f9311cef020@gmail.com> In-Reply-To: <20240327-loongson1-nand-v6-0-7f9311cef020@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=1711536289; l=2162; i=keguang.zhang@gmail.com; s=20231129; h=from:subject:message-id; bh=lS2LSZ/s5Z4DeAh+vHqnlTAlI1Wu1nzKK/BPFHeBtfc=; b=jswAkTrM2ib8XVP9hzAqLEdJrjizPymy8TfvB7eIXISh60W8V0vf2sTb+pWo5AXZDxYFqVxq0 TOgwt6PbWkYD9qEkmXxlJXaJWaV/TZCv+eBZKcqpxkLIwTTX4oWrFmH 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 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