[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1514570627.26695.114.camel@impinj.com>
Date: Fri, 29 Dec 2017 18:03:47 +0000
From: Trent Piepho <tpiepho@...inj.com>
To: "linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
"linux@...linux.org.uk" <linux@...linux.org.uk>,
"broonie@...nel.org" <broonie@...nel.org>,
"cyrille.pitchen@...ev4u.fr" <cyrille.pitchen@...ev4u.fr>,
"dwmw2@...radead.org" <dwmw2@...radead.org>,
"computersforpeace@...il.com" <computersforpeace@...il.com>,
"vigneshr@...com" <vigneshr@...com>,
"boris.brezillon@...e-electrons.com"
<boris.brezillon@...e-electrons.com>,
"richard@....at" <richard@....at>,
"marek.vasut@...il.com" <marek.vasut@...il.com>
CC: "linux-spi@...r.kernel.org" <linux-spi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"nicolas.ferre@...rochip.com" <nicolas.ferre@...rochip.com>,
"radu.pirea@...rochip.com" <radu.pirea@...rochip.com>,
"robh@...nel.org" <robh@...nel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>
Subject: Re: [PATCH 1/3] mtd: spi-nor: add optional DMA-safe bounce buffer for
data transfer
On Fri, 2017-12-29 at 15:46 +0530, Vignesh R wrote:
> On Friday 29 December 2017 12:24 AM, Trent Piepho wrote:
> >
> > > Vignesh has suggested to call virt_addr_valid() instead.
> > > I think Boris has also told me about this function.
> > > So it might be the right solution. What do you think about their proposal?
> >
> > Not sure what exactly the differences are between these methods. The
> > fact that each of the many existing DMA fixes uses slightly different
> > code to detect what is unsafe speaks to the difficulty of this problem!
>
> My understanding based on Documentation/DMA-API-HOWTO.txt and
> Documentation/arm/memory.txt is that
> virt_addr_valid() will guarantee that address is in range of
> PAGE_OFFSET to high_memory-1 (Kernel direct-mapped RAM region) which is
> address range of buffers that are DMA'able.
There's code in gpmi-nand.c that does:
/* first try to map the upper buffer directly */
if (virt_addr_valid(this->upper_buf) &&
!object_is_on_stack(this->upper_buf)) {
sg_init_one(sgl, this->upper_buf, this->upper_len);
So whoever wrote that thought that stack objects needed an additional
test beyond virt_addr_valid. But it does appear to be far more common
to depend on just virt_addr_valid, so perhaps the code in gpmi-nand is
in error.
> > virt_addr_valid() is already used by spi-ti-qspi. spi core uses for
> > the buffer map helper, but that code path is for buffers which are NOT
> > vmalloc or highmem, but are still not virt_addr_valid() for some other
> > reason.
> >
>
> if (vmalloced_buf || kmap_buf) {
> /* Handle vmalloc'd or kmap'd buffers */
> ...
This stuff does get DMAed. So I have to wonder, if spi.c thinks it can
use DMA with vmalloc or highmem, couldn't spi-not do the same instead
of the bounce buffer?
> } else if (virt_addr_valid(buf)) {
> /* Handle kmalloc'd and such buffers */
> ...
> } else {
> /* Error if none of the above */
So what is this case here for? It's some class that does not have a
valid virtual address and yet is not vmalloc or highmem.
> return -EINVAL;
> }
>
Powered by blists - more mailing lists