Lines Matching refs:iommu

22 static inline bool need_flush(struct iommu_map_table *iommu)  in need_flush()  argument
24 return ((iommu->flags & IOMMU_NEED_FLUSH) != 0); in need_flush()
27 static inline void set_flush(struct iommu_map_table *iommu) in set_flush() argument
29 iommu->flags |= IOMMU_NEED_FLUSH; in set_flush()
32 static inline void clear_flush(struct iommu_map_table *iommu) in clear_flush() argument
34 iommu->flags &= ~IOMMU_NEED_FLUSH; in clear_flush()
55 void iommu_tbl_pool_init(struct iommu_map_table *iommu, in iommu_tbl_pool_init() argument
63 struct iommu_pool *p = &(iommu->large_pool); in iommu_tbl_pool_init()
67 iommu->nr_pools = IOMMU_NR_POOLS; in iommu_tbl_pool_init()
69 iommu->nr_pools = npools; in iommu_tbl_pool_init()
72 iommu->table_shift = table_shift; in iommu_tbl_pool_init()
73 iommu->lazy_flush = lazy_flush; in iommu_tbl_pool_init()
76 iommu->flags |= IOMMU_NO_SPAN_BOUND; in iommu_tbl_pool_init()
78 iommu->flags |= IOMMU_HAS_LARGE_POOL; in iommu_tbl_pool_init()
81 iommu->poolsize = num_entries/iommu->nr_pools; in iommu_tbl_pool_init()
83 iommu->poolsize = (num_entries * 3 / 4)/iommu->nr_pools; in iommu_tbl_pool_init()
84 for (i = 0; i < iommu->nr_pools; i++) { in iommu_tbl_pool_init()
85 spin_lock_init(&(iommu->pools[i].lock)); in iommu_tbl_pool_init()
86 iommu->pools[i].start = start; in iommu_tbl_pool_init()
87 iommu->pools[i].hint = start; in iommu_tbl_pool_init()
88 start += iommu->poolsize; /* start for next pool */ in iommu_tbl_pool_init()
89 iommu->pools[i].end = start - 1; in iommu_tbl_pool_init()
102 struct iommu_map_table *iommu, in iommu_tbl_range_alloc() argument
113 unsigned int npools = iommu->nr_pools; in iommu_tbl_range_alloc()
115 bool large_pool = ((iommu->flags & IOMMU_HAS_LARGE_POOL) != 0); in iommu_tbl_range_alloc()
130 pool = &(iommu->large_pool); in iommu_tbl_range_alloc()
135 pool = &(iommu->pools[pool_nr]); in iommu_tbl_range_alloc()
156 shift = iommu->table_map_base >> iommu->table_shift; in iommu_tbl_range_alloc()
165 pool = &(iommu->pools[0]); in iommu_tbl_range_alloc()
175 1 << iommu->table_shift); in iommu_tbl_range_alloc()
177 boundary_size = ALIGN(1ULL << 32, 1 << iommu->table_shift); in iommu_tbl_range_alloc()
179 boundary_size = boundary_size >> iommu->table_shift; in iommu_tbl_range_alloc()
185 if ((iommu->flags & IOMMU_NO_SPAN_BOUND) != 0) { in iommu_tbl_range_alloc()
187 boundary_size = iommu->poolsize * iommu->nr_pools; in iommu_tbl_range_alloc()
189 n = iommu_area_alloc(iommu->map, limit, start, npages, shift, in iommu_tbl_range_alloc()
195 set_flush(iommu); in iommu_tbl_range_alloc()
198 } else if (!largealloc && pass <= iommu->nr_pools) { in iommu_tbl_range_alloc()
200 pool_nr = (pool_nr + 1) & (iommu->nr_pools - 1); in iommu_tbl_range_alloc()
201 pool = &(iommu->pools[pool_nr]); in iommu_tbl_range_alloc()
204 set_flush(iommu); in iommu_tbl_range_alloc()
213 if (iommu->lazy_flush && in iommu_tbl_range_alloc()
214 (n < pool->hint || need_flush(iommu))) { in iommu_tbl_range_alloc()
215 clear_flush(iommu); in iommu_tbl_range_alloc()
216 iommu->lazy_flush(iommu); in iommu_tbl_range_alloc()
255 void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, in iommu_tbl_range_free() argument
260 unsigned long shift = iommu->table_shift; in iommu_tbl_range_free()
263 entry = (dma_addr - iommu->table_map_base) >> shift; in iommu_tbl_range_free()
264 pool = get_pool(iommu, entry); in iommu_tbl_range_free()
267 bitmap_clear(iommu->map, entry, npages); in iommu_tbl_range_free()