2009-07-24 03:27:23

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 0/5] powerpc: use asm-generic/dma-mapping-common.h

This patchset converts POWERPC to use asm-generic/dma-mapping-common.h.

The major change is removing addr_needs_map in struct dma_mapping_ops
(1/5):

http://marc.info/?t=124719060200001&r=1&w=2

This is on the top of my swiotlb cleanup patchset:

http://marc.info/?l=linuxppc-embedded&m=124718920320951&w=2

The patchset also is available via a git tree:

git://git.kernel.org/pub/scm/linux/kernel/git/tomo/linux-2.6-misc.git powerpc


=
arch/powerpc/Kconfig | 2 +-
arch/powerpc/include/asm/device.h | 7 +-
arch/powerpc/include/asm/dma-mapping.h | 308 ++--------------------------
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/swiotlb.h | 8 +-
arch/powerpc/kernel/dma-iommu.c | 2 +-
arch/powerpc/kernel/dma-swiotlb.c | 50 ++---
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 +-
arch/powerpc/kernel/vio.c | 2 +-
arch/powerpc/platforms/85xx/mpc8536_ds.c | 3 +-
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 3 +-
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 3 +-
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 3 +-
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 +-
include/linux/dma-mapping.h | 1 +
18 files changed, 63 insertions(+), 349 deletions(-)



2009-07-24 03:27:19

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 2/5] powerpc: remove swiotlb_pci_dma_ops

Now swiotlb_pci_dma_ops is identical to swiotlb_dma_ops; we can use
swiotlb_dma_ops with any devices. This removes swiotlb_pci_dma_ops.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/powerpc/include/asm/swiotlb.h | 1 -
arch/powerpc/kernel/dma-swiotlb.c | 14 --------------
arch/powerpc/platforms/85xx/mpc8536_ds.c | 2 +-
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 2 +-
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 2 +-
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 2 +-
6 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 31e0e43..21ce0a3 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -14,7 +14,6 @@
#include <linux/swiotlb.h>

extern struct dma_mapping_ops swiotlb_dma_ops;
-extern struct dma_mapping_ops swiotlb_pci_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index c9f6a30..ca141e1 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -45,20 +45,6 @@ struct dma_mapping_ops swiotlb_dma_ops = {
.sync_sg_for_device = swiotlb_sync_sg_for_device
};

-struct dma_mapping_ops swiotlb_pci_dma_ops = {
- .alloc_coherent = dma_direct_alloc_coherent,
- .free_coherent = dma_direct_free_coherent,
- .map_sg = swiotlb_map_sg_attrs,
- .unmap_sg = swiotlb_unmap_sg_attrs,
- .dma_supported = swiotlb_dma_supported,
- .map_page = swiotlb_map_page,
- .unmap_page = swiotlb_unmap_page,
- .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
- .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
- .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
- .sync_sg_for_device = swiotlb_sync_sg_for_device
-};
-
void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
{
struct pci_controller *hose;
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index bf052c0..004b7d3 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -96,7 +96,7 @@ static void __init mpc8536_ds_setup_arch(void)
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
- set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index c6f92cc..544011a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -192,7 +192,7 @@ static void __init mpc85xx_ds_setup_arch(void)
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
- set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 8b8e5f9..c4961ed 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -241,7 +241,7 @@ static void __init mpc85xx_mds_setup_arch(void)
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
- set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 8032301..2aa69a6 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -105,7 +105,7 @@ mpc86xx_hpcn_setup_arch(void)
#ifdef CONFIG_SWIOTLB
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
- set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
--
1.6.0.6

2009-07-24 03:27:53

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 1/5] powerpc: remove addr_needs_map in struct dma_mapping_ops

This patch adds max_direct_dma_addr to struct dev_archdata to remove
addr_needs_map in struct dma_mapping_ops. It also converts
dma_capable() to use max_direct_dma_addr.

max_direct_dma_addr is initialized in pci_dma_dev_setup_swiotlb(),
called via ppc_md.pci_dma_dev_setup hook.

For further information:
http://marc.info/?t=124719060200001&r=1&w=2

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/powerpc/include/asm/device.h | 3 ++
arch/powerpc/include/asm/dma-mapping.h | 8 +++---
arch/powerpc/include/asm/swiotlb.h | 5 +--
arch/powerpc/kernel/dma-swiotlb.c | 36 +++++++++++----------------
arch/powerpc/platforms/85xx/mpc8536_ds.c | 1 +
arch/powerpc/platforms/85xx/mpc85xx_ds.c | 1 +
arch/powerpc/platforms/85xx/mpc85xx_mds.c | 1 +
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 1 +
8 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 7d2277c..0086f8d 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -16,6 +16,9 @@ struct dev_archdata {
/* DMA operations on that device */
struct dma_mapping_ops *dma_ops;
void *dma_data;
+#ifdef CONFIG_SWIOTLB
+ dma_addr_t max_direct_dma_addr;
+#endif
};

static inline void dev_archdata_set_node(struct dev_archdata *ad,
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 0c34371..1765c37 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -87,8 +87,6 @@ struct dma_mapping_ops {
dma_addr_t dma_address, size_t size,
enum dma_data_direction direction,
struct dma_attrs *attrs);
- int (*addr_needs_map)(struct device *dev, dma_addr_t addr,
- size_t size);
#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
void (*sync_single_range_for_cpu)(struct device *hwdev,
dma_addr_t dma_handle, unsigned long offset,
@@ -426,10 +424,12 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)

static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
{
- struct dma_mapping_ops *ops = get_dma_ops(dev);
+#ifdef CONFIG_SWIOTLB
+ struct dev_archdata *sd = &dev->archdata;

- if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size))
+ if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr)
return 0;
+#endif

if (!dev->dma_mask)
return 0;
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 30891d6..31e0e43 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -16,12 +16,11 @@
extern struct dma_mapping_ops swiotlb_dma_ops;
extern struct dma_mapping_ops swiotlb_pci_dma_ops;

-int swiotlb_arch_address_needs_mapping(struct device *, dma_addr_t,
- size_t size);
-
static inline void dma_mark_clean(void *addr, size_t size) {}

extern unsigned int ppc_swiotlb_enable;
int __init swiotlb_setup_bus_notifier(void);

+extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
+
#endif /* __ASM_SWIOTLB_H */
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e8a57de..c9f6a30 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -25,26 +25,6 @@ int swiotlb __read_mostly;
unsigned int ppc_swiotlb_enable;

/*
- * Determine if an address is reachable by a pci device, or if we must bounce.
- */
-static int
-swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size)
-{
- dma_addr_t max;
- struct pci_controller *hose;
- struct pci_dev *pdev = to_pci_dev(hwdev);
-
- hose = pci_bus_to_host(pdev->bus);
- max = hose->dma_window_base_cur + hose->dma_window_size;
-
- /* check that we're within mapped pci window space */
- if ((addr + size > max) | (addr < hose->dma_window_base_cur))
- return 1;
-
- return 0;
-}
-
-/*
* At the moment, all platforms that use this code only require
* swiotlb to be used if we're operating on HIGHMEM. Since
* we don't ever call anything other than map_sg, unmap_sg,
@@ -73,22 +53,36 @@ struct dma_mapping_ops swiotlb_pci_dma_ops = {
.dma_supported = swiotlb_dma_supported,
.map_page = swiotlb_map_page,
.unmap_page = swiotlb_unmap_page,
- .addr_needs_map = swiotlb_pci_addr_needs_map,
.sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
.sync_single_range_for_device = swiotlb_sync_single_range_for_device,
.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
.sync_sg_for_device = swiotlb_sync_sg_for_device
};

+void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
+{
+ struct pci_controller *hose;
+ struct dev_archdata *sd;
+
+ hose = pci_bus_to_host(pdev->bus);
+ sd = &pdev->dev.archdata;
+ sd->max_direct_dma_addr =
+ hose->dma_window_base_cur + hose->dma_window_size;
+}
+
static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
unsigned long action, void *data)
{
struct device *dev = data;
+ struct dev_archdata *sd;

/* We are only intereted in device addition */
if (action != BUS_NOTIFY_ADD_DEVICE)
return 0;

