[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200820051512.GA5141@lst.de>
Date: Thu, 20 Aug 2020 07:15:12 +0200
From: Christoph Hellwig <hch@....de>
To: Tomasz Figa <tfiga@...omium.org>
Cc: Christoph Hellwig <hch@....de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
Joonyoung Shim <jy0922.shim@...sung.com>,
Seung-Woo Kim <sw0312.kim@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Ben Skeggs <bskeggs@...hat.com>,
Pawel Osciak <pawel@...iak.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Matt Porter <mporter@...nel.crashing.org>,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <iommu@...ts.linux-foundation.org>,
Tom Lendacky <thomas.lendacky@....com>,
alsa-devel@...a-project.org,
linux-samsung-soc <linux-samsung-soc@...r.kernel.org>,
linux-ia64@...r.kernel.org, linux-scsi@...r.kernel.org,
linux-parisc@...r.kernel.org,
Linux Doc Mailing List <linux-doc@...r.kernel.org>,
nouveau@...ts.freedesktop.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-nvme@...ts.infradead.org, linux-mips@...r.kernel.org,
linux-mm@...ck.org, netdev@...r.kernel.org,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <linux-arm-kernel@...ts.infradead.org>,
Linux Media Mailing List <linux-media@...r.kernel.org>
Subject: Re: [PATCH 19/28] dma-mapping: replace DMA_ATTR_NON_CONSISTENT
with dma_{alloc, free}_pages
On Wed, Aug 19, 2020 at 05:03:52PM +0200, Tomasz Figa wrote:
> >
> > -Warning: These pieces of the DMA API should not be used in the
> > -majority of cases, since they cater for unlikely corner cases that
> > -don't belong in usual drivers.
> > +These APIs allow to allocate pages that can be used like normal pages
> > +in the kernel direct mapping, but are guaranteed to be DMA addressable.
>
> Could we elaborate a bit more on what "like normal pages in kernel
> direct mapping" mean from the driver perspective?
It mostly means you can call virt_to_page and then do anything you'd
do with a page struct. Unlike dma_alloc_attrs that just return an
opaque virtual address that the caller is not allowed to poke into.
> There is one aspect that the existing dma_alloc_attrs() handles, but
> this new function doesn't: IOMMU support. The function will always
> allocate a physically-contiguous block memory, which is a costly
> operation and not even guaranteed to succeed, even if enough free
> memory is available.
>
> Modern SoCs employ IOMMUs to avoid the need to allocate
> physically-contiguous memory and those happen to be also the devices
> that could benefit from non-coherent allocations a lot. One of the
> tasks of the DMA API was making it possible to allocate suitable
> memory for a given device, without having the driver know about the
> SoC integration details, such as the presence of an IOMMU.
This is completely out of scope for this API exactly because it
guarantees a page in the direct mapping. But see my previous mail
in reply to Robin on how you can implement the funtionality you
want right now without any help from the dma-mapping subsystem.
Powered by blists - more mailing lists