Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2594352rdb; Fri, 22 Sep 2023 03:22:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxSEKPvDB5i6gYj6g76jnFNwMR3tjiLQLEusGHvxuq6GnV77GsoBxOZiafIaiKMTejp4It X-Received: by 2002:a05:6a00:280b:b0:68f:b5a3:5ec6 with SMTP id bl11-20020a056a00280b00b0068fb5a35ec6mr2175697pfb.0.1695378126222; Fri, 22 Sep 2023 03:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695378126; cv=none; d=google.com; s=arc-20160816; b=KvWE7lI7rYm+eB31ZKTYdwufjj3SUMWmVxAkKdLDphfjXu35/YWxr1i6461n5Hvsq9 Vh2/GQsZe2WStLJHgEMYyEnxSJDuTOx12G8mPS8OZD/DvkE8b++BQOxIhGUa23E2ZIo1 1vPeyCi3FDcZIlAdHAfs1JN23mEdjSAjJSJ8qermrl+ONPlJaH3JuVQ0ryd96TteaPlD rrAINcDJZU3zkUfZeRPoa0hR72wuew91q0CmGgD4tOQGTRRCiJvaIYNGmFF+HjNI2sad m2HxaxcQmmFdu8MinLe7L7+/7M069JvrlIeln5mqNXD+JSsoFRjCksIKHGOAV0o0UMwi /1Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=LSskr9azFWp4E6aBT5kVr9wPhLhyJRwn9Xj2Hi2QW6w=; fh=DLJRfZ6wK1eEEP19gqK7GLmSk25IKXJ2v3Lw1QD6Bm0=; b=euS3tqymkgRx2+n/R6sjaf/6Nh3JAYxCcndFbf8ieCSW8k6rI8gYX8IiLNsF5STlOZ eAlg/9CiV/oaiWwhDGQVHPISmgZNWXCbaznO7EbseR06/5Taxqk4fKuiHA/GykheRhTR 5qThc8uA22ZuYsxI3LSjLBn6lAfB2kopU+MDsEMDK0DoN6RYJHuvLkh1pXI9pIg/KUYf papbG3kSCzty4lGZgGdpRSUzXHRP5EZJYBlqLYEJuUlVqY6hWpa9TUHEbcMCRr8ds17R 0NqCGCSooeDgP3XkNNTgqFJBerUoUfPTlb7O9LzPy22TKVPNkv/vD+I9HPURXgTUz0DS z4DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y5-20020a056a001c8500b0068a52819fd2si3342570pfw.331.2023.09.22.03.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 84141830C30E; Fri, 22 Sep 2023 03:07:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233171AbjIVKHz convert rfc822-to-8bit (ORCPT + 99 others); Fri, 22 Sep 2023 06:07:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbjIVKHz (ORCPT ); Fri, 22 Sep 2023 06:07:55 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A62A18F for ; Fri, 22 Sep 2023 03:07:48 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[IPv6:::1]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qjd4Z-0004fu-Eb; Fri, 22 Sep 2023 12:07:43 +0200 Message-ID: <259fd7d260dc303e50804986c62d3176ace40da0.camel@pengutronix.de> Subject: Re: [PATCH] mtd: rawnand: check nand support for cache reads From: Rouven Czerwinski To: Martin =?ISO-8859-1?Q?Hundeb=F8ll?= , =?ISO-8859-1?Q?M=E5ns_Rullg=E5rd?= , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , JaimeLiao Cc: kernel@pengutronix.de, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 22 Sep 2023 12:07:42 +0200 In-Reply-To: References: <20230922100116.145090-1-r.czerwinski@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.48.4 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: r.czerwinski@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 03:07:56 -0700 (PDT) On Fri, 2023-09-22 at 12:04 +0200, Martin Hundebøll wrote: > On Fri, 2023-09-22 at 12:01 +0200, Rouven Czerwinski wrote: > > Both the JEDEC and ONFI specification say that read cache > > sequential > > support is an optional command. This means that we not only need to > > check whether the individual controller implements the command, we > > also > > need to check the parameter pages for both ONFI and JEDEC NAND > > flashes > > before enabling sequential cache reads. > > > > This fixes support for NAND flashes which don't support enabling > > cache > > reads, i.e. Samsung K9F4G08U0F or Toshiba TC58NVG0S3HTA00. > > > > Sequential cache reads are no only available for ONFI and JEDEC > > devices, > > if individual vendors implement this, it needs to be enabled per > > vendor. > > > > Tested on i.MX6Q with a Samsung NAND flash chip that doesn't > > support > > sequential reads. > > > > Fixes: 003fe4b9545b ("mtd: rawnand: Support for sequential cache > > reads") > > > > Signed-off-by: Rouven Czerwinski > > --- > > @Martin, Måns: > > I would appreciate if you could test this on your hardware. > > > > @Miguel: > > I didn't have the time to test this on ONFI/JEDEC devices with > > support > > yet, I'd be fine if you hold off merging this. > > > >  drivers/mtd/nand/raw/nand_base.c  | 3 +++ > >  drivers/mtd/nand/raw/nand_jedec.c | 3 +++ > >  drivers/mtd/nand/raw/nand_onfi.c  | 3 +++ > >  include/linux/mtd/jedec.h         | 3 +++ > >  include/linux/mtd/onfi.h          | 1 + > >  include/linux/mtd/rawnand.h       | 1 + > >  6 files changed, 14 insertions(+) > > > > diff --git a/drivers/mtd/nand/raw/nand_base.c > > b/drivers/mtd/nand/raw/nand_base.c > > index d4b55155aeae..1fcac403cee6 100644 > > --- a/drivers/mtd/nand/raw/nand_base.c > > +++ b/drivers/mtd/nand/raw/nand_base.c > > @@ -5110,6 +5110,9 @@ static void > > rawnand_check_cont_read_support(struct nand_chip *chip) > >  { > >         struct mtd_info *mtd = nand_to_mtd(chip); > >   > > +       if (!chip->parameters.supports_read_cache) > > +               return; > > + > >         if (chip->read_retries) > >                 return; > >   > > diff --git a/drivers/mtd/nand/raw/nand_jedec.c > > b/drivers/mtd/nand/raw/nand_jedec.c > > index 836757717660..e6ecbc4b2493 100644 > > --- a/drivers/mtd/nand/raw/nand_jedec.c > > +++ b/drivers/mtd/nand/raw/nand_jedec.c > > @@ -94,6 +94,9 @@ int nand_jedec_detect(struct nand_chip *chip) > >                 goto free_jedec_param_page; > >         } > >   > > +       if (p->opt_cmd[0] & JEDEC_OPT_CMD_READ_CACHE) > > +               chip->parameters.supports_read_cache; > > Missing ` = true` here ? > > > + > >         memorg->pagesize = le32_to_cpu(p->byte_per_page); > >         mtd->writesize = memorg->pagesize; > >   > > diff --git a/drivers/mtd/nand/raw/nand_onfi.c > > b/drivers/mtd/nand/raw/nand_onfi.c > > index f15ef90aec8c..bf79bf2b5866 100644 > > --- a/drivers/mtd/nand/raw/nand_onfi.c > > +++ b/drivers/mtd/nand/raw/nand_onfi.c > > @@ -303,6 +303,9 @@ int nand_onfi_detect(struct nand_chip *chip) > >                            ONFI_FEATURE_ADDR_TIMING_MODE, 1); > >         } > >   > > +       if (le16_to_cpu(p->opt_cmd) & ONFI_OPT_CMD_READ_CACHE) > > +               chip->parameters.supports_read_cache; > > And here? > > // Martin Argh, totally. This should still fix your device, but cause performance regressions on devices supporting cached sequential reads. Unfortunately I don't have hardware to test this. Fixed locally, I'll send a v2 later. > > + > >         onfi = kzalloc(sizeof(*onfi), GFP_KERNEL); > >         if (!onfi) { > >                 ret = -ENOMEM; > > diff --git a/include/linux/mtd/jedec.h b/include/linux/mtd/jedec.h > > index 0b6b59f7cfbd..56047a4e54c9 100644 > > --- a/include/linux/mtd/jedec.h > > +++ b/include/linux/mtd/jedec.h > > @@ -21,6 +21,9 @@ struct jedec_ecc_info { > >  /* JEDEC features */ > >  #define JEDEC_FEATURE_16_BIT_BUS       (1 << 0) > >   > > +/* JEDEC Optional Commands */ > > +#define JEDEC_OPT_CMD_READ_CACHE       BIT(1) > > + > >  struct nand_jedec_params { > >         /* rev info and features block */ > >         /* 'J' 'E' 'S' 'D'  */ > > diff --git a/include/linux/mtd/onfi.h b/include/linux/mtd/onfi.h > > index a7376f9beddf..55ab2e4d62f9 100644 > > --- a/include/linux/mtd/onfi.h > > +++ b/include/linux/mtd/onfi.h > > @@ -55,6 +55,7 @@ > >  #define ONFI_SUBFEATURE_PARAM_LEN      4 > >   > >  /* ONFI optional commands SET/GET FEATURES supported? */ > > +#define ONFI_OPT_CMD_READ_CACHE                BIT(1) > >  #define ONFI_OPT_CMD_SET_GET_FEATURES  BIT(2) > >   > >  struct nand_onfi_params { > > diff --git a/include/linux/mtd/rawnand.h > > b/include/linux/mtd/rawnand.h > > index 90a141ba2a5a..766856fcaba8 100644 > > --- a/include/linux/mtd/rawnand.h > > +++ b/include/linux/mtd/rawnand.h > > @@ -233,6 +233,7 @@ struct nand_parameters { > >         /* Generic parameters */ > >         const char *model; > >         bool supports_set_get_features; > > +       bool supports_read_cache; > >         DECLARE_BITMAP(set_feature_list, ONFI_FEATURE_NUMBER); > >         DECLARE_BITMAP(get_feature_list, ONFI_FEATURE_NUMBER); > >   > >