Skip to content

Commit 0cfdc72

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (33 commits) iommu/core: Remove global iommu_ops and register_iommu iommu/msm: Use bus_set_iommu instead of register_iommu iommu/omap: Use bus_set_iommu instead of register_iommu iommu/vt-d: Use bus_set_iommu instead of register_iommu iommu/amd: Use bus_set_iommu instead of register_iommu iommu/core: Use bus->iommu_ops in the iommu-api iommu/core: Convert iommu_found to iommu_present iommu/core: Add bus_type parameter to iommu_domain_alloc Driver core: Add iommu_ops to bus_type iommu/core: Define iommu_ops and register_iommu only with CONFIG_IOMMU_API iommu/amd: Fix wrong shift direction iommu/omap: always provide iommu debug code iommu/core: let drivers know if an iommu fault handler isn't installed iommu/core: export iommu_set_fault_handler() iommu/omap: Fix build error with !IOMMU_SUPPORT iommu/omap: Migrate to the generic fault report mechanism iommu/core: Add fault reporting mechanism iommu/core: Use PAGE_SIZE instead of hard-coded value iommu/core: use the existing IS_ALIGNED macro iommu/msm: ->unmap() should return order of unmapped page ... Fixup trivial conflicts in drivers/iommu/Makefile: "move omap iommu to dedicated iommu folder" vs "Rename the DMAR and INTR_REMAP config options" just happened to touch lines next to each other.
2 parents b48aeab + 1abb4ba commit 0cfdc72

File tree

28 files changed

+869
-647
lines changed

28 files changed

+869
-647
lines changed

arch/arm/mach-omap2/iommu2.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
((pgsz) == MMU_CAM_PGSZ_4K) ? 0xfffff000 : 0)
6767

6868

69-
static void __iommu_set_twl(struct iommu *obj, bool on)
69+
static void __iommu_set_twl(struct omap_iommu *obj, bool on)
7070
{
7171
u32 l = iommu_read_reg(obj, MMU_CNTL);
7272

@@ -85,7 +85,7 @@ static void __iommu_set_twl(struct iommu *obj, bool on)
8585
}
8686

8787

88-
static int omap2_iommu_enable(struct iommu *obj)
88+
static int omap2_iommu_enable(struct omap_iommu *obj)
8989
{
9090
u32 l, pa;
9191
unsigned long timeout;
@@ -127,7 +127,7 @@ static int omap2_iommu_enable(struct iommu *obj)
127127
return 0;
128128
}
129129

130-
static void omap2_iommu_disable(struct iommu *obj)
130+
static void omap2_iommu_disable(struct omap_iommu *obj)
131131
{
132132
u32 l = iommu_read_reg(obj, MMU_CNTL);
133133

@@ -138,12 +138,12 @@ static void omap2_iommu_disable(struct iommu *obj)
138138
dev_dbg(obj->dev, "%s is shutting down\n", obj->name);
139139
}
140140

141-
static void omap2_iommu_set_twl(struct iommu *obj, bool on)
141+
static void omap2_iommu_set_twl(struct omap_iommu *obj, bool on)
142142
{
143143
__iommu_set_twl(obj, false);
144144
}
145145

146-
static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
146+
static u32 omap2_iommu_fault_isr(struct omap_iommu *obj, u32 *ra)
147147
{
148148
u32 stat, da;
149149
u32 errs = 0;
@@ -173,13 +173,13 @@ static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
173173
return errs;
174174
}
175175

176-
static void omap2_tlb_read_cr(struct iommu *obj, struct cr_regs *cr)
176+
static void omap2_tlb_read_cr(struct omap_iommu *obj, struct cr_regs *cr)
177177
{
178178
cr->cam = iommu_read_reg(obj, MMU_READ_CAM);
179179
cr->ram = iommu_read_reg(obj, MMU_READ_RAM);
180180
}
181181

