aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 17:53:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-16 17:53:01 -0500
commit6f51ee709e4c6b56f2c2a071da2d056a109b9d26 (patch)
tree3287f25e522e362725b8a2fe72f8862f17ddb8ba /include/linux
parent205dc205ed3ba748bab9770016bbbffb68558146 (diff)
parentfd522d279235b8bcafc39c1040895fe2d938d1e7 (diff)
Merge tag 'iommu-config-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC/iommu configuration update from Arnd Bergmann: "The iomm-config branch contains work from Will Deacon, quoting his description: This series adds automatic IOMMU and DMA-mapping configuration for OF-based DMA masters described using the generic IOMMU devicetree bindings. Although there is plenty of future work around splitting up iommu_ops, adding default IOMMU domains and sorting out automatic IOMMU group creation for the platform_bus, this is already useful enough for people to port over their IOMMU drivers and start using the new probing infrastructure (indeed, Marek has patches queued for the Exynos IOMMU). The branch touches core ARM and IOMMU driver files, and the respective maintainers (Russell King and Joerg Roedel) agreed to have the contents merged through the arm-soc tree. The final version was ready just before the merge window, so we ended up delaying it a bit longer than the rest, but we don't expect to see regressions because this is just additional infrastructure that will get used in drivers starting in 3.20 but is unused so far" * tag 'iommu-config-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: iommu: store DT-probed IOMMU data privately arm: dma-mapping: plumb our iommu mapping ops into arch_setup_dma_ops arm: call iommu_init before of_platform_populate dma-mapping: detect and configure IOMMU in of_dma_configure iommu: fix initialization without 'add_device' callback iommu: provide helper function to configure an IOMMU for an of master iommu: add new iommu_ops callback for adding an OF device dma-mapping: replace set_arch_dma_coherent_ops with arch_setup_dma_ops iommu: provide early initialisation hook for IOMMU drivers
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/dma-mapping.h13
-rw-r--r--include/linux/iommu.h8
-rw-r--r--include/linux/of_iommu.h23
3 files changed, 39 insertions, 5 deletions
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index d5d388160f42..c3007cb4bfa6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -129,11 +129,14 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
129 129
130extern u64 dma_get_required_mask(struct device *dev); 130extern u64 dma_get_required_mask(struct device *dev);
131 131
132#ifndef set_arch_dma_coherent_ops 132#ifndef arch_setup_dma_ops
133static inline int set_arch_dma_coherent_ops(struct device *dev) 133static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
134{ 134 u64 size, struct iommu_ops *iommu,
135 return 0; 135 bool coherent) { }
136} 136#endif
137
138#ifndef arch_teardown_dma_ops
139static inline void arch_teardown_dma_ops(struct device *dev) { }
137#endif 140#endif
138 141
139static inline unsigned int dma_get_max_seg_size(struct device *dev) 142static inline unsigned int dma_get_max_seg_size(struct device *dev)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 7a7bd15e54f1..38daa453f2e5 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/of.h>
24#include <linux/types.h> 25#include <linux/types.h>
25#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
26#include <trace/events/iommu.h> 27#include <trace/events/iommu.h>
@@ -106,7 +107,9 @@ enum iommu_attr {
106 * @remove_device: remove device from iommu grouping 107 * @remove_device: remove device from iommu grouping
107 * @domain_get_attr: Query domain attributes 108 * @domain_get_attr: Query domain attributes
108 * @domain_set_attr: Change domain attributes 109 * @domain_set_attr: Change domain attributes
110 * @of_xlate: add OF master IDs to iommu grouping
109 * @pgsize_bitmap: bitmap of supported page sizes 111 * @pgsize_bitmap: bitmap of supported page sizes
112 * @priv: per-instance data private to the iommu driver
110 */ 113 */
111struct iommu_ops { 114struct iommu_ops {
112 bool (*capable)(enum iommu_cap); 115 bool (*capable)(enum iommu_cap);
@@ -138,7 +141,12 @@ struct iommu_ops {
138 /* Get the numer of window per domain */ 141 /* Get the numer of window per domain */
139 u32 (*domain_get_windows)(struct iommu_domain *domain); 142 u32 (*domain_get_windows)(struct iommu_domain *domain);
140 143
144#ifdef CONFIG_OF_IOMMU
145 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
146#endif
147
141 unsigned long pgsize_bitmap; 148 unsigned long pgsize_bitmap;
149 void *priv;
142}; 150};
143 151
144#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */ 152#define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h
index 51a560f34bca..16c75547d725 100644
--- a/include/linux/of_iommu.h
+++ b/include/linux/of_iommu.h
@@ -1,12 +1,19 @@
1#ifndef __OF_IOMMU_H 1#ifndef __OF_IOMMU_H
2#define __OF_IOMMU_H 2#define __OF_IOMMU_H
3 3
4#include <linux/device.h>
5#include <linux/iommu.h>
6#include <linux/of.h>
7
4#ifdef CONFIG_OF_IOMMU 8#ifdef CONFIG_OF_IOMMU
5 9
6extern int of_get_dma_window(struct device_node *dn, const char *prefix, 10extern int of_get_dma_window(struct device_node *dn, const char *prefix,
7 int index, unsigned long *busno, dma_addr_t *addr, 11 int index, unsigned long *busno, dma_addr_t *addr,
8 size_t *size); 12 size_t *size);
9 13
14extern void of_iommu_init(void);
15extern struct iommu_ops *of_iommu_configure(struct device *dev);
16
10#else 17#else
11 18
12static inline int of_get_dma_window(struct device_node *dn, const char *prefix, 19static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
@@ -16,6 +23,22 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix,
16 return -EINVAL; 23 return -EINVAL;
17} 24}
18 25
26static inline void of_iommu_init(void) { }
27static inline struct iommu_ops *of_iommu_configure(struct device *dev)
28{
29 return NULL;
30}
31
19#endif /* CONFIG_OF_IOMMU */ 32#endif /* CONFIG_OF_IOMMU */
20 33
34void of_iommu_set_ops(struct device_node *np, struct iommu_ops *ops);
35struct iommu_ops *of_iommu_get_ops(struct device_node *np);
36
37extern struct of_device_id __iommu_of_table;
38
39typedef int (*of_iommu_init_fn)(struct device_node *);
40
41#define IOMMU_OF_DECLARE(name, compat, fn) \
42 _OF_DECLARE(iommu, name, compat, fn, of_iommu_init_fn)
43
21#endif /* __OF_IOMMU_H */ 44#endif /* __OF_IOMMU_H */