]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
iommu/io-pgtable-arm: Don't use dma_to_phys()
authorRobin Murphy <Robin.Murphy@arm.com>
Thu, 17 Sep 2015 16:42:16 +0000 (17:42 +0100)
committerWill Deacon <will.deacon@arm.com>
Tue, 22 Sep 2015 16:35:33 +0000 (17:35 +0100)
commitffcb6d1686ceb4a6b50776fb2597ab0e4dd79040
tree55f734b2d6a0ee79b0c0e5ede21e7a94feadd0c4
parent6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f
iommu/io-pgtable-arm: Don't use dma_to_phys()

In checking whether DMA addresses differ from physical addresses, using
dma_to_phys() is actually the wrong thing to do, since it may hide any
DMA offset, which is precisely one of the things we are checking for.
Simply casting between the two address types, whilst ugly, is in fact
the appropriate course of action. Further care (and ugliness) is also
necessary in the comparison to avoid truncation if phys_addr_t and
dma_addr_t differ in size.

We can also reject any device with a fixed DMA offset up-front at page
table creation, leaving the allocation-time check for the more subtle
cases like bounce buffering due to an incorrect DMA mask.

Furthermore, we can then fix the hackish KConfig dependency so that
architectures without a dma_to_phys() implementation may still
COMPILE_TEST (or even use!) the code. The true dependency is on the
DMA API, so use the appropriate symbol for that.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[will: folded in selftest fix from Yong Wu]
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/Kconfig
drivers/iommu/io-pgtable-arm.c