x86 updates for v2.6.28, phase #3 - IOMMU
Subsystems (5)
Linus,
Please pull the latest x86-v28-for-linus-phase3 git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-v28-for-linus-phase3
IOMMU updates.
out-of-topic modifications in x86-v28-for-linus-phase3:
-------------------------------------------------------MAINTAINERS # bbd001c: add AMD IOMMU tree to MAINTAINERS
arch/ia64/include/asm/dma-mapping.h# 3a80b6a: ia64: dma_alloc_coherent always udrivers/char/agp/uninorth-agp.c # c09ff7e: linux-next: fix x86 tree build fainclude/linux/dma-mapping.h # 07a2c01: convert swiotlb to use dma_get_ma
# 589fc9a6: iommu: add dma_get_mask helper f # 636dc67: add is_buffer_dma_capable helperinclude/linux/iommu-helper.h # 1e19b16: AMD IOMMU: use iommu_device_max_i
# d26dbc5: iommu: export iommu_area_reserve # eecfffc: iommu: add iommu_device_max_indexinclude/linux/pci_ids.h # 2426824: x86: add PCI IDs for AMD Barcelon
# ca1af29: x86, pci: add northbridge pci ids
kernel/dma-coherent.c # a38409f: dma-coherent: export dma_[alloc|r lib/iommu-helper.c # d26dbc5: iommu: export iommu_area_reserve lib/swiotlb.c # 07a2c01: convert swiotlb to use dma_get_ma
# 2797982: swiotlb: convert swiotlb to use i # 640aebf: swiotlb: add is_swiotlb_buffer he # 21f6c4d: swiotlb: use unmap_single instead # 9dfda12: swiotlb: use map_single instead o # 68e91d6: swiotlb: remove GFP_DMA hack in s
Thanks,
Ingo
------------------>
David Woodhouse (1):
x86: blacklist DMAR on Intel G31/G33 chipsets
FUJITA Tomonori (32):
dma-mapping.h, x86: remove last user of dma_mapping_ops->map_simple
x86: dma_*_coherent rework patchset v2, fix
x86: gart alloc_coherent doesn't need to check NULL device argument
ia64: dma_alloc_coherent always use GFP_DMA
x86: move pci-nommu's dma_mask check to common code
x86: fix nommu_alloc_coherent allocation with NULL device argument
x86: dma_alloc_coherent sets gfp flags properly
swiotlb: remove GFP_DMA hack in swiotlb_alloc_coherent
swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent
swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent
swiotlb: add is_swiotlb_buffer helper function
add is_buffer_dma_capable helper function
x86: convert gart to use is_buffer_dma_capable helper function
x86: convert pci-nommu to use is_buffer_dma_capable helper function
swiotlb: convert swiotlb to use is_buffer_dma_capable helper function
x86: remove duplicated extern force_iommu
x86: convert dma_alloc_coherent to use is_device_dma_capable
iommu: add iommu_device_max_index IOMMU helper function
iommu: add dma_get_mask helper function
x86: make GART to respect device's dma_mask about virtual mappings
x86: avoid unnecessary low zone allocation in Calgary's alloc_coherent
x86: gart alloc_coherent does virtual mapppings only when necessary convert swiotlb to use dma_get_mask
AMD IOMMU: avoid unnecessary low zone allocation in alloc_coherent
iommu: export iommu_area_reserve helper function
x86: remove set_bit_string()
iommu: remove fullflush and nofullflush in IOMMU generic option
x86: export pci-nommu's alloc_coherent
revert "x86: make GART to respect device's dma_mask about virtual mappings"
x86: restore old GART alloc_coherent behavior
x86 gart: remove unnecessary initialization
AMD IOMMU: use iommu_device_max_index
Ingo Molnar (2):
dma-coherent: export dma_[alloc|release]_from_coherent methods
x86: add PCI IDs for AMD Barcelona PCI devices
Joerg Roedel (37):
x86: add alloc_coherent dma_ops callback to GART driver
x86: add free_coherent dma_ops callback to GART driver
x86: add free_coherent dma_ops callback to Calgary IOMMU driver
x86: add alloc_coherent dma_ops callback to NOMMU driver
x86: add free_coherent dma_ops callback to NOMMU driver
x86: cleanup dma_*_coherent functions
x86: move dma_*_coherent functions to include file x86, AMD IOMMU: remove obsolete FIXME comment
x86, pci: add northbridge pci ids for fam 0x11 processors x86, gart: add detection of AMD family 0x11 northbridges AMD IOMMU: check for invalid device pointers
AMD IOMMU: move TLB flushing to the map/unmap helper functions
x86: move GART TLB flushing options to generic code AMD IOMMU: implement lazy IO/TLB flushing
AMD IOMMU: add branch hints to completion wait checks AMD IOMMU: align alloc_coherent addresses properly
AMD IOMMU: add event buffer allocation
AMD IOMMU: save pci segment from ACPI tables
AMD IOMMU: save pci_dev instead of devid
AMD IOMMU: add MSI interrupt support
AMD IOMMU: add event handling code
AMD IOMMU: enable event logging
AMD IOMMU: allow IO page faults from devices
AMD IOMMU: add dma_supported callback
AMD IOMMU: don't assign preallocated protection domains to devices AMD IOMMU: some set_device_domain cleanups
AMD IOMMU: replace memset with __GFP_ZERO in alloc_coherent AMD IOMMU: simplify dma_mask_to_pages
AMD IOMMU: free domain bitmap with its allocation order AMD IOMMU: remove unnecessary cast to u64 in the init code AMD IOMMU: calculate IVHD size with a function
AMD IOMMU: use cmd_buf_size when freeing the command buffer add AMD IOMMU tree to MAINTAINERS file
AMD IOMMU: use coherent_dma_mask in alloc_coherent x86/iommu: make GART driver checkpatch clean x86/iommu: convert GART need_flush to bool
x86/iommu: use __GFP_ZERO instead of memset for GART
Steven Noonan (1):
x86: unused variable in dma_alloc_coherent_gfp_flags()
Thomas Gleixner (1):
AMD IOMMU: use iommu_device_max_index, fix
Documentation/kernel-parameters.txt | 5 + MAINTAINERS | 1 + arch/ia64/include/asm/dma-mapping.h | 4 +- arch/x86/Kconfig | 1 + arch/x86/kernel/amd_iommu.c | 328 ++++++++++++++++++++++++++++------- arch/x86/kernel/amd_iommu_init.c | 194 +++++++++++++++++++-- arch/x86/kernel/early-quirks.c | 18 ++ arch/x86/kernel/k8.c | 5 +- arch/x86/kernel/pci-calgary_64.c | 18 ++- arch/x86/kernel/pci-dma.c | 177 ++++--------------- arch/x86/kernel/pci-gart_64.c | 125 +++++++------ arch/x86/kernel/pci-nommu.c | 10 +- drivers/pci/intel-iommu.c | 2 +- include/asm-x86/amd_iommu.h | 3 + include/asm-x86/amd_iommu_types.h | 64 +++++++- include/asm-x86/bitops.h | 10 - include/asm-x86/dma-mapping.h | 87 ++++++++-- include/asm-x86/gart.h | 2 + include/asm-x86/iommu.h | 1 + include/linux/dma-mapping.h | 12 ++ include/linux/iommu-helper.h | 16 ++ include/linux/pci_ids.h | 10 + kernel/dma-coherent.c | 2 + lib/iommu-helper.c | 5 +- lib/swiotlb.c | 49 ++--- 25 files changed, 803 insertions(+), 346 deletions(-)
Quoted 5 lines · Ingo Molnar
Linus,
Please pull the latest x86-v28-for-linus-phase3 git tree from:
IOMMU updates.
Linus, please find the updated pull request below - relative to the respun x86-v28-for-linus-phase2-B.
Ingo
-------------->
Linus,
Please pull the latest x86-v28-for-linus-phase3-B git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-v28-for-linus-phase3-B
out-of-topic modifications in x86-v28-for-linus-phase3-B:
---------------------------------------------------------MAINTAINERS # bbd001c: add AMD IOMMU tree to MAINTAINERS
arch/ia64/include/asm/dma-mapping.h# 3a80b6a: ia64: dma_alloc_coherent always uinclude/linux/dma-mapping.h # 07a2c01: convert swiotlb to use dma_get_ma
# 589fc9a6: iommu: add dma_get_mask helper f # 636dc67: add is_buffer_dma_capable helperinclude/linux/iommu-helper.h # 1e19b16: AMD IOMMU: use iommu_device_max_i
# d26dbc5: iommu: export iommu_area_reserve # eecfffc: iommu: add iommu_device_max_indexinclude/linux/pci_ids.h # 2426824: x86: add PCI IDs for AMD Barcelon
# ca1af29: x86, pci: add northbridge pci ids
kernel/dma-coherent.c # a38409f: dma-coherent: export dma_[alloc|r lib/iommu-helper.c # d26dbc5: iommu: export iommu_area_reserve lib/swiotlb.c # 07a2c01: convert swiotlb to use dma_get_ma
# 2797982: swiotlb: convert swiotlb to use i # 640aebf: swiotlb: add is_swiotlb_buffer he # 21f6c4d: swiotlb: use unmap_single instead # 9dfda12: swiotlb: use map_single instead o # 68e91d6: swiotlb: remove GFP_DMA hack in s
Thanks,
Ingo
------------------>
David Woodhouse (1):
x86: blacklist DMAR on Intel G31/G33 chipsets
FUJITA Tomonori (32):
dma-mapping.h, x86: remove last user of dma_mapping_ops->map_simple
x86: dma_*_coherent rework patchset v2, fix
x86: gart alloc_coherent doesn't need to check NULL device argument
ia64: dma_alloc_coherent always use GFP_DMA
x86: move pci-nommu's dma_mask check to common code
x86: fix nommu_alloc_coherent allocation with NULL device argument
x86: dma_alloc_coherent sets gfp flags properly
swiotlb: remove GFP_DMA hack in swiotlb_alloc_coherent
swiotlb: use map_single instead of swiotlb_map_single in swiotlb_alloc_coherent
swiotlb: use unmap_single instead of swiotlb_unmap_single in swiotlb_free_coherent
swiotlb: add is_swiotlb_buffer helper function
add is_buffer_dma_capable helper function
x86: convert gart to use is_buffer_dma_capable helper function
x86: convert pci-nommu to use is_buffer_dma_capable helper function
swiotlb: convert swiotlb to use is_buffer_dma_capable helper function
x86: remove duplicated extern force_iommu
x86: convert dma_alloc_coherent to use is_device_dma_capable
iommu: add iommu_device_max_index IOMMU helper function
iommu: add dma_get_mask helper function
x86: make GART to respect device's dma_mask about virtual mappings
x86: avoid unnecessary low zone allocation in Calgary's alloc_coherent
x86: gart alloc_coherent does virtual mapppings only when necessary convert swiotlb to use dma_get_mask
AMD IOMMU: avoid unnecessary low zone allocation in alloc_coherent
iommu: export iommu_area_reserve helper function
x86: remove set_bit_string()
iommu: remove fullflush and nofullflush in IOMMU generic option
x86: export pci-nommu's alloc_coherent
revert "x86: make GART to respect device's dma_mask about virtual mappings"
x86: restore old GART alloc_coherent behavior
x86 gart: remove unnecessary initialization
AMD IOMMU: use iommu_device_max_index
Ingo Molnar (2):
dma-coherent: export dma_[alloc|release]_from_coherent methods
x86: add PCI IDs for AMD Barcelona PCI devices
Joerg Roedel (37):
x86: add alloc_coherent dma_ops callback to GART driver
x86: add free_coherent dma_ops callback to GART driver
x86: add free_coherent dma_ops callback to Calgary IOMMU driver
x86: add alloc_coherent dma_ops callback to NOMMU driver
x86: add free_coherent dma_ops callback to NOMMU driver
x86: cleanup dma_*_coherent functions
x86: move dma_*_coherent functions to include file x86, AMD IOMMU: remove obsolete FIXME comment
x86, pci: add northbridge pci ids for fam 0x11 processors x86, gart: add detection of AMD family 0x11 northbridges AMD IOMMU: check for invalid device pointers
AMD IOMMU: move TLB flushing to the map/unmap helper functions
x86: move GART TLB flushing options to generic code AMD IOMMU: implement lazy IO/TLB flushing
AMD IOMMU: add branch hints to completion wait checks AMD IOMMU: align alloc_coherent addresses properly
AMD IOMMU: add event buffer allocation
AMD IOMMU: save pci segment from ACPI tables
AMD IOMMU: save pci_dev instead of devid
AMD IOMMU: add MSI interrupt support
AMD IOMMU: add event handling code
AMD IOMMU: enable event logging
AMD IOMMU: allow IO page faults from devices
AMD IOMMU: add dma_supported callback
AMD IOMMU: don't assign preallocated protection domains to devices AMD IOMMU: some set_device_domain cleanups
AMD IOMMU: replace memset with __GFP_ZERO in alloc_coherent AMD IOMMU: simplify dma_mask_to_pages
AMD IOMMU: free domain bitmap with its allocation order AMD IOMMU: remove unnecessary cast to u64 in the init code AMD IOMMU: calculate IVHD size with a function
AMD IOMMU: use cmd_buf_size when freeing the command buffer add AMD IOMMU tree to MAINTAINERS file
AMD IOMMU: use coherent_dma_mask in alloc_coherent x86/iommu: make GART driver checkpatch clean x86/iommu: convert GART need_flush to bool
x86/iommu: use __GFP_ZERO instead of memset for GART
Steven Noonan (1):
x86: unused variable in dma_alloc_coherent_gfp_flags()
Thomas Gleixner (1):
AMD IOMMU: use iommu_device_max_index, fix
Documentation/kernel-parameters.txt | 5 + MAINTAINERS | 1 + arch/ia64/include/asm/dma-mapping.h | 4 +- arch/x86/Kconfig | 1 + arch/x86/kernel/amd_iommu.c | 328 ++++++++++++++++++++++++++++------- arch/x86/kernel/amd_iommu_init.c | 194 +++++++++++++++++++-- arch/x86/kernel/early-quirks.c | 18 ++ arch/x86/kernel/k8.c | 5 +- arch/x86/kernel/pci-calgary_64.c | 18 ++- arch/x86/kernel/pci-dma.c | 177 ++++--------------- arch/x86/kernel/pci-gart_64.c | 125 +++++++------ arch/x86/kernel/pci-nommu.c | 10 +- drivers/pci/intel-iommu.c | 2 +- include/asm-x86/amd_iommu.h | 3 + include/asm-x86/amd_iommu_types.h | 64 +++++++- include/asm-x86/bitops.h | 10 - include/asm-x86/dma-mapping.h | 87 ++++++++-- include/asm-x86/gart.h | 2 + include/asm-x86/iommu.h | 1 + include/linux/dma-mapping.h | 12 ++ include/linux/iommu-helper.h | 16 ++ include/linux/pci_ids.h | 10 + kernel/dma-coherent.c | 2 + lib/iommu-helper.c | 5 +- lib/swiotlb.c | 49 ++--- 25 files changed, 803 insertions(+), 346 deletions(-)
Documentation/kernel-parameters.txt +5 -0
@@ -284,6 +284,11 @@ and is between 256 and 4096 characters. It is defined in the file isolate - enable device isolation (each device, as far as possible, will get its own protection domain) + fullflush - enable flushing of IO/TLB entries when + they are unmapped. Otherwise they are + flushed before they will be reused, which + is a lot of faster + amd_iommu_size= [HW,X86-64] Define the size of the aperture for the AMD IOMMU driver. Possible values are:
MAINTAINERS +1 -0
@@ -387,6 +387,7 @@ AMD IOMMU (AMD-VI) P: Joerg Roedel M: [email protected] L: [email protected] +T: git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu.git S: Supported AMS (Apple Motion Sensor) DRIVER
arch/ia64/include/asm/dma-mapping.h +3 -1
@@ -8,7 +8,9 @@#include <asm/machvec.h> #include <linux/scatterlist.h> -#define dma_alloc_coherent platform_dma_alloc_coherent +#define dma_alloc_coherent (dev, size, handle, gfp) \ + platform_dma_alloc_coherent(dev, size, handle, (gfp) | GFP_DMA) +/* coherent mem. is cheap */ static inline void * dma_alloc_noncoherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
arch/x86/Kconfig +1 -0
@@ -554,6 +554,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT config AMD_IOMMU bool "AMD IOMMU support" select SWIOTLB + select PCI_MSI depends on X86_64 && PCI && ACPI help With this option you can enable support for AMD IOMMU hardware in
arch/x86/kernel/amd_iommu.c +267 -61
568 lines not on this page · raw message
arch/x86/kernel/amd_iommu_init.c +176 -18
323 lines not on this page · raw message
arch/x86/kernel/early-quirks.c +18 -0
@@ -95,6 +95,20 @@ static void __init nvidia_bugs(int num, int slot, int func) } +#ifdef CONFIG_DMAR +static void __init intel_g33_dmar (int num,int slot,int func) +{ +struct acpi_table_header *dmar_tbl; +acpi_status status; + + status =acpi_get_table (ACPI_SIG_DMAR ,0 , &dmar_tbl); +if (ACPI_SUCCESS (status)) { +printk (KERN_INFO "BIOS BUG: DMAR advertised on Intel G31/G33 chipset -- ignoring\n" ); + dmar_disabled =1 ; + } +} +#endif +#define QFLAG_APPLY_ONCE 0x1#define QFLAG_APPLIED 0x2#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -114,6 +128,10 @@ static struct chipset early_qrk[] __initdata = { PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, via_bugs }, { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB, PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, fix_hypertransport_config }, +#ifdef CONFIG_DMAR + { PCI_VENDOR_ID_INTEL, 0x29c0, + PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, intel_g33_dmar }, +#endif {} };
arch/x86/kernel/k8.c +3 -2
@@ -16,8 +16,9 @@ EXPORT_SYMBOL(num_k8_northbridges);static u32 *flush_words;struct pci_device_id k8_nb_ids[] = { - {PCI_DEVICE (PCI_VENDOR_ID_AMD ,0x1103 ) }, - {PCI_DEVICE (PCI_VENDOR_ID_AMD ,0x1203 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_K8_NB_MISC ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_10H_NB_MISC ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_11H_NB_MISC ) }, {} };EXPORT_SYMBOL (k8_nb_ids);
arch/x86/kernel/pci-calgary_64.c +17 -1
@@ -261,7 +261,7 @@ static void iommu_range_reserve(struct iommu_table *tbl, badbit, tbl, start_addr, npages); } -set_bit_string (tbl->it_map, index, npages); +iommu_area_reserve (tbl->it_map, index, npages);spin_unlock_irqrestore (&tbl->it_lock, flags); }
@@ -491,6 +491,8 @@ static void* calgary_alloc_coherent(struct device *dev, size_t size, npages = size >>PAGE_SHIFT ; order =get_order (size); + flag &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32); +/* alloc enough pages (and possibly more) */ ret = (void *)__get_free_pages (flag, order);if (!ret)
@@ -510,8 +512,22 @@ error:return ret; } +static void calgary_free_coherent (struct device *dev,size_t size, +void *vaddr,dma_addr_t dma_handle) +{ +unsigned int npages; +struct iommu_table *tbl =find_iommu_table (dev); + + size =PAGE_ALIGN (size); + npages = size >>PAGE_SHIFT ; + +iommu_free (tbl, dma_handle, npages); +free_pages ((unsigned long )vaddr,get_order (size)); +} +static struct dma_mapping_ops calgary_dma_ops = { .alloc_coherent = calgary_alloc_coherent, + .free_coherent = calgary_free_coherent, .map_single = calgary_map_single, .unmap_single = calgary_unmap_single, .map_sg = calgary_map_sg,
arch/x86/kernel/pci-dma.c +34 -143
198 lines not on this page · raw message
arch/x86/kernel/pci-gart_64.c +67 -58
259 lines not on this page · raw message
arch/x86/kernel/pci-nommu.c +9 -1
@@ -14,7 +14,7 @@static int check_addr (char *name,struct device *hwdev,dma_addr_t bus,size_t size) { -if (hwdev && bus + size > *hwdev->dma_mask) { +if (hwdev && !is_buffer_dma_capable (*hwdev->dma_mask, bus, size)) {if (*hwdev->dma_mask >=DMA_32BIT_MASK ) printk(KERN_ERR "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
@@ -72,7 +72,15 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,return nents; } +static void nommu_free_coherent (struct device *dev,size_t size,void *vaddr, +dma_addr_t dma_addr) +{ +free_pages ((unsigned long )vaddr,get_order (size)); +} +struct dma_mapping_ops nommu_dma_ops = { + .alloc_coherent = dma_generic_alloc_coherent, + .free_coherent = nommu_free_coherent, .map_single = nommu_map_single, .map_sg = nommu_map_sg, .is_phys =1 ,
drivers/pci/intel-iommu.c +1 -1
@@ -80,7 +80,7 @@ static long list_size;static void domain_remove_dev_info (struct dmar_domain *domain); -static int dmar_disabled; +int dmar_disabled;static int __initdata dmar_map_gfx =1 ;static int dmar_forcedac;static int intel_iommu_strict;
include/asm-x86/amd_iommu.h +3 -0
@@ -20,10 +20,13 @@#ifndef ASM_X86__AMD_IOMMU_H #define ASM_X86__AMD_IOMMU_H +#include <linux/irqreturn.h> +#ifdef CONFIG_AMD_IOMMU extern int amd_iommu_init (void );extern int amd_iommu_init_dma_ops (void );extern void amd_iommu_detect (void ); +extern irqreturn_t amd_iommu_int_handler (int irq,void *data);#else static inline int amd_iommu_init (void ) {return -ENODEV ; }static inline void amd_iommu_detect (void ) { }
include/asm-x86/amd_iommu_types.h +62 -2
139 lines not on this page · raw message
include/asm-x86/bitops.h +0 -10
@@ -424,16 +424,6 @@ static inline int fls(int x)#undef ADDR -static inline void set_bit_string (unsigned long *bitmap, -unsigned long i,int len) -{ -unsigned long end = i + len; -while (i < end) { -__set_bit (i, bitmap); - i++; - } -} -#ifdef __KERNEL__#include <asm-generic/bitops/sched.h>
include/asm-x86/dma-mapping.h +71 -16
123 lines not on this page · raw message
include/asm-x86/gart.h +2 -0
@@ -29,6 +29,8 @@ extern int fix_aperture;#define AMD64_GARTCACHECTL 0x9c#define AMD64_GARTEN (1<<0) +extern int agp_amd64_init (void ); +static inline void enable_gart_translation (struct pci_dev *dev,u64 addr) {u32 tmp, ctl;
include/asm-x86/iommu.h +1 -0
@@ -6,6 +6,7 @@ extern void no_iommu_init(void);extern struct dma_mapping_ops nommu_dma_ops;extern int force_iommu, no_iommu;extern int iommu_detected; +extern int dmar_disabled;extern unsigned long iommu_num_pages (unsigned long addr,unsigned long len);
include/linux/dma-mapping.h +12 -0
@@ -48,6 +48,11 @@ static inline int is_device_dma_capable(struct device *dev)return dev->dma_mask !=NULL && *dev->dma_mask !=DMA_MASK_NONE ; } +static inline int is_buffer_dma_capable (u64 mask,dma_addr_t addr,size_t size) +{ +return addr + size <= mask; +} +#ifdef CONFIG_HAS_DMA #include <asm/dma-mapping.h> #else
@@ -58,6 +63,13 @@ static inline int is_device_dma_capable(struct device *dev)#define dma_sync_single dma_sync_single_for_cpu#define dma_sync_sg dma_sync_sg_for_cpu +static inline u64 dma_get_mask (struct device *dev) +{ +if (dev && dev->dma_mask && *dev->dma_mask) +return *dev->dma_mask; +return DMA_32BIT_MASK ; +} +extern u64 dma_get_required_mask (struct device *dev);static inline unsigned int dma_get_max_seg_size (struct device *dev)
include/linux/iommu-helper.h +16 -0
@@ -1,6 +1,20 @@ +#ifndef _LINUX_IOMMU_HELPER_H +#define _LINUX_IOMMU_HELPER_H + +static inline unsigned long iommu_device_max_index (unsigned long size, +unsigned long offset, +u64 dma_mask) +{ +if (size + offset > dma_mask) +return dma_mask - offset +1 ; +else +return size; +} +extern int iommu_is_span_boundary (unsigned int index,unsigned int nr,unsigned long shift,unsigned long boundary_size); +extern void iommu_area_reserve (unsigned long *map,unsigned long i,int len); extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, unsigned long shift,
@@ -8,3 +22,5 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size, unsigned long align_mask);extern void iommu_area_free (unsigned long *map,unsigned long start,unsigned int nr); + +#endif
include/linux/pci_ids.h +10 -0
@@ -497,6 +497,16 @@#define PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP 0x1101#define PCI_DEVICE_ID_AMD_K8_NB_MEMCTL 0x1102#define PCI_DEVICE_ID_AMD_K8_NB_MISC 0x1103 +#define PCI_DEVICE_ID_AMD_10H_NB_HT 0x1200 +#define PCI_DEVICE_ID_AMD_10H_NB_MAP 0x1201 +#define PCI_DEVICE_ID_AMD_10H_NB_DRAM 0x1202 +#define PCI_DEVICE_ID_AMD_10H_NB_MISC 0x1203 +#define PCI_DEVICE_ID_AMD_10H_NB_LINK 0x1204 +#define PCI_DEVICE_ID_AMD_11H_NB_HT 0x1300 +#define PCI_DEVICE_ID_AMD_11H_NB_MAP 0x1301 +#define PCI_DEVICE_ID_AMD_11H_NB_DRAM 0x1302 +#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303 +#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304#define PCI_DEVICE_ID_AMD_LANCE 0x2000#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001#define PCI_DEVICE_ID_AMD_SCSI 0x2020
kernel/dma-coherent.c +2 -0
@@ -124,6 +124,7 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size, }return (mem !=NULL ); } +EXPORT_SYMBOL (dma_alloc_from_coherent);/** * dma_release_from_coherent() - try to free the memory allocated from per-device coherent memory pool
@@ -151,3 +152,4 @@ int dma_release_from_coherent(struct device *dev, int order, void *vaddr) }return 0 ; } +EXPORT_SYMBOL (dma_release_from_coherent);
lib/iommu-helper.c +2 -3
@@ -30,8 +30,7 @@ again:return index; } -static inline void set_bit_area (unsigned long *map,unsigned long i, -int len) +void iommu_area_reserve (unsigned long *map,unsigned long i,int len) {unsigned long end = i + len;while (i < end) {
@@ -64,7 +63,7 @@ again: start = index +1 ; goto again; } -set_bit_area (map, index, nr); +iommu_area_reserve (map, index, nr); }return index; }
lib/swiotlb.c +20 -29
121 lines not on this page · raw message