+ sd = &dev->archdata;
+ sd->max_direct_dma_addr = 0;
+
/* May need to bounce if the device can't address all of DRAM */
if (dma_get_mask(dev) < lmb_end_of_DRAM())
set_dma_ops(dev, &swiotlb_dma_ops);
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 055ff41..bf052c0 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -97,6 +97,7 @@ static void __init mpc8536_ds_setup_arch(void)
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 849c0ac..c6f92cc 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -193,6 +193,7 @@ static void __init mpc85xx_ds_setup_arch(void)
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 60ed9c0..8b8e5f9 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -242,6 +242,7 @@ static void __init mpc85xx_mds_setup_arch(void)
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
}
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 6632702..8032301 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -106,6 +106,7 @@ mpc86xx_hpcn_setup_arch(void)
if (lmb_end_of_DRAM() > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_pci_dma_ops);
+ ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
}
--
1.6.0.6

2009-07-24 03:27:24

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 4/5] powerpc: use dma_map_ops struct

This converts uses dma_map_ops struct (in include/linux/dma-mapping.h)
instead of POWERPC homegrown dma_mapping_ops.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/powerpc/include/asm/device.h | 4 +-
arch/powerpc/include/asm/dma-mapping.h | 84 ++++++++-----------------------
arch/powerpc/include/asm/pci.h | 4 +-
arch/powerpc/include/asm/swiotlb.h | 2 +-
arch/powerpc/kernel/dma-iommu.c | 2 +-
arch/powerpc/kernel/dma-swiotlb.c | 2 +-
arch/powerpc/kernel/dma.c | 2 +-
arch/powerpc/kernel/ibmebus.c | 2 +-
arch/powerpc/kernel/pci-common.c | 6 +-
arch/powerpc/kernel/vio.c | 2 +-
arch/powerpc/platforms/cell/iommu.c | 2 +-
arch/powerpc/platforms/ps3/system-bus.c | 4 +-
12 files changed, 37 insertions(+), 79 deletions(-)

diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index 0086f8d..67fcd7f 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -6,7 +6,7 @@
#ifndef _ASM_POWERPC_DEVICE_H
#define _ASM_POWERPC_DEVICE_H

-struct dma_mapping_ops;
+struct dma_map_ops;
struct device_node;

struct dev_archdata {
@@ -14,7 +14,7 @@ struct dev_archdata {
struct device_node *of_node;

/* DMA operations on that device */
- struct dma_mapping_ops *dma_ops;
+ struct dma_map_ops *dma_ops;
void *dma_data;
#ifdef CONFIG_SWIOTLB
dma_addr_t max_direct_dma_addr;
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 1765c37..8ca2b51 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -64,56 +64,14 @@ static inline unsigned long device_to_mask(struct device *dev)
}

/*
- * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
- */
-struct dma_mapping_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 *vaddr, dma_addr_t dma_handle);
- int (*map_sg)(struct device *dev, struct scatterlist *sg,
- int nents, enum dma_data_direction direction,
- struct dma_attrs *attrs);
- void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
- int nents, enum dma_data_direction direction,
- struct dma_attrs *attrs);
- int (*dma_supported)(struct device *dev, u64 mask);
- int (*set_dma_mask)(struct device *dev, u64 dma_mask);
- dma_addr_t (*map_page)(struct device *dev, struct page *page,
- unsigned long offset, size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs);
- void (*unmap_page)(struct device *dev,
- dma_addr_t dma_address, size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs);
-#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
- void (*sync_single_range_for_cpu)(struct device *hwdev,
- dma_addr_t dma_handle, unsigned long offset,
- size_t size,
- enum dma_data_direction direction);
- void (*sync_single_range_for_device)(struct device *hwdev,
- dma_addr_t dma_handle, unsigned long offset,
- size_t size,
- enum dma_data_direction direction);
- void (*sync_sg_for_cpu)(struct device *hwdev,
- struct scatterlist *sg, int nelems,
- enum dma_data_direction direction);
- void (*sync_sg_for_device)(struct device *hwdev,
- struct scatterlist *sg, int nelems,
- enum dma_data_direction direction);
-#endif
-};
-
-/*
* Available generic sets of operations
*/
#ifdef CONFIG_PPC64
-extern struct dma_mapping_ops dma_iommu_ops;
+extern struct dma_map_ops dma_iommu_ops;
#endif
-extern struct dma_mapping_ops dma_direct_ops;
+extern struct dma_map_ops dma_direct_ops;

