提交 a8522509 编写于 作者: F FUJITA Tomonori 提交者: Linus Torvalds

swiotlb: use iommu_is_span_boundary helper function

iommu_is_span_boundary in lib/iommu-helper.c was exported for PARISC IOMMUs
(commit 3715863a).  SWIOTLB can use it instead
of the homegrown function.
Signed-off-by: NFUJITA 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 a7133a15
...@@ -47,6 +47,9 @@ config MMU ...@@ -47,6 +47,9 @@ config MMU
config SWIOTLB config SWIOTLB
bool bool
config IOMMU_HELPER
bool
config GENERIC_LOCKBREAK config GENERIC_LOCKBREAK
bool bool
default y default y
...@@ -615,7 +618,7 @@ config IRQ_PER_CPU ...@@ -615,7 +618,7 @@ config IRQ_PER_CPU
default y default y
config IOMMU_HELPER config IOMMU_HELPER
def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC) def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC || SWIOTLB)
source "arch/ia64/hp/sim/Kconfig" source "arch/ia64/hp/sim/Kconfig"
......
...@@ -537,9 +537,6 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT ...@@ -537,9 +537,6 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
Calgary anyway, pass 'iommu=calgary' on the kernel command line. Calgary anyway, pass 'iommu=calgary' on the kernel command line.
If unsure, say Y. If unsure, say Y.
config IOMMU_HELPER
def_bool (CALGARY_IOMMU || GART_IOMMU)
# need this always selected by IOMMU for the VIA workaround # need this always selected by IOMMU for the VIA workaround
config SWIOTLB config SWIOTLB
bool bool
...@@ -550,6 +547,8 @@ config SWIOTLB ...@@ -550,6 +547,8 @@ config SWIOTLB
access 32-bits of memory can be used on systems with more than access 32-bits of memory can be used on systems with more than
3 GB of memory. If unsure, say Y. 3 GB of memory. If unsure, say Y.
config IOMMU_HELPER
def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB)
config NR_CPUS config NR_CPUS
int "Maximum number of CPUs (2-255)" int "Maximum number of CPUs (2-255)"
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/iommu-helper.h>
#define OFFSET(val,align) ((unsigned long) \ #define OFFSET(val,align) ((unsigned long) \
( (val) & ( (align) - 1))) ( (val) & ( (align) - 1)))
...@@ -282,15 +283,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr) ...@@ -282,15 +283,6 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr)
return (addr & ~mask) != 0; return (addr & ~mask) != 0;
} }
static inline unsigned int is_span_boundary(unsigned int index,
unsigned int nslots,
unsigned long offset_slots,
unsigned long max_slots)
{
unsigned long offset = (offset_slots + index) & (max_slots - 1);
return offset + nslots > max_slots;
}
/* /*
* Allocates bounce buffer and returns its kernel virtual address. * Allocates bounce buffer and returns its kernel virtual address.
*/ */
...@@ -337,8 +329,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) ...@@ -337,8 +329,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
wrap = index; wrap = index;
do { do {
while (is_span_boundary(index, nslots, offset_slots, while (iommu_is_span_boundary(index, nslots, offset_slots,
max_slots)) { max_slots)) {
index += stride; index += stride;
if (index >= io_tlb_nslabs) if (index >= io_tlb_nslabs)
index = 0; index = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册