PATCH 0/5 - sparc: use asm-generic/dma-mapping-common.h and pci-dma-compat.h

FUJITA Tomonori
2009-07-06T06:15:56+00:00

This patchset converts SPARC to use asm-generic/dma-mapping-common.h
and pci-dma-compat.h.

1/5, 2/5, and 3/5 converts SPARC to use
asm-generic/dma-mapping-common.h. All the preparation for this was
already merged in 2.6.31-rc1 so the chages are pretty trivial.

4/5 and 5/5 converts SPARC to use asm-generic/pci-dma-compat.h instead of 
the homegrown mechnism to handle dma-* and pci-* API.

SPARC32 has two dma-map-ops structures for pci and sbus (removing
arch/sparc/kernel/dma.c, PCI and SBUS DMA accessor). The global
'dma-ops' is set to sbus-dma-ops and get-dma-ops() returns
pci32-dma-ops for pci devices so we can use the appropriate dma
mapping operations.

The patchset is only compile-tested (sorry about it).

=
 arch/sparc/Kconfig                   |    1 +
 arch/sparc/include/asm/dma-mapping.h |  138 +++

PATCH 1/5 - sparc: use dma_map_ops struct by FUJITA Tomonori on 2009-07-06T06:16:15+00:00
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-diff  
-struct dma-ops {
-	void *(*alloc-coherent)(struct device *dev, size-t size,
-				dma-addr-t *dma-handle, gfp-t flag);
-	void (*free-coherent)(struct device *dev, size-t size,
-			      void *cpu-addr, dma-addr-t dma-handle);
-	dma-addr-t (*map-page)(struct device *dev, struct page *page,
-			       unsigned long offset, size-t size,
-			       enum dma-data-direction direction);
-	void (*unmap-page)(struct device *dev, dma-addr-t dma-addr,
-			   size-t size,
-			   enum dma-data-direction direction);
-	int (*map-sg)(struct device *dev, struct scatterlist *sg, int nents,
-		      enum dma-data-direction direction);
-	void (*unmap-sg)(struct device *dev, struct scatterlist *sg,
-			 int nhwentries,
-			 enum dma-data-direction direction);
-	void (*sync-single-for-cpu)(struct device *dev,
-				    dma-addr-t dma-handle, size-t size,
-				    enum dma-data-direction direction);
-	void (*sync-single-for-device)(struct device *dev,
-				       dma-addr-t dma-handle, size-t size,
-				       enum dma-data-direction direction);
-	void (*sync-sg-for-cpu)(struct device *dev, struct scatterlist *sg,
-				int nelems,
-				enum dma-data-direction direction);
-	void (*sync-sg-for-device)(struct device *dev,
-				   struct scatterlist *sg, int nents,
-				   enum dma-data-direction dir);
-};
-extern const struct dma-ops *dma-ops;
+extern const struct dma-map-ops *dma-ops;
 
 static inline void *dma-alloc-coherent(struct device *dev, size-t size,
 				       dma-addr-t *dma-handle, gfp-t flag)
