2005-11-21 21:51:01

by Muli Ben-Yehuda

[permalink] [raw]
Subject: [RFC PATCH 0/3] move swiotlb header file into common code

This patchset does two main things:

- creates an asm-generic/swiotlb.h header file and makes x86-64 and
IA64 both use it.

- make swiotlb use 'enum dma_direction_dir' instead of 'int dir',
which is the right thing to do in the DMA API, and updates x86-64 and
ia64 accordingly.

This is the first step towards having a common IOMMU
infrastructure. Unfortunatly applying any of the patches require the
other 2.

Compile tested on both x86-64 and IA64, I'll appreciate it if someone
knowledgable about IA64 could double check the IA64 bits.

Cheers,
Muli
--
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/


2005-11-21 21:54:11

by Muli Ben-Yehuda

[permalink] [raw]
Subject: [RFC PATCH 1/3] move swiotlb header file into common code - generic bits

muli@granada:~/tmp$ diffstat move-swiotlb-into-generic-code-generic-bits-A1
include/asm-generic/swiotlb.h | 60 +++++++++++++++++++++++++++++++++++++
include/linux/dma-data-direction.h | 13 ++++++++
include/linux/dma-mapping.h | 10 ------
lib/swiotlb.c | 36 +++++++++++-----------
4 files changed, 93 insertions(+), 26 deletions(-)

---

diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/asm-generic/swiotlb.h dma_data_direction.hg/include/asm-generic/swiotlb.h
--- vanilla/include/asm-generic/swiotlb.h 1969-12-31 19:00:00.000000000 -0500
+++ dma_data_direction.hg/include/asm-generic/swiotlb.h 2005-11-21 13:32:14.000000000 -0500
@@ -0,0 +1,60 @@
+#ifndef _ASM_GENERIC_SWIOTLB_H
+#define _ASM_GENERIC_SWTIOLB_H 1
+
+#include <linux/dma-data-direction.h>
+
+struct device;
+struct scatterlist;
+
+extern dma_addr_t
+swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
+ enum dma_data_direction dir);
+
+extern void
+swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
+ enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, size_t size,
+ enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
+ size_t size, enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
+ unsigned long offset, size_t size, enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
+ unsigned long offset, size_t size, enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, int nelems,
+ enum dma_data_direction dir);
+
+extern void
+swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
+ int nelems, enum dma_data_direction dir);
+
+extern int
+swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+
+extern void
+swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+
+extern int
+swiotlb_dma_mapping_error(dma_addr_t dma_addr);
+
+extern void*
+swiotlb_alloc_coherent (struct device *hwdev, size_t size, dma_addr_t *dma_handle,
+ gfp_t flags);
+
+extern void
+swiotlb_free_coherent (struct device *hwdev, size_t size, void *vaddr,
+ dma_addr_t dma_handle);
+
+#endif /* _ASM_GENERIC_SWTIOLB_H */
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/linux/dma-data-direction.h dma_data_direction.hg/include/linux/dma-data-direction.h
--- vanilla/include/linux/dma-data-direction.h 1969-12-31 19:00:00.000000000 -0500
+++ dma_data_direction.hg/include/linux/dma-data-direction.h 2005-11-21 13:31:18.000000000 -0500
@@ -0,0 +1,13 @@
+#ifndef _ASM_LINUX_DMA_DATA_DIRECTION_H
+#define _ASM_LINUX_DMA_DATA_DIRECTION_H
+
+/* These definitions mirror those in pci.h, so they can be used
+ * interchangeably with their PCI_ counterparts */
+enum dma_data_direction {
+ DMA_BIDIRECTIONAL = 0,
+ DMA_TO_DEVICE = 1,
+ DMA_FROM_DEVICE = 2,
+ DMA_NONE = 3,
+};
+
+#endif /* _ASM_LINUX_DMA_DATA_DIRECTION_H */
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/linux/dma-mapping.h dma_data_direction.hg/include/linux/dma-mapping.h
--- vanilla/include/linux/dma-mapping.h 2005-09-08 07:07:32.000000000 -0400
+++ dma_data_direction.hg/include/linux/dma-mapping.h 2005-11-21 13:31:40.000000000 -0500
@@ -3,15 +3,7 @@

