From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Cc: Vignesh R <vigneshr@ti.com>,
computersforpeace@gmail.com, dwmw2@infradead.org, richard@nod.at,
marek.vasut@gmail.com, linux-mtd@lists.infradead.org,
broonie@kernel.org, linux@armlinux.org.uk,
linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org,
robh@kernel.org, devicetree@vger.kernel.org,
nicolas.ferre@microchip.com, radu.pirea@microchip.com
Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer
Date: Sun, 7 Jan 2018 21:07:03 +0100 [thread overview]
Message-ID: <20180107210703.31fdf0a0@bbrezillon> (raw)
In-Reply-To: <ae977280-28b4-d746-da4b-0f807dad609d@wedev4u.fr>
On Tue, 26 Dec 2017 14:59:00 +0100
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> wrote:
> Hi Vignesh
>
> Le 26/12/2017 à 14:42, Vignesh R a écrit :
> > Hi Cyrille,
> >
> > Thanks for doing this series! One comment below.
> >
> > On 24-Dec-17 10:06 AM, Cyrille Pitchen wrote:
> > [...]
> >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> >> index 8bafd462f0ae..59f9fbd45234 100644
> >> --- a/drivers/mtd/spi-nor/spi-nor.c
> >> +++ b/drivers/mtd/spi-nor/spi-nor.c
> >> @@ -14,8 +14,10 @@
> >> #include <linux/errno.h>
> >> #include <linux/module.h>
> >> #include <linux/device.h>
> >> +#include <linux/highmem.h>
> >> #include <linux/mutex.h>
> >> #include <linux/math64.h>
> >> +#include <linux/mm.h>
> >> #include <linux/sizes.h>
> >> #include <linux/slab.h>
> >>
> >> @@ -1232,6 +1234,56 @@ static const struct flash_info spi_nor_ids[] = {
> >> { },
> >> };
> >>
> >> +static bool spi_nor_is_dma_safe(const void *buf)
> >> +{
> >> + if (is_vmalloc_addr(buf))
> >> + return false;
> >> +
> >> +#ifdef CONFIG_HIGHMEM
> >> + if ((unsigned long)buf >= PKMAP_BASE &&
> >> + (unsigned long)buf < (PKMAP_BASE + (LAST_PKMAP * PAGE_SIZE)))
> >> + return false;
> >> +#endif
> >> +
> >> + return true;
> >> +}
> >> +
> >
> > Better way would be to use virt_addr_valid():
> > static bool spi_nor_is_dma_safe(const void *buf)
> > {
> > return virt_addr_valid(buf);
> > }
> >
> > Regards
> > Vignesh
> >
>
> Thanks for the advice :)
>
> https://patchwork.kernel.org/patch/9768341/
> Maybe I could check both virt_addr_valid() and object_is_on_stack() too ?
Yep, see the explanation given here [1].
[1]http://elixir.free-electrons.com/linux/v4.15-rc6/source/Documentation/DMA-API-HOWTO.txt#L132
next prev parent reply other threads:[~2018-01-07 20:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-24 4:36 [PATCH 0/3] mtd: spi-nor: fix DMA-unsafe buffer issue between MTD and SPI Cyrille Pitchen
2017-12-24 4:36 ` [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for data transfer Cyrille Pitchen
2017-12-26 13:42 ` Vignesh R
2017-12-26 13:59 ` Cyrille Pitchen
2018-01-07 20:07 ` Boris Brezillon [this message]
2017-12-26 19:43 ` Trent Piepho
2017-12-28 10:39 ` Cyrille Pitchen
2017-12-28 18:54 ` Trent Piepho
2017-12-29 10:16 ` Vignesh R
2017-12-29 18:03 ` Trent Piepho
2018-01-02 10:00 ` Vignesh R
2018-01-07 20:49 ` Boris Brezillon
2017-12-24 4:36 ` [PATCH 2/3] dt-bindings: mtd: atmel-quadspi: add an optional property 'dmacap,memcpy' Cyrille Pitchen
2017-12-26 23:23 ` Rob Herring
2017-12-27 21:40 ` Cyrille Pitchen
2018-01-02 10:22 ` Ludovic Desroches
2018-01-02 19:18 ` Trent Piepho
2018-01-03 6:51 ` ludovic.desroches
2018-01-03 11:51 ` Mark Brown
2017-12-24 4:36 ` [PATCH 3/3] mtd: atmel-quadspi: add support of DMA memcpy() Cyrille Pitchen
2017-12-26 18:45 ` [PATCH 0/3] mtd: spi-nor: fix DMA-unsafe buffer issue between MTD and SPI Trent Piepho
2017-12-27 10:36 ` Mark Brown
2017-12-27 20:15 ` Trent Piepho
2017-12-28 9:36 ` Cyrille Pitchen
2018-01-03 11:49 ` Mark Brown
2017-12-29 9:16 ` Vignesh R
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=20180107210703.31fdf0a0@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=broonie@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marek.vasut@gmail.com \
--cc=nicolas.ferre@microchip.com \
--cc=radu.pirea@microchip.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).