Lines Matching refs:iommu

4  * Based almost entirely upon the powerpc iommu allocator.
10 #include <linux/iommu-helper.h>
13 #include <asm/iommu-common.h>
19 static inline bool need_flush(struct iommu_map_table *iommu)
21 return ((iommu->flags & IOMMU_NEED_FLUSH) != 0);
24 static inline void set_flush(struct iommu_map_table *iommu)
26 iommu->flags |= IOMMU_NEED_FLUSH;
29 static inline void clear_flush(struct iommu_map_table *iommu)
31 iommu->flags &= ~IOMMU_NEED_FLUSH;
52 void iommu_tbl_pool_init(struct iommu_map_table *iommu,
60 struct iommu_pool *p = &(iommu->large_pool);
64 iommu->nr_pools = IOMMU_NR_POOLS;
66 iommu->nr_pools = npools;
69 iommu->table_shift = table_shift;
70 iommu->lazy_flush = lazy_flush;
73 iommu->flags |= IOMMU_NO_SPAN_BOUND;
75 iommu->flags |= IOMMU_HAS_LARGE_POOL;
78 iommu->poolsize = num_entries/iommu->nr_pools;
80 iommu->poolsize = (num_entries * 3 / 4)/iommu->nr_pools;
81 for (i = 0; i < iommu->nr_pools; i++) {
82 spin_lock_init(&(iommu->pools[i].lock));
83 iommu->pools[i].start = start;
84 iommu->pools[i].hint = start;
85 start += iommu->poolsize; /* start for next pool */
86 iommu->pools[i].end = start - 1;
98 struct iommu_map_table *iommu,
109 unsigned int npools = iommu->nr_pools;
111 bool large_pool = ((iommu->flags & IOMMU_HAS_LARGE_POOL) != 0);
126 pool = &(iommu->large_pool);
131 pool = &(iommu->pools[pool_nr]);
152 shift = iommu->table_map_base >> iommu->table_shift;
161 pool = &(iommu->pools[0]);
174 if ((iommu->flags & IOMMU_NO_SPAN_BOUND) != 0) {
176 boundary_size = iommu->poolsize * iommu->nr_pools;
179 iommu->table_shift);
181 n = iommu_area_alloc(iommu->map, limit, start, npages, shift,
187 set_flush(iommu);
190 } else if (!largealloc && pass <= iommu->nr_pools) {
192 pool_nr = (pool_nr + 1) & (iommu->nr_pools - 1);
193 pool = &(iommu->pools[pool_nr]);
196 set_flush(iommu);
205 if (iommu->lazy_flush &&
206 (n < pool->hint || need_flush(iommu))) {
207 clear_flush(iommu);
208 iommu->lazy_flush(iommu);
242 /* Caller supplies the index of the entry into the iommu map table
246 void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr,
251 unsigned long shift = iommu->table_shift;
254 entry = (dma_addr - iommu->table_map_base) >> shift;
255 pool = get_pool(iommu, entry);
258 bitmap_clear(iommu->map, entry, npages);