-static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
+static inline struct dma_map_ops *get_dma_ops(struct device *dev)
{
/* We don't handle the NULL dev case for ISA for now. We could
* do it via an out of line call but it is not needed for now. The
@@ -126,14 +84,14 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
return dev->archdata.dma_ops;
}

-static inline void set_dma_ops(struct device *dev, struct dma_mapping_ops *ops)
+static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
{
dev->archdata.dma_ops = ops;
}

static inline int dma_supported(struct device *dev, u64 mask)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return 0;
@@ -147,7 +105,7 @@ static inline int dma_supported(struct device *dev, u64 mask)

static inline int dma_set_mask(struct device *dev, u64 dma_mask)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

if (unlikely(dma_ops == NULL))
return -EIO;
@@ -161,7 +119,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)

/*
* map_/unmap_single actually call through to map/unmap_page now that all the
- * dma_mapping_ops have been converted over. We just have to get the page and
+ * dma_map_ops have been converted over. We just have to get the page and
* offset to pass through to map_page
*/
static inline dma_addr_t dma_map_single_attrs(struct device *dev,
@@ -170,7 +128,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev,
enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -185,7 +143,7 @@ static inline void dma_unmap_single_attrs(struct device *dev,
enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -198,7 +156,7 @@ static inline dma_addr_t dma_map_page_attrs(struct device *dev,
enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -211,7 +169,7 @@ static inline void dma_unmap_page_attrs(struct device *dev,
enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -222,7 +180,7 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
int nents, enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);
return dma_ops->map_sg(dev, sg, nents, direction, attrs);
@@ -234,7 +192,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev,
enum dma_data_direction direction,
struct dma_attrs *attrs)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);
dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
@@ -243,7 +201,7 @@ static inline void dma_unmap_sg_attrs(struct device *dev,
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);
return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
@@ -252,7 +210,7 @@ static inline void *dma_alloc_coherent(struct device *dev, size_t size,
static inline void dma_free_coherent(struct device *dev, size_t size,
void *cpu_addr, dma_addr_t dma_handle)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);
dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
@@ -304,7 +262,7 @@ static inline void dma_sync_single_for_cpu(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -317,7 +275,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -330,7 +288,7 @@ static inline void dma_sync_sg_for_cpu(struct device *dev,
struct scatterlist *sgl, int nents,
enum dma_data_direction direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -342,7 +300,7 @@ static inline void dma_sync_sg_for_device(struct device *dev,
struct scatterlist *sgl, int nents,
enum dma_data_direction direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -354,7 +312,7 @@ 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 direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

@@ -367,7 +325,7 @@ 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 direction)
{
- struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+ struct dma_map_ops *dma_ops = get_dma_ops(dev);

BUG_ON(!dma_ops);

diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index d9483c5..7ae46d7 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -61,8 +61,8 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
}

#ifdef CONFIG_PCI
-extern void set_pci_dma_ops(struct dma_mapping_ops *dma_ops);
-extern struct dma_mapping_ops *get_pci_dma_ops(void);
+extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
+extern struct dma_map_ops *get_pci_dma_ops(void);
#else /* CONFIG_PCI */
#define set_pci_dma_ops(d)
#define get_pci_dma_ops() NULL
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 21ce0a3..8979d4c 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,7 +13,7 @@

#include <linux/swiotlb.h>

-extern struct dma_mapping_ops swiotlb_dma_ops;
+extern struct dma_map_ops swiotlb_dma_ops;

static inline void dma_mark_clean(void *addr, size_t size) {}

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index 2983ada..87ddb3f 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device *dev, u64 mask)
return 1;
}

-struct dma_mapping_ops dma_iommu_ops = {
+struct dma_map_ops dma_iommu_ops = {
.alloc_coherent = dma_iommu_alloc_coherent,
.free_coherent = dma_iommu_free_coherent,
.map_sg = dma_iommu_map_sg,
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index ca141e1..d1143a6 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
* map_page, and unmap_page on highmem, use normal dma_ops
* for everything else.
*/
-struct dma_mapping_ops swiotlb_dma_ops = {
+struct dma_map_ops swiotlb_dma_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = swiotlb_map_sg_attrs,
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 20a60d6..3e8bb9a 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -140,7 +140,7 @@ static inline void dma_direct_sync_single_range(struct device *dev,
}
#endif

-struct dma_mapping_ops dma_direct_ops = {
+struct dma_map_ops dma_direct_ops = {
.alloc_coherent = dma_direct_alloc_coherent,
.free_coherent = dma_direct_free_coherent,
.map_sg = dma_direct_map_sg,
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 6e3f624..a4c8b38 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
return 1;
}

-static struct dma_mapping_ops ibmebus_dma_ops = {
+static struct dma_map_ops ibmebus_dma_ops = {
.alloc_coherent = ibmebus_alloc_coherent,
.free_coherent = ibmebus_free_coherent,
.map_sg = ibmebus_map_sg,
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 5a56e97..7585f1f 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
unsigned int ppc_pci_flags = 0;


-static struct dma_mapping_ops *pci_dma_ops = &dma_direct_ops;
+static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;

-void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
+void set_pci_dma_ops(struct dma_map_ops *dma_ops)
{
pci_dma_ops = dma_ops;
}

-struct dma_mapping_ops *get_pci_dma_ops(void)
+struct dma_map_ops *get_pci_dma_ops(void)
{
return pci_dma_ops;
}
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 819e59f..bc7b41e 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -601,7 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device *dev,
vio_cmo_dealloc(viodev, alloc_size);
}

-struct dma_mapping_ops vio_dma_mapping_ops = {
+struct dma_map_ops vio_dma_mapping_ops = {
.alloc_coherent = vio_dma_iommu_alloc_coherent,
.free_coherent = vio_dma_iommu_free_coherent,
.map_sg = vio_dma_iommu_map_sg,
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 5b34fc2..416db17 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device *dev, u64 mask)

static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);

-struct dma_mapping_ops dma_iommu_fixed_ops = {
+struct dma_map_ops dma_iommu_fixed_ops = {
.alloc_coherent = dma_fixed_alloc_coherent,
.free_coherent = dma_fixed_free_coherent,
.map_sg = dma_fixed_map_sg,
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 3f763c5..02ddcc2 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device *_dev, u64 mask)
return mask >= DMA_BIT_MASK(32);
}

-static struct dma_mapping_ops ps3_sb_dma_ops = {
+static struct dma_map_ops ps3_sb_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_sb_map_sg,
@@ -704,7 +704,7 @@ static struct dma_mapping_ops ps3_sb_dma_ops = {
.unmap_page = ps3_unmap_page,
};

-static struct dma_mapping_ops ps3_ioc0_dma_ops = {
+static struct dma_map_ops ps3_ioc0_dma_ops = {
.alloc_coherent = ps3_alloc_coherent,
.free_coherent = ps3_free_coherent,
.map_sg = ps3_ioc0_map_sg,
--
1.6.0.6

2009-07-24 03:27:21

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 5/5] powerpc: use asm-generic/dma-mapping-common.h

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/powerpc/Kconfig | 2 +-
arch/powerpc/include/asm/dma-mapping.h | 242 +-------------------------------
2 files changed, 7 insertions(+), 237 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d00131c..0603b6c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -120,7 +120,7 @@ config PPC
select HAVE_KRETPROBES
select HAVE_ARCH_TRACEHOOK
select HAVE_LMB
- select HAVE_DMA_ATTRS if PPC64
+ select HAVE_DMA_ATTRS
select USE_GENERIC_SMP_HELPERS if SMP
select HAVE_OPROFILE
select HAVE_SYSCALL_WRAPPERS if PPC64
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 8ca2b51..91217e4 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -14,6 +14,7 @@
#include <linux/mm.h>
#include <linux/scatterlist.h>
#include <linux/dma-attrs.h>
+#include <linux/dma-debug.h>
#include <asm/io.h>
#include <asm/swiotlb.h>

@@ -89,6 +90,11 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
dev->archdata.dma_ops = ops;
}

+/* this will be removed soon */
+#define flush_write_buffers()
+
+#include <asm-generic/dma-mapping-common.h>
+
static inline int dma_supported(struct device *dev, u64 mask)
{
struct dma_map_ops *dma_ops = get_dma_ops(dev);
@@ -117,87 +123,6 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
return 0;
}

-/*
- * map_/unmap_single actually call through to map/unmap_page now that all the
- * dma_map_ops have been converted over. We just have to get the page and
- * offset to pass through to map_page
- */
-static inline dma_addr_t dma_map_single_attrs(struct device *dev,
- void *cpu_addr,
- size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- return dma_ops->map_page(dev, virt_to_page(cpu_addr),
- (unsigned long)cpu_addr % PAGE_SIZE, size,
- direction, attrs);
-}
-
-static inline void dma_unmap_single_attrs(struct device *dev,
- dma_addr_t dma_addr,
- size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- dma_ops->unmap_page(dev, dma_addr, size, direction, attrs);
-}
-
-static inline dma_addr_t dma_map_page_attrs(struct device *dev,
- struct page *page,
- unsigned long offset, size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- return dma_ops->map_page(dev, page, offset, size, direction, attrs);
-}
-
-static inline void dma_unmap_page_attrs(struct device *dev,
- dma_addr_t dma_address,
- size_t size,
- enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- dma_ops->unmap_page(dev, dma_address, size, direction, attrs);
-}
-
-static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
- int nents, enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
- return dma_ops->map_sg(dev, sg, nents, direction, attrs);
-}
-
-static inline void dma_unmap_sg_attrs(struct device *dev,
- struct scatterlist *sg,
- int nhwentries,
- enum dma_data_direction direction,
- struct dma_attrs *attrs)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
- dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
-}
-
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
@@ -216,161 +141,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_map_single_attrs(dev, cpu_addr, 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_unmap_single_attrs(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_map_page_attrs(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_unmap_page_attrs(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_map_sg_attrs(dev, sg, nents, direction, NULL);
-}
-
-static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
- int nhwentries,
- enum dma_data_direction direction)
-{
- dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL);
-}
-
-#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
-static inline void dma_sync_single_for_cpu(struct device *dev,
- dma_addr_t dma_handle, size_t size,
- enum dma_data_direction direction)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_single_range_for_cpu)
- dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
- 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)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_single_range_for_device)
- dma_ops->sync_single_range_for_device(dev, dma_handle,
- 0, size, direction);
-}
-
-static inline void dma_sync_sg_for_cpu(struct device *dev,
- struct scatterlist *sgl, int nents,
- enum dma_data_direction direction)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_sg_for_cpu)
- dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
-}
-
-static inline void dma_sync_sg_for_device(struct device *dev,
- struct scatterlist *sgl, int nents,
- enum dma_data_direction direction)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_sg_for_device)
- dma_ops->sync_sg_for_device(dev, sgl, nents, 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 direction)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_single_range_for_cpu)
- dma_ops->sync_single_range_for_cpu(dev, dma_handle,
- offset, size, direction);
-}
-
-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 direction)
-{
- struct dma_map_ops *dma_ops = get_dma_ops(dev);
-
- BUG_ON(!dma_ops);
-
- if (dma_ops->sync_single_range_for_device)
- dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
- size, direction);
-}
-#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
-static inline void dma_sync_single_for_cpu(struct device *dev,
- dma_addr_t dma_handle, size_t size,
- enum dma_data_direction 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)
-{
-}
-
-static inline void dma_sync_sg_for_cpu(struct device *dev,
- struct scatterlist *sgl, int nents,
- enum dma_data_direction direction)
-{
-}
-
-static inline void dma_sync_sg_for_device(struct device *dev,
- struct scatterlist *sgl, int nents,
- enum dma_data_direction 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 direction)
-{
-}
-
-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 direction)
-{
-}
-#endif
-
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
#ifdef CONFIG_PPC64
--
1.6.0.6

