From: robin.murphy@arm•com (Robin Murphy)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v5 1/3] iommu: Implement common IOMMU ops for DMA mapping
Date: Tue, 11 Aug 2015 14:31:34 +0100 [thread overview]
Message-ID: <55C9F936.8080201@arm.com> (raw)
In-Reply-To: <20150811093742.GC14980@8bytes.org>
Hi Joerg,
On 11/08/15 10:37, Joerg Roedel wrote:
> On Fri, Aug 07, 2015 at 02:38:39PM +0100, Robin Murphy wrote:
>> Indeed, DMA_DEBUG will check that a driver is making DMA API calls
>> to the arch code in the right way; this is a different check, to
>> catch things like the arch code passing the wrong domain into this
>> layer, or someone else having messed directly with the domain via
>> the IOMMU API. If the iommu_unmap doesn't match the IOVA region we
>> looked up, that means the IOMMU page tables have somehow become
>> inconsistent with the IOVA allocator, so we are in an unrecoverable
>> situation where we can no longer be sure what devices have access
>> to. That's bad.
>
> Sure, but the BUG_ON would also trigger on things like a double-free,
> which is bad to handle as a BUG_ON. A WARN_ON for this is sufficient.
Oh dear, it gets even better than that; in the case of a simple
double-unmap where the IOVA is already free, we wouldn't even get as far
as that check because we'd die calling iova_size(NULL). How on Earth did
I get to v5 without spotting that? :(
Anyway, on reflection I think you're probably right; I've clearly been
working on this for long enough to start falling into the "my thing is
obviously more important than all the other things" trap.
>> AFAIK, yes (this is just a slight tidyup of the existing code that
>> 32-bit Exynos/Tegra/Rockchip/etc. devices are already using) - the
>> display guys want increasingly massive contiguous allocations for
>> framebuffers, layers, etc., so having IOMMU magic deal with that
>> saves CMA for non-IOMMU devices that really need it.
>
> Makes sense, I thougt about something similar for x86 too to avoid the
> high-order allocations we currently do. I guess the buffer will later be
> mapped into the vmalloc space for the CPU?
Indeed - for non-coherent devices we have to remap all allocations
(IOMMU or not) anyway in order to get a non-cacheable CPU mapping of the
buffer, so having non-contiguous pages is no bother; for coherent
devices we can just do the same thing but keep the vmalloc mapping
cacheable. There's also the DMA_ATTR_NO_KERNEL_MAPPING case (e.g. GPU
just wants a big buffer to render into and read back out again) where we
wouldn't need a CPU address at all, although on arm64 vmalloc space is
cheap enough that we've no plans to implement that at the moment.
Robin.
next prev parent reply other threads:[~2015-08-11 13:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 17:18 [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Robin Murphy
2015-07-31 17:18 ` [PATCH v5 1/3] iommu: Implement common IOMMU ops for " Robin Murphy
2015-08-03 17:40 ` Catalin Marinas
2015-08-06 15:23 ` Will Deacon
2015-08-06 17:54 ` joro at 8bytes.org
2015-08-07 8:42 ` Joerg Roedel
2015-08-07 13:38 ` Robin Murphy
2015-08-11 9:37 ` Joerg Roedel
2015-08-11 13:31 ` Robin Murphy [this message]
2015-07-31 17:18 ` [PATCH v5 2/3] arm64: Add IOMMU dma_ops Robin Murphy
2015-08-03 17:33 ` Catalin Marinas
2015-08-07 8:52 ` Joerg Roedel
2015-08-07 15:27 ` Robin Murphy
2015-08-11 9:49 ` Joerg Roedel
2015-08-11 20:15 ` Robin Murphy
2015-09-22 17:12 ` Daniel Kurtz
2015-09-22 18:11 ` Robin Murphy
2015-07-31 17:18 ` [PATCH v5 3/3] arm64: Hook up " Robin Murphy
2015-08-07 8:55 ` Joerg Roedel
2015-08-26 6:19 ` [PATCH v5 0/3] arm64: IOMMU-backed DMA mapping Yong Wu
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=55C9F936.8080201@arm.com \
--to=robin.murphy@arm$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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