182-
static void omap2_tlb_load_cr(struct iommu *obj, struct cr_regs *cr)
182+
static void omap2_tlb_load_cr(struct omap_iommu *obj, struct cr_regs *cr)
183183
{
184184
iommu_write_reg(obj, cr->cam | MMU_CAM_V, MMU_CAM);
185185
iommu_write_reg(obj, cr->ram, MMU_RAM);
@@ -193,7 +193,8 @@ static u32 omap2_cr_to_virt(struct cr_regs *cr)
193193
return cr->cam & mask;
194194
}
195195

196-
static struct cr_regs *omap2_alloc_cr(struct iommu *obj, struct iotlb_entry *e)
196+
static struct cr_regs *omap2_alloc_cr(struct omap_iommu *obj,
197+
struct iotlb_entry *e)
197198
{
198199
struct cr_regs *cr;
199200

@@ -230,7 +231,8 @@ static u32 omap2_get_pte_attr(struct iotlb_entry *e)
230231
return attr;
231232
}
232233

233-
static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
234+
static ssize_t
235+
omap2_dump_cr(struct omap_iommu *obj, struct cr_regs *cr, char *buf)
234236
{
235237
char *p = buf;
236238

@@ -254,7 +256,8 @@ static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
254256
goto out; \
255257
} while (0)
256258

257-
static ssize_t omap2_iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t len)
259+
static ssize_t
260+
omap2_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len)
258261
{
259262
char *p = buf;
260263

@@ -280,7 +283,7 @@ static ssize_t omap2_iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t len)
280283
return p - buf;
281284
}
282285

283-
static void omap2_iommu_save_ctx(struct iommu *obj)
286+
static void omap2_iommu_save_ctx(struct omap_iommu *obj)
284287
{
285288
int i;
286289
u32 *p = obj->ctx;
@@ -293,7 +296,7 @@ static void omap2_iommu_save_ctx(struct iommu *obj)
293296
BUG_ON(p[0] != IOMMU_ARCH_VERSION);
294297
}
295298