2009-07-24 03:27:52

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 3/5] add set_dma_mask hook to struct dma_map_ops

POWERPC needs this hook. SPARC could use it too.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
include/linux/dma-mapping.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index c0f6c3c..91b7618 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -58,6 +58,7 @@ struct dma_map_ops {
enum dma_data_direction dir);
int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
int (*dma_supported)(struct device *dev, u64 mask);
+ int (*set_dma_mask)(struct device *dev, u64 mask);
int is_phys;
};

--
1.6.0.6

2009-07-27 21:02:21

by Becky Bruce

[permalink] [raw]
Subject: Re: [PATCH 1/5] powerpc: remove addr_needs_map in struct dma_mapping_ops


On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:

> This patch adds max_direct_dma_addr to struct dev_archdata to remove
> addr_needs_map in struct dma_mapping_ops. It also converts
> dma_capable() to use max_direct_dma_addr.
>
> max_direct_dma_addr is initialized in pci_dma_dev_setup_swiotlb(),
> called via ppc_md.pci_dma_dev_setup hook.
>
> For further information:
> http://marc.info/?t=124719060200001&r=1&w=2
>
> Signed-off-by: FUJITA Tomonori <[email protected]>

Acked-by: Becky Bruce <[email protected]>

>
> ---
> arch/powerpc/include/asm/device.h | 3 ++
> arch/powerpc/include/asm/dma-mapping.h | 8 +++---
> arch/powerpc/include/asm/swiotlb.h | 5 +--
> arch/powerpc/kernel/dma-swiotlb.c | 36 ++++++++++
> +----------------
> arch/powerpc/platforms/85xx/mpc8536_ds.c | 1 +
> arch/powerpc/platforms/85xx/mpc85xx_ds.c | 1 +
> arch/powerpc/platforms/85xx/mpc85xx_mds.c | 1 +
> arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 1 +
> 8 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/
> include/asm/device.h
> index 7d2277c..0086f8d 100644
> --- a/arch/powerpc/include/asm/device.h
> +++ b/arch/powerpc/include/asm/device.h
> @@ -16,6 +16,9 @@ struct dev_archdata {
> /* DMA operations on that device */
> struct dma_mapping_ops *dma_ops;
> void *dma_data;
> +#ifdef CONFIG_SWIOTLB
> + dma_addr_t max_direct_dma_addr;
> +#endif
> };
>
> static inline void dev_archdata_set_node(struct dev_archdata *ad,
> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/
> include/asm/dma-mapping.h
> index 0c34371..1765c37 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -87,8 +87,6 @@ struct dma_mapping_ops {
> dma_addr_t dma_address, size_t size,
> enum dma_data_direction direction,
> struct dma_attrs *attrs);
> - int (*addr_needs_map)(struct device *dev, dma_addr_t addr,
> - size_t size);
> #ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
> void (*sync_single_range_for_cpu)(struct device *hwdev,
> dma_addr_t dma_handle, unsigned long offset,
> @@ -426,10 +424,12 @@ static inline int dma_mapping_error(struct
> device *dev, dma_addr_t dma_addr)
>
> static inline bool dma_capable(struct device *dev, dma_addr_t addr,
> size_t size)
> {
> - struct dma_mapping_ops *ops = get_dma_ops(dev);
> +#ifdef CONFIG_SWIOTLB
> + struct dev_archdata *sd = &dev->archdata;
>
> - if (ops->addr_needs_map && ops->addr_needs_map(dev, addr, size))
> + if (sd->max_direct_dma_addr && addr + size > sd-
> >max_direct_dma_addr)
> return 0;
> +#endif
>
> if (!dev->dma_mask)
> return 0;
> diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/
> include/asm/swiotlb.h
> index 30891d6..31e0e43 100644
> --- a/arch/powerpc/include/asm/swiotlb.h
> +++ b/arch/powerpc/include/asm/swiotlb.h
> @@ -16,12 +16,11 @@
> extern struct dma_mapping_ops swiotlb_dma_ops;
> extern struct dma_mapping_ops swiotlb_pci_dma_ops;
>
> -int swiotlb_arch_address_needs_mapping(struct device *, dma_addr_t,
> - size_t size);
> -
> static inline void dma_mark_clean(void *addr, size_t size) {}
>
> extern unsigned int ppc_swiotlb_enable;
> int __init swiotlb_setup_bus_notifier(void);
>
> +extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
> +
> #endif /* __ASM_SWIOTLB_H */
> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/
> dma-swiotlb.c
> index e8a57de..c9f6a30 100644
> --- a/arch/powerpc/kernel/dma-swiotlb.c
> +++ b/arch/powerpc/kernel/dma-swiotlb.c
> @@ -25,26 +25,6 @@ int swiotlb __read_mostly;
> unsigned int ppc_swiotlb_enable;
>
> /*
> - * Determine if an address is reachable by a pci device, or if we
> must bounce.
> - */
> -static int
> -swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr,
> size_t size)
> -{
> - dma_addr_t max;
> - struct pci_controller *hose;
> - struct pci_dev *pdev = to_pci_dev(hwdev);
> -
> - hose = pci_bus_to_host(pdev->bus);
> - max = hose->dma_window_base_cur + hose->dma_window_size;
> -
> - /* check that we're within mapped pci window space */
> - if ((addr + size > max) | (addr < hose->dma_window_base_cur))
> - return 1;
> -
> - return 0;
> -}
> -
> -/*
> * At the moment, all platforms that use this code only require
> * swiotlb to be used if we're operating on HIGHMEM. Since
> * we don't ever call anything other than map_sg, unmap_sg,
> @@ -73,22 +53,36 @@ struct dma_mapping_ops swiotlb_pci_dma_ops = {
> .dma_supported = swiotlb_dma_supported,
> .map_page = swiotlb_map_page,
> .unmap_page = swiotlb_unmap_page,
> - .addr_needs_map = swiotlb_pci_addr_needs_map,
> .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
> .sync_single_range_for_device = swiotlb_sync_single_range_for_device,
> .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
> .sync_sg_for_device = swiotlb_sync_sg_for_device
> };
>
> +void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
> +{
> + struct pci_controller *hose;
> + struct dev_archdata *sd;
> +
> + hose = pci_bus_to_host(pdev->bus);
> + sd = &pdev->dev.archdata;
> + sd->max_direct_dma_addr =
> + hose->dma_window_base_cur + hose->dma_window_size;
> +}
> +
> static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
> unsigned long action, void *data)
> {
> struct device *dev = data;
> + struct dev_archdata *sd;
>
> /* We are only intereted in device addition */
> if (action != BUS_NOTIFY_ADD_DEVICE)
> return 0;
>
> + sd = &dev->archdata;
> + sd->max_direct_dma_addr = 0;
> +
> /* May need to bounce if the device can't address all of DRAM */
> if (dma_get_mask(dev) < lmb_end_of_DRAM())
> set_dma_ops(dev, &swiotlb_dma_ops);
> diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/
> platforms/85xx/mpc8536_ds.c
> index 055ff41..bf052c0 100644
> --- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
> +++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
> @@ -97,6 +97,7 @@ static void __init mpc8536_ds_setup_arch(void)
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
>
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/
> platforms/85xx/mpc85xx_ds.c
> index 849c0ac..c6f92cc 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
> @@ -193,6 +193,7 @@ static void __init mpc85xx_ds_setup_arch(void)
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
>
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/
> powerpc/platforms/85xx/mpc85xx_mds.c
> index 60ed9c0..8b8e5f9 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -242,6 +242,7 @@ static void __init mpc85xx_mds_setup_arch(void)
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> }
> diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/
> powerpc/platforms/86xx/mpc86xx_hpcn.c
> index 6632702..8032301 100644
> --- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
> +++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
> @@ -106,6 +106,7 @@ mpc86xx_hpcn_setup_arch(void)
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> }
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-27 21:04:31

