Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3530911pxu; Mon, 30 Nov 2020 05:17:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQnUku/ALKgcMj2o9crl3oqRw+ttCrBAQxVjD72MIsAeDvE5YQ/PtlgDIpV9BdK2AaN6w7 X-Received: by 2002:a2e:730c:: with SMTP id o12mr9692449ljc.376.1606742256586; Mon, 30 Nov 2020 05:17:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606742256; cv=none; d=google.com; s=arc-20160816; b=GMy6O7XezBMYQP60J8smiVJXZHnVujHuLU4+qY3+7AwA4lNoUUH7hM+R27AZ4j1Zwm bzMH++4HugauBc3EtzN5XK9NFBpN/FFUnPNqx8K7D2X773luABrQu09fosL9utgJ+Fzr dCyxzQ/NplwSY1FnfhuSnBIisno/HcEQHPhswZwkFlHME6cZKTMAf5cjpLwpMrXs6vX/ HiRr7JqQeFEZ/9o/O1tIbQTDkbL+cR2zJFfo7hODv3ecDVq+5jQ6G51rW0O65ASh2tFy cFznHXAmpHQZCDtd0GwLNzjIBboklhEdPvNdmy4ikOZzoQp6dR1xULoiEwhT5gMh3ULj pXtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZMa7CqsWs8Y1MDXPkyCW/iCcme+i36HSODQwwL5Sy1U=; b=jnQBqjsDJT+1xfRrntc7+APpRS1geYGecnabWZjvKTbVxVoxlXa7Ob2OIvwzX95eHi BEySNZiMamjKHYlTqIUzjVAA+Q5dP2AR0GeuHUY+40QAlsOPma+6s7kvnkgoIGZ6v5wK GVoCz9wsBOGDT4ZJOVSce4UFlGM1bIdpUZ3bqQ/xhGVxpR+Fu8Lu5d+FmXQ8MFMFm8m5 Pt5vsb10vcei1UYqByX9b/8T8s4fTnFO8c2P6oyYWmT3fzlpBsVs4XmWmrwnTs5c9k3o HgyN/a/xRr2xzsB4juUBqFvIVEsK36czxYDR6QUGwVcAXgGD+tACo6vdo6wn77MWWAEE q1zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=u2RCJkWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si11102133edj.545.2020.11.30.05.17.13; Mon, 30 Nov 2020 05:17:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=u2RCJkWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbgK3NPx (ORCPT + 99 others); Mon, 30 Nov 2020 08:15:53 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:34150 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgK3NPs (ORCPT ); Mon, 30 Nov 2020 08:15:48 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 0AUDDrqr083502; Mon, 30 Nov 2020 07:13:53 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1606742033; bh=ZMa7CqsWs8Y1MDXPkyCW/iCcme+i36HSODQwwL5Sy1U=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=u2RCJkWeoVqW5E56guTFni9BdpbnN9arVSBMfgEg8K6DdNwzNZmhALND+NMvZE18k BfVLvWnOsatGgQJYj/zg/8N0VSSBLnWIzLbJCIZyl5Aexd1CUMLAe9+KLSFLLS+ooQ 0GOehTkS6O5I4i0QvYpzg/803eNmr6s1thziJlRo= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 0AUDDrYp046597 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 30 Nov 2020 07:13:53 -0600 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 30 Nov 2020 07:13:53 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 30 Nov 2020 07:13:53 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 0AUDDq4q044478; Mon, 30 Nov 2020 07:13:53 -0600 Date: Mon, 30 Nov 2020 18:43:52 +0530 From: Pratyush Yadav To: CC: , , , , Subject: Re: [PATCH v2 2/3] mtd: spi-nor: core: Allow flashes to specify MTD writesize Message-ID: <20201130131350.spqvde2al4ajf4fz@ti.com> References: <20201118182459.18197-1-p.yadav@ti.com> <20201118182459.18197-3-p.yadav@ti.com> <939dcad9-b556-ea3e-9eca-c008a86fd01b@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <939dcad9-b556-ea3e-9eca-c008a86fd01b@microchip.com> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/11/20 10:59AM, Tudor.Ambarus@microchip.com wrote: > On 11/18/20 8:24 PM, Pratyush Yadav wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > Some flashes like the Cypress S28 family use ECC. Under this ECC scheme, > > multi-pass writes to an ECC block is not allowed. In other words, once > > data is programmed to an ECC block, it can't be programmed again without > > erasing it first. > > > > Upper layers like file systems need to be given this information so they > > do not cause error conditions on the flash by attempting multi-pass > > programming. This can be done by setting 'writesize' in 'struct > > mtd_info'. > > > > Set the default to 1 but allow flashes to modify it in fixup hooks. If > > more flashes show up with this constraint in the future it might be > > worth it to add it to 'struct flash_info', but for now increasing its > > size is not worth it. > > > > Signed-off-by: Pratyush Yadav > > --- > > > > Notes: > > New in v2. > > > > drivers/mtd/spi-nor/core.c | 4 +++- > > drivers/mtd/spi-nor/core.h | 3 +++ > > 2 files changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > > index 5bee7c8da4dc..80fbcb9c0828 100644 > > --- a/drivers/mtd/spi-nor/core.c > > +++ b/drivers/mtd/spi-nor/core.c > > @@ -3054,6 +3054,8 @@ static int spi_nor_init_params(struct spi_nor *nor) > > if (!nor->params) > > return -ENOMEM; > > > > + nor->params->writesize = 1; > > + > > please do default inits in spi_nor_info_init_params(). A good place would be: > > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -2885,6 +2885,7 @@ static void spi_nor_info_init_params(struct spi_nor *nor) > nor->flags |= SNOR_F_HAS_16BIT_SR; > > /* Set SPI NOR sizes. */ > + params->writesize = 1; > params->size = (u64)info->sector_size * info->n_sectors; > params->page_size = info->page_size; Ok. > > > spi_nor_info_init_params(nor); > > > > spi_nor_manufacturer_init_params(nor); > > @@ -3430,7 +3432,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, > > mtd->name = dev_name(dev); > > mtd->priv = nor; > > mtd->type = MTD_NORFLASH; > > - mtd->writesize = 1; > > + mtd->writesize = nor->params->writesize; > > mtd->flags = MTD_CAP_NORFLASH; > > mtd->size = nor->params->size; > > mtd->_erase = spi_nor_erase; > > diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h > > index 0a775a7b5606..413ea311e632 100644 > > --- a/drivers/mtd/spi-nor/core.h > > +++ b/drivers/mtd/spi-nor/core.h > > @@ -197,6 +197,8 @@ struct spi_nor_locking_ops { > > * @rdsr_dummy: dummy cycles needed for Read Status Register command. > > * @rdsr_addr_nbytes: dummy address bytes needed for Read Status Register > > * command. > > + * @writesize Minimal writable flash unit size. Defaults to 1. Set to > > + * ECC unit size for ECC-ed flashes. > > * @hwcaps: describes the read and page program hardware > > * capabilities. > > * @reads: read capabilities ordered by priority: the higher index > > @@ -222,6 +224,7 @@ struct spi_nor_flash_parameter { > > u32 page_size; > > I would put writesize before or after page_size, because they are related. > Also, it would probably avoid padding. Ok. > With these addressed, one can add: > > Reviewed-by: Tudor Ambarus Thanks. > > u8 rdsr_dummy; > > u8 rdsr_addr_nbytes; > > + u32 writesize; > > > > struct spi_nor_hwcaps hwcaps; > > struct spi_nor_read_command reads[SNOR_CMD_READ_MAX]; > > -- > > 2.28.0 > > > -- Regards, Pratyush Yadav Texas Instruments India