swiotlb: create appropriate common header for swiotlb
Subsystems (5)
PATCH 1/2 swiotlb: create appropriate common header for swiotlb
swiotlb.c was moved into lib/ as a generic service, but its prototypes are still in asm-x86. Move the common parts to linux/swiotlb.h, and update the users accordingly.
---
arch/x86/kernel/aperture_64.c | 1 arch/x86/kernel/pci-calgary_64.c | 1 arch/x86/kernel/pci-dma.c | 1 arch/x86/kernel/pci-gart_64.c | 2 - arch/x86/kernel/pci-swiotlb_64.c | 2 - drivers/pci/dmar.c | 1 drivers/pci/intel-iommu.c | 1 drivers/pci/xen-iommu.c | 2 - include/asm-x86/dma-mapping.h | 1 include/asm-x86/swiotlb.h | 42 ------------------------------- include/linux/swiotlb.h | 50 ++++++++++++++++++++++++++++++++++++++ lib/swiotlb.c | 3 -- 12 files changed, 59 insertions(+), 48 deletions(-)
===================================================================
arch/x86/kernel/aperture_64.c +0 -0
@@ -16,6 +16,7 @@
#include <linux/mmzone.h>
#include <linux/pci_ids.h>
#include <linux/pci.h>
+#include <linux/swiotlb.h>
#include <linux/bitops.h>
#include <linux/ioport.h>
#include <linux/suspend.h>
===================================================================
arch/x86/kernel/pci-calgary_64.c +0 -0
@@ -36,6 +36,7 @@
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/scatterlist.h>
+#include <linux/swiotlb.h>
#include <linux/iommu-helper.h>
#include <asm/iommu.h>
===================================================================
arch/x86/kernel/pci-dma.c +0 -0
@@ -1,6 +1,7 @@
#include <linux/dma-mapping.h>
#include <linux/dmar.h>
#include <linux/bootmem.h>
+#include <linux/swiotlb.h>
#include <linux/pci.h>
#include <asm/proto.h>
===================================================================
arch/x86/kernel/pci-gart_64.c +0 -0
@@ -21,6 +21,7 @@
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/topology.h>
+#include <linux/swiotlb.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/kdebug.h>
@@ -35,7 +36,6 @@
#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/cacheflush.h>
-#include <asm/swiotlb.h>
#include <asm/dma.h>
#include <asm/k8.h>
===================================================================
arch/x86/kernel/pci-swiotlb_64.c +0 -0
@@ -3,10 +3,10 @@
#include <linux/pci.h>
#include <linux/cache.h>
#include <linux/module.h>
+#include <linux/swiotlb.h>
#include <linux/dma-mapping.h>
#include <asm/iommu.h>
-#include <asm/swiotlb.h>
#include <asm/dma.h>
int swiotlb __read_mostly;
===================================================================
drivers/pci/dmar.c +0 -0
@@ -29,6 +29,7 @@
#include <linux/pci.h>
#include <linux/dmar.h>
#include <linux/timer.h>
+#include <linux/swiotlb.h>
#include "iova.h"
#include "intel-iommu.h"
===================================================================
drivers/pci/intel-iommu.c +0 -0
@@ -29,6 +29,7 @@
#include <linux/sysdev.h>
#include <linux/spinlock.h>
#include <linux/pci.h>
+#include <linux/swiotlb.h>
#include <linux/dmar.h>
#include <linux/dma-mapping.h>
#include <linux/mempool.h>
===================================================================
drivers/pci/xen-iommu.c +0 -0
@@ -5,6 +5,7 @@
#include <linux/module.h>
#include <linux/version.h>
#include <linux/scatterlist.h>
+#include <linux/swiotlb.h>
#include <linux/io.h>
#include <linux/bug.h>
@@ -13,7 +14,6 @@
#include <xen/xen-ops.h>
#include <asm/iommu.h>
-#include <asm/swiotlb.h>
#include <asm/tlbflush.h>
#define IOMMU_BUG_ON(test) \
===================================================================
include/asm-x86/dma-mapping.h +0 -0
@@ -8,7 +8,6 @@
#include <linux/scatterlist.h>
#include <asm/io.h>
-#include <asm/swiotlb.h>
#include <asm-generic/dma-coherent.h>
extern dma_addr_t bad_dma_address;
===================================================================
include/asm-x86/swiotlb.h +0 -0
@@ -1,47 +1,5 @@
#ifndef ASM_X86__SWIOTLB_H
#define ASM_X86__SWIOTLB_H
-
-#include <asm/dma-mapping.h>
-
-/* SWIOTLB interface */
-
-extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr,
- size_t size, int dir);
-extern void *swiotlb_alloc_coherent(struct device *hwdev, size_t size,
- dma_addr_t *dma_handle, gfp_t flags);
-extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir);
-extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
- dma_addr_t dev_addr,
- size_t size, int dir);
-extern void swiotlb_sync_single_for_device(struct device *hwdev,
- dma_addr_t dev_addr,
- size_t size, int dir);
-extern void swiotlb_sync_single_range_for_cpu(struct device *hwdev,
- dma_addr_t dev_addr, - unsigned long offset, - size_t size, int dir);
-extern void swiotlb_sync_single_range_for_device(struct device *hwdev,
- dma_addr_t dev_addr,
- unsigned long offset,
- size_t size, int dir);
-extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
- struct scatterlist *sg, int nelems,
- int dir);
-extern void swiotlb_sync_sg_for_device(struct device *hwdev,
- struct scatterlist *sg, int nelems,
- int dir);
-extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
- int nents, int direction);
-extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
- int nents, int direction);
-extern int swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr); -extern void swiotlb_free_coherent(struct device *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle);
-extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); -extern void swiotlb_init(void);
-
-extern int swiotlb_force;
#ifdef CONFIG_SWIOTLB
extern int swiotlb;
===================================================================
include/linux/swiotlb.h new file +50 -0
50 lines not on this page · raw message
===================================================================
lib/swiotlb.c +0 -0
@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/string.h>
+#include <linux/swiotlb.h>
#include <linux/types.h>
#include <linux/ctype.h>
@@ -685,8 +686,6 @@
SYNC_FOR_DEVICE); }
-void swiotlb_unmap_sg_attrs(struct device *, struct scatterlist *, int, int,
- struct dma_attrs *);
/*
* Map a set of buffers described by scatterlist in streaming mode for DMA.
* This is the scatter-gather version of the above swiotlb_map_single
I did a similar patchset 2 months ago. It should be in the -mm tree.
See http://lkml.org/lkml/2008/8/7/130
Joerg
Quoted 271 lines · Jeremy Fitzhardinge
swiotlb.cwas moved intolib/as a generic service, but its prototypes are still in asm-x86. Move the common parts tolinux/swiotlb.h, and update the users accordingly.Signed-off-by Jeremy Fitzhardinge <[email protected]>Cc Joerg Roedel <[email protected]>Cc Jan Beulich <[email protected]>Cc Tony Luck <[email protected]>Cc FUJITA Tomonori <[email protected]>--- arch/x86/kernel/aperture_64.c | 1 arch/x86/kernel/pci-calgary_64.c | 1 arch/x86/kernel/pci-dma.c | 1 arch/x86/kernel/pci-gart_64.c | 2 - arch/x86/kernel/pci-swiotlb_64.c | 2 - drivers/pci/dmar.c | 1 drivers/pci/intel-iommu.c | 1 drivers/pci/xen-iommu.c | 2 - include/asm-x86/dma-mapping.h | 1 include/asm-x86/swiotlb.h | 42 ------------------------------- include/linux/swiotlb.h | 50 ++++++++++++++++++++++++++++++++++++++ lib/swiotlb.c | 3 -- 12 files changed, 59 insertions(+), 48 deletions(-)===================================================================
arch/x86/kernel/aperture_64.c +1
-0@@ -16,6 +16,7 @@#include <linux/mmzone.h> #include <linux/pci_ids.h> #include <linux/pci.h> +#include <linux/swiotlb.h> #include <linux/bitops.h> #include <linux/ioport.h> #include <linux/suspend.h> ===================================================================
arch/x86/kernel/pci-calgary_64.c +1
-0@@ -36,6 +36,7 @@#include <linux/pci.h> #include <linux/delay.h> #include <linux/scatterlist.h> +#include <linux/swiotlb.h> #include <linux/iommu-helper.h> #include <asm/iommu.h> ===================================================================
arch/x86/kernel/pci-dma.c +1
-0@@ -1,6 +1,7 @@#include <linux/dma-mapping.h> #include <linux/dmar.h> #include <linux/bootmem.h> +#include <linux/swiotlb.h> #include <linux/pci.h> #include <asm/proto.h> ===================================================================
arch/x86/kernel/pci-gart_64.c +1
-1@@ -21,6 +21,7 @@#include <linux/pci.h> #include <linux/module.h> #include <linux/topology.h> +#include <linux/swiotlb.h> #include <linux/interrupt.h> #include <linux/bitops.h> #include <linux/kdebug.h> @@ -35,7 +36,6 @@#include <asm/iommu.h> #include <asm/gart.h> #include <asm/cacheflush.h> -#include <asm/swiotlb.h> #include <asm/dma.h> #include <asm/k8.h> ===================================================================
arch/x86/kernel/pci-swiotlb_64.c +1
-1@@ -3,10 +3,10 @@#include <linux/pci.h> #include <linux/cache.h> #include <linux/module.h> +#include <linux/swiotlb.h> #include <linux/dma-mapping.h> #include <asm/iommu.h> -#include <asm/swiotlb.h> #include <asm/dma.h> int swiotlb__read_mostly ;===================================================================
drivers/pci/dmar.c +1
-0@@ -29,6 +29,7 @@#include <linux/pci.h> #include <linux/dmar.h> #include <linux/timer.h> +#include <linux/swiotlb.h> #include "iova.h" #include "intel-iommu.h" ===================================================================
drivers/pci/intel-iommu.c +1
-0@@ -29,6 +29,7 @@#include <linux/sysdev.h> #include <linux/spinlock.h> #include <linux/pci.h> +#include <linux/swiotlb.h> #include <linux/dmar.h> #include <linux/dma-mapping.h> #include <linux/mempool.h> ===================================================================
drivers/pci/xen-iommu.c +1
-1@@ -5,6 +5,7 @@#include <linux/module.h> #include <linux/version.h> #include <linux/scatterlist.h> +#include <linux/swiotlb.h> #include <linux/io.h> #include <linux/bug.h> @@ -13,7 +14,6 @@#include <xen/xen-ops.h> #include <asm/iommu.h> -#include <asm/swiotlb.h> #include <asm/tlbflush.h> #define IOMMU_BUG_ON (test) \===================================================================
include/asm-x86/dma-mapping.h +0
-1@@ -8,7 +8,6 @@#include <linux/scatterlist.h> #include <asm/io.h> -#include <asm/swiotlb.h> #include <asm-generic/dma-coherent.h> extern dma_addr_t bad_dma_address;===================================================================
include/asm-x86/swiotlb.h +0
-42@@ -1,47 +1,5 @@#ifndef ASM_X86__SWIOTLB_H #define ASM_X86__SWIOTLB_H - -#include <asm/dma-mapping.h> - -/* SWIOTLB interface */ - -extern dma_addr_t swiotlb_map_single (struct device *hwdev,void *ptr, -size_t size,int dir); -extern void *swiotlb_alloc_coherent (struct device *hwdev,size_t size, -dma_addr_t *dma_handle,gfp_t flags); -extern void swiotlb_unmap_single (struct device *hwdev,dma_addr_t dev_addr, -size_t size,int dir); -extern void swiotlb_sync_single_for_cpu (struct device *hwdev, -dma_addr_t dev_addr, -size_t size,int dir); -extern void swiotlb_sync_single_for_device (struct device *hwdev, -dma_addr_t dev_addr, -size_t size,int dir); -extern void swiotlb_sync_single_range_for_cpu (struct device *hwdev, -dma_addr_t dev_addr, -unsigned long offset, -size_t size,int dir); -extern void swiotlb_sync_single_range_for_device (struct device *hwdev, -dma_addr_t dev_addr, -unsigned long offset, -size_t size,int dir); -extern void swiotlb_sync_sg_for_cpu (struct device *hwdev, -struct scatterlist *sg,int nelems, -int dir); -extern void swiotlb_sync_sg_for_device (struct device *hwdev, -struct scatterlist *sg,int nelems, -int dir); -extern int swiotlb_map_sg (struct device *hwdev,struct scatterlist *sg, -int nents,int direction); -extern void swiotlb_unmap_sg (struct device *hwdev,struct scatterlist *sg, -int nents,int direction); -extern int swiotlb_dma_mapping_error (struct device *hwdev,dma_addr_t dma_addr); -extern void swiotlb_free_coherent (struct device *hwdev,size_t size, -void *vaddr,dma_addr_t dma_handle); -extern int swiotlb_dma_supported (struct device *hwdev,u64 mask); -extern void swiotlb_init (void ); - -extern int swiotlb_force;#ifdef CONFIG_SWIOTLB extern int swiotlb;===================================================================
include/linux/swiotlb.h new file +50
-0@@ -0,0 +1,50 @@ +#ifndef LINUX__SWIOTLB_H +#define LINUX__SWIOTLB_H + +#include <asm/swiotlb.h> + +/* SWIOTLB interface */ + +extern dma_addr_t swiotlb_map_single (struct device *hwdev,void *ptr, +size_t size,int dir); +extern void *swiotlb_alloc_coherent (struct device *hwdev,size_t size, +dma_addr_t *dma_handle,gfp_t flags); +extern void swiotlb_unmap_single (struct device *hwdev,dma_addr_t dev_addr, +size_t size,int dir); +extern void swiotlb_sync_single_for_cpu (struct device *hwdev, +dma_addr_t dev_addr, +size_t size,int dir); +extern void swiotlb_sync_single_for_device (struct device *hwdev, +dma_addr_t dev_addr, +size_t size,int dir); +extern void swiotlb_sync_single_range_for_cpu (struct device *hwdev, +dma_addr_t dev_addr, +unsigned long offset, +size_t size,int dir); +extern void swiotlb_sync_single_range_for_device (struct device *hwdev, +dma_addr_t dev_addr, +unsigned long offset, +size_t size,int dir); +extern void swiotlb_sync_sg_for_cpu (struct device *hwdev, +struct scatterlist *sg,int nelems, +int dir); +extern void swiotlb_sync_sg_for_device (struct device *hwdev, +struct scatterlist *sg,int nelems, +int dir); +extern int swiotlb_map_sg (struct device *hwdev,struct scatterlist *sg, +int nents,int direction); +extern void swiotlb_unmap_sg (struct device *hwdev,struct scatterlist *sg, +int nents,int direction); +extern void swiotlb_unmap_sg_attrs (struct device *hwdev, +struct scatterlist *sgl, +int nelems,int dir, +struct dma_attrs *attrs); +extern int swiotlb_dma_mapping_error (struct device *hwdev,dma_addr_t dma_addr); +extern void swiotlb_free_coherent (struct device *hwdev,size_t size, +void *vaddr,dma_addr_t dma_handle); +extern int swiotlb_dma_supported (struct device *hwdev,u64 mask); +extern void swiotlb_init (void ); + +extern int swiotlb_force; + +#endif /* LINUX__SWIOTLB_H */ ===================================================================
lib/swiotlb.c +1
-2@@ -22,6 +22,7 @@#include <linux/module.h> #include <linux/spinlock.h> #include <linux/string.h> +#include <linux/swiotlb.h> #include <linux/types.h> #include <linux/ctype.h> @@ -685,8 +686,6 @@ SYNC_FOR_DEVICE); } -void swiotlb_unmap_sg_attrs (struct device *,struct scatterlist *,int ,int , -struct dma_attrs *);/* * Map a set of buffers described by scatterlist in streaming mode for DMA. * This is the scatter-gather version of the above swiotlb_map_single
Signature · 6 lines
| AMD Saxony Limited Liability Company & Co. KG
Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany
System | Register Court Dresden: HRA 4896
Research | General Partner authorized to represent:
Center | AMD Saxony LLC (Wilmington, Delaware, US)
| General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoyQuoted 4 lines · Joerg
I did a similar patchset 2 months ago. It should be in the -mm tree.
Oh, great! I was worried that I may have broken ia64 or other architectures, but you've got a pre-tested fix.
Is it held up on anything? Is there any reason it isn't in mainline yet?
Thanks,
J