aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iommu.h
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2011-11-10 04:32:26 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2011-11-10 05:40:37 -0500
commit7d3002cc8c160dbda0e6ab9cd66dc6eb401b8b70 (patch)
tree453bad0319d12fc0a3fe6594b8e212615e7e2a70 /include/linux/iommu.h
parent5009065d38c95455bd2d27c2838313e3dd0c5bc7 (diff)
iommu/core: split mapping to page sizes as supported by the hardware
When mapping a memory region, split it to page sizes as supported by the iommu hardware. Always prefer bigger pages, when possible, in order to reduce the TLB pressure. The logic to do that is now added to the IOMMU core, so neither the iommu drivers themselves nor users of the IOMMU API have to duplicate it. This allows a more lenient granularity of mappings; traditionally the IOMMU API took 'order' (of a page) as a mapping size, and directly let the low level iommu drivers handle the mapping, but now that the IOMMU core can split arbitrary memory regions into pages, we can remove this limitation, so users don't have to split those regions by themselves. Currently the supported page sizes are advertised once and they then remain static. That works well for OMAP and MSM but it would probably not fly well with intel's hardware, where the page size capabilities seem to have the potential to be different between several DMA remapping devices. register_iommu() currently sets a default pgsize behavior, so we can convert the IOMMU drivers in subsequent patches. After all the drivers are converted, the temporary default settings will be removed. Mainline users of the IOMMU API (kvm and omap-iovmm) are adopted to deal with bytes instead of page order. Many thanks to Joerg Roedel <Joerg.Roedel@amd.com> for significant review! Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Cc: David Brown <davidb@codeaurora.org> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Joerg Roedel <Joerg.Roedel@amd.com> Cc: Stepan Moskovchenko <stepanm@codeaurora.org> Cc: KyongHo Cho <pullip.cho@samsung.com> Cc: Hiroshi DOYU <hdoyu@nvidia.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: kvm@vger.kernel.org Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'include/linux/iommu.h')
-rw-r--r--include/linux/iommu.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d5ebf3f4dd53..cc26f89c4ee6 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -48,6 +48,19 @@ struct iommu_domain {
48 48
49#ifdef CONFIG_IOMMU_API 49#ifdef CONFIG_IOMMU_API
50 50
51/**
52 * struct iommu_ops - iommu ops and capabilities
53 * @domain_init: init iommu domain
54 * @domain_destroy: destroy iommu domain
55 * @attach_dev: attach device to an iommu domain
56 * @detach_dev: detach device from an iommu domain
57 * @map: map a physically contiguous memory region to an iommu domain
58 * @unmap: unmap a physically contiguous memory region from an iommu domain
59 * @iova_to_phys: translate iova to physical address
60 * @domain_has_cap: domain capabilities query
61 * @commit: commit iommu domain
62 * @pgsize_bitmap: bitmap of supported page sizes
63 */
51struct iommu_ops { 64struct iommu_ops {
52 int (*domain_init)(struct iommu_domain *domain); 65 int (*domain_init)(struct iommu_domain *domain);
53 void (*domain_destroy)(struct iommu_domain *domain); 66 void (*domain_destroy)(struct iommu_domain *domain);
@@ -61,6 +74,7 @@ struct iommu_ops {
61 unsigned long iova); 74 unsigned long iova);
62 int (*domain_has_cap)(struct iommu_domain *domain, 75 int (*domain_has_cap)(struct iommu_domain *domain,
63 unsigned long cap); 76 unsigned long cap);
77 unsigned long pgsize_bitmap;
64}; 78};
65 79
66extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops); 80extern int bus_set_iommu(struct bus_type *bus, struct iommu_ops *ops);
@@ -72,9 +86,9 @@ extern int iommu_attach_device(struct iommu_domain *domain,
72extern void iommu_detach_device(struct iommu_domain *domain, 86extern void iommu_detach_device(struct iommu_domain *domain,
73 struct device *dev); 87 struct device *dev);
74extern int iommu_map(struct iommu_domain *domain, unsigned long iova, 88extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
75 phys_addr_t paddr, int gfp_order, int prot); 89 phys_addr_t paddr, size_t size, int prot);
76extern int iommu_unmap(struct iommu_domain *domain, unsigned long iova, 90extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
77 int gfp_order); 91 size_t size);
78extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, 92extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
79 unsigned long iova); 93 unsigned long iova);
80extern int iommu_domain_has_cap(struct iommu_domain *domain, 94extern int iommu_domain_has_cap(struct iommu_domain *domain,