All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <vigneshr@ti.com>, <m.felsch@pengutronix.de>,
	<miquel.raynal@bootlin.com>, <richard@nod.at>,
	<sergei.shtylyov@cogentembedded.com>,
	<boris.brezillon@collabora.com>, <michael@walle.cc>,
	<j.neuschaefer@gmx.net>
Cc: <linux-mtd@lists.infradead.org>, <kernel@pengutronix.de>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices
Date: Wed, 16 Sep 2020 09:36:20 +0000	[thread overview]
Message-ID: <7cee3de0-19ee-d9f7-fd04-7f0771f73da5@microchip.com> (raw)
In-Reply-To: <dc80d00a-27a3-6c75-5820-97ad2e297d8e@ti.com>

On 9/14/20 3:00 PM, Vignesh Raghavendra wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 9/11/20 8:17 PM, Marco Felsch wrote:
>> The sst write support for devices using the special SST_WRITE routine
>> is broken since commit commit df5c21002cf4 ("mtd: spi-nor: use spi-mem
>> dirmap API") because the spi_nor_create_write_dirmap() function checks
>> SPINOR_OP_AAI_WP and sst_write_second. These checks are not valid during
>> probe. The check seems also to be broken since the "op->addr.nbytes = 0"
>> causes the devm_spi_mem_dirmap_create() function to return
>> PTR_ERR(-EINVAL) and the probe() function will fail.
>>
>> It seems that the commit only copy'n'pasted the existing logic. Use the
>> correct SST_WRITE flag and return 0 to fix both issues.
>>
>> Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API")
>> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
>> ---
>>  drivers/mtd/spi-nor/core.c | 12 +++++++++---
>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
>> index 65eff4ce6ab1..31869ac245a8 100644
>> --- a/drivers/mtd/spi-nor/core.c
>> +++ b/drivers/mtd/spi-nor/core.c
>> @@ -3289,15 +3289,21 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
>>       };
>>       struct spi_mem_op *op = &info.op_tmpl;
>>
>> +     /*
>> +      * Most SST SPI-NOR's have a special write routine.which should so
> 
> s/SPI-NOR/SPI NOR.
> 
>> +      * dirmap.wdesc is not supported for these.
> 
> Or How about more readable version:
> 
> "Most SST flashes have special sequence for writing data to the flash
> and therefore cannot support writes through direct mapping APIs."
> 
>> +      */
>> +     if (nor->info->flags & SST_WRITE) {
>> +             nor->dirmap.wdesc = NULL;
> 
> nor->dirmap.wdesc is known to be NULL at this point. So no need to set
> to NULL again.
> 
>> +             return 0;
>> +     }
>> +
>>       /* get transfer protocols. */
>>       op->cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->write_proto);
>>       op->addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto);
>>       op->dummy.buswidth = op->addr.buswidth;
>>       op->data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto);
>>
>> -     if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
>> -             op->addr.nbytes = 0;
>> -
>>       nor->dirmap.wdesc = devm_spi_mem_dirmap_create(nor->dev, nor->spimem,
>>                                                      &info);
>>       return PTR_ERR_OR_ZERO(nor->dirmap.wdesc);
>>

With Vignesh's comments addressed, one can add:
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>

WARNING: multiple messages have this Message-ID (diff)
From: <Tudor.Ambarus@microchip.com>
To: <vigneshr@ti.com>, <m.felsch@pengutronix.de>,
	<miquel.raynal@bootlin.com>,  <richard@nod.at>,
	<sergei.shtylyov@cogentembedded.com>,
	<boris.brezillon@collabora.com>, <michael@walle.cc>,
	<j.neuschaefer@gmx.net>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices
Date: Wed, 16 Sep 2020 09:36:20 +0000	[thread overview]
Message-ID: <7cee3de0-19ee-d9f7-fd04-7f0771f73da5@microchip.com> (raw)
In-Reply-To: <dc80d00a-27a3-6c75-5820-97ad2e297d8e@ti.com>

On 9/14/20 3:00 PM, Vignesh Raghavendra wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On 9/11/20 8:17 PM, Marco Felsch wrote:
>> The sst write support for devices using the special SST_WRITE routine
>> is broken since commit commit df5c21002cf4 ("mtd: spi-nor: use spi-mem
>> dirmap API") because the spi_nor_create_write_dirmap() function checks
>> SPINOR_OP_AAI_WP and sst_write_second. These checks are not valid during
>> probe. The check seems also to be broken since the "op->addr.nbytes = 0"
>> causes the devm_spi_mem_dirmap_create() function to return
>> PTR_ERR(-EINVAL) and the probe() function will fail.
>>
>> It seems that the commit only copy'n'pasted the existing logic. Use the
>> correct SST_WRITE flag and return 0 to fix both issues.
>>
>> Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API")
>> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
>> ---
>>  drivers/mtd/spi-nor/core.c | 12 +++++++++---
>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
>> index 65eff4ce6ab1..31869ac245a8 100644
>> --- a/drivers/mtd/spi-nor/core.c
>> +++ b/drivers/mtd/spi-nor/core.c
>> @@ -3289,15 +3289,21 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
>>       };
>>       struct spi_mem_op *op = &info.op_tmpl;
>>
>> +     /*
>> +      * Most SST SPI-NOR's have a special write routine.which should so
> 
> s/SPI-NOR/SPI NOR.
> 
>> +      * dirmap.wdesc is not supported for these.
> 
> Or How about more readable version:
> 
> "Most SST flashes have special sequence for writing data to the flash
> and therefore cannot support writes through direct mapping APIs."
> 
>> +      */
>> +     if (nor->info->flags & SST_WRITE) {
>> +             nor->dirmap.wdesc = NULL;
> 
> nor->dirmap.wdesc is known to be NULL at this point. So no need to set
> to NULL again.
> 
>> +             return 0;
>> +     }
>> +
>>       /* get transfer protocols. */
>>       op->cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->write_proto);
>>       op->addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto);
>>       op->dummy.buswidth = op->addr.buswidth;
>>       op->data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto);
>>
>> -     if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
>> -             op->addr.nbytes = 0;
>> -
>>       nor->dirmap.wdesc = devm_spi_mem_dirmap_create(nor->dev, nor->spimem,
>>                                                      &info);
>>       return PTR_ERR_OR_ZERO(nor->dirmap.wdesc);
>>

With Vignesh's comments addressed, one can add:
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2020-09-16  9:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 14:47 [PATCH 0/3] MTD: SST SPI-NOR fixes Marco Felsch
2020-09-11 14:47 ` Marco Felsch
2020-09-11 14:47 ` [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices Marco Felsch
2020-09-11 14:47   ` Marco Felsch
2020-09-14 12:00   ` Vignesh Raghavendra
2020-09-14 12:00     ` Vignesh Raghavendra
2020-09-16  9:36     ` Tudor.Ambarus [this message]
2020-09-16  9:36       ` Tudor.Ambarus
2020-09-11 14:47 ` [PATCH 2/3] mtd: spi-nor: sst: add missing write_enable Marco Felsch
2020-09-11 14:47   ` Marco Felsch
2020-09-11 14:47 ` [PATCH 3/3] mtd: spi-nor: sst: move sst_write_second to local driver Marco Felsch
2020-09-11 14:47   ` Marco Felsch
2020-11-24 20:35 ` [PATCH 0/3] MTD: SST SPI-NOR fixes Michael Auchter
2020-11-24 20:35   ` Michael Auchter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cee3de0-19ee-d9f7-fd04-7f0771f73da5@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=boris.brezillon@collabora.com \
    --cc=j.neuschaefer@gmx.net \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.