diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-04-29 03:59:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:05 -0400 |
commit | a8522509200b460443a7ca59138dc63bec1b690a (patch) | |
tree | d3da544c245a40740018080e9e451fc9096aedb3 | |
parent | a7133a15587b8921af8b074e0d3fe1606cbe5597 (diff) |
swiotlb: use iommu_is_span_boundary helper function
iommu_is_span_boundary in lib/iommu-helper.c was exported for PARISC IOMMUs
(commit 3715863aa142c4f4c5208f5f3e5e9bac06006d2f). 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>
-rw-r--r-- | arch/ia64/Kconfig | 5 | ||||
-rw-r--r-- | arch/x86/Kconfig | 5 | ||||
-rw-r--r-- | lib/swiotlb.c | 14 |
3 files changed, 9 insertions, 15 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 3aa6c821449a..07f5d353b54a 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig | |||
@@ -47,6 +47,9 @@ config MMU | |||
47 | config SWIOTLB | 47 | config SWIOTLB |
48 | bool | 48 | bool |
49 | 49 | ||
50 | config IOMMU_HELPER | ||
51 | bool | ||
52 | |||
50 | config GENERIC_LOCKBREAK | 53 | config GENERIC_LOCKBREAK |
51 | bool | 54 | bool |
52 | default y | 55 | default y |
@@ -615,7 +618,7 @@ config IRQ_PER_CPU | |||
615 | default y | 618 | default y |
616 | 619 | ||
617 | config IOMMU_HELPER | 620 | 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) |
619 | 622 | ||
620 | source "arch/ia64/hp/sim/Kconfig" | 623 | source "arch/ia64/hp/sim/Kconfig" |
621 | 624 | ||
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a12dbb2b93f3..1d9d874cba59 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -537,9 +537,6 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT | |||
537 | Calgary anyway, pass 'iommu=calgary' on the kernel command line. | 537 | Calgary anyway, pass 'iommu=calgary' on the kernel command line. |
538 | If unsure, say Y. | 538 | If unsure, say Y. |
539 | 539 | ||
540 | config IOMMU_HELPER | ||
541 | def_bool (CALGARY_IOMMU || GART_IOMMU) | ||
542 | |||
543 | # need this always selected by IOMMU for the VIA workaround | 540 | # need this always selected by IOMMU for the VIA workaround |
544 | config SWIOTLB | 541 | config SWIOTLB |
545 | bool | 542 | bool |
@@ -550,6 +547,8 @@ config SWIOTLB | |||
550 | access 32-bits of memory can be used on systems with more than | 547 | access 32-bits of memory can be used on systems with more than |
551 | 3 GB of memory. If unsure, say Y. | 548 | 3 GB of memory. If unsure, say Y. |
552 | 549 | ||
550 | config IOMMU_HELPER | ||
551 | def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB) | ||
553 | 552 | ||
554 | config NR_CPUS | 553 | config NR_CPUS |
555 | int "Maximum number of CPUs (2-255)" | 554 | int "Maximum number of CPUs (2-255)" |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 256c8445e54d..3c95922e51e7 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/bootmem.h> | 33 | #include <linux/bootmem.h> |
34 | #include <linux/iommu-helper.h> | ||
34 | 35 | ||
35 | #define OFFSET(val,align) ((unsigned long) \ | 36 | #define OFFSET(val,align) ((unsigned long) \ |
36 | ( (val) & ( (align) - 1))) | 37 | ( (val) & ( (align) - 1))) |
@@ -282,15 +283,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr) | |||
282 | return (addr & ~mask) != 0; | 283 | return (addr & ~mask) != 0; |
283 | } | 284 | } |
284 | 285 | ||
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 | |||
294 | /* | 286 | /* |
295 | * Allocates bounce buffer and returns its kernel virtual address. | 287 | * Allocates bounce buffer and returns its kernel virtual address. |
296 | */ | 288 | */ |
@@ -337,8 +329,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) | |||
337 | wrap = index; | 329 | wrap = index; |
338 | 330 | ||
339 | do { | 331 | do { |
340 | while (is_span_boundary(index, nslots, offset_slots, | 332 | while (iommu_is_span_boundary(index, nslots, offset_slots, |
341 | max_slots)) { | 333 | max_slots)) { |
342 | index += stride; | 334 | index += stride; |
343 | if (index >= io_tlb_nslabs) | 335 | if (index >= io_tlb_nslabs) |
344 | index = 0; | 336 | index = 0; |