Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3092735rwb; Mon, 7 Aug 2023 08:09:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF10UV6glhXTS5grrtQjs2/DLSdNR4ShZ4HWLQUUrfy1ixNqXYESQx657/LuGmz9/nOd5TZ X-Received: by 2002:a17:906:74cd:b0:993:f90b:e549 with SMTP id z13-20020a17090674cd00b00993f90be549mr8763928ejl.37.1691420966321; Mon, 07 Aug 2023 08:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691420966; cv=none; d=google.com; s=arc-20160816; b=YBXnoeMP3nBjg2xueJuqwWpR1tkgu2ayBvmsTvN+CL5deFU65/PLf+cIb8eY8/5pVF j9Ye9LAXR+2AtjVua3NfdMPulizKBrW4CP/FD4vsQLvpB+6K4J/F5MxqrrFQFioyD73x MrBaSi1IbNgtxkNJjxhohfCkOKE4vWC4OItnTndbnBHAbiX/3KnnmONb+nyM64VDpzmL IMoXPq5sUrouaobD9lKnKa0ubHj7hgoLnBhdZlda8P4O/UbdCw1es8ol4623QPcI1DK6 R2Cjr4yhhIXEHpEb8MgBy8FhtEB7FPOoMaZUVii1q0i9+ahSEvl1FCRfeliKq85uZw5h QZLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=sgpG9tc96RXAVrisVjb1ZlL6kzhbThzQ6qjQYGBJXDE=; fh=RMviJqarwRMxTKDshv6fzV4JIqcZYUKPFmkzgO5Yfv8=; b=C1hiXA8BF2YPXoN5u9iTKKvDCKaMUMqj7mf5CTj5huWQ3QKdvfNPMT3J0ArOD86Q3e 454yDbQxgot1JPNkEiyVks2SWw9ifpt8sT50tmLwrwIHliYZ7gN0ETT8YiwwHhLE6pAK 6r5ahCGerU9w7e1LAIJqdHkk2CYHGIiaIZFjx905ef3DWkQbmAvvW40MgQiusEaakVH9 P1VlLKFnprOOyDpm0m98pmWFgGyhca/lToWk1Ac5rkqkNAwGdKD8a9IFj1Mh8m0sCBLA gPlAXgo62fj7zsMd/DRt15OCQK/ukzjdopFSlqnCv3ASjjhsd32f70csa1FWHxApIzjo b+pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="TcK/Qaf6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170906b08300b009930c030830si5482198ejy.633.2023.08.07.08.09.01; Mon, 07 Aug 2023 08:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="TcK/Qaf6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234329AbjHGNsi (ORCPT + 99 others); Mon, 7 Aug 2023 09:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234650AbjHGNs2 (ORCPT ); Mon, 7 Aug 2023 09:48:28 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAE610DC for ; Mon, 7 Aug 2023 06:48:00 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id DFCF31C0008; Mon, 7 Aug 2023 13:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691416075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sgpG9tc96RXAVrisVjb1ZlL6kzhbThzQ6qjQYGBJXDE=; b=TcK/Qaf6BTFBfmi0nKENimcG8cRbDvwZmNIJOV7uL9WiUwWXtLBDlIap8QQZ+Rxmsw9Kr8 c9DvDaTNGJ7jYloYQCoL0KYqquyxJyb52pWB1YfJIOn7JPRxh83ijtj+WHLstyh5d1HiZb L4W+NJpnoCJck3F+4mBXPUMMUfr+9YoTXwTmj2Btsey8lUs2r6kMSmoeREZ5gdoU/VbSOv XD60PWfl0qKgZNdwAff6C/yz/fkBmhkLvACUGy5bl6l148wqdl77TYgduQITBadwR3aJKn jv1GCoApA6ZSDXekfzV/TLZSMuUaw/VPMyASEC3tIB+yjf271ud9aXVx/wYlCA== Date: Mon, 7 Aug 2023 15:47:54 +0200 From: Miquel Raynal To: Michael Walle Cc: Tudor Ambarus , Pratyush Yadav , Michael Walle , Richard Weinberger , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: Re: [PATCH 06/41] mtd: spi-nor: default page_size to 256 bytes Message-ID: <20230807154754.70e994fa@xps-13> In-Reply-To: <20230807-mtd-flash-info-db-rework-v1-6-3d3d5bef4ba4@kernel.org> References: <20230807-mtd-flash-info-db-rework-v1-0-3d3d5bef4ba4@kernel.org> <20230807-mtd-flash-info-db-rework-v1-6-3d3d5bef4ba4@kernel.org> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 Hi Michael, mwalle@kernel.org wrote on Mon, 07 Aug 2023 15:21:00 +0200: > The INFO() macro always set the page_size to 256 bytes. Make that an > optinal parameter. This default is a sane one for all older flashes, optional > newer ones will set the page size by its SFDP tables anyway. >=20 > Signed-off-by: Michael Walle > --- > drivers/mtd/spi-nor/core.c | 7 +------ > drivers/mtd/spi-nor/core.h | 8 ++++++-- > 2 files changed, 7 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index c504a5af4032..138bc1e0a67c 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -2017,11 +2017,6 @@ static const struct spi_nor_manufacturer *manufact= urers[] =3D { > static const struct flash_info spi_nor_generic_flash =3D { > .name =3D "spi-nor-generic", > .n_banks =3D 1, > - /* > - * JESD216 rev A doesn't specify the page size, therefore we need a > - * sane default. > - */ > - .page_size =3D 256, > .parse_sfdp =3D true, > }; > =20 > @@ -3000,7 +2995,7 @@ static void spi_nor_init_default_params(struct spi_= nor *nor) > params->writesize =3D 1; > params->size =3D info->size; > params->bank_size =3D params->size; > - params->page_size =3D info->page_size; > + params->page_size =3D info->page_size ?: SPI_NOR_DEFAULT_PAGE_SIZE; Would you mind clarifying this? It does not look right, while perhaps it is. But TBH, I have no idea what params->page_size will be after this assignment. > =20 > if (!(info->flags & SPI_NOR_NO_FR)) { > /* Default to Fast Read for DT and non-DT platform devices. */ > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h > index 12c35409493b..25bc18197614 100644 > --- a/drivers/mtd/spi-nor/core.h > +++ b/drivers/mtd/spi-nor/core.h > @@ -10,6 +10,11 @@ > #include "sfdp.h" > =20 > #define SPI_NOR_MAX_ID_LEN 6 > +/* > + * 256 bytes is a sane default for most older flashes. Newer flashes will > + * have the page size defined within their SFDP tables. > + */ > +#define SPI_NOR_DEFAULT_PAGE_SIZE 256 > =20 > /* Standard SPI NOR flash operations. */ > #define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \ > @@ -447,7 +452,7 @@ struct spi_nor_fixups { > * @sector_size: the size listed here is what works with SPINOR_OP_SE= , which > * isn't necessarily called a "sector" by the vendor. > * @n_banks: the number of banks. > - * @page_size: the flash's page size. > + * @page_size: (optional) the flash's page size. Defaults to 256. > * @addr_nbytes: number of address bytes to send. > * > * @parse_sfdp: true when flash supports SFDP tables. The false valu= e has no > @@ -558,7 +563,6 @@ struct flash_info { > #define SPI_NOR_GEOMETRY(_sector_size, _n_sectors, _n_banks) \ > .size =3D (_sector_size) * (_n_sectors), \ > .sector_size =3D (_sector_size), \ > - .page_size =3D 256, \ > .n_banks =3D (_n_banks) > =20 > /* Used when the "_ext_id" is two bytes at most */ >=20 Otherwise, lgtm. Reviewed-by: Miquel Raynal Thanks, Miqu=C3=A8l