Re: [PATCH REPOST v3] mtd: spi-nor: use spi-mem dirmap API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Sergei,

On 11/22/19 11:02 PM, Sergei Shtylyov wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Make use of the spi-mem direct mapping API to let advanced controllers
> optimize read/write operations when they support direct mapping.
> 
> Based on the original patch by Boris Brezillon <boris.brezillon@xxxxxxxxxxx>.
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@xxxxxxxxxxxxxxxxxx>
> Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>
> 
> ---
> The patch is against the 'spi-nor/next' branch of the MTD 'linux.git repo...
> Forgot to post to 'linux-mtd' 1st time... :-(
> 
> Changes in version 3:
> - simplified the way spi_mem_dirmap_{read|write}() are called;
> - refreshed the patch;
> - added Boris' tag.
> 
> Changes in version 2:
> - moved the spi_mem_dirmap_{read|write}() calls from spi_nor_{read|write}() to
>   spi_nor_spimem_{read|write}_data().
> 
>  drivers/mtd/spi-nor/spi-nor.c |   66 ++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/spi-nor.h   |    5 +++
>  2 files changed, 71 insertions(+)
> 
> Index: linux/drivers/mtd/spi-nor/spi-nor.c
> ===================================================================
> --- linux.orig/drivers/mtd/spi-nor/spi-nor.c
> +++ linux/drivers/mtd/spi-nor/spi-nor.c
> @@ -311,6 +311,9 @@ static ssize_t spi_nor_spimem_read_data(
>                            SPI_MEM_OP_DUMMY(nor->read_dummy, 1),
>                            SPI_MEM_OP_DATA_IN(len, buf, 1));
> 
> +       if (nor->dirmap.rdesc)
> +               return spi_mem_dirmap_read(nor->dirmap.rdesc, from, len, buf);
> +
>         /* get transfer protocols. */
>         op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->read_proto);
>         op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->read_proto);
> @@ -360,6 +363,9 @@ static ssize_t spi_nor_spimem_write_data
>                            SPI_MEM_OP_NO_DUMMY,
>                            SPI_MEM_OP_DATA_OUT(len, buf, 1));
> 
> +       if (nor->dirmap.wdesc)

This check is always true. The dirmap API is available just for the spi-mem
drivers, and we are already in the nor->spimem case.

> +               return spi_mem_dirmap_write(nor->dirmap.wdesc, to, len, buf);
> +
This doesn't guarantee that the buffer is DMA-able. You should instead modify
the spi_nor_spimem_xfer_data() method.

Cheers,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux