Skip to content

Commit a852250

Browse files
fujitatorvalds
authored andcommitted
swiotlb: use iommu_is_span_boundary helper function
iommu_is_span_boundary in lib/iommu-helper.c was exported for PARISC IOMMUs (commit 3715863). SWIOTLB can use it instead of the homegrown function. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Tony Luck <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a7133a1 commit a852250

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

‎arch/ia64/Kconfig‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ config MMU
4747
config SWIOTLB
4848
bool
4949

50+
config IOMMU_HELPER
51+
bool
52+
5053
config GENERIC_LOCKBREAK
5154
bool
5255
default y
@@ -615,7 +618,7 @@ config IRQ_PER_CPU
615618
default y
616619

617620
config IOMMU_HELPER
618-
def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC)
621+
def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC || SWIOTLB)
619622

620623
source "arch/ia64/hp/sim/Kconfig"
621624

‎arch/x86/Kconfig‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,6 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
537537
Calgary anyway, pass 'iommu=calgary' on the kernel command line.
538538
If unsure, say Y.
539539

540-
config IOMMU_HELPER
541-
def_bool (CALGARY_IOMMU || GART_IOMMU)
542-
543540
# need this always selected by IOMMU for the VIA workaround
544541
config SWIOTLB
545542
bool
@@ -550,6 +547,8 @@ config SWIOTLB
550547
access 32-bits of memory can be used on systems with more than
551548
3 GB of memory. If unsure, say Y.
552549

550+
config IOMMU_HELPER
551+
def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB)
553552

554553
config NR_CPUS
555554
int "Maximum number of CPUs (2-255)"

‎lib/swiotlb.c‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include <linux/init.h>
3333
#include <linux/bootmem.h>
34+
#include <linux/iommu-helper.h>
3435

3536
#define OFFSET(val,align) ((unsigned long) \
3637
( (val) & ( (align) - 1)))
@@ -282,15 +283,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr)
282283
return (addr & ~mask) != 0;
283284
}
284285

285-
static inline unsigned int is_span_boundary(unsigned int index,
286-
unsigned int nslots,
287-
unsigned long offset_slots,
288-
unsigned long max_slots)
289-
{
290-
unsigned long offset = (offset_slots + index) & (max_slots - 1);
291-
return offset + nslots > max_slots;
292-
}
293-
294286
/*
295287
* Allocates bounce buffer and returns its kernel virtual address.
296288
*/
@@ -337,8 +329,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
337329
wrap = index;
338330

339331
do {
340-
while (is_span_boundary(index, nslots, offset_slots,
341-
max_slots)) {
332+
while (iommu_is_span_boundary(index, nslots, offset_slots,
333+
max_slots)) {
342334
index += stride;
343335
if (index >= io_tlb_nslabs)
344336
index = 0;

0 commit comments

Comments
 (0)