#include <linux/device.h>
#include <linux/err.h>
-
-/* These definitions mirror those in pci.h, so they can be used
- * interchangeably with their PCI_ counterparts */
-enum dma_data_direction {
- DMA_BIDIRECTIONAL = 0,
- DMA_TO_DEVICE = 1,
- DMA_FROM_DEVICE = 2,
- DMA_NONE = 3,
-};
+#include <linux/dma-data-direction.h>

#define DMA_64BIT_MASK 0xffffffffffffffffULL
#define DMA_40BIT_MASK 0x000000ffffffffffULL
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/lib/swiotlb.c dma_data_direction.hg/lib/swiotlb.c
--- vanilla/lib/swiotlb.c 2005-11-12 15:52:15.000000000 -0500
+++ dma_data_direction.hg/lib/swiotlb.c 2005-11-18 16:24:29.000000000 -0500
@@ -280,7 +280,7 @@ address_needs_mapping(struct device *hwd
* Allocates bounce buffer and returns its kernel virtual address.
*/
static void *
-map_single(struct device *hwdev, char *buffer, size_t size, int dir)
+map_single(struct device *hwdev, char *buffer, size_t size, enum dma_data_direction dir)
{
unsigned long flags;
char *dma_addr;
@@ -363,7 +363,7 @@ map_single(struct device *hwdev, char *b
* dma_addr is the kernel virtual address of the bounce buffer to unmap.
*/
static void
-unmap_single(struct device *hwdev, char *dma_addr, size_t size, int dir)
+unmap_single(struct device *hwdev, char *dma_addr, size_t size, enum dma_data_direction dir)
{
unsigned long flags;
int i, count, nslots = ALIGN(size, 1 << IO_TLB_SHIFT) >> IO_TLB_SHIFT;
@@ -408,7 +408,7 @@ unmap_single(struct device *hwdev, char

static void
sync_single(struct device *hwdev, char *dma_addr, size_t size,
- int dir, int target)
+ enum dma_data_direction dir, int target)
{
int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
char *buffer = io_tlb_orig_addr[index];
@@ -497,7 +497,7 @@ swiotlb_free_coherent(struct device *hwd
}

static void
-swiotlb_full(struct device *dev, size_t size, int dir, int do_panic)
+swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, int do_panic)
{
/*
* Ran out of IOMMU space for this operation. This is very bad.
@@ -525,7 +525,7 @@ swiotlb_full(struct device *dev, size_t
* either swiotlb_unmap_single or swiotlb_dma_sync_single is performed.
*/
dma_addr_t
-swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
+swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, enum dma_data_direction dir)
{
unsigned long dev_addr = virt_to_phys(ptr);
void *map;
@@ -589,7 +589,7 @@ mark_clean(void *addr, size_t size)
*/
void
swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
- int dir)
+ enum dma_data_direction dir)
{
char *dma_addr = phys_to_virt(dev_addr);

@@ -613,7 +613,7 @@ swiotlb_unmap_single(struct device *hwde
*/
static inline void
swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir, int target)
+ size_t size, enum dma_data_direction dir, int target)
{
char *dma_addr = phys_to_virt(dev_addr);

@@ -627,14 +627,14 @@ swiotlb_sync_single(struct device *hwdev

void
swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir)
+ size_t size, enum dma_data_direction dir)
{
swiotlb_sync_single(hwdev, dev_addr, size, dir, SYNC_FOR_CPU);
}

void
swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr,
- size_t size, int dir)
+ size_t size, enum dma_data_direction dir)
{
swiotlb_sync_single(hwdev, dev_addr, size, dir, SYNC_FOR_DEVICE);
}
@@ -645,7 +645,7 @@ swiotlb_sync_single_for_device(struct de
static inline void
swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
unsigned long offset, size_t size,
- int dir, int target)
+ enum dma_data_direction dir, int target)
{
char *dma_addr = phys_to_virt(dev_addr) + offset;

@@ -659,7 +659,8 @@ swiotlb_sync_single_range(struct device

void
swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr,
- unsigned long offset, size_t size, int dir)
+ unsigned long offset, size_t size,
+ enum dma_data_direction dir)
{
swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir,
SYNC_FOR_CPU);
@@ -667,7 +668,8 @@ swiotlb_sync_single_range_for_cpu(struct

void
swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
- unsigned long offset, size_t size, int dir)
+ unsigned long offset, size_t size,
+ enum dma_data_direction dir)
{
swiotlb_sync_single_range(hwdev, dev_addr, offset, size, dir,
SYNC_FOR_DEVICE);
@@ -691,7 +693,7 @@ swiotlb_sync_single_range_for_device(str
*/
int
swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
- int dir)
+ enum dma_data_direction dir)
{
void *addr;
unsigned long dev_addr;
@@ -726,7 +728,7 @@ swiotlb_map_sg(struct device *hwdev, str
*/
void
swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
- int dir)
+ enum dma_data_direction dir)
{
int i;

@@ -749,7 +751,7 @@ swiotlb_unmap_sg(struct device *hwdev, s
*/
static inline void
swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
- int nelems, int dir, int target)
+ int nelems, enum dma_data_direction dir, int target)
{
int i;

@@ -764,14 +766,14 @@ swiotlb_sync_sg(struct device *hwdev, st

void
swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
- int nelems, int dir)
+ int nelems, enum dma_data_direction dir)
{
swiotlb_sync_sg(hwdev, sg, nelems, dir, SYNC_FOR_CPU);
}

