diff mbox series

[RFC,02/10] mtd: spi-nor: Use the highest supported READ protocol

Message ID 1512548141-3319-3-git-send-email-prabhakar.kushwaha@nxp.com
State Rejected
Delegated to: Cyrille Pitchen
Headers show
Series mtd: spi-nor: Update spi-nor framework | expand

Commit Message

Prabhakar Kushwaha Dec. 6, 2017, 8:15 a.m. UTC
HWCAP read capabilities defines higher bit position as the higher
priority. i.e. use Octo SPI protocols first, then Quad SPI protocols
before Dual SPI protocols, Fast Read and lastly (Slow) Read.

Currently implementation chose the last set bit i.e. slowest read.
This patch select the highest available read capability.

Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
---
 drivers/mtd/spi-nor/spi-nor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyrille Pitchen Dec. 6, 2017, 9:53 a.m. UTC | #1
Hi Prabhakar,

Le 06/12/2017 à 09:15, Prabhakar Kushwaha a écrit :
> HWCAP read capabilities defines higher bit position as the higher
> priority. i.e. use Octo SPI protocols first, then Quad SPI protocols
> before Dual SPI protocols, Fast Read and lastly (Slow) Read.
> 
> Currently implementation chose the last set bit i.e. slowest read.
> This patch select the highest available read capability.
> 
> Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 7d3b52f..01898e1 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -2521,7 +2521,7 @@ static int spi_nor_select_read(struct spi_nor *nor,
>  			       const struct spi_nor_flash_parameter *params,
>  			       u32 shared_hwcaps)
>  {
> -	int cmd, best_match = fls(shared_hwcaps & SNOR_HWCAPS_READ_MASK) - 1;
> +	int cmd, best_match = ffs(shared_hwcaps & SNOR_HWCAPS_READ_MASK) - 1;

I'm pretty sure this patch is wrong and fls() - find last
(most-significant) bit set - is actually what we want to select the best match.

Is the implementation of fls() correct on your platform ?

Best regards,

Cyrille

>  	const struct spi_nor_read_command *read;
>  
>  	if (best_match < 0)
>
Prabhakar Kushwaha Dec. 7, 2017, 8:29 a.m. UTC | #2
Regards,
Prabhakar

> -----Original Message-----

> From: Cyrille Pitchen [mailto:cyrille.pitchen@wedev4u.fr]

> Sent: Wednesday, December 06, 2017 3:24 PM

> To: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>; linux-

> mtd@lists.infradead.org

> Cc: boris.brezillon@free-electrons.com; computersforpeace@gmail.com;

> dedekind1@gmail.com

> Subject: Re: [RFC 02/10] mtd: spi-nor: Use the highest supported READ protocol

> 

> Hi Prabhakar,

> 

> Le 06/12/2017 à 09:15, Prabhakar Kushwaha a écrit :

> > HWCAP read capabilities defines higher bit position as the higher

> > priority. i.e. use Octo SPI protocols first, then Quad SPI protocols

> > before Dual SPI protocols, Fast Read and lastly (Slow) Read.

> >

> > Currently implementation chose the last set bit i.e. slowest read.

> > This patch select the highest available read capability.

> >

> > Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>

> > ---

> >  drivers/mtd/spi-nor/spi-nor.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c

> > index 7d3b52f..01898e1 100644

> > --- a/drivers/mtd/spi-nor/spi-nor.c

> > +++ b/drivers/mtd/spi-nor/spi-nor.c

> > @@ -2521,7 +2521,7 @@ static int spi_nor_select_read(struct spi_nor *nor,

> >  			       const struct spi_nor_flash_parameter *params,

> >  			       u32 shared_hwcaps)

> >  {

> > -	int cmd, best_match = fls(shared_hwcaps &

> SNOR_HWCAPS_READ_MASK) - 1;

> > +	int cmd, best_match = ffs(shared_hwcaps &

> SNOR_HWCAPS_READ_MASK) - 1;

> 

> I'm pretty sure this patch is wrong and fls() - find last

> (most-significant) bit set - is actually what we want to select the best match.

> 


I misunderstood below line.   Thanks for correcting me. 

/*
 * fls() returns zero if the input is zero, otherwise returns the bit
 * position of the last set bit, where the LSB is 1 and MSB is 32.
 */

--pk
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 7d3b52f..01898e1 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -2521,7 +2521,7 @@  static int spi_nor_select_read(struct spi_nor *nor,
 			       const struct spi_nor_flash_parameter *params,
 			       u32 shared_hwcaps)
 {
-	int cmd, best_match = fls(shared_hwcaps & SNOR_HWCAPS_READ_MASK) - 1;
+	int cmd, best_match = ffs(shared_hwcaps & SNOR_HWCAPS_READ_MASK) - 1;
 	const struct spi_nor_read_command *read;
 
 	if (best_match < 0)