@@ -62,40 +33,40 @@ static inline dma-addr-t dma-map-single(struct device *dev, void *cpu-addr,
 {
 	return dma-ops->map-page(dev, virt-to-page(cpu-addr),
 				 (unsigned long)cpu-addr & ~PAGE-MASK, size,
-				 direction);
+				 direction, NULL);
 }
 
 static inline void dma-unmap-single(struct device *dev, dma-addr-t dma-addr,
 				    size-t size,
 				    enum dma-data-direction direction)
 {
-	dma-ops->unmap-page(dev, dma-addr, size, direction);
+	dma-ops->unmap-page(dev, dma-addr, size, direction, NULL);
 }
 
 static inline dma-addr-t dma-map-page(struct device *dev, struct page *page,
 				      unsigned long offset, size-t size,
 				      enum dma-data-direction direction)
 {
-	return dma-ops->map-page(dev, page, offset, size, direction);
+	return dma-ops->map-page(dev, page, offset, size, direction, NULL);
 }
 
 static inline void dma-unmap-page(struct device *dev, dma-addr-t dma-address,
 				  size-t size,
 				  enum dma-data-direction direction)
 {
-	dma-ops->unmap-page(dev, dma-address, size, direction);
+	dma-ops->unmap-page(dev, dma-address, size, direction, NULL);
 }
 
 static inline int dma-map-sg(struct device *dev, struct scatterlist *sg,
 			     int nents, enum dma-data-direction direction)
 {
-	return dma-ops->map-sg(dev, sg, nents, direction);
+	return dma-ops->map-sg(dev, sg, nents, direction, NULL);
 }
 
 static inline void dma-unmap-sg(struct device *dev, struct scatterlist *sg,
 				int nents, enum dma-data-direction direction)
 {
-	dma-ops->unmap-sg(dev, sg, nents, direction);
+	dma-ops->unmap-sg(dev, sg, nents, direction, NULL);
 }
 
 static inline void dma-sync-single-for-cpu(struct device *dev,
diff  				 unsigned long offset, size-t size,
-				 enum dma-data-direction direction)
+				 enum dma-data-direction direction,
+				 struct dma-attrs *attrs)
 {
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type)
@@ -72,7 +73,8 @@ static dma-addr-t dma32-map-page(struct device *dev, struct page *page,
 }
 
 static void dma32-unmap-page(struct device *dev, dma-addr-t dma-address,
-			     size-t size, enum dma-data-direction direction)
+			     size-t size, enum dma-data-direction direction,
+			     struct dma-attrs *attrs)
 {
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type) {
@@ -85,7 +87,8 @@ static void dma32-unmap-page(struct device *dev, dma-addr-t dma-address,
 }
 
 static int dma32-map-sg(struct device *dev, struct scatterlist *sg,
-			int nents, enum dma-data-direction direction)
+			int nents, enum dma-data-direction direction,
+			struct dma-attrs *attrs)
 {
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type)
@@ -95,7 +98,8 @@ static int dma32-map-sg(struct device *dev, struct scatterlist *sg,
 }
 
 void dma32-unmap-sg(struct device *dev, struct scatterlist *sg,
-		    int nents, enum dma-data-direction direction)
+		    int nents, enum dma-data-direction direction,
+		    struct dma-attrs *attrs)
 {
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type) {
@@ -161,7 +165,7 @@ static void dma32-sync-sg-for-device(struct device *dev,
 	BUG();
 }
 
-static const struct dma-ops dma32-dma-ops = {
+static const struct dma-map-ops dma32-dma-ops = {
 	.alloc-coherent		= dma32-alloc-coherent,
 	.free-coherent		= dma32-free-coherent,
 	.map-page		= dma32-map-page,
@@ -174,5 +178,5 @@ static const struct dma-ops dma32-dma-ops = {
 	.sync-sg-for-device	= dma32-sync-sg-for-device,
 };
 
-const struct dma-ops *dma-ops = &dma32-dma-ops;
+const struct dma-map-ops *dma-ops = &dma32-dma-ops;
 EXPORT-SYMBOL(dma-ops);
diff  				  unsigned long offset, size-t sz,
-				  enum dma-data-direction direction)
+				  enum dma-data-direction direction,
+				  struct dma-attrs *attrs)
 {
 	struct iommu *iommu;
 	struct strbuf *strbuf;
@@ -474,7 +475,8 @@ do-flush-sync:
 }
 
 static void dma-4u-unmap-page(struct device *dev, dma-addr-t bus-addr,
-			      size-t sz, enum dma-data-direction direction)
+			      size-t sz, enum dma-data-direction direction,
+			      struct dma-attrs *attrs)
 {
 	struct iommu *iommu;
 	struct strbuf *strbuf;
@@ -520,7 +522,8 @@ static void dma-4u-unmap-page(struct device *dev, dma-addr-t bus-addr,
 }
 
 static int dma-4u-map-sg(struct device *dev, struct scatterlist *sglist,
-			 int nelems, enum dma-data-direction direction)
+			 int nelems, enum dma-data-direction direction,
+			 struct dma-attrs *attrs)
 {
 	struct scatterlist *s, *outs, *segstart;
 	unsigned long flags, handle, prot, ctx;
@@ -691,7 +694,8 @@ static unsigned long fetch-sg-ctx(struct iommu *iommu, struct scatterlist *sg)
 }
 
 static void dma-4u-unmap-sg(struct device *dev, struct scatterlist *sglist,
-			    int nelems, enum dma-data-direction direction)
+			    int nelems, enum dma-data-direction direction,
+			    struct dma-attrs *attrs)
 {
 	unsigned long flags, ctx;
 	struct scatterlist *sg;
@@ -822,7 +826,7 @@ static void dma-4u-sync-sg-for-cpu(struct device *dev,
 	spin-unlock-irqrestore(&iommu->lock, flags);
 }
 
-static const struct dma-ops sun4u-dma-ops = {
+static const struct dma-map-ops sun4u-dma-ops = {
 	.alloc-coherent		= dma-4u-alloc-coherent,
 	.free-coherent		= dma-4u-free-coherent,
 	.map-page		= dma-4u-map-page,
@@ -833,7 +837,7 @@ static const struct dma-ops sun4u-dma-ops = {
 	.sync-sg-for-cpu	= dma-4u-sync-sg-for-cpu,
 };
 
-const struct dma-ops *dma-ops = &sun4u-dma-ops;
+const struct dma-map-ops *dma-ops = &sun4u-dma-ops;
 EXPORT-SYMBOL(dma-ops);
 
 int dma-supported(struct device *dev, u64 device-mask)
diff  				  unsigned long offset, size-t sz,
-				  enum dma-data-direction direction)
+				  enum dma-data-direction direction,
+				  struct dma-attrs *attrs)
 {
 	struct iommu *iommu;
 	unsigned long flags, npages, oaddr;
@@ -296,7 +297,8 @@ iommu-map-fail:
 }
 
 static void dma-4v-unmap-page(struct device *dev, dma-addr-t bus-addr,
-			      size-t sz, enum dma-data-direction direction)
+			      size-t sz, enum dma-data-direction direction,
+			      struct dma-attrs *attrs)
 {
 	struct pci-pbm-info *pbm;
 	struct iommu *iommu;
@@ -336,7 +338,8 @@ static void dma-4v-unmap-page(struct device *dev, dma-addr-t bus-addr,
 }
 
 static int dma-4v-map-sg(struct device *dev, struct scatterlist *sglist,
-			 int nelems, enum dma-data-direction direction)
+			 int nelems, enum dma-data-direction direction,
+			 struct dma-attrs *attrs)
 {
 	struct scatterlist *s, *outs, *segstart;
 	unsigned long flags, handle, prot;
@@ -478,7 +481,8 @@ iommu-map-failed:
 }
 
 static void dma-4v-unmap-sg(struct device *dev, struct scatterlist *sglist,
-			    int nelems, enum dma-data-direction direction)
+			    int nelems, enum dma-data-direction direction,
+			    struct dma-attrs *attrs)
 {
 	struct pci-pbm-info *pbm;
 	struct scatterlist *sg;
@@ -535,7 +539,7 @@ static void dma-4v-sync-sg-for-cpu(struct device *dev,
 	/* Nothing to do... */
 }
 
-static const struct dma-ops sun4v-dma-ops = {
+static const struct dma-map-ops sun4v-dma-ops = {
 	.alloc-coherent			= dma-4v-alloc-coherent,
 	.free-coherent			= dma-4v-free-coherent,
 	.map-page			= dma-4v-map-page,

PATCH 2/5 - sparc: use asm-generic/dma-mapping-common.h by FUJITA Tomonori on 2009-07-06T06:16:28+00:00
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-diff  	select RTC-DRV-M48T59
+	select HAVE-DMA-ATTRS
 
 config SPARC32
 	def-bool !64BIT
diff  
-extern const struct dma-map-ops *dma-ops;
+extern struct dma-map-ops *dma-ops;
+
+static inline struct dma-map-ops *get-dma-ops(struct device *dev)
+{
+	return dma-ops;
+}
+
+#define flush-write-buffers()
+
+#include <asm-generic/dma-mapping-common.h>
 
 static inline void *dma-alloc-coherent(struct device *dev, size-t size,
 				       dma-addr-t *dma-handle, gfp-t flag)
@@ -27,99 +36,6 @@ static inline void dma-free-coherent(struct device *dev, size-t size,
 	dma-ops->free-coherent(dev, size, cpu-addr, dma-handle);
 }
 
-static inline dma-addr-t dma-map-single(struct device *dev, void *cpu-addr,
-					size-t size,
-					enum dma-data-direction direction)
-{
-	return dma-ops->map-page(dev, virt-to-page(cpu-addr),
-				 (unsigned long)cpu-addr & ~PAGE-MASK, size,
-				 direction, NULL);
-}
-
-static inline void dma-unmap-single(struct device *dev, dma-addr-t dma-addr,
-				    size-t size,
-				    enum dma-data-direction direction)
-{
-	dma-ops->unmap-page(dev, dma-addr, size, direction, NULL);
-}
-
-static inline dma-addr-t dma-map-page(struct device *dev, struct page *page,
-				      unsigned long offset, size-t size,
-				      enum dma-data-direction direction)
-{
-	return dma-ops->map-page(dev, page, offset, size, direction, NULL);
-}
-
-static inline void dma-unmap-page(struct device *dev, dma-addr-t dma-address,
-				  size-t size,
-				  enum dma-data-direction direction)
-{
-	dma-ops->unmap-page(dev, dma-address, size, direction, NULL);
-}
-
-static inline int dma-map-sg(struct device *dev, struct scatterlist *sg,
-			     int nents, enum dma-data-direction direction)
-{
-	return dma-ops->map-sg(dev, sg, nents, direction, NULL);
-}
-
-static inline void dma-unmap-sg(struct device *dev, struct scatterlist *sg,
-				int nents, enum dma-data-direction direction)
-{
-	dma-ops->unmap-sg(dev, sg, nents, direction, NULL);
-}
-
-static inline void dma-sync-single-for-cpu(struct device *dev,
-					   dma-addr-t dma-handle, size-t size,
-					   enum dma-data-direction direction)
-{
-	dma-ops->sync-single-for-cpu(dev, dma-handle, size, direction);
-}
-
-static inline void dma-sync-single-for-device(struct device *dev,
-					      dma-addr-t dma-handle,
-					      size-t size,
-					      enum dma-data-direction direction)
-{
-	if (dma-ops->sync-single-for-device)
-		dma-ops->sync-single-for-device(dev, dma-handle, size,
-						direction);
-}
-
-static inline void dma-sync-sg-for-cpu(struct device *dev,
-				       struct scatterlist *sg, int nelems,
-				       enum dma-data-direction direction)
-{
-	dma-ops->sync-sg-for-cpu(dev, sg, nelems, direction);
-}
-
-static inline void dma-sync-sg-for-device(struct device *dev,
-					  struct scatterlist *sg, int nelems,
-					  enum dma-data-direction direction)
-{
-	if (dma-ops->sync-sg-for-device)
-		dma-ops->sync-sg-for-device(dev, sg, nelems, direction);
-}
-
-static inline void dma-sync-single-range-for-cpu(struct device *dev,
-						 dma-addr-t dma-handle,
-						 unsigned long offset,
-						 size-t size,
-						 enum dma-data-direction dir)
-{
-	dma-sync-single-for-cpu(dev, dma-handle+offset, size, dir);
-}
-
-static inline void dma-sync-single-range-for-device(struct device *dev,
-						    dma-addr-t dma-handle,
-						    unsigned long offset,
-						    size-t size,
-						    enum dma-data-direction dir)
-{
-	dma-sync-single-for-device(dev, dma-handle+offset, size, dir);
-}
-
-
 static inline int dma-mapping-error(struct device *dev, dma-addr-t dma-addr)
 {
 	return (dma-addr == DMA-ERROR-CODE);
diff  
-static const struct dma-map-ops dma32-dma-ops = {
+static struct dma-map-ops dma32-dma-ops = {
 	.alloc-coherent		= dma32-alloc-coherent,
 	.free-coherent		= dma32-free-coherent,
 	.map-page		= dma32-map-page,
@@ -178,5 +178,5 @@ static const struct dma-map-ops dma32-dma-ops = {
 	.sync-sg-for-device	= dma32-sync-sg-for-device,
 };
 
-const struct dma-map-ops *dma-ops = &dma32-dma-ops;
+struct dma-map-ops *dma-ops = &dma32-dma-ops;
 EXPORT-SYMBOL(dma-ops);
diff  
-static const struct dma-map-ops sun4u-dma-ops = {
+static struct dma-map-ops sun4u-dma-ops = {
 	.alloc-coherent		= dma-4u-alloc-coherent,
 	.free-coherent		= dma-4u-free-coherent,
 	.map-page		= dma-4u-map-page,
@@ -837,7 +837,7 @@ static const struct dma-map-ops sun4u-dma-ops = {
 	.sync-sg-for-cpu	= dma-4u-sync-sg-for-cpu,
 };
 
-const struct dma-map-ops *dma-ops = &sun4u-dma-ops;
+struct dma-map-ops *dma-ops = &sun4u-dma-ops;
 EXPORT-SYMBOL(dma-ops);
 
 int dma-supported(struct device *dev, u64 device-mask)
diff  
-static const struct dma-map-ops sun4v-dma-ops = {
+static struct dma-map-ops sun4v-dma-ops = {
 	.alloc-coherent			= dma-4v-alloc-coherent,
 	.free-coherent			= dma-4v-free-coherent,
 	.map-page			= dma-4v-map-page,

PATCH 5/5 - sparc: use asm-generic/pci-dma-compat by FUJITA Tomonori on 2009-07-06T06:16:47+00:00
This converts SPARC to use asm-generic/pci-dma-compat instead of the
homegrown mechnism.

SPARC32 has two dma-map-ops structures for pci and sbus (removing
arch/sparc/kernel/dma.c, PCI and SBUS DMA accessor). The global
'dma-ops' is set to sbus-dma-ops and get-dma-ops() returns
pci32-dma-ops for pci devices so we can use the appropriate dma
mapping operations.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-diff  
-extern struct dma-map-ops *dma-ops;
+extern struct dma-map-ops *dma-ops, pci32-dma-ops;
+extern struct bus-type pci-bus-type;
 
 static inline struct dma-map-ops *get-dma-ops(struct device *dev)
 {
+#if defined(CONFIG-SPARC32) && defined(CONFIG-PCI)
+	if (dev->bus == &pci-bus-type)
+		return &pci32-dma-ops;
+#endif
 	return dma-ops;
 }
 
diff  #endif
+
+#include <asm-generic/pci-dma-compat.h>
+
 #endif
diff  
-#include <asm/scatterlist.h>
-
 struct pci-dev;
 
-/* Allocate and map kernel buffer using consistent mode DMA for a device.
- * hwdev should be valid struct pci-dev pointer for PCI devices.
- */
-extern void *pci-alloc-consistent(struct pci-dev *hwdev, size-t size, dma-addr-t *dma-handle);
-
-/* Free and unmap a consistent DMA buffer.
- * cpu-addr is what was returned from pci-alloc-consistent,
- * size must be the same as what as passed into pci-alloc-consistent,
- * and likewise dma-addr must be the same as what *dma-addrp was set to.
- *
- * References to the memory and mappings assosciated with cpu-addr/dma-addr
- * past this call are illegal.
- */
-extern void pci-free-consistent(struct pci-dev *hwdev, size-t size, void *vaddr, dma-addr-t dma-handle);
-
-/* Map a single buffer of the indicated size for DMA in streaming mode.
- * The 32-bit bus address to use is returned.
- *
- * Once the device is given the dma address, the device owns this memory
- * until either pci-unmap-single or pci-dma-sync-single-for-cpu is performed.
- */
-extern dma-addr-t pci-map-single(struct pci-dev *hwdev, void *ptr, size-t size, int direction);
-
-/* Unmap a single streaming mode DMA translation.  The dma-addr and size
- * must match what was provided for in a previous pci-map-single call.  All
- * other usages are undefined.
- *
- * After this call, reads by the cpu to the buffer are guaranteed to see
- * whatever the device wrote there.
- */
-extern void pci-unmap-single(struct pci-dev *hwdev, dma-addr-t dma-addr, size-t size, int direction);
-
 /* pci-unmap-{single,page} is not a nop, thus... */
 #define DECLARE-PCI-UNMAP-ADDR(ADDR-NAME)	
 	dma-addr-t ADDR-NAME;
@@ -81,69 +47,6 @@ extern void pci-unmap-single(struct pci-dev *hwdev, dma-addr-t dma-addr, size-t
 #define pci-unmap-len-set(PTR, LEN-NAME, VAL)		
 	(((PTR)->LEN-NAME) = (VAL))
 
-/*
- * Same as above, only with pages instead of mapped addresses.
- */
-extern dma-addr-t pci-map-page(struct pci-dev *hwdev, struct page *page,
-			unsigned long offset, size-t size, int direction);
-extern void pci-unmap-page(struct pci-dev *hwdev,
-			dma-addr-t dma-address, size-t size, int direction);
-
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
- * above pci-map-single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg-dma-{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci-map-single are
- * the same here.
- */
-extern int pci-map-sg(struct pci-dev *hwdev, struct scatterlist *sg, int nents, int direction);
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci-unmap-single() above.
- */
-extern void pci-unmap-sg(struct pci-dev *hwdev, struct scatterlist *sg, int nhwents, int direction);
-
-/* Make physical memory consistent for a single
- * streaming mode DMA translation after a transfer.
- *
- * If you perform a pci-map-single() but wish to interrogate the
- * buffer using the cpu, yet do not wish to teardown the PCI dma
- * mapping, you must call this function before doing so.  At the
- * next point you give the PCI dma address back to the card, you
- * must first perform a pci-dma-sync-for-device, and then the device
- * again owns the buffer.
- */
-extern void pci-dma-sync-single-for-cpu(struct pci-dev *hwdev, dma-addr-t dma-handle, size-t size, int direction);
-extern void pci-dma-sync-single-for-device(struct pci-dev *hwdev, dma-addr-t dma-handle, size-t size, int direction);
-
-/* Make physical memory consistent for a set of streaming
- * mode DMA translations after a transfer.
- *
- * The same as pci-dma-sync-single-* but for a scatter-gather list,
- * same rules and usage.
- */
-extern void pci-dma-sync-sg-for-cpu(struct pci-dev *hwdev, struct scatterlist *sg, int nelems, int direction);
-extern void pci-dma-sync-sg-for-device(struct pci-dev *hwdev, struct scatterlist *sg, int nelems, int direction);
-
-/* Return whether the given PCI device DMA address mask can
- * be supported properly.  For example, if your device can
- * only drive the low 24-bits during PCI bus mastering, then
- * you would pass 0x00ffffff as the mask to this function.
- */
-static inline int pci-dma-supported(struct pci-dev *hwdev, u64 mask)
-{
-	return 1;
-}
-
 #ifdef CONFIG-PCI
 static inline void pci-dma-burst-advice(struct pci-dev *pdev,
 					enum pci-dma-burst-strategy *strat,
@@ -154,14 +57,6 @@ static inline void pci-dma-burst-advice(struct pci-dev *pdev,
 }
 #endif
 
-#define PCI-DMA-ERROR-CODE      (~(dma-addr-t)0x0)
-
-static inline int pci-dma-mapping-error(struct pci-dev *pdev,
-					dma-addr-t dma-addr)
-{
-        return (dma-addr == PCI-DMA-ERROR-CODE);
-}
-
 struct device-node;
 extern struct device-node *pci-device-to-OF-node(struct pci-dev *pdev);
 
diff  
-static inline void *pci-alloc-consistent(struct pci-dev *pdev, size-t size,
-					 dma-addr-t *dma-handle)
-{
-	return dma-alloc-coherent(&pdev->dev, size, dma-handle, GFP-ATOMIC);
-}
-
-static inline void pci-free-consistent(struct pci-dev *pdev, size-t size,
-				       void *vaddr, dma-addr-t dma-handle)
-{
-	return dma-free-coherent(&pdev->dev, size, vaddr, dma-handle);
-}
-
-static inline dma-addr-t pci-map-single(struct pci-dev *pdev, void *ptr,
-					size-t size, int direction)
-{
-	return dma-map-single(&pdev->dev, ptr, size,
-			      (enum dma-data-direction) direction);
-}
-
-static inline void pci-unmap-single(struct pci-dev *pdev, dma-addr-t dma-addr,
-				    size-t size, int direction)
-{
-	dma-unmap-single(&pdev->dev, dma-addr, size,
-			 (enum dma-data-direction) direction);
-}
-
-#define pci-map-page(dev, page, off, size, dir) 
-	pci-map-single(dev, (page-address(page) + (off)), size, dir)
-#define pci-unmap-page(dev,addr,sz,dir) 
-	pci-unmap-single(dev,addr,sz,dir)
-
 /* pci-unmap-{single,page} is not a nop, thus... */
 #define DECLARE-PCI-UNMAP-ADDR(ADDR-NAME)	
 	dma-addr-t ADDR-NAME;
@@ -80,57 +49,6 @@ static inline void pci-unmap-single(struct pci-dev *pdev, dma-addr-t dma-addr,
 #define pci-unmap-len-set(PTR, LEN-NAME, VAL)		
 	(((PTR)->LEN-NAME) = (VAL))
 
-static inline int pci-map-sg(struct pci-dev *pdev, struct scatterlist *sg,
-			     int nents, int direction)
-{
-	return dma-map-sg(&pdev->dev, sg, nents,
-			  (enum dma-data-direction) direction);
-}
-
-static inline void pci-unmap-sg(struct pci-dev *pdev, struct scatterlist *sg,
-				int nents, int direction)
-{
-	dma-unmap-sg(&pdev->dev, sg, nents,
-		     (enum dma-data-direction) direction);
-}
-
-static inline void pci-dma-sync-single-for-cpu(struct pci-dev *pdev,
-					       dma-addr-t dma-handle,
-					       size-t size, int direction)
-{
-	dma-sync-single-for-cpu(&pdev->dev, dma-handle, size,
-				(enum dma-data-direction) direction);
-}
-
-static inline void pci-dma-sync-single-for-device(struct pci-dev *pdev,
-						  dma-addr-t dma-handle,
-						  size-t size, int direction)
-{
-	/* No flushing needed to sync cpu writes to the device.  */
-}
-
-static inline void pci-dma-sync-sg-for-cpu(struct pci-dev *pdev,
-					   struct scatterlist *sg,
-					   int nents, int direction)
-{
-	dma-sync-sg-for-cpu(&pdev->dev, sg, nents,
-			    (enum dma-data-direction) direction);
-}
-
-static inline void pci-dma-sync-sg-for-device(struct pci-dev *pdev,
-					      struct scatterlist *sg,
-					      int nelems, int direction)
-{
-	/* No flushing needed to sync cpu writes to the device.  */
-}
-
-/* Return whether the given PCI device DMA address mask can
- * be supported properly.  For example, if your device can
- * only drive the low 24-bits during PCI bus mastering, then
- * you would pass 0x00ffffff as the mask to this function.
- */
-extern int pci-dma-supported(struct pci-dev *hwdev, u64 mask);
-
 /* PCI IOMMU mapping bypass support. */
 
 /* PCI 64-bit addressing works for all slots on all controller
@@ -140,12 +58,6 @@ extern int pci-dma-supported(struct pci-dev *hwdev, u64 mask);
 #define PCI64-REQUIRED-MASK	(~(dma64-addr-t)0)
 #define PCI64-ADDR-BASE		0xfffc000000000000UL
 
-static inline int pci-dma-mapping-error(struct pci-dev *pdev,
-					dma-addr-t dma-addr)
-{
-	return dma-mapping-error(&pdev->dev, dma-addr);
-}
-
 #ifdef CONFIG-PCI
 static inline void pci-dma-burst-advice(struct pci-dev *pdev,
 					enum pci-dma-burst-strategy *strat,
diff  
-#include "dma.h"
-
+/*
+ * Return whether the given PCI device DMA address mask can be
+ * supported properly.  For example, if your device can only drive the
+ * low 24-bits during PCI bus mastering, then you would pass
+ * 0x00ffffff as the mask to this function.
+ */
 int dma-supported(struct device *dev, u64 mask)
 {
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type)
-		return pci-dma-supported(to-pci-dev(dev), mask);
+		return 1;
 #endif
 	return 0;
 }
@@ -34,148 +38,3 @@ int dma-set-mask(struct device *dev, u64 dma-mask)
 	return -EOPNOTSUPP;
 }
 EXPORT-SYMBOL(dma-set-mask);
-
-static void *dma32-alloc-coherent(struct device *dev, size-t size,
-				  dma-addr-t *dma-handle, gfp-t flag)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type)
-		return pci-alloc-consistent(to-pci-dev(dev), size, dma-handle);
-#endif
-	return sbus-alloc-consistent(dev, size, dma-handle);
-}
-
-static void dma32-free-coherent(struct device *dev, size-t size,
-				void *cpu-addr, dma-addr-t dma-handle)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-free-consistent(to-pci-dev(dev), size,
-				    cpu-addr, dma-handle);
-		return;
-	}
-#endif
-	sbus-free-consistent(dev, size, cpu-addr, dma-handle);
-}
-
-static dma-addr-t dma32-map-page(struct device *dev, struct page *page,
-				 unsigned long offset, size-t size,
-				 enum dma-data-direction direction,
-				 struct dma-attrs *attrs)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type)
-		return pci-map-page(to-pci-dev(dev), page, offset,
-				    size, (int)direction);
-#endif
-	return sbus-map-page(dev, page, offset, size, (int)direction);
-}
-
-static void dma32-unmap-page(struct device *dev, dma-addr-t dma-address,
-			     size-t size, enum dma-data-direction direction,
-			     struct dma-attrs *attrs)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-unmap-page(to-pci-dev(dev), dma-address,
-			       size, (int)direction);
-		return;
-	}
-#endif
-	sbus-unmap-page(dev, dma-address, size, (int)direction);
-}
-
-static int dma32-map-sg(struct device *dev, struct scatterlist *sg,
-			int nents, enum dma-data-direction direction,
-			struct dma-attrs *attrs)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type)
-		return pci-map-sg(to-pci-dev(dev), sg, nents, (int)direction);
-#endif
-	return sbus-map-sg(dev, sg, nents, direction);
-}
-
-void dma32-unmap-sg(struct device *dev, struct scatterlist *sg,
-		    int nents, enum dma-data-direction direction,
-		    struct dma-attrs *attrs)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-unmap-sg(to-pci-dev(dev), sg, nents, (int)direction);
-		return;
-	}
-#endif
-	sbus-unmap-sg(dev, sg, nents, (int)direction);
-}
-
-static void dma32-sync-single-for-cpu(struct device *dev, dma-addr-t dma-handle,
-				      size-t size,
-				      enum dma-data-direction direction)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-dma-sync-single-for-cpu(to-pci-dev(dev), dma-handle,
-					    size, (int)direction);
-		return;
-	}
-#endif
-	sbus-dma-sync-single-for-cpu(dev, dma-handle, size, (int) direction);
-}
-
-static void dma32-sync-single-for-device(struct device *dev,
-					 dma-addr-t dma-handle, size-t size,
-					 enum dma-data-direction direction)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-dma-sync-single-for-device(to-pci-dev(dev), dma-handle,
-					       size, (int)direction);
-		return;
-	}
-#endif
-	sbus-dma-sync-single-for-device(dev, dma-handle, size, (int) direction);
-}
-
-static void dma32-sync-sg-for-cpu(struct device *dev, struct scatterlist *sg,
-				  int nelems, enum dma-data-direction direction)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-dma-sync-sg-for-cpu(to-pci-dev(dev), sg,
-					nelems, (int)direction);
-		return;
-	}
-#endif
-	BUG();
-}
-
-static void dma32-sync-sg-for-device(struct device *dev,
-				     struct scatterlist *sg, int nelems,
-				     enum dma-data-direction direction)
-{
-#ifdef CONFIG-PCI
-	if (dev->bus == &pci-bus-type) {
-		pci-dma-sync-sg-for-device(to-pci-dev(dev), sg,
-					   nelems, (int)direction);
-		return;
-	}
-#endif
-	BUG();
-}
-
-static struct dma-map-ops dma32-dma-ops = {
-	.alloc-coherent		= dma32-alloc-coherent,
-	.free-coherent		= dma32-free-coherent,
-	.map-page		= dma32-map-page,
-	.unmap-page		= dma32-unmap-page,
-	.map-sg			= dma32-map-sg,
-	.unmap-sg		= dma32-unmap-sg,
-	.sync-single-for-cpu	= dma32-sync-single-for-cpu,
-	.sync-single-for-device	= dma32-sync-single-for-device,
-	.sync-sg-for-cpu	= dma32-sync-sg-for-cpu,
-	.sync-sg-for-device	= dma32-sync-sg-for-device,
-};
-
-struct dma-map-ops *dma-ops = &dma32-dma-ops;
-EXPORT-SYMBOL(dma-ops);
diff -void sbus-free-consistent(struct device *dev, long n, void *p, u32 ba);
-dma-addr-t sbus-map-page(struct device *dev, struct page *page,
-			 unsigned long offset, size-t len, int direction);
-void sbus-unmap-page(struct device *dev, dma-addr-t ba,
-		       size-t n, int direction);
-int sbus-map-sg(struct device *dev, struct scatterlist *sg,
-		int n, int direction);
-void sbus-unmap-sg(struct device *dev, struct scatterlist *sg,
-		   int n, int direction);
-void sbus-dma-sync-single-for-cpu(struct device *dev, dma-addr-t ba,
-				  size-t size, int direction);
-void sbus-dma-sync-single-for-device(struct device *dev, dma-addr-t ba,
-				     size-t size, int direction);
diff  
+extern int pci64-dma-supported(struct pci-dev *pdev, u64 device-mask);
+
 int dma-supported(struct device *dev, u64 device-mask)
 {
 	struct iommu *iommu = dev->archdata.iommu;
@@ -853,7 +855,7 @@ int dma-supported(struct device *dev, u64 device-mask)
 
 #ifdef CONFIG-PCI
 	if (dev->bus == &pci-bus-type)
-		return pci-dma-supported(to-pci-dev(dev), device-mask);
+		return pci64-dma-supported(to-pci-dev(dev), device-mask);
 #endif
 
 	return 0;
diff  
-#include "dma.h"
-
 #define mmu-inval-dma-area(p, l)	/* Anton pulled it out for 2.4.0-xx */
 
 static struct resource *-sparc-find-resource(struct resource *r,
@@ -246,7 +244,8 @@ EXPORT-SYMBOL(sbus-set-sbus64);
  * Typically devices use them for control blocks.
  * CPU may access them without any explicit flushing.
  */
-void *sbus-alloc-consistent(struct device *dev, long len, u32 *dma-addrp)
+static void *sbus-alloc-coherent(struct device *dev, size-t len,
+				 dma-addr-t *dma-addrp, gfp-t gfp)
 {
 	struct of-device *op = to-of-device(dev);
 	unsigned long len-total = (len + PAGE-SIZE-1) & PAGE-MASK;
@@ -299,7 +298,8 @@ err-nopages:
 	return NULL;
 }
 
-void sbus-free-consistent(struct device *dev, long n, void *p, u32 ba)
+static void sbus-free-coherent(struct device *dev, size-t n, void *p,
+			       dma-addr-t ba)
 {
 	struct resource *res;
 	struct page *pgv;
@@ -317,7 +317,7 @@ void sbus-free-consistent(struct device *dev, long n, void *p, u32 ba)
 
 	n = (n + PAGE-SIZE-1) & PAGE-MASK;
 	if ((res->end-res->start)+1 != n) {
-		printk("sbus-free-consistent: region 0x%lx asked 0x%lx
",
+		printk("sbus-free-consistent: region 0x%lx asked 0x%zx
",
 		    (long)((res->end-res->start)+1), n);
 		return;
 	}
@@ -337,8 +337,10 @@ void sbus-free-consistent(struct device *dev, long n, void *p, u32 ba)
  * CPU view of this memory may be inconsistent with
  * a device view and explicit flushing is necessary.
  */
-dma-addr-t sbus-map-page(struct device *dev, struct page *page,
-			 unsigned long offset, size-t len, int direction)
+static dma-addr-t sbus-map-page(struct device *dev, struct page *page,
+				unsigned long offset, size-t len,
+				enum dma-data-direction dir,
+				struct dma-attrs *attrs)
 {
 	void *va = page-address(page) + offset;
 
@@ -353,12 +355,14 @@ dma-addr-t sbus-map-page(struct device *dev, struct page *page,
 	return mmu-get-scsi-one(dev, va, len);
 }
 
-void sbus-unmap-page(struct device *dev, dma-addr-t ba, size-t n, int direction)
+static void sbus-unmap-page(struct device *dev, dma-addr-t ba, size-t n,
+			    enum dma-data-direction dir, struct dma-attrs *attrs)
 {
 	mmu-release-scsi-one(dev, ba, n);
 }
 
-int sbus-map-sg(struct device *dev, struct scatterlist *sg, int n, int direction)
+static int sbus-map-sg(struct device *dev, struct scatterlist *sg, int n,
+		       enum dma-data-direction dir, struct dma-attrs *attrs)
 {
 	mmu-get-scsi-sgl(dev, sg, n);
 
@@ -369,19 +373,38 @@ int sbus-map-sg(struct device *dev, struct scatterlist *sg, int n, int direction
 	return n;
 }
 
-void sbus-unmap-sg(struct device *dev, struct scatterlist *sg, int n, int direction)
+static void sbus-unmap-sg(struct device *dev, struct scatterlist *sg, int n,
+			  enum dma-data-direction dir, struct dma-attrs *attrs)
 {
 	mmu-release-scsi-sgl(dev, sg, n);
 }
 
-void sbus-dma-sync-single-for-cpu(struct device *dev, dma-addr-t ba, size-t size, int direction)
+static void sbus-sync-sg-for-cpu(struct device *dev, struct scatterlist *sg,
+				 int n,	enum dma-data-direction dir)
 {
+	BUG();
 }
 
-void sbus-dma-sync-single-for-device(struct device *dev, dma-addr-t ba, size-t size, int direction)
+static void sbus-sync-sg-for-device(struct device *dev, struct scatterlist *sg,
+				    int n, enum dma-data-direction dir)
 {
+	BUG();
 }
 
+struct dma-map-ops sbus-dma-ops = {
+	.alloc-coherent		= sbus-alloc-coherent,
+	.free-coherent		= sbus-free-coherent,
+	.map-page		= sbus-map-page,
+	.unmap-page		= sbus-unmap-page,
+	.map-sg			= sbus-map-sg,
+	.unmap-sg		= sbus-unmap-sg,
+	.sync-sg-for-cpu	= sbus-sync-sg-for-cpu,
+	.sync-sg-for-device	= sbus-sync-sg-for-device,
+};
+
+struct dma-map-ops *dma-ops = &sbus-dma-ops;
+EXPORT-SYMBOL(dma-ops);
+
 static int -void *pci-alloc-consistent(struct pci-dev *pdev, size-t len, dma-addr-t *pba)
+static void *pci32-alloc-coherent(struct device *dev, size-t len,
+				  dma-addr-t *pba, gfp-t gfp)
 {
 	unsigned long len-total = (len + PAGE-SIZE-1) & PAGE-MASK;
 	unsigned long va;
@@ -442,7 +466,6 @@ void *pci-alloc-consistent(struct pci-dev *pdev, size-t len, dma-addr-t *pba)
 	*pba = virt-to-phys(va); /* equals virt-to-bus (R.I.P.) for us. */
 	return (void *) res->start;
 }
-EXPORT-SYMBOL(pci-alloc-consistent);
 
 /* Free and unmap a consistent DMA buffer.
  * cpu-addr is what was returned from pci-alloc-consistent,
@@ -452,7 +475,8 @@ EXPORT-SYMBOL(pci-alloc-consistent);
  * References to the memory and mappings associated with cpu-addr/dma-addr
  * past this call are illegal.
  */
-void pci-free-consistent(struct pci-dev *pdev, size-t n, void *p, dma-addr-t ba)
+static void pci32-free-coherent(struct device *dev, size-t n, void *p,
+				dma-addr-t ba)
 {
 	struct resource *res;
 	unsigned long pgp;
@@ -484,60 +508,18 @@ void pci-free-consistent(struct pci-dev *pdev, size-t n, void *p, dma-addr-t ba)
 
 	free-pages(pgp, get-order(n));
 }
-EXPORT-SYMBOL(pci-free-consistent);
-
-/* Map a single buffer of the indicated size for DMA in streaming mode.
- * The 32-bit bus address to use is returned.
- *
- * Once the device is given the dma address, the device owns this memory
- * until either pci-unmap-single or pci-dma-sync-single-* is performed.
- */
-dma-addr-t pci-map-single(struct pci-dev *hwdev, void *ptr, size-t size,
-    int direction)
-{
-	BUG-ON(direction == PCI-DMA-NONE);
-	/* IIep is write-through, not flushing. */
-	return virt-to-phys(ptr);
-}
-EXPORT-SYMBOL(pci-map-single);
-
-/* Unmap a single streaming mode DMA translation.  The dma-addr and size
- * must match what was provided for in a previous pci-map-single call.  All
- * other usages are undefined.
- *
- * After this call, reads by the cpu to the buffer are guaranteed to see
- * whatever the device wrote there.
- */
-void pci-unmap-single(struct pci-dev *hwdev, dma-addr-t ba, size-t size,
-    int direction)
-{
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
-		mmu-inval-dma-area((unsigned long)phys-to-virt(ba),
-		    (size + PAGE-SIZE-1) & PAGE-MASK);
-	}
-}
-EXPORT-SYMBOL(pci-unmap-single);
 
 /*
  * Same as pci-map-single, but with pages.
  */
-dma-addr-t pci-map-page(struct pci-dev *hwdev, struct page *page,
-			unsigned long offset, size-t size, int direction)
+static dma-addr-t pci32-map-page(struct device *dev, struct page *page,
+				 unsigned long offset, size-t size,
+				 enum dma-data-direction dir,
+				 struct dma-attrs *attrs)
 {
-	BUG-ON(direction == PCI-DMA-NONE);
 	/* IIep is write-through, not flushing. */
 	return page-to-phys(page) + offset;
 }
-EXPORT-SYMBOL(pci-map-page);
-
-void pci-unmap-page(struct pci-dev *hwdev,
-			dma-addr-t dma-address, size-t size, int direction)
-{
-	BUG-ON(direction == PCI-DMA-NONE);
-	/* mmu-inval-dma-area XXX */
-}
-EXPORT-SYMBOL(pci-unmap-page);
 
 /* Map a set of buffers described by scatterlist in streaming
  * mode for DMA.  This is the scather-gather version of the
@@ -554,13 +536,13 @@ EXPORT-SYMBOL(pci-unmap-page);
  * Device ownership issues as mentioned above for pci-map-single are
  * the same here.
  */
-int pci-map-sg(struct pci-dev *hwdev, struct scatterlist *sgl, int nents,
-    int direction)
+static int pci32-map-sg(struct device *device, struct scatterlist *sgl,
+			int nents, enum dma-data-direction dir,
+			struct dma-attrs *attrs)
 {
 	struct scatterlist *sg;
 	int n;
 
-	BUG-ON(direction == PCI-DMA-NONE);
 	/* IIep is write-through, not flushing. */
 	for-each-sg(sgl, sg, nents, n) {
 		BUG-ON(page-address(sg-page(sg)) == NULL);
@@ -569,20 +551,19 @@ int pci-map-sg(struct pci-dev *hwdev, struct scatterlist *sgl, int nents,
 	}
 	return nents;
 }
-EXPORT-SYMBOL(pci-map-sg);
 
 /* Unmap a set of streaming mode DMA translations.
  * Again, cpu read rules concerning calls here are the same as for
  * pci-unmap-single() above.
  */
-void pci-unmap-sg(struct pci-dev *hwdev, struct scatterlist *sgl, int nents,
-    int direction)
+static void pci32-unmap-sg(struct device *dev, struct scatterlist *sgl,
+			   int nents, enum dma-data-direction dir,
+			   struct dma-attrs *attrs)
 {
 	struct scatterlist *sg;
 	int n;
 
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
+	if (dir != PCI-DMA-TODEVICE) {
 		for-each-sg(sgl, sg, nents, n) {
 			BUG-ON(page-address(sg-page(sg)) == NULL);
 			mmu-inval-dma-area(
@@ -591,7 +572,6 @@ void pci-unmap-sg(struct pci-dev *hwdev, struct scatterlist *sgl, int nents,
 		}
 	}
 }
-EXPORT-SYMBOL(pci-unmap-sg);
 
 /* Make physical memory consistent for a single
  * streaming mode DMA translation before or after a transfer.
@@ -603,25 +583,23 @@ EXPORT-SYMBOL(pci-unmap-sg);
  * must first perform a pci-dma-sync-for-device, and then the
  * device again owns the buffer.
  */
-void pci-dma-sync-single-for-cpu(struct pci-dev *hwdev, dma-addr-t ba, size-t size, int direction)
+static void pci32-sync-single-for-cpu(struct device *dev, dma-addr-t ba,
+				      size-t size, enum dma-data-direction dir)
 {
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
+	if (dir != PCI-DMA-TODEVICE) {
 		mmu-inval-dma-area((unsigned long)phys-to-virt(ba),
 		    (size + PAGE-SIZE-1) & PAGE-MASK);
 	}
 }
-EXPORT-SYMBOL(pci-dma-sync-single-for-cpu);
 
-void pci-dma-sync-single-for-device(struct pci-dev *hwdev, dma-addr-t ba, size-t size, int direction)
+static void pci32-sync-single-for-device(struct device *dev, dma-addr-t ba,
+					 size-t size, enum dma-data-direction dir)
 {
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
+	if (dir != PCI-DMA-TODEVICE) {
 		mmu-inval-dma-area((unsigned long)phys-to-virt(ba),
 		    (size + PAGE-SIZE-1) & PAGE-MASK);
 	}
 }
-EXPORT-SYMBOL(pci-dma-sync-single-for-device);
 
 /* Make physical memory consistent for a set of streaming
  * mode DMA translations after a transfer.
@@ -629,13 +607,13 @@ EXPORT-SYMBOL(pci-dma-sync-single-for-device);
  * The same as pci-dma-sync-single-* but for a scatter-gather list,
  * same rules and usage.
  */
-void pci-dma-sync-sg-for-cpu(struct pci-dev *hwdev, struct scatterlist *sgl, int nents, int direction)
+static void pci32-sync-sg-for-cpu(struct device *dev, struct scatterlist *sgl,
+				  int nents, enum dma-data-direction dir)
 {
 	struct scatterlist *sg;
 	int n;
 
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
+	if (dir != PCI-DMA-TODEVICE) {
 		for-each-sg(sgl, sg, nents, n) {
 			BUG-ON(page-address(sg-page(sg)) == NULL);
 			mmu-inval-dma-area(
@@ -644,15 +622,14 @@ void pci-dma-sync-sg-for-cpu(struct pci-dev *hwdev, struct scatterlist *sgl, int
 		}
 	}
 }
-EXPORT-SYMBOL(pci-dma-sync-sg-for-cpu);
 
-void pci-dma-sync-sg-for-device(struct pci-dev *hwdev, struct scatterlist *sgl, int nents, int direction)
+static void pci32-sync-sg-for-device(struct device *device, struct scatterlist *sgl,
+				     int nents, enum dma-data-direction dir)
 {
 	struct scatterlist *sg;
 	int n;
 
-	BUG-ON(direction == PCI-DMA-NONE);
-	if (direction != PCI-DMA-TODEVICE) {
+	if (dir != PCI-DMA-TODEVICE) {
 		for-each-sg(sgl, sg, nents, n) {
 			BUG-ON(page-address(sg-page(sg)) == NULL);
 			mmu-inval-dma-area(
@@ -661,7 +638,20 @@ void pci-dma-sync-sg-for-device(struct pci-dev *hwdev, struct scatterlist *sgl,
 		}
 	}
 }
-EXPORT-SYMBOL(pci-dma-sync-sg-for-device);
+
+struct dma-map-ops pci32-dma-ops = {
+	.alloc-coherent		= pci32-alloc-coherent,
+	.free-coherent		= pci32-free-coherent,
+	.map-page		= pci32-map-page,
+	.map-sg			= pci32-map-sg,
+	.unmap-sg		= pci32-unmap-sg,
+	.sync-single-for-cpu	= pci32-sync-single-for-cpu,
+	.sync-single-for-device	= pci32-sync-single-for-device,
+	.sync-sg-for-cpu	= pci32-sync-sg-for-cpu,
+	.sync-sg-for-device	= pci32-sync-sg-for-device,
+};
+EXPORT-SYMBOL(pci32-dma-ops);
+
 #endif /* CONFIG-PCI */
 
 #ifdef CONFIG-PROC-FS
diff  
-int pci-dma-supported(struct pci-dev *pdev, u64 device-mask)
+int pci64-dma-supported(struct pci-dev *pdev, u64 device-mask)
 {
 	u64 dma-addr-mask;
 

Re: PATCH 5/5 - sparc: use asm-generic/pci-dma-compat by Arnd Bergmann on 2009-07-06T08:22:08+00:00
On Monday 06 July 2009, FUJITA Tomonori wrote:

> > -extern int pci-dma-supported(struct pci-dev *hwdev, u64 mask);
> -
>  /* PCI IOMMU mapping bypass support. */
>  
>  /* PCI 64-bit addressing works for all slots on all controller
> > +
>  int dma-supported(struct device *dev, u64 device-mask)
>  {
>  	struct iommu *iommu = dev->archdata.iommu;

Minor nitpicking: The declaration should better be left in the header
file to avoid extern declarations in C files.

	Arnd <><

Re: PATCH 2/5 - sparc: use asm-generic/dma-mapping-common.h by Arnd Bergmann on 2009-07-06T08:26:54+00:00
On Monday 06 July 2009, FUJITA Tomonori wrote:
> +static inline struct dma-map-ops *get-dma-ops(struct device *dev)
> +{
> +       return dma-ops;
> +}
> +
> +#define flush-write-buffers()
> +
> +#include <asm-generic/dma-mapping-common.h>

I still think the flush-write-buffers() x86-ism should not be required
to use dma-mapping-common.h and only be used in arch/x86/kernel/pci-nommu.c
so you don't have to add dummy definitions to all architectures.

See http://lkml.org/lkml/2009/6/30/134

Otherwise, your series looks good!

	Arnd <><
Loading


$ This page is proudly powered by www.pubbs.net, you can see more at kernel archive | Partners: Global Manufacturers