void
swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
- int nelems, int dir)
+ int nelems, enum dma_data_direction dir)
{
swiotlb_sync_sg(hwdev, sg, nelems, dir, SYNC_FOR_DEVICE);
}


--
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

2005-11-21 21:55:49

by Muli Ben-Yehuda

[permalink] [raw]
Subject: [RFC PATCH 2/3] move swiotlb header file into common code - x86-64 bits

arch/x86_64/kernel/pci-gart.c | 22 +++++++++++++--------
include/asm-x86_64/dma-mapping.h | 33 +++++++++++++++++++-------------
include/asm-x86_64/swiotlb.h | 40 +--------------------------------------
3 files changed, 36 insertions(+), 59 deletions(-)

---

diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/x86_64/kernel/pci-gart.c dma_data_direction.hg/arch/x86_64/kernel/pci-gart.c
--- vanilla/arch/x86_64/kernel/pci-gart.c 2005-11-15 09:52:45.000000000 -0500
+++ dma_data_direction.hg/arch/x86_64/kernel/pci-gart.c 2005-11-18 16:28:06.000000000 -0500
@@ -30,6 +30,7 @@
#include <asm/proto.h>
#include <asm/cacheflush.h>
#include <asm/kdebug.h>
+#include <asm/swiotlb.h>

dma_addr_t bad_dma_address;

@@ -103,7 +104,7 @@ AGPEXTERN __u32 *agp_gatt_table;
static unsigned long next_bit; /* protected by iommu_bitmap_lock */
static int need_flush; /* global flush state. set for each gart wrap */
static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
- size_t size, int dir, int do_panic);
+ size_t size, enum dma_data_direction dir, int do_panic);

/* Dummy device used for NULL arguments (normally ISA). Better would
be probably a smaller DMA mask, but this is bug-to-bug compatible to i386. */
@@ -326,7 +327,8 @@ void dump_leak(void)
#define CLEAR_LEAK(x)
#endif

-static void iommu_full(struct device *dev, size_t size, int dir, int do_panic)
+static void iommu_full(struct device *dev, size_t size, enum dma_data_direction dir,
+ int do_panic)
{
/*
* Ran out of IOMMU space for this operation. This is very bad.
@@ -386,7 +388,8 @@ static inline int nonforced_iommu(struct
* Caller needs to check if the iommu is needed and flush.
*/
static dma_addr_t dma_map_area(struct device *dev, unsigned long phys_mem,
- size_t size, int dir, int do_panic)
+ size_t size, enum dma_data_direction dir,
+ int do_panic)
{
unsigned long npages = to_pages(phys_mem, size);
unsigned long iommu_page = alloc_iommu(npages);
@@ -409,7 +412,8 @@ static dma_addr_t dma_map_area(struct de
}

/* Map a single area into the IOMMU */
-dma_addr_t dma_map_single(struct device *dev, void *addr, size_t size, int dir)
+dma_addr_t dma_map_single(struct device *dev, void *addr, size_t size,
+ enum dma_data_direction dir)
{
unsigned long phys_mem, bus;

@@ -431,7 +435,7 @@ dma_addr_t dma_map_single(struct device

/* Fallback for dma_map_sg in case of overflow */
static int dma_map_sg_nonforce(struct device *dev, struct scatterlist *sg,
- int nents, int dir)
+ int nents, enum dma_data_direction dir)
{
int i;

@@ -515,7 +519,8 @@ static inline int dma_map_cont(struct sc
* DMA map all entries in a scatterlist.
* Merge chunks that have page aligned sizes into a continuous mapping.
*/
-int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
+int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction dir)
{
int i;
int out;
@@ -587,7 +592,7 @@ error:
* Free a DMA mapping.
*/
void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
- size_t size, int direction)
+ size_t size, enum dma_data_direction direction)
{
unsigned long iommu_page;
int npages;
@@ -613,7 +618,8 @@ void dma_unmap_single(struct device *dev
/*
* Wrapper for pci_unmap_single working with scatterlists.
*/
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
+void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction dir)
{
int i;
if (swiotlb) {
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/asm-x86_64/dma-mapping.h dma_data_direction.hg/include/asm-x86_64/dma-mapping.h
--- vanilla/include/asm-x86_64/dma-mapping.h 2005-11-03 01:38:45.000000000 -0500
+++ dma_data_direction.hg/include/asm-x86_64/dma-mapping.h 2005-11-18 16:29:39.000000000 -0500
@@ -24,16 +24,16 @@ void dma_free_coherent(struct device *de
#ifdef CONFIG_GART_IOMMU

extern dma_addr_t dma_map_single(struct device *hwdev, void *ptr, size_t size,
- int direction);
+ enum dma_data_direction direction);
extern void dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
- int direction);
+ enum dma_data_direction direction);

#else

/* No IOMMU */

static inline dma_addr_t dma_map_single(struct device *hwdev, void *ptr,
- size_t size, int direction)
+ size_t size, enum dma_data_direction direction)
{
dma_addr_t addr;

@@ -47,7 +47,7 @@ static inline dma_addr_t dma_map_single(
}

static inline void dma_unmap_single(struct device *hwdev, dma_addr_t dma_addr,
- size_t size, int direction)
+ size_t size, enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -61,7 +61,8 @@ static inline void dma_unmap_single(stru

static inline void dma_sync_single_for_cpu(struct device *hwdev,
dma_addr_t dma_handle,
- size_t size, int direction)
+ size_t size,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -74,7 +75,8 @@ static inline void dma_sync_single_for_c

static inline void dma_sync_single_for_device(struct device *hwdev,
dma_addr_t dma_handle,
- size_t size, int direction)
+ size_t size,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -88,7 +90,8 @@ static inline void dma_sync_single_for_d
static inline void dma_sync_single_range_for_cpu(struct device *hwdev,
dma_addr_t dma_handle,
unsigned long offset,
- size_t size, int direction)
+ size_t size,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -102,7 +105,8 @@ static inline void dma_sync_single_range
static inline void dma_sync_single_range_for_device(struct device *hwdev,
dma_addr_t dma_handle,
unsigned long offset,
- size_t size, int direction)
+ size_t size,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -115,7 +119,8 @@ static inline void dma_sync_single_range

static inline void dma_sync_sg_for_cpu(struct device *hwdev,
struct scatterlist *sg,
- int nelems, int direction)
+ int nelems,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -128,7 +133,8 @@ static inline void dma_sync_sg_for_cpu(s

static inline void dma_sync_sg_for_device(struct device *hwdev,
struct scatterlist *sg,
- int nelems, int direction)
+ int nelems,
+ enum dma_data_direction direction)
{
if (direction == DMA_NONE)
out_of_line_bug();
@@ -140,9 +146,9 @@ static inline void dma_sync_sg_for_devic
}

extern int dma_map_sg(struct device *hwdev, struct scatterlist *sg,
- int nents, int direction);
+ int nents, enum dma_data_direction direction);
extern void dma_unmap_sg(struct device *hwdev, struct scatterlist *sg,
- int nents, int direction);
+ int nents, enum dma_data_direction direction);

#define dma_unmap_page dma_unmap_single

@@ -158,7 +164,8 @@ static inline int dma_set_mask(struct de
return 0;
}

-static inline void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir)
+static inline void dma_cache_sync(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
flush_write_buffers();
}
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/asm-x86_64/swiotlb.h dma_data_direction.hg/include/asm-x86_64/swiotlb.h
--- vanilla/include/asm-x86_64/swiotlb.h 2005-11-03 01:38:45.000000000 -0500
+++ dma_data_direction.hg/include/asm-x86_64/swiotlb.h 2005-11-18 16:13:27.000000000 -0500
@@ -1,43 +1,7 @@
#ifndef _ASM_SWIOTLB_H
#define _ASM_SWTIOLB_H 1

-#include <linux/config.h>
-
-/* SWIOTLB interface */
-
-extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
- int dir);
-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(dma_addr_t dma_addr);
-extern void *swiotlb_alloc_coherent (struct device *hwdev, size_t size,
- dma_addr_t *dma_handle, gfp_t flags);
-extern void swiotlb_free_coherent (struct device *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle);
+#include <asm-generic/swiotlb.h>