296-
static void omap2_iommu_restore_ctx(struct iommu *obj)
299+
static void omap2_iommu_restore_ctx(struct omap_iommu *obj)
297300
{
298301
int i;
299302
u32 *p = obj->ctx;
@@ -343,13 +346,13 @@ static const struct iommu_functions omap2_iommu_ops = {
343346

344347
static int __init omap2_iommu_init(void)
345348
{
346-
return install_iommu_arch(&omap2_iommu_ops);
349+
return omap_install_iommu_arch(&omap2_iommu_ops);
347350
}
348351
module_init(omap2_iommu_init);
349352

350353
static void __exit omap2_iommu_exit(void)
351354
{
352-
uninstall_iommu_arch(&omap2_iommu_ops);
355+
omap_uninstall_iommu_arch(&omap2_iommu_ops);
353356
}
354357
module_exit(omap2_iommu_exit);
355358

arch/arm/plat-omap/Kconfig

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ config OMAP_MBOX_KFIFO_SIZE
134134
This can also be changed at runtime (via the mbox_kfifo_size
135135
module parameter).
136136

137-
config OMAP_IOMMU
138-
tristate
139-
140-
config OMAP_IOMMU_DEBUG
141-
tristate "Export OMAP IOMMU internals in DebugFS"
142-
depends on OMAP_IOMMU && DEBUG_FS
143-
help
144-
Select this to see extensive information about
145-
the internal state of OMAP IOMMU in debugfs.
146-
147-
Say N unless you know you need this.
148-
149137
config OMAP_IOMMU_IVA2
150138
bool
151139

arch/arm/plat-omap/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ obj-$(CONFIG_ARCH_OMAP3) += omap_device.o
1818
obj-$(CONFIG_ARCH_OMAP4) += omap_device.o
1919

2020
obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
21-
obj-$(CONFIG_OMAP_IOMMU) += iommu.o iovmm.o
22-
obj-$(CONFIG_OMAP_IOMMU_DEBUG) += iommu-debug.o
2321

2422
obj-$(CONFIG_CPU_FREQ) += cpu-omap.o
2523
obj-$(CONFIG_OMAP_DM_TIMER) += dmtimer.o

arch/arm/plat-omap/include/plat/iommu.h

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ struct iotlb_entry {
2525
};
2626
};
2727

28-
struct iommu {
28+
struct omap_iommu {
2929
const char *name;
3030
struct module *owner;
3131
struct clk *clk;
3232
void __iomem *regbase;
3333
struct device *dev;
3434
void *isr_priv;
35+
struct iommu_domain *domain;
3536

3637
unsigned int refcount;
37-
struct mutex iommu_lock; /* global for this whole object */
38+
spinlock_t iommu_lock; /* global for this whole object */
3839

3940
/*
4041
* We don't change iopgd for a situation like pgd for a task,
@@ -48,8 +49,6 @@ struct iommu {
4849
struct list_head mmap;
4950
struct mutex mmap_lock; /* protect mmap */
5051

51-
int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs, void *priv);
52-
5352
void *ctx; /* iommu context: registres saved area */
5453
u32 da_start;
5554
u32 da_end;
@@ -81,25 +80,27 @@ struct iotlb_lock {
8180
struct iommu_functions {
8281
unsigned long version;
8382

84-
int (*enable)(struct iommu *obj);
85-
void (*disable)(struct iommu *obj);
86-
void (*set_twl)(struct iommu *obj, bool on);
87-
u32 (*fault_isr)(struct iommu *obj, u32 *ra);
83+
int (*enable)(struct omap_iommu *obj);
84+
void (*disable)(struct omap_iommu *obj);
85+
void (*set_twl)(struct omap_iommu *obj, bool on);
86+
u32 (*fault_isr)(struct omap_iommu *obj, u32 *ra);
8887

89-
void (*tlb_read_cr)(struct iommu *obj, struct cr_regs *cr);
90-
void (*tlb_load_cr)(struct iommu *obj, struct cr_regs *cr);
88+
void (*tlb_read_cr)(struct omap_iommu *obj, struct cr_regs *cr);
89+
void (*tlb_load_cr)(struct omap_iommu *obj, struct cr_regs *cr);
9190

92-
struct cr_regs *(*alloc_cr)(struct iommu *obj, struct iotlb_entry *e);
91+
struct cr_regs *(*alloc_cr)(struct omap_iommu *obj,
92+
struct iotlb_entry *e);
9393
int (*cr_valid)(struct cr_regs *cr);
9494
u32 (*cr_to_virt)(struct cr_regs *cr);
9595
void (*cr_to_e)(struct cr_regs *cr, struct iotlb_entry *e);
96-
ssize_t (*dump_cr)(struct iommu *obj, struct cr_regs *cr, char *buf);
96+
ssize_t (*dump_cr)(struct omap_iommu *obj, struct cr_regs *cr,
97+
char *buf);
9798

9899
u32 (*get_pte_attr)(struct iotlb_entry *e);
99100

100-
void (*save_ctx)(struct iommu *obj);
101-
void (*restore_ctx)(struct iommu *obj);
102-
ssize_t (*dump_ctx)(struct iommu *obj, char *buf, ssize_t len);
101+
void (*save_ctx)(struct omap_iommu *obj);
102+
void (*restore_ctx)(struct omap_iommu *obj);
103+
ssize_t (*dump_ctx)(struct omap_iommu *obj, char *buf, ssize_t len);
103104
};
104105

105106
struct iommu_platform_data {
@@ -150,40 +151,31 @@ struct iommu_platform_data {
150151
/*
151152
* global functions
152153
*/
153-
extern u32 iommu_arch_version(void);
154-
155-
extern void iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
156-
extern u32 iotlb_cr_to_virt(struct cr_regs *cr);
157-
158-
extern int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e);
159-
extern void iommu_set_twl(struct iommu *obj, bool on);
160-
extern void flush_iotlb_page(struct iommu *obj, u32 da);
161-
extern void flush_iotlb_range(struct iommu *obj, u32 start, u32 end);
162-
extern void flush_iotlb_all(struct iommu *obj);
163-
164-
extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e);
165-
extern void iopgtable_lookup_entry(struct iommu *obj, u32 da, u32 **ppgd,
166-
u32 **ppte);
167-
extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova);
168-
169-
extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
170-
extern struct iommu *iommu_get(const char *name);
171-
extern void iommu_put(struct iommu *obj);
172-
extern int iommu_set_isr(const char *name,
173-
int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
154+
extern u32 omap_iommu_arch_version(void);
155+
156+
extern void omap_iotlb_cr_to_e(struct cr_regs *cr, struct iotlb_entry *e);
157+
158+
extern int
159+
omap_iopgtable_store_entry(struct omap_iommu *obj, struct iotlb_entry *e);
160+
161+
extern int omap_iommu_set_isr(const char *name,
162+
int (*isr)(struct omap_iommu *obj, u32 da, u32 iommu_errs,
174163
void *priv),
175164
void *isr_priv);
176165

177-
extern void iommu_save_ctx(struct iommu *obj);
178-
extern void iommu_restore_ctx(struct iommu *obj);
166+
extern void omap_iommu_save_ctx(struct omap_iommu *obj);
167+
extern void omap_iommu_restore_ctx(struct omap_iommu *obj);
179168

180-
extern int install_iommu_arch(const struct iommu_functions *ops);
181-
extern void uninstall_iommu_arch(const struct iommu_functions *ops);
169+
extern int omap_install_iommu_arch(const struct iommu_functions *ops);
170+
extern void omap_uninstall_iommu_arch(const struct iommu_functions *ops);
182171

183-
extern int foreach_iommu_device(void *data,
172+
extern int omap_foreach_iommu_device(void *data,
184173
int (*fn)(struct device *, void *));
185174

186-
extern ssize_t iommu_dump_ctx(struct iommu *obj, char *buf, ssize_t len);
187-
extern size_t dump_tlb_entries(struct iommu *obj, char *buf, ssize_t len);
175+
extern ssize_t
176+
omap_iommu_dump_ctx(struct omap_iommu *obj, char *buf, ssize_t len);
177+
extern size_t
178+
omap_dump_tlb_entries(struct omap_iommu *obj, char *buf, ssize_t len);
179+
struct device *omap_find_iommu_device(const char *name);
188180

189181
#endif /* __MACH_IOMMU_H */

arch/arm/plat-omap/include/plat/iommu2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@
8383
/*
8484
* register accessors
8585
*/
86-
static inline u32 iommu_read_reg(struct iommu *obj, size_t offs)
86+
static inline u32 iommu_read_reg(struct omap_iommu *obj, size_t offs)
8787
{
8888
return __raw_readl(obj->regbase + offs);
8989
}
9090

91-
static inline void iommu_write_reg(struct iommu *obj, u32 val, size_t offs)
91+
static inline void iommu_write_reg(struct omap_iommu *obj, u32 val, size_t offs)
9292
{
9393
__raw_writel(val, obj->regbase + offs);
9494
}

arch/arm/plat-omap/iopgtable.h renamed to arch/arm/plat-omap/include/plat/iopgtable.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@
5656

5757
#define IOPAGE_MASK IOPTE_MASK
5858

59+
/**
60+
* omap_iommu_translate() - va to pa translation
61+
* @d: omap iommu descriptor
62+
* @va: virtual address
63+
* @mask: omap iommu descriptor mask
64+
*
65+
* va to pa translation
66+
*/
67+
static inline phys_addr_t omap_iommu_translate(u32 d, u32 va, u32 mask)
68+
{
69+
return (d & mask) | (va & (~mask));
70+
}
71+
5972
/*
6073
* some descriptor attributes.
6174
*/
@@ -64,10 +77,15 @@
6477
#define IOPGD_SUPER (1 << 18 | 2 << 0)
6578

6679
#define iopgd_is_table(x) (((x) & 3) == IOPGD_TABLE)
80+
#define iopgd_is_section(x) (((x) & (1 << 18 | 3)) == IOPGD_SECTION)
81+
#define iopgd_is_super(x) (((x) & (1 << 18 | 3)) == IOPGD_SUPER)
6782

6883
#define IOPTE_SMALL (2 << 0)
6984
#define IOPTE_LARGE (1 << 0)
7085

86+
#define iopte_is_small(x) (((x) & 2) == IOPTE_SMALL)
87+
#define iopte_is_large(x) (((x) & 3) == IOPTE_LARGE)
88+
7189
/* to find an entry in a page-table-directory */
7290
#define iopgd_index(da) (((da) >> IOPGD_SHIFT) & (PTRS_PER_IOPGD - 1))
7391
#define iopgd_offset(obj, da) ((obj)->iopgd + iopgd_index(da))
@@ -97,6 +115,6 @@ static inline u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa,
97115
}
98116

99117
#define to_iommu(dev) \
100-
(struct iommu *)platform_get_drvdata(to_platform_device(dev))
118+
(struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))
101119

102120
#endif /* __PLAT_OMAP_IOMMU_H */

arch/arm/plat-omap/include/plat/iovmm.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
#ifndef __IOMMU_MMAP_H
1414
#define __IOMMU_MMAP_H
1515

16+
#include <linux/iommu.h>
17+
1618
struct iovm_struct {
17-
struct iommu *iommu; /* iommu object which this belongs to */
19+
struct omap_iommu *iommu; /* iommu object which this belongs to */
1820
u32 da_start; /* area definition */
1921
u32 da_end;
2022
u32 flags; /* IOVMF_: see below */
@@ -70,20 +72,18 @@ struct iovm_struct {
7072
#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
7173

7274

73-
extern struct iovm_struct *find_iovm_area(struct iommu *obj, u32 da);
74-
extern u32 iommu_vmap(struct iommu *obj, u32 da,
75+
extern struct iovm_struct *omap_find_iovm_area(struct omap_iommu *obj, u32 da);
76+
extern u32
77+
omap_iommu_vmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da,
7578
const struct sg_table *sgt, u32 flags);
76-
extern struct sg_table *iommu_vunmap(struct iommu *obj, u32 da);
77-
extern u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes,
78-
u32 flags);
79-
extern void iommu_vfree(struct iommu *obj, const u32 da);
80-
extern u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
81-
u32 flags);
82-
extern void iommu_kunmap(struct iommu *obj, u32 da);
83-
extern u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes,
84-
u32 flags);
85-
extern void iommu_kfree(struct iommu *obj, u32 da);
86-
87-
extern void *da_to_va(struct iommu *obj, u32 da);
79+
extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
80+
struct omap_iommu *obj, u32 da);
81+
extern u32
82+
omap_iommu_vmalloc(struct iommu_domain *domain, struct omap_iommu *obj,
83+
u32 da, size_t bytes, u32 flags);
84+
extern void
85+
omap_iommu_vfree(struct iommu_domain *domain, struct omap_iommu *obj,
86+
const u32 da);
87+
extern void *omap_da_to_va(struct omap_iommu *obj, u32 da);
8888

8989
#endif /* __IOMMU_MMAP_H */

arch/ia64/kvm/kvm-ia64.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/uaccess.h>
3434
#include <linux/iommu.h>
3535
#include <linux/intel-iommu.h>
36+
#include <linux/pci.h>
3637

3738
#include <asm/pgtable.h>
3839
#include <asm/gcc_intrin.h>
@@ -204,7 +205,7 @@ int kvm_dev_ioctl_check_extension(long ext)
204205
r = KVM_COALESCED_MMIO_PAGE_OFFSET;
205206
break;
206207
case KVM_CAP_IOMMU:
207-
r = iommu_found();
208+
r = iommu_present(&pci_bus_type);
208209
break;
209210
default:
210211
r = 0;

0 commit comments

Comments
 (0)