Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1590244

Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle vmalloc'd buffers

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle vmalloc'd buffers
Date 2017-03-01 12:00 +0100
Message-ID <tga9d-1UD-39@gated-at.bofh.it> (permalink)
References <tfsrv-5qX-11@gated-at.bofh.it> <tfsrw-5qX-27@gated-at.bofh.it> <tg1yW-43J-11@gated-at.bofh.it> <tg9wt-1CS-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 1 Mar 2017 11:09:57 +0100
Cyrille Pitchen <cyrille.pitchen@atmel.com> wrote:

> Le 28/02/2017 à 22:39, Richard Weinberger a écrit :
> > Vignesh,
> > 
> > Am 27.02.2017 um 13:08 schrieb Vignesh R:  
> >> Filesystems like UBIFS may pass vmalloc'd buffers to SPI NOR layer which
> >> will end up in SPI layer. SPI core does try to handle such buffers (see
> >> spi_map_buf()) by doing vmalloc_to_page() and creating scatterlist. But,
> >> its known that this does not work well with VIVT/aliasing cache
> >> architectures.
> >> This also fails when buffers are addressed using LPAE (buffers in region
> >> higher than 32 bit addressable region), if DMA is 32bit only.
> >>
> >> Introduce bounce buffers support in SPI NOR framework to handle
> >> vmalloc'd buffers. Use a pre-allocated per flash bounce buffer equal to
> >> the sector size of the flash. Flash drivers can enable this feature by
> >> setting SNOR_F_USE_BOUNCE_BUFFER flag.
> >> This would also enable SPI NOR drivers to safely use DMA in their
> >> read/write callbacks.
> >>
> >> Signed-off-by: Vignesh R <vigneshr@ti.com>
> >> ---
> >>  drivers/mtd/spi-nor/spi-nor.c | 30 +++++++++++++++++++++++++++---
> >>  include/linux/mtd/spi-nor.h   |  4 ++++
> >>  2 files changed, 31 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> >> index 747645c74134..c241fefa5aff 100644
> >> --- a/drivers/mtd/spi-nor/spi-nor.c
> >> +++ b/drivers/mtd/spi-nor/spi-nor.c
> >> @@ -17,6 +17,7 @@
> >>  #include <linux/mutex.h>
> >>  #include <linux/math64.h>
> >>  #include <linux/sizes.h>
> >> +#include <linux/mm.h>
> >>  
> >>  #include <linux/mtd/mtd.h>
> >>  #include <linux/of_platform.h>
> >> @@ -1205,11 +1206,21 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len,
> >>  
> >>  	while (len) {
> >>  		loff_t addr = from;
> >> +		bool use_bb = false;
> >> +		u_char *dst_buf = buf;
> >> +		size_t buf_len = len;
> >>  
> >>  		if (nor->flags & SNOR_F_S3AN_ADDR_DEFAULT)
> >>  			addr = spi_nor_s3an_addr_convert(nor, addr);
> >>  
> >> -		ret = nor->read(nor, addr, len, buf);
> >> +		if (!virt_addr_valid(buf) && nor->bounce_buf) {  
> 
> Should we use is_vmalloc_addr() instead of virt_addr_valid() ?
> 
> I guess virt_addr_valid() returns true even for kmalloc'ed buffers
> however the copy into the bounce buffer should be avoided for kmalloc'ed
> memory.

The test is !virt_addr_valid(), so we won't use the bounce buffer for
kmalloc-ed regions. I don't remember why we use virt_addr_valid()
instead of is_vmalloc_addr() in the NAND framework, but there was a
good reason (virt_addr_valid() is more restrictive, but I don't
remember why it's safer :))

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 0/2] mtd: spi-nor: Handle vmalloc'd buffers Vignesh R <vigneshr@ti.com> - 2017-02-27 13:20 +0100
  [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce buffer support Vignesh R <vigneshr@ti.com> - 2017-02-27 13:20 +0100
    Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Richard Weinberger <richard@nod.at> - 2017-02-28 22:50 +0100
      Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Vignesh R <vigneshr@ti.com> - 2017-03-01 09:00 +0100
        Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-03-01 12:10 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Frode Isaksen <fisaksen@baylibre.com> - 2017-03-01 12:50 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 13:40 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 15:30 +0100
            Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-03-01 15:40 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-03-01 15:30 +0100
            Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Mark Brown <broonie@kernel.org> - 2017-03-01 17:00 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 17:20 +0100
          Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 18:00 +0100
            Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Frode Isaksen <fisaksen@baylibre.com> - 2017-03-02 10:10 +0100
              Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-02 16:00 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Frode Isaksen <fisaksen@baylibre.com> - 2017-03-02 16:20 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-02 17:00 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Frode Isaksen <fisaksen@baylibre.com> - 2017-03-03 10:10 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-03-02 17:50 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Mark Brown <broonie@kernel.org> - 2017-03-02 19:20 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-03 04:20 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Mark Brown <broonie@kernel.org> - 2017-03-03 14:20 +0100
                Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Vignesh R <vigneshr@ti.com> - 2017-03-06 12:50 +0100
              Re: [RFC PATCH 2/2] mtd: devices: m25p80: Enable spi-nor bounce  buffer support Vignesh R <vigneshr@ti.com> - 2017-03-03 23:10 +0100
  [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle vmalloc'd buffers Vignesh R <vigneshr@ti.com> - 2017-02-27 13:20 +0100
    Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Richard Weinberger <richard@nod.at> - 2017-03-01 02:50 +0100
      Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Vignesh R <vigneshr@ti.com> - 2017-03-01 09:00 +0100
      Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Cyrille Pitchen <cyrille.pitchen@atmel.com> - 2017-03-01 11:20 +0100
        Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 12:00 +0100
          Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Frode Isaksen <fisaksen@baylibre.com> - 2017-03-01 12:30 +0100
            Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-03-01 13:40 +0100
        Re: [RFC PATCH 1/2] mtd: spi-nor: Introduce bounce buffer to handle  vmalloc'd buffers Vignesh R <vigneshr@ti.com> - 2017-03-01 13:00 +0100
  Re: [RFC PATCH 0/2] mtd: spi-nor: Handle vmalloc'd buffers Frode Isaksen <fisaksen@baylibre.com> - 2017-02-27 17:00 +0100

csiph-web