#ifdef CONFIG_SWIOTLB
extern int swiotlb;
@@ -45,4 +9,4 @@ extern int swiotlb;
#define swiotlb 0
#endif

-#endif
+#endif /* _ASM_SWTIOLB_H */


--
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

2005-11-21 21:56:50

by Muli Ben-Yehuda

[permalink] [raw]
Subject: [RFC PATCH 3/3] move swiotlb header file into common code - IA64 bits

arch/ia64/hp/common/hwsw_iommu.c | 23 +++++++++++++++--------
arch/ia64/hp/common/sba_iommu.c | 12 ++++++++----
arch/ia64/kernel/machvec.c | 6 ++++--
arch/ia64/sn/pci/pci_dma.c | 16 ++++++++--------
arch/ia64/sn/pci/pcibr/pcibr_dma.c | 3 ++-
arch/ia64/sn/pci/tioca_provider.c | 3 ++-
arch/ia64/sn/pci/tioce_provider.c | 3 ++-
include/asm-ia64/machvec.h | 22 ++++++++++++----------
8 files changed, 53 insertions(+), 35 deletions(-)

---

diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/hp/common/hwsw_iommu.c dma_data_direction.hg/arch/ia64/hp/common/hwsw_iommu.c
--- vanilla/arch/ia64/hp/common/hwsw_iommu.c 2005-10-30 04:52:06.000000000 -0500
+++ dma_data_direction.hg/arch/ia64/hp/common/hwsw_iommu.c 2005-11-18 16:46:51.000000000 -0500
@@ -98,7 +98,7 @@ hwsw_free_coherent (struct device *dev,
}