by Becky Bruce

[permalink] [raw]
Subject: Re: [PATCH 2/5] powerpc: remove swiotlb_pci_dma_ops


On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:

> Now swiotlb_pci_dma_ops is identical to swiotlb_dma_ops; we can use
> swiotlb_dma_ops with any devices. This removes swiotlb_pci_dma_ops.
>
> Signed-off-by: FUJITA Tomonori <[email protected]>

Acked-by: Becky Bruce <[email protected]>

>
> ---
> arch/powerpc/include/asm/swiotlb.h | 1 -
> arch/powerpc/kernel/dma-swiotlb.c | 14 --------------
> arch/powerpc/platforms/85xx/mpc8536_ds.c | 2 +-
> arch/powerpc/platforms/85xx/mpc85xx_ds.c | 2 +-
> arch/powerpc/platforms/85xx/mpc85xx_mds.c | 2 +-
> arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 2 +-
> 6 files changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/
> include/asm/swiotlb.h
> index 31e0e43..21ce0a3 100644
> --- a/arch/powerpc/include/asm/swiotlb.h
> +++ b/arch/powerpc/include/asm/swiotlb.h
> @@ -14,7 +14,6 @@
> #include <linux/swiotlb.h>
>
> extern struct dma_mapping_ops swiotlb_dma_ops;
> -extern struct dma_mapping_ops swiotlb_pci_dma_ops;
>
> static inline void dma_mark_clean(void *addr, size_t size) {}
>
> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/
> dma-swiotlb.c
> index c9f6a30..ca141e1 100644
> --- a/arch/powerpc/kernel/dma-swiotlb.c
> +++ b/arch/powerpc/kernel/dma-swiotlb.c
> @@ -45,20 +45,6 @@ struct dma_mapping_ops swiotlb_dma_ops = {
> .sync_sg_for_device = swiotlb_sync_sg_for_device
> };
>
> -struct dma_mapping_ops swiotlb_pci_dma_ops = {
> - .alloc_coherent = dma_direct_alloc_coherent,
> - .free_coherent = dma_direct_free_coherent,
> - .map_sg = swiotlb_map_sg_attrs,
> - .unmap_sg = swiotlb_unmap_sg_attrs,
> - .dma_supported = swiotlb_dma_supported,
> - .map_page = swiotlb_map_page,
> - .unmap_page = swiotlb_unmap_page,
> - .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu,
> - .sync_single_range_for_device =
> swiotlb_sync_single_range_for_device,
> - .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
> - .sync_sg_for_device = swiotlb_sync_sg_for_device
> -};
> -
> void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
> {
> struct pci_controller *hose;
> diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/
> platforms/85xx/mpc8536_ds.c
> index bf052c0..004b7d3 100644
> --- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
> +++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
> @@ -96,7 +96,7 @@ static void __init mpc8536_ds_setup_arch(void)
> #ifdef CONFIG_SWIOTLB
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> - set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + set_pci_dma_ops(&swiotlb_dma_ops);
> ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/
> platforms/85xx/mpc85xx_ds.c
> index c6f92cc..544011a 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
> @@ -192,7 +192,7 @@ static void __init mpc85xx_ds_setup_arch(void)
> #ifdef CONFIG_SWIOTLB
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> - set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + set_pci_dma_ops(&swiotlb_dma_ops);
> ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/
> powerpc/platforms/85xx/mpc85xx_mds.c
> index 8b8e5f9..c4961ed 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -241,7 +241,7 @@ static void __init mpc85xx_mds_setup_arch(void)
> #ifdef CONFIG_SWIOTLB
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> - set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + set_pci_dma_ops(&swiotlb_dma_ops);
> ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/
> powerpc/platforms/86xx/mpc86xx_hpcn.c
> index 8032301..2aa69a6 100644
> --- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
> +++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
> @@ -105,7 +105,7 @@ mpc86xx_hpcn_setup_arch(void)
> #ifdef CONFIG_SWIOTLB
> if (lmb_end_of_DRAM() > max) {
> ppc_swiotlb_enable = 1;
> - set_pci_dma_ops(&swiotlb_pci_dma_ops);
> + set_pci_dma_ops(&swiotlb_dma_ops);
> ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
> }
> #endif
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-27 21:04:37

by Becky Bruce

[permalink] [raw]
Subject: Re: [PATCH 3/5] add set_dma_mask hook to struct dma_map_ops


On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:

> POWERPC needs this hook. SPARC could use it too.
>
> Signed-off-by: FUJITA Tomonori <[email protected]>

Acked-by: Becky Bruce <[email protected]>

>
> ---
> include/linux/dma-mapping.h | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index c0f6c3c..91b7618 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -58,6 +58,7 @@ struct dma_map_ops {
> enum dma_data_direction dir);
> int (*mapping_error)(struct device *dev, dma_addr_t dma_addr);
> int (*dma_supported)(struct device *dev, u64 mask);
> + int (*set_dma_mask)(struct device *dev, u64 mask);
> int is_phys;
> };
>
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-27 21:04:42

by Becky Bruce

[permalink] [raw]
Subject: Re: [PATCH 4/5] powerpc: use dma_map_ops struct


On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:

> This converts uses dma_map_ops struct (in include/linux/dma-mapping.h)
> instead of POWERPC homegrown dma_mapping_ops.
>
> Signed-off-by: FUJITA Tomonori <[email protected]>

Acked-by: Becky Bruce <[email protected]>

