* [PATCH 2/7] Add celleb_dma_dev_setup()
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
@ 2007-12-05 7:20 ` Michael Ellerman
2007-12-05 23:40 ` Arnd Bergmann
2007-12-05 7:21 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops Michael Ellerman
` (5 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:20 UTC (permalink / raw)
To: linuxppc-dev
Celleb always uses dma_direct_ops, and sets dma_direct_offset, so it too
should set dma_data to dma_direct_offset.
Currently there's no pci_dma_dev_setup() routine for Celleb so add one.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/celleb/iommu.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/platforms/celleb/iommu.c b/arch/powerpc/platforms/celleb/iommu.c
index 755d869..04d5678 100644
--- a/arch/powerpc/platforms/celleb/iommu.c
+++ b/arch/powerpc/platforms/celleb/iommu.c
@@ -71,6 +71,17 @@ static void __init celleb_init_direct_mapping(void)
dma_direct_offset = dma_base;
}
+static void celleb_dma_dev_setup(struct device *dev)
+{
+ dev->archdata.dma_ops = get_pci_dma_ops();
+ dev->archdata.dma_data = &dma_direct_offset;
+}
+
+static void celleb_pci_dma_dev_setup(struct pci_dev *pdev)
+{
+ celleb_dma_dev_setup(&pdev->dev);
+}
+
static int celleb_of_bus_notify(struct notifier_block *nb,
unsigned long action, void *data)
{
@@ -80,7 +91,7 @@ static int celleb_of_bus_notify(struct notifier_block *nb,
if (action != BUS_NOTIFY_ADD_DEVICE)
return 0;
- dev->archdata.dma_ops = get_pci_dma_ops();
+ celleb_dma_dev_setup(dev);
return 0;
}
@@ -96,6 +107,7 @@ static int __init celleb_init_iommu(void)
celleb_init_direct_mapping();
set_pci_dma_ops(&dma_direct_ops);
+ ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup;
bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier);
return 0;
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 3/7] Use archdata.dma_data in dma_direct_ops
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
2007-12-05 7:20 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:40 ` Arnd Bergmann
2007-12-05 7:21 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:21 UTC (permalink / raw)
To: linuxppc-dev
Now that all platforms using dma_direct_offset setup the archdata.dma_data
correctly, we can change the dma_direct_ops to retrieve the offset from
the dma_data, rather than directly from the global.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/dma_64.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 14206e3..19d5fb0 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -117,6 +117,18 @@ EXPORT_SYMBOL(dma_iommu_ops);
*/
unsigned long dma_direct_offset;
+static unsigned long get_dma_direct_offset(struct device *dev)
+{
+ unsigned long *offset;
+
+ offset = dev->archdata.dma_data;
+
+ if (offset)
+ return *offset;
+
+ return 0;
+}
+
static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
@@ -130,7 +142,7 @@ static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
return NULL;
ret = page_address(page);
memset(ret, 0, size);
- *dma_handle = virt_to_abs(ret) | dma_direct_offset;
+ *dma_handle = virt_to_abs(ret) | get_dma_direct_offset(dev);
return ret;
}
@@ -145,7 +157,7 @@ static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
size_t size,
enum dma_data_direction direction)
{
- return virt_to_abs(ptr) | dma_direct_offset;
+ return virt_to_abs(ptr) | get_dma_direct_offset(dev);
}
static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
@@ -161,7 +173,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
int i;
for_each_sg(sgl, sg, nents, i) {
- sg->dma_address = sg_phys(sg) | dma_direct_offset;
+ sg->dma_address = sg_phys(sg) | get_dma_direct_offset(dev);
sg->dma_length = sg->length;
}
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 4/7] Have cell use its own dma_direct_offset variable
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
2007-12-05 7:20 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
2007-12-05 7:21 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:40 ` Arnd Bergmann
2007-12-05 7:21 ` [PATCH 5/7] Have celleb " Michael Ellerman
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:21 UTC (permalink / raw)
To: linuxppc-dev
Rather than using the global variable, have cell use its own variable to
store the direct DMA offset.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/cell/iommu.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 2edb1ad..d2f9242 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -489,6 +489,8 @@ static struct cbe_iommu *cell_iommu_for_node(int nid)
return NULL;
}
+static unsigned long cell_dma_direct_offset;
+
static void cell_dma_dev_setup(struct device *dev)
{
struct iommu_window *window;
@@ -496,7 +498,7 @@ static void cell_dma_dev_setup(struct device *dev)
struct dev_archdata *archdata = &dev->archdata;
if (get_pci_dma_ops() == &dma_direct_ops) {
- archdata->dma_data = &dma_direct_offset;
+ archdata->dma_data = &cell_dma_direct_offset;
return;
}
@@ -654,7 +656,7 @@ static int __init cell_iommu_init_disabled(void)
/* If we have no Axon, we set up the spider DMA magic offset */
if (of_find_node_by_name(NULL, "axon") == NULL)
- dma_direct_offset = SPIDER_DMA_OFFSET;
+ cell_dma_direct_offset = SPIDER_DMA_OFFSET;
/* Now we need to check to see where the memory is mapped
* in PCI space. We assume that all busses use the same dma
@@ -688,10 +690,10 @@ static int __init cell_iommu_init_disabled(void)
return -ENODEV;
}
- dma_direct_offset += base;
+ cell_dma_direct_offset += base;
printk("iommu: disabled, direct DMA offset is 0x%lx\n",
- dma_direct_offset);
+ cell_dma_direct_offset);
return 0;
}
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 5/7] Have celleb use its own dma_direct_offset variable
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (2 preceding siblings ...)
2007-12-05 7:21 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:41 ` Arnd Bergmann
2007-12-05 7:21 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
` (2 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:21 UTC (permalink / raw)
To: linuxppc-dev
Rather than using the global variable, have celleb use its own variable to
store the direct DMA offset.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/celleb/iommu.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/celleb/iommu.c b/arch/powerpc/platforms/celleb/iommu.c
index 04d5678..85af76f 100644
--- a/arch/powerpc/platforms/celleb/iommu.c
+++ b/arch/powerpc/platforms/celleb/iommu.c
@@ -51,6 +51,8 @@ static int __init find_dma_window(u64 *io_space_id, u64 *ioid,
return 0;
}
+static unsigned long celleb_dma_direct_offset;
+
static void __init celleb_init_direct_mapping(void)
{
u64 lpar_addr, io_addr;
@@ -68,13 +70,13 @@ static void __init celleb_init_direct_mapping(void)
ioid, DMA_FLAGS);
}
- dma_direct_offset = dma_base;
+ celleb_dma_direct_offset = dma_base;
}
static void celleb_dma_dev_setup(struct device *dev)
{
dev->archdata.dma_ops = get_pci_dma_ops();
- dev->archdata.dma_data = &dma_direct_offset;
+ dev->archdata.dma_data = &celleb_dma_direct_offset;
}
static void celleb_pci_dma_dev_setup(struct pci_dev *pdev)
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 6/7] Remove the global dma_direct_offset
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (3 preceding siblings ...)
2007-12-05 7:21 ` [PATCH 5/7] Have celleb " Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:41 ` Arnd Bergmann
2007-12-05 7:21 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
2007-12-05 23:38 ` [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Arnd Bergmann
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:21 UTC (permalink / raw)
To: linuxppc-dev
We no longer need the global dma_direct_offset, update the comment to
reflect the new reality.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/dma_64.c | 7 ++++---
include/asm-powerpc/dma-mapping.h | 2 --
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 19d5fb0..26c0d8c 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -112,10 +112,11 @@ EXPORT_SYMBOL(dma_iommu_ops);
/*
* Generic direct DMA implementation
*
- * This implementation supports a global offset that can be applied if
- * the address at which memory is visible to devices is not 0.
+ * This implementation supports a per-device offset that can be applied if
+ * the address at which memory is visible to devices is not 0. Platform code
+ * can point archdata.dma_data at an unsigned long holding the offset. By
+ * default no offset is used.
*/
-unsigned long dma_direct_offset;
static unsigned long get_dma_direct_offset(struct device *dev)
{
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index ff52013..d9b429a 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -186,8 +186,6 @@ static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
extern struct dma_mapping_ops dma_iommu_ops;
extern struct dma_mapping_ops dma_direct_ops;
-extern unsigned long dma_direct_offset;
-
#else /* CONFIG_PPC64 */
#define dma_supported(dev, mask) (1)
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent()
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (4 preceding siblings ...)
2007-12-05 7:21 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:41 ` Arnd Bergmann
2007-12-05 23:38 ` [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Arnd Bergmann
6 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2007-12-05 7:21 UTC (permalink / raw)
To: linuxppc-dev
Since commit c80d9133e99de1af607314107910a2a1645efb17 (Make direct DMA use
node local allocations) went in this comment makes no sense.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/dma_64.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 26c0d8c..1ef919d 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -137,7 +137,6 @@ static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
void *ret;
int node = dev->archdata.numa_node;
- /* TODO: Maybe use the numa node here too ? */
page = alloc_pages_node(node, flag, get_order(size));
if (page == NULL)
return NULL;
--
1.5.3.7.1.g4e596e
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()
2007-12-05 7:20 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (5 preceding siblings ...)
2007-12-05 7:21 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
@ 2007-12-05 23:38 ` Arnd Bergmann
6 siblings, 0 replies; 16+ messages in thread
From: Arnd Bergmann @ 2007-12-05 23:38 UTC (permalink / raw)
To: linuxppc-dev
On Wednesday 05 December 2007, Michael Ellerman wrote:
> Store a pointer to the direct_dma_offset in each device's dma_data
> in the case where we're using the direct DMA ops.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 16+ messages in thread