Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu: export iommu_is_span_boundary helper function

iommu_is_span_boundary is used internally in the IOMMU helper
(lib/iommu-helper.c), a primitive function that judges whether a memory area
spans LLD's segment boundary or not.

It's difficult to convert some IOMMUs to use the IOMMU helper but
iommu_is_span_boundary is still useful for them. So this patch exports it.

This is needed for the parisc iommu fixes.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Kyle McMartin <kyle@parisc-linux.org>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Grant Grundler <grundler@parisc-linux.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

FUJITA Tomonori and committed by
Linus Torvalds
3715863a 7eb701dc

+9 -4
+3
include/linux/iommu-helper.h
··· 1 + extern int iommu_is_span_boundary(unsigned int index, unsigned int nr, 2 + unsigned long shift, 3 + unsigned long boundary_size); 1 4 extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, 2 5 unsigned long start, unsigned int nr, 3 6 unsigned long shift,
+6 -4
lib/iommu-helper.c
··· 40 40 } 41 41 } 42 42 43 - static inline int is_span_boundary(unsigned int index, unsigned int nr, 44 - unsigned long shift, 45 - unsigned long boundary_size) 43 + int iommu_is_span_boundary(unsigned int index, unsigned int nr, 44 + unsigned long shift, 45 + unsigned long boundary_size) 46 46 { 47 + BUG_ON(!is_power_of_2(boundary_size)); 48 + 47 49 shift = (shift + index) & (boundary_size - 1); 48 50 return shift + nr > boundary_size; 49 51 } ··· 59 57 again: 60 58 index = find_next_zero_area(map, size, start, nr, align_mask); 61 59 if (index != -1) { 62 - if (is_span_boundary(index, nr, shift, boundary_size)) { 60 + if (iommu_is_span_boundary(index, nr, shift, boundary_size)) { 63 61 /* we could do more effectively */ 64 62 start = index + 1; 65 63 goto again;