dma_addr_t
-hwsw_map_single (struct device *dev, void *addr, size_t size, int dir)
+hwsw_map_single (struct device *dev, void *addr, size_t size, enum dma_data_direction dir)
{
if (use_swiotlb(dev))
return swiotlb_map_single(dev, addr, size, dir);
@@ -107,7 +107,8 @@ hwsw_map_single (struct device *dev, voi
}

void
-hwsw_unmap_single (struct device *dev, dma_addr_t iova, size_t size, int dir)
+hwsw_unmap_single (struct device *dev, dma_addr_t iova, size_t size,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
return swiotlb_unmap_single(dev, iova, size, dir);
@@ -117,7 +118,8 @@ hwsw_unmap_single (struct device *dev, d


int
-hwsw_map_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir)
+hwsw_map_sg (struct device *dev, struct scatterlist *sglist, int nents,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
return swiotlb_map_sg(dev, sglist, nents, dir);
@@ -126,7 +128,8 @@ hwsw_map_sg (struct device *dev, struct
}

void
-hwsw_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir)
+hwsw_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
return swiotlb_unmap_sg(dev, sglist, nents, dir);
@@ -135,7 +138,8 @@ hwsw_unmap_sg (struct device *dev, struc
}

void
-hwsw_sync_single_for_cpu (struct device *dev, dma_addr_t addr, size_t size, int dir)
+hwsw_sync_single_for_cpu (struct device *dev, dma_addr_t addr, size_t size,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
swiotlb_sync_single_for_cpu(dev, addr, size, dir);
@@ -144,7 +148,8 @@ hwsw_sync_single_for_cpu (struct device
}

void
-hwsw_sync_sg_for_cpu (struct device *dev, struct scatterlist *sg, int nelems, int dir)
+hwsw_sync_sg_for_cpu (struct device *dev, struct scatterlist *sg, int nelems,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
swiotlb_sync_sg_for_cpu(dev, sg, nelems, dir);
@@ -153,7 +158,8 @@ hwsw_sync_sg_for_cpu (struct device *dev
}

void
-hwsw_sync_single_for_device (struct device *dev, dma_addr_t addr, size_t size, int dir)
+hwsw_sync_single_for_device (struct device *dev, dma_addr_t addr, size_t size,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
swiotlb_sync_single_for_device(dev, addr, size, dir);
@@ -162,7 +168,8 @@ hwsw_sync_single_for_device (struct devi
}

void
-hwsw_sync_sg_for_device (struct device *dev, struct scatterlist *sg, int nelems, int dir)
+hwsw_sync_sg_for_device (struct device *dev, struct scatterlist *sg, int nelems,
+ enum dma_data_direction dir)
{
if (use_swiotlb(dev))
swiotlb_sync_sg_for_device(dev, sg, nelems, dir);
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/hp/common/sba_iommu.c dma_data_direction.hg/arch/ia64/hp/common/sba_iommu.c
--- vanilla/arch/ia64/hp/common/sba_iommu.c 2005-10-30 04:52:06.000000000 -0500
+++ dma_data_direction.hg/arch/ia64/hp/common/sba_iommu.c 2005-11-18 16:48:22.000000000 -0500
@@ -884,7 +884,8 @@ sba_mark_invalid(struct ioc *ioc, dma_ad
* See Documentation/DMA-mapping.txt
*/
dma_addr_t
-sba_map_single(struct device *dev, void *addr, size_t size, int dir)
+sba_map_single(struct device *dev, void *addr, size_t size,
+ enum dma_data_direction dir)
{
struct ioc *ioc;
dma_addr_t iovp;
@@ -998,7 +999,8 @@ sba_mark_clean(struct ioc *ioc, dma_addr
*
* See Documentation/DMA-mapping.txt
*/
-void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, int dir)
+void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
+ enum dma_data_direction dir)
{
struct ioc *ioc;
#if DELAYED_RESOURCE_CNT > 0
@@ -1387,7 +1389,8 @@ sba_coalesce_chunks( struct ioc *ioc,
*
* See Documentation/DMA-mapping.txt
*/
-int sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, int dir)
+int sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
+ enum dma_data_direction dir)
{
struct ioc *ioc;
int coalesced, filled = 0;
@@ -1477,7 +1480,8 @@ int sba_map_sg(struct device *dev, struc
*
* See Documentation/DMA-mapping.txt
*/
-void sba_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir)
+void sba_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents,
+ enum dma_data_direction dir)
{
#ifdef ASSERT_PDIR_SANITY
struct ioc *ioc;
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/kernel/machvec.c dma_data_direction.hg/arch/ia64/kernel/machvec.c
--- vanilla/arch/ia64/kernel/machvec.c 2005-09-08 07:06:37.000000000 -0400
+++ dma_data_direction.hg/arch/ia64/kernel/machvec.c 2005-11-18 16:49:39.000000000 -0500
@@ -56,14 +56,16 @@ machvec_timer_interrupt (int irq, void *
EXPORT_SYMBOL(machvec_timer_interrupt);

void
-machvec_dma_sync_single (struct device *hwdev, dma_addr_t dma_handle, size_t size, int dir)
+machvec_dma_sync_single (struct device *hwdev, dma_addr_t dma_handle, size_t size,
+ enum dma_data_direction dir)
{
mb();
}
EXPORT_SYMBOL(machvec_dma_sync_single);

void
-machvec_dma_sync_sg (struct device *hwdev, struct scatterlist *sg, int n, int dir)
+machvec_dma_sync_sg (struct device *hwdev, struct scatterlist *sg, int n,
+ enum dma_data_direction dir)
{
mb();
}
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/sn/pci/pcibr/pcibr_dma.c dma_data_direction.hg/arch/ia64/sn/pci/pcibr/pcibr_dma.c
--- vanilla/arch/ia64/sn/pci/pcibr/pcibr_dma.c 2005-09-26 08:09:53.000000000 -0400
+++ dma_data_direction.hg/arch/ia64/sn/pci/pcibr/pcibr_dma.c 2005-11-18 16:52:01.000000000 -0500
@@ -179,7 +179,8 @@ pcibr_dmatrans_direct32(struct pcidev_in
* DMA mappings for Direct 64 and 32 do not have any DMA maps.
*/
void
-pcibr_dma_unmap(struct pci_dev *hwdev, dma_addr_t dma_handle, int direction)
+pcibr_dma_unmap(struct pci_dev *hwdev, dma_addr_t dma_handle,
+ enum dma_data_direction direction)
{
struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(hwdev);
struct pcibus_info *pcibus_info =
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/sn/pci/pci_dma.c dma_data_direction.hg/arch/ia64/sn/pci/pci_dma.c
--- vanilla/arch/ia64/sn/pci/pci_dma.c 2005-10-30 04:52:06.000000000 -0500
+++ dma_data_direction.hg/arch/ia64/sn/pci/pci_dma.c 2005-11-18 16:50:15.000000000 -0500
@@ -166,7 +166,7 @@ EXPORT_SYMBOL(sn_dma_free_coherent);
* figure out how to save dmamap handle so can use two step.
*/
dma_addr_t sn_dma_map_single(struct device *dev, void *cpu_addr, size_t size,
- int direction)
+ enum dma_data_direction direction)
{
dma_addr_t dma_addr;
unsigned long phys_addr;
@@ -197,7 +197,7 @@ EXPORT_SYMBOL(sn_dma_map_single);
* coherent, so we just need to free any ATEs associated with this mapping.
*/
void sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
- int direction)
+ enum dma_data_direction direction)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
@@ -218,7 +218,7 @@ EXPORT_SYMBOL(sn_dma_unmap_single);
* Unmap a set of streaming mode DMA translations.
*/
void sn_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
- int nhwentries, int direction)
+ int nhwentries, enum dma_data_direction direction)
{
int i;
struct pci_dev *pdev = to_pci_dev(dev);
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(sn_dma_unmap_sg);
* Maps each entry of @sg for DMA.
*/
int sn_dma_map_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
- int direction)
+ enum dma_data_direction direction)
{
unsigned long phys_addr;
struct scatterlist *saved_sg = sg;
@@ -281,28 +281,28 @@ int sn_dma_map_sg(struct device *dev, st
EXPORT_SYMBOL(sn_dma_map_sg);

void sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
- size_t size, int direction)
+ size_t size, enum dma_data_direction direction)
{
BUG_ON(dev->bus != &pci_bus_type);
}
EXPORT_SYMBOL(sn_dma_sync_single_for_cpu);

void sn_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
- size_t size, int direction)
+ size_t size, enum dma_data_direction direction)
{
BUG_ON(dev->bus != &pci_bus_type);
}
EXPORT_SYMBOL(sn_dma_sync_single_for_device);

void sn_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
- int nelems, int direction)
+ int nelems, enum dma_data_direction direction)
{
BUG_ON(dev->bus != &pci_bus_type);
}
EXPORT_SYMBOL(sn_dma_sync_sg_for_cpu);

void sn_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
- int nelems, int direction)
+ int nelems, enum dma_data_direction direction)
{
BUG_ON(dev->bus != &pci_bus_type);
}
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/sn/pci/tioca_provider.c dma_data_direction.hg/arch/ia64/sn/pci/tioca_provider.c
--- vanilla/arch/ia64/sn/pci/tioca_provider.c 2005-10-30 04:52:06.000000000 -0500
+++ dma_data_direction.hg/arch/ia64/sn/pci/tioca_provider.c 2005-11-18 16:52:25.000000000 -0500
@@ -465,7 +465,8 @@ map_return:
* resources to release.
*/
static void
-tioca_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir)
+tioca_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr,
+ enum dma_data_direction dir)
{
int i, entry;
struct tioca_common *tioca_common;
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/arch/ia64/sn/pci/tioce_provider.c dma_data_direction.hg/arch/ia64/sn/pci/tioce_provider.c
--- vanilla/arch/ia64/sn/pci/tioce_provider.c 2005-11-12 15:51:54.000000000 -0500
+++ dma_data_direction.hg/arch/ia64/sn/pci/tioce_provider.c 2005-11-18 16:52:37.000000000 -0500
@@ -323,7 +323,8 @@ tioce_dma_barrier(uint64_t bus_addr, int
* to release.
*/
void
-tioce_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr, int dir)
+tioce_dma_unmap(struct pci_dev *pdev, dma_addr_t bus_addr,
+ enum dma_data_direction dir)
{
int i;
int port;
diff -Naurp --exclude-from /home/muli/w/dontdiff vanilla/include/asm-ia64/machvec.h dma_data_direction.hg/include/asm-ia64/machvec.h
--- vanilla/include/asm-ia64/machvec.h 2005-10-30 04:52:23.000000000 -0500
+++ dma_data_direction.hg/include/asm-ia64/machvec.h 2005-11-21 13:46:44.000000000 -0500
@@ -13,6 +13,8 @@
#include <linux/config.h>
#include <linux/types.h>

+#include <asm-generic/swiotlb.h>
+
/* forward declarations: */
struct device;
struct pt_regs;
@@ -39,14 +41,14 @@ typedef int ia64_mv_pci_legacy_write_t (
typedef void ia64_mv_dma_init (void);
typedef void *ia64_mv_dma_alloc_coherent (struct device *, size_t, dma_addr_t *, gfp_t);
typedef void ia64_mv_dma_free_coherent (struct device *, size_t, void *, dma_addr_t);
-typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, int);
-typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, int);
-typedef int ia64_mv_dma_map_sg (struct device *, struct scatterlist *, int, int);
-typedef void ia64_mv_dma_unmap_sg (struct device *, struct scatterlist *, int, int);
-typedef void ia64_mv_dma_sync_single_for_cpu (struct device *, dma_addr_t, size_t, int);
-typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, int);
-typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, int);
-typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, int);
+typedef dma_addr_t ia64_mv_dma_map_single (struct device *, void *, size_t, enum dma_data_direction);
+typedef void ia64_mv_dma_unmap_single (struct device *, dma_addr_t, size_t, enum dma_data_direction);
+typedef int ia64_mv_dma_map_sg (struct device *, struct scatterlist *, int, enum dma_data_direction);
+typedef void ia64_mv_dma_unmap_sg (struct device *, struct scatterlist *, int, enum dma_data_direction);
+typedef void ia64_mv_dma_sync_single_for_cpu (struct device *, dma_addr_t, size_t, enum dma_data_direction);
+typedef void ia64_mv_dma_sync_sg_for_cpu (struct device *, struct scatterlist *, int, enum dma_data_direction);
+typedef void ia64_mv_dma_sync_single_for_device (struct device *, dma_addr_t, size_t, enum dma_data_direction);
+typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist *, int, enum dma_data_direction);
typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr);
typedef int ia64_mv_dma_supported (struct device *, u64);

@@ -87,8 +89,8 @@ machvec_noop_mm (struct mm_struct *mm)

extern void machvec_setup (char **);
extern void machvec_timer_interrupt (int, void *, struct pt_regs *);
-extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int);
-extern void machvec_dma_sync_sg (struct device *, struct scatterlist *, int, int);
+extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, enum dma_data_direction);
+extern void machvec_dma_sync_sg (struct device *, struct scatterlist *, int, enum dma_data_direction);
extern void machvec_tlb_migrate_finish (struct mm_struct *);

# if defined (CONFIG_IA64_HP_SIM)


--
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/