>
> ---
> arch/powerpc/include/asm/device.h | 4 +-
> arch/powerpc/include/asm/dma-mapping.h | 84 +++++++
> +-----------------------
> arch/powerpc/include/asm/pci.h | 4 +-
> arch/powerpc/include/asm/swiotlb.h | 2 +-
> arch/powerpc/kernel/dma-iommu.c | 2 +-
> arch/powerpc/kernel/dma-swiotlb.c | 2 +-
> arch/powerpc/kernel/dma.c | 2 +-
> arch/powerpc/kernel/ibmebus.c | 2 +-
> arch/powerpc/kernel/pci-common.c | 6 +-
> arch/powerpc/kernel/vio.c | 2 +-
> arch/powerpc/platforms/cell/iommu.c | 2 +-
> arch/powerpc/platforms/ps3/system-bus.c | 4 +-
> 12 files changed, 37 insertions(+), 79 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/
> include/asm/device.h
> index 0086f8d..67fcd7f 100644
> --- a/arch/powerpc/include/asm/device.h
> +++ b/arch/powerpc/include/asm/device.h
> @@ -6,7 +6,7 @@
> #ifndef _ASM_POWERPC_DEVICE_H
> #define _ASM_POWERPC_DEVICE_H
>
> -struct dma_mapping_ops;
> +struct dma_map_ops;
> struct device_node;
>
> struct dev_archdata {
> @@ -14,7 +14,7 @@ struct dev_archdata {
> struct device_node *of_node;
>
> /* DMA operations on that device */
> - struct dma_mapping_ops *dma_ops;
> + struct dma_map_ops *dma_ops;
> void *dma_data;
> #ifdef CONFIG_SWIOTLB
> dma_addr_t max_direct_dma_addr;
> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/
> include/asm/dma-mapping.h
> index 1765c37..8ca2b51 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -64,56 +64,14 @@ static inline unsigned long
> device_to_mask(struct device *dev)
> }
>
> /*
> - * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
> - */
> -struct dma_mapping_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 *vaddr, dma_addr_t dma_handle);
> - int (*map_sg)(struct device *dev, struct scatterlist *sg,
> - int nents, enum dma_data_direction direction,
> - struct dma_attrs *attrs);
> - void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
> - int nents, enum dma_data_direction direction,
> - struct dma_attrs *attrs);
> - int (*dma_supported)(struct device *dev, u64 mask);
> - int (*set_dma_mask)(struct device *dev, u64 dma_mask);
> - dma_addr_t (*map_page)(struct device *dev, struct page *page,
> - unsigned long offset, size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs);
> - void (*unmap_page)(struct device *dev,
> - dma_addr_t dma_address, size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs);
> -#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
> - void (*sync_single_range_for_cpu)(struct device *hwdev,
> - dma_addr_t dma_handle, unsigned long offset,
> - size_t size,
> - enum dma_data_direction direction);
> - void (*sync_single_range_for_device)(struct device
> *hwdev,
> - dma_addr_t dma_handle, unsigned long offset,
> - size_t size,
> - enum dma_data_direction direction);
> - void (*sync_sg_for_cpu)(struct device *hwdev,
> - struct scatterlist *sg, int nelems,
> - enum dma_data_direction direction);
> - void (*sync_sg_for_device)(struct device *hwdev,
> - struct scatterlist *sg, int nelems,
> - enum dma_data_direction direction);
> -#endif
> -};
> -
> -/*
> * Available generic sets of operations
> */
> #ifdef CONFIG_PPC64
> -extern struct dma_mapping_ops dma_iommu_ops;
> +extern struct dma_map_ops dma_iommu_ops;
> #endif
> -extern struct dma_mapping_ops dma_direct_ops;
> +extern struct dma_map_ops dma_direct_ops;
>
> -static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
> +static inline struct dma_map_ops *get_dma_ops(struct device *dev)
> {
> /* We don't handle the NULL dev case for ISA for now. We could
> * do it via an out of line call but it is not needed for now. The
> @@ -126,14 +84,14 @@ static inline struct dma_mapping_ops
> *get_dma_ops(struct device *dev)
> return dev->archdata.dma_ops;
> }
>
> -static inline void set_dma_ops(struct device *dev, struct
> dma_mapping_ops *ops)
> +static inline void set_dma_ops(struct device *dev, struct
> dma_map_ops *ops)
> {
> dev->archdata.dma_ops = ops;
> }
>
> static inline int dma_supported(struct device *dev, u64 mask)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> if (unlikely(dma_ops == NULL))
> return 0;
> @@ -147,7 +105,7 @@ static inline int dma_supported(struct device
> *dev, u64 mask)
>
> static inline int dma_set_mask(struct device *dev, u64 dma_mask)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> if (unlikely(dma_ops == NULL))
> return -EIO;
> @@ -161,7 +119,7 @@ static inline int dma_set_mask(struct device
> *dev, u64 dma_mask)
>
> /*
> * map_/unmap_single actually call through to map/unmap_page now
> that all the
> - * dma_mapping_ops have been converted over. We just have to get
> the page and
> + * dma_map_ops have been converted over. We just have to get the
> page and
> * offset to pass through to map_page
> */
> static inline dma_addr_t dma_map_single_attrs(struct device *dev,
> @@ -170,7 +128,7 @@ static inline dma_addr_t
> dma_map_single_attrs(struct device *dev,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -185,7 +143,7 @@ static inline void dma_unmap_single_attrs(struct
> device *dev,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -198,7 +156,7 @@ static inline dma_addr_t
> dma_map_page_attrs(struct device *dev,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -211,7 +169,7 @@ static inline void dma_unmap_page_attrs(struct
> device *dev,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -222,7 +180,7 @@ static inline int dma_map_sg_attrs(struct device
> *dev, struct scatterlist *sg,
> int nents, enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> return dma_ops->map_sg(dev, sg, nents, direction, attrs);
> @@ -234,7 +192,7 @@ static inline void dma_unmap_sg_attrs(struct
> device *dev,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
> @@ -243,7 +201,7 @@ static inline void dma_unmap_sg_attrs(struct
> device *dev,
> static inline void *dma_alloc_coherent(struct device *dev, size_t
> size,
> dma_addr_t *dma_handle, gfp_t flag)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
> @@ -252,7 +210,7 @@ static inline void *dma_alloc_coherent(struct
> device *dev, size_t size,
> static inline void dma_free_coherent(struct device *dev, size_t size,
> void *cpu_addr, dma_addr_t dma_handle)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
> dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
> @@ -304,7 +262,7 @@ static inline void
> dma_sync_single_for_cpu(struct device *dev,
> dma_addr_t dma_handle, size_t size,
> enum dma_data_direction direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -317,7 +275,7 @@ static inline void
> dma_sync_single_for_device(struct device *dev,
> dma_addr_t dma_handle, size_t size,
> enum dma_data_direction direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -330,7 +288,7 @@ static inline void dma_sync_sg_for_cpu(struct
> device *dev,
> struct scatterlist *sgl, int nents,
> enum dma_data_direction direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -342,7 +300,7 @@ static inline void dma_sync_sg_for_device(struct
> device *dev,
> struct scatterlist *sgl, int nents,
> enum dma_data_direction direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -354,7 +312,7 @@ 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 direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> @@ -367,7 +325,7 @@ 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 direction)
> {
> - struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
> + struct dma_map_ops *dma_ops = get_dma_ops(dev);
>
> BUG_ON(!dma_ops);
>
> diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/
> asm/pci.h
> index d9483c5..7ae46d7 100644
> --- a/arch/powerpc/include/asm/pci.h
> +++ b/arch/powerpc/include/asm/pci.h
> @@ -61,8 +61,8 @@ static inline int pci_get_legacy_ide_irq(struct
> pci_dev *dev, int channel)
> }
>
> #ifdef CONFIG_PCI
> -extern void set_pci_dma_ops(struct dma_mapping_ops *dma_ops);
> -extern struct dma_mapping_ops *get_pci_dma_ops(void);
> +extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
> +extern struct dma_map_ops *get_pci_dma_ops(void);
> #else /* CONFIG_PCI */
> #define set_pci_dma_ops(d)
> #define get_pci_dma_ops() NULL
> diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/
> include/asm/swiotlb.h
> index 21ce0a3..8979d4c 100644
> --- a/arch/powerpc/include/asm/swiotlb.h
> +++ b/arch/powerpc/include/asm/swiotlb.h
> @@ -13,7 +13,7 @@
>
> #include <linux/swiotlb.h>
>
> -extern struct dma_mapping_ops swiotlb_dma_ops;
> +extern struct dma_map_ops swiotlb_dma_ops;
>
> static inline void dma_mark_clean(void *addr, size_t size) {}
>
> diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/
> dma-iommu.c
> index 2983ada..87ddb3f 100644
> --- a/arch/powerpc/kernel/dma-iommu.c
> +++ b/arch/powerpc/kernel/dma-iommu.c
> @@ -89,7 +89,7 @@ static int dma_iommu_dma_supported(struct device
> *dev, u64 mask)
> return 1;
> }
>
> -struct dma_mapping_ops dma_iommu_ops = {
> +struct dma_map_ops dma_iommu_ops = {
> .alloc_coherent = dma_iommu_alloc_coherent,
> .free_coherent = dma_iommu_free_coherent,
> .map_sg = dma_iommu_map_sg,
> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/
> dma-swiotlb.c
> index ca141e1..d1143a6 100644
> --- a/arch/powerpc/kernel/dma-swiotlb.c
> +++ b/arch/powerpc/kernel/dma-swiotlb.c
> @@ -31,7 +31,7 @@ unsigned int ppc_swiotlb_enable;
> * map_page, and unmap_page on highmem, use normal dma_ops
> * for everything else.
> */
> -struct dma_mapping_ops swiotlb_dma_ops = {
> +struct dma_map_ops swiotlb_dma_ops = {
> .alloc_coherent = dma_direct_alloc_coherent,
> .free_coherent = dma_direct_free_coherent,
> .map_sg = swiotlb_map_sg_attrs,
> diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
> index 20a60d6..3e8bb9a 100644
> --- a/arch/powerpc/kernel/dma.c
> +++ b/arch/powerpc/kernel/dma.c
> @@ -140,7 +140,7 @@ static inline void
> dma_direct_sync_single_range(struct device *dev,
> }
> #endif
>
> -struct dma_mapping_ops dma_direct_ops = {
> +struct dma_map_ops dma_direct_ops = {
> .alloc_coherent = dma_direct_alloc_coherent,
> .free_coherent = dma_direct_free_coherent,
> .map_sg = dma_direct_map_sg,
> diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/
> ibmebus.c
> index 6e3f624..a4c8b38 100644
> --- a/arch/powerpc/kernel/ibmebus.c
> +++ b/arch/powerpc/kernel/ibmebus.c
> @@ -127,7 +127,7 @@ static int ibmebus_dma_supported(struct device
> *dev, u64 mask)
> return 1;
> }
>
> -static struct dma_mapping_ops ibmebus_dma_ops = {
> +static struct dma_map_ops ibmebus_dma_ops = {
> .alloc_coherent = ibmebus_alloc_coherent,
> .free_coherent = ibmebus_free_coherent,
> .map_sg = ibmebus_map_sg,
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/
> pci-common.c
> index 5a56e97..7585f1f 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -50,14 +50,14 @@ resource_size_t isa_mem_base;
> unsigned int ppc_pci_flags = 0;
>
>
> -static struct dma_mapping_ops *pci_dma_ops = &dma_direct_ops;
> +static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
>
> -void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
> +void set_pci_dma_ops(struct dma_map_ops *dma_ops)
> {
> pci_dma_ops = dma_ops;
> }
>
> -struct dma_mapping_ops *get_pci_dma_ops(void)
> +struct dma_map_ops *get_pci_dma_ops(void)
> {
> return pci_dma_ops;
> }
> diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
> index 819e59f..bc7b41e 100644
> --- a/arch/powerpc/kernel/vio.c
> +++ b/arch/powerpc/kernel/vio.c
> @@ -601,7 +601,7 @@ static void vio_dma_iommu_unmap_sg(struct device
> *dev,
> vio_cmo_dealloc(viodev, alloc_size);
> }
>
> -struct dma_mapping_ops vio_dma_mapping_ops = {
> +struct dma_map_ops vio_dma_mapping_ops = {
> .alloc_coherent = vio_dma_iommu_alloc_coherent,
> .free_coherent = vio_dma_iommu_free_coherent,
> .map_sg = vio_dma_iommu_map_sg,
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/
> platforms/cell/iommu.c
> index 5b34fc2..416db17 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -642,7 +642,7 @@ static int dma_fixed_dma_supported(struct device
> *dev, u64 mask)
>
> static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);
>
> -struct dma_mapping_ops dma_iommu_fixed_ops = {
> +struct dma_map_ops dma_iommu_fixed_ops = {
> .alloc_coherent = dma_fixed_alloc_coherent,
> .free_coherent = dma_fixed_free_coherent,
> .map_sg = dma_fixed_map_sg,
> diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/
> platforms/ps3/system-bus.c
> index 3f763c5..02ddcc2 100644
> --- a/arch/powerpc/platforms/ps3/system-bus.c
> +++ b/arch/powerpc/platforms/ps3/system-bus.c
> @@ -694,7 +694,7 @@ static int ps3_dma_supported(struct device
> *_dev, u64 mask)
> return mask >= DMA_BIT_MASK(32);
> }
>
> -static struct dma_mapping_ops ps3_sb_dma_ops = {
> +static struct dma_map_ops ps3_sb_dma_ops = {
> .alloc_coherent = ps3_alloc_coherent,
> .free_coherent = ps3_free_coherent,
> .map_sg = ps3_sb_map_sg,
> @@ -704,7 +704,7 @@ static struct dma_mapping_ops ps3_sb_dma_ops = {
> .unmap_page = ps3_unmap_page,
> };
>
> -static struct dma_mapping_ops ps3_ioc0_dma_ops = {
> +static struct dma_map_ops ps3_ioc0_dma_ops = {
> .alloc_coherent = ps3_alloc_coherent,
> .free_coherent = ps3_free_coherent,
> .map_sg = ps3_ioc0_map_sg,
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-27 21:08:56

by Becky Bruce

[permalink] [raw]
Subject: Re: [PATCH 5/5] powerpc: use asm-generic/dma-mapping-common.h


On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:

> Signed-off-by: FUJITA Tomonori <[email protected]>

Fujita,

Since you're removing all the uses of it, you should probably remove
PPC_NEED_DMA_SYNC_OPS from arch/powerpc/Kconfig:

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0603b6c..fb3f4ff 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -307,10 +307,6 @@ config SWIOTLB
platforms where the size of a physical address is larger
than the bus address. Not all platforms support this.

-config PPC_NEED_DMA_SYNC_OPS
- def_bool y
- depends on (NOT_COHERENT_CACHE || SWIOTLB)
-
config HOTPLUG_CPU
bool "Support for enabling/disabling CPUs"
depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES ||
PPC_PMAC)

Otherwise, this looks good to me.

I also think you want an ACK from Ben - making this switch does add
slight overhead to platforms that don't need sync ops, but I think
it's worth it. IIRC, it was Ben who asked for the optimization of
NEED_DMA_SYNC_OPS, so I'd like him to weigh in here.

Cheers,
Becky


>
> ---
> arch/powerpc/Kconfig | 2 +-
> arch/powerpc/include/asm/dma-mapping.h | 242
> +-------------------------------
> 2 files changed, 7 insertions(+), 237 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index d00131c..0603b6c 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -120,7 +120,7 @@ config PPC
> select HAVE_KRETPROBES
> select HAVE_ARCH_TRACEHOOK
> select HAVE_LMB
> - select HAVE_DMA_ATTRS if PPC64
> + select HAVE_DMA_ATTRS
> select USE_GENERIC_SMP_HELPERS if SMP
> select HAVE_OPROFILE
> select HAVE_SYSCALL_WRAPPERS if PPC64
> diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/
> include/asm/dma-mapping.h
> index 8ca2b51..91217e4 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -14,6 +14,7 @@
> #include <linux/mm.h>
> #include <linux/scatterlist.h>
> #include <linux/dma-attrs.h>
> +#include <linux/dma-debug.h>
> #include <asm/io.h>
> #include <asm/swiotlb.h>
>
> @@ -89,6 +90,11 @@ static inline void set_dma_ops(struct device
> *dev, struct dma_map_ops *ops)
> dev->archdata.dma_ops = ops;
> }
>
> +/* this will be removed soon */
> +#define flush_write_buffers()
> +
> +#include <asm-generic/dma-mapping-common.h>
> +
> static inline int dma_supported(struct device *dev, u64 mask)
> {
> struct dma_map_ops *dma_ops = get_dma_ops(dev);
> @@ -117,87 +123,6 @@ static inline int dma_set_mask(struct device
> *dev, u64 dma_mask)
> return 0;
> }
>
> -/*
> - * map_/unmap_single actually call through to map/unmap_page now
> that all the
> - * dma_map_ops have been converted over. We just have to get the
> page and
> - * offset to pass through to map_page
> - */
> -static inline dma_addr_t dma_map_single_attrs(struct device *dev,
> - void *cpu_addr,
> - size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - return dma_ops->map_page(dev, virt_to_page(cpu_addr),
> - (unsigned long)cpu_addr % PAGE_SIZE, size,
> - direction, attrs);
> -}
> -
> -static inline void dma_unmap_single_attrs(struct device *dev,
> - dma_addr_t dma_addr,
> - size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - dma_ops->unmap_page(dev, dma_addr, size, direction, attrs);
> -}
> -
> -static inline dma_addr_t dma_map_page_attrs(struct device *dev,
> - struct page *page,
> - unsigned long offset, size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - return dma_ops->map_page(dev, page, offset, size, direction, attrs);
> -}
> -
> -static inline void dma_unmap_page_attrs(struct device *dev,
> - dma_addr_t dma_address,
> - size_t size,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - dma_ops->unmap_page(dev, dma_address, size, direction, attrs);
> -}
> -
> -static inline int dma_map_sg_attrs(struct device *dev, struct
> scatterlist *sg,
> - int nents, enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> - return dma_ops->map_sg(dev, sg, nents, direction, attrs);
> -}
> -
> -static inline void dma_unmap_sg_attrs(struct device *dev,
> - struct scatterlist *sg,
> - int nhwentries,
> - enum dma_data_direction direction,
> - struct dma_attrs *attrs)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> - dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
> -}
> -
> static inline void *dma_alloc_coherent(struct device *dev, size_t
> size,
> dma_addr_t *dma_handle, gfp_t flag)
> {
> @@ -216,161 +141,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_map_single_attrs(dev, cpu_addr, 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_unmap_single_attrs(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_map_page_attrs(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_unmap_page_attrs(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_map_sg_attrs(dev, sg, nents, direction, NULL);
> -}
> -
> -static inline void dma_unmap_sg(struct device *dev, struct
> scatterlist *sg,
> - int nhwentries,
> - enum dma_data_direction direction)
> -{
> - dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL);
> -}
> -
> -#ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS
> -static inline void dma_sync_single_for_cpu(struct device *dev,
> - dma_addr_t dma_handle, size_t size,
> - enum dma_data_direction direction)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_single_range_for_cpu)
> - dma_ops->sync_single_range_for_cpu(dev, dma_handle, 0,
> - 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)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_single_range_for_device)
> - dma_ops->sync_single_range_for_device(dev, dma_handle,
> - 0, size, direction);
> -}
> -
> -static inline void dma_sync_sg_for_cpu(struct device *dev,
> - struct scatterlist *sgl, int nents,
> - enum dma_data_direction direction)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_sg_for_cpu)
> - dma_ops->sync_sg_for_cpu(dev, sgl, nents, direction);
> -}
> -
> -static inline void dma_sync_sg_for_device(struct device *dev,
> - struct scatterlist *sgl, int nents,
> - enum dma_data_direction direction)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_sg_for_device)
> - dma_ops->sync_sg_for_device(dev, sgl, nents, 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 direction)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_single_range_for_cpu)
> - dma_ops->sync_single_range_for_cpu(dev, dma_handle,
> - offset, size, direction);
> -}
> -
> -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 direction)
> -{
> - struct dma_map_ops *dma_ops = get_dma_ops(dev);
> -
> - BUG_ON(!dma_ops);
> -
> - if (dma_ops->sync_single_range_for_device)
> - dma_ops->sync_single_range_for_device(dev, dma_handle, offset,
> - size, direction);
> -}
> -#else /* CONFIG_PPC_NEED_DMA_SYNC_OPS */
> -static inline void dma_sync_single_for_cpu(struct device *dev,
> - dma_addr_t dma_handle, size_t size,
> - enum dma_data_direction 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)
> -{
> -}
> -
> -static inline void dma_sync_sg_for_cpu(struct device *dev,
> - struct scatterlist *sgl, int nents,
> - enum dma_data_direction direction)
> -{
> -}
> -
> -static inline void dma_sync_sg_for_device(struct device *dev,
> - struct scatterlist *sgl, int nents,
> - enum dma_data_direction 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 direction)
> -{
> -}
> -
> -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 direction)
> -{
> -}
> -#endif
> -
> static inline int dma_mapping_error(struct device *dev, dma_addr_t
> dma_addr)
> {
> #ifdef CONFIG_PPC64
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-07-28 05:55:12

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH 5/5] powerpc: use asm-generic/dma-mapping-common.h

On Mon, 27 Jul 2009 16:08:46 -0500
Becky Bruce <[email protected]> wrote:

>
> On Jul 23, 2009, at 10:24 PM, FUJITA Tomonori wrote:
>
> > Signed-off-by: FUJITA Tomonori <[email protected]>
>
> Fujita,
>
> Since you're removing all the uses of it, you should probably remove
> PPC_NEED_DMA_SYNC_OPS from arch/powerpc/Kconfig:
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 0603b6c..fb3f4ff 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -307,10 +307,6 @@ config SWIOTLB
> platforms where the size of a physical address is larger
> than the bus address. Not all platforms support this.
>
> -config PPC_NEED_DMA_SYNC_OPS
> - def_bool y
> - depends on (NOT_COHERENT_CACHE || SWIOTLB)
> -
> config HOTPLUG_CPU
> bool "Support for enabling/disabling CPUs"
> depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES ||
> PPC_PMAC)
>
> Otherwise, this looks good to me.

Ah, thanks. I fold the above change. The updated patchset is available
at:

git://git.kernel.org/pub/scm/linux/kernel/git/tomo/linux-2.6-misc.git powerpc


> I also think you want an ACK from Ben - making this switch does add
> slight overhead to platforms that don't need sync ops, but I think
> it's worth it. IIRC, it was Ben who asked for the optimization of
> NEED_DMA_SYNC_OPS, so I'd like him to weigh in here.

Yeah, of course. Ben?