* [PATCH 5/7] Have celleb use its own dma_direct_offset variable
2007-12-05 7:20 Michael Ellerman
@ 2007-12-05 7:21 ` Michael Ellerman
2007-12-05 23:41 ` Arnd Bergmann
0 siblings, 1 reply; 17+ 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] 17+ messages in thread
* Re: [PATCH 5/7] Have celleb use its own dma_direct_offset variable
2007-12-05 7:21 ` [PATCH 5/7] Have celleb use its own dma_direct_offset variable Michael Ellerman
@ 2007-12-05 23:41 ` Arnd Bergmann
0 siblings, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2007-12-05 23:41 UTC (permalink / raw)
To: linuxppc-dev
On Wednesday 05 December 2007, Michael Ellerman wrote:
> 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>
Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()
@ 2008-01-21 5:42 Michael Ellerman
2008-01-21 5:42 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
` (6 more replies)
0 siblings, 7 replies; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-dev
Store the direct_dma_offset in each device's dma_data in the case
where we're using the direct DMA ops.
We need to make sure we setup the ppc_md.pci_dma_dev_setup() callback
if we're using a non-zero offset.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/platforms/cell/iommu.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index bceb5e1..9682b63 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -496,9 +496,10 @@ static void cell_dma_dev_setup(struct device *dev)
struct cbe_iommu *iommu;
struct dev_archdata *archdata = &dev->archdata;
- /* If we run without iommu, no need to do anything */
- if (get_pci_dma_ops() == &dma_direct_ops)
+ if (get_pci_dma_ops() == &dma_direct_ops) {
+ archdata->dma_data = (void *)dma_direct_offset;
return;
+ }
/* Current implementation uses the first window available in that
* node's iommu. We -might- do something smarter later though it may
@@ -690,6 +691,9 @@ static int __init cell_iommu_init_disabled(void)
dma_direct_offset += base;
+ if (dma_direct_offset != 0)
+ ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
+
printk("iommu: disabled, direct DMA offset is 0x%lx\n",
dma_direct_offset);
--
1.5.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/7] Add celleb_dma_dev_setup()
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:20 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset Michael Ellerman
` (5 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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 41e1e6f..843a66f 100644
--- a/arch/powerpc/platforms/celleb/iommu.c
+++ b/arch/powerpc/platforms/celleb/iommu.c
@@ -72,6 +72,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 = (void *)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)
{
@@ -81,7 +92,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;
}
@@ -94,6 +105,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.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
2008-01-21 5:42 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
` (4 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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.
While we're here, change the way the offset is used - instead of or'ing it
into the value, add it. This should have no effect on current implementations
where the offset is far larger than memory, however in future we may want
to use smaller offsets.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
arch/powerpc/kernel/dma_64.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 14206e3..a2d076d 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -117,6 +117,11 @@ EXPORT_SYMBOL(dma_iommu_ops);
*/
unsigned long dma_direct_offset;
+static unsigned long get_dma_direct_offset(struct device *dev)
+{
+ return (unsigned long)dev->archdata.dma_data;
+}
+
static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
@@ -130,7 +135,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 +150,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 +166,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.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/7] Have cell use its own dma_direct_offset variable
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
2008-01-21 5:42 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
2008-01-21 5:42 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 5/7] Have celleb " Michael Ellerman
` (3 subsequent siblings)
6 siblings, 2 replies; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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 | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 9682b63..7f45d59 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -490,6 +490,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;
@@ -497,7 +499,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 = (void *)dma_direct_offset;
+ archdata->dma_data = (void *)cell_dma_direct_offset;
return;
}
@@ -655,7 +657,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
@@ -689,13 +691,13 @@ static int __init cell_iommu_init_disabled(void)
return -ENODEV;
}
- dma_direct_offset += base;
+ cell_dma_direct_offset += base;
- if (dma_direct_offset != 0)
+ if (cell_dma_direct_offset != 0)
ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
printk("iommu: disabled, direct DMA offset is 0x%lx\n",
- dma_direct_offset);
+ cell_dma_direct_offset);
return 0;
}
--
1.5.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 5/7] Have celleb use its own dma_direct_offset variable
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (2 preceding siblings ...)
2008-01-21 5:42 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
` (2 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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 843a66f..93b0efd 100644
--- a/arch/powerpc/platforms/celleb/iommu.c
+++ b/arch/powerpc/platforms/celleb/iommu.c
@@ -52,6 +52,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;
@@ -69,13 +71,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 = (void *)dma_direct_offset;
+ dev->archdata.dma_data = (void *)celleb_dma_direct_offset;
}
static void celleb_pci_dma_dev_setup(struct pci_dev *pdev)
--
1.5.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 6/7] Remove the global dma_direct_offset
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (3 preceding siblings ...)
2008-01-21 5:42 ` [PATCH 5/7] Have celleb " Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
2008-01-21 6:20 ` [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Benjamin Herrenschmidt
6 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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 a2d076d..72fdc06 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 set archdata.dma_data to an unsigned long holding the offset. By
+ * default the offset is zero.
*/
-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 e974876..5eea6db 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -189,8 +189,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.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent()
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (4 preceding siblings ...)
2008-01-21 5:42 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
@ 2008-01-21 5:42 ` Michael Ellerman
2008-01-21 6:22 ` Benjamin Herrenschmidt
2008-01-21 6:20 ` [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Benjamin Herrenschmidt
6 siblings, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2008-01-21 5:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Arnd Bergmann, cbe-oss-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 72fdc06..8423907 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -130,7 +130,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.2.rc1.1884.g59b20
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
` (5 preceding siblings ...)
2008-01-21 5:42 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
@ 2008-01-21 6:20 ` Benjamin Herrenschmidt
6 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:20 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> Store the direct_dma_offset in each device's dma_data in the case
> where we're using the direct DMA ops.
>
> We need to make sure we setup the ppc_md.pci_dma_dev_setup() callback
> if we're using a non-zero offset.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/platforms/cell/iommu.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
> index bceb5e1..9682b63 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -496,9 +496,10 @@ static void cell_dma_dev_setup(struct device *dev)
> struct cbe_iommu *iommu;
> struct dev_archdata *archdata = &dev->archdata;
>
> - /* If we run without iommu, no need to do anything */
> - if (get_pci_dma_ops() == &dma_direct_ops)
> + if (get_pci_dma_ops() == &dma_direct_ops) {
> + archdata->dma_data = (void *)dma_direct_offset;
> return;
> + }
>
> /* Current implementation uses the first window available in that
> * node's iommu. We -might- do something smarter later though it may
> @@ -690,6 +691,9 @@ static int __init cell_iommu_init_disabled(void)
>
> dma_direct_offset += base;
>
> + if (dma_direct_offset != 0)
> + ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
> +
> printk("iommu: disabled, direct DMA offset is 0x%lx\n",
> dma_direct_offset);
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/7] Add celleb_dma_dev_setup()
2008-01-21 5:42 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
@ 2008-01-21 6:20 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:20 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 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 41e1e6f..843a66f 100644
> --- a/arch/powerpc/platforms/celleb/iommu.c
> +++ b/arch/powerpc/platforms/celleb/iommu.c
> @@ -72,6 +72,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 = (void *)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)
> {
> @@ -81,7 +92,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;
> }
> @@ -94,6 +105,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;
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset
2008-01-21 5:42 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset Michael Ellerman
@ 2008-01-21 6:21 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:21 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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.
>
> While we're here, change the way the offset is used - instead of or'ing it
> into the value, add it. This should have no effect on current implementations
> where the offset is far larger than memory, however in future we may want
> to use smaller offsets.
>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/kernel/dma_64.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
> index 14206e3..a2d076d 100644
> --- a/arch/powerpc/kernel/dma_64.c
> +++ b/arch/powerpc/kernel/dma_64.c
> @@ -117,6 +117,11 @@ EXPORT_SYMBOL(dma_iommu_ops);
> */
> unsigned long dma_direct_offset;
>
> +static unsigned long get_dma_direct_offset(struct device *dev)
> +{
> + return (unsigned long)dev->archdata.dma_data;
> +}
> +
> static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
> dma_addr_t *dma_handle, gfp_t flag)
> {
> @@ -130,7 +135,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 +150,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 +166,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;
> }
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/7] Have cell use its own dma_direct_offset variable
2008-01-21 5:42 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
@ 2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 6:21 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:21 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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 | 12 +++++++-----
> 1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
> index 9682b63..7f45d59 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -490,6 +490,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;
> @@ -497,7 +499,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 = (void *)dma_direct_offset;
> + archdata->dma_data = (void *)cell_dma_direct_offset;
> return;
> }
>
> @@ -655,7 +657,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
> @@ -689,13 +691,13 @@ static int __init cell_iommu_init_disabled(void)
> return -ENODEV;
> }
>
> - dma_direct_offset += base;
> + cell_dma_direct_offset += base;
>
> - if (dma_direct_offset != 0)
> + if (cell_dma_direct_offset != 0)
> ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
>
> printk("iommu: disabled, direct DMA offset is 0x%lx\n",
> - dma_direct_offset);
> + cell_dma_direct_offset);
>
> return 0;
> }
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/7] Have cell use its own dma_direct_offset variable
2008-01-21 5:42 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
@ 2008-01-21 6:21 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:21 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/platforms/cell/iommu.c | 12 +++++++-----
> 1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
> index 9682b63..7f45d59 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -490,6 +490,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;
> @@ -497,7 +499,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 = (void *)dma_direct_offset;
> + archdata->dma_data = (void *)cell_dma_direct_offset;
> return;
> }
>
> @@ -655,7 +657,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
> @@ -689,13 +691,13 @@ static int __init cell_iommu_init_disabled(void)
> return -ENODEV;
> }
>
> - dma_direct_offset += base;
> + cell_dma_direct_offset += base;
>
> - if (dma_direct_offset != 0)
> + if (cell_dma_direct_offset != 0)
> ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
>
> printk("iommu: disabled, direct DMA offset is 0x%lx\n",
> - dma_direct_offset);
> + cell_dma_direct_offset);
>
> return 0;
> }
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 5/7] Have celleb use its own dma_direct_offset variable
2008-01-21 5:42 ` [PATCH 5/7] Have celleb " Michael Ellerman
@ 2008-01-21 6:21 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:21 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 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 843a66f..93b0efd 100644
> --- a/arch/powerpc/platforms/celleb/iommu.c
> +++ b/arch/powerpc/platforms/celleb/iommu.c
> @@ -52,6 +52,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;
> @@ -69,13 +71,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 = (void *)dma_direct_offset;
> + dev->archdata.dma_data = (void *)celleb_dma_direct_offset;
> }
>
> static void celleb_pci_dma_dev_setup(struct pci_dev *pdev)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 6/7] Remove the global dma_direct_offset
2008-01-21 5:42 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
@ 2008-01-21 6:21 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:21 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 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 a2d076d..72fdc06 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 set archdata.dma_data to an unsigned long holding the offset. By
> + * default the offset is zero.
> */
> -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 e974876..5eea6db 100644
> --- a/include/asm-powerpc/dma-mapping.h
> +++ b/include/asm-powerpc/dma-mapping.h
> @@ -189,8 +189,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)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent()
2008-01-21 5:42 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
@ 2008-01-21 6:22 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Herrenschmidt @ 2008-01-21 6:22 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann, cbe-oss-dev
On Mon, 2008-01-21 at 16:42 +1100, Michael Ellerman wrote:
> 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>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 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 72fdc06..8423907 100644
> --- a/arch/powerpc/kernel/dma_64.c
> +++ b/arch/powerpc/kernel/dma_64.c
> @@ -130,7 +130,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;
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-01-21 6:22 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 5:42 [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Michael Ellerman
2008-01-21 5:42 ` [PATCH 2/7] Add celleb_dma_dev_setup() Michael Ellerman
2008-01-21 6:20 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 3/7] Use archdata.dma_data in dma_direct_ops and add the offset Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 4/7] Have cell use its own dma_direct_offset variable Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 5/7] Have celleb " Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 6/7] Remove the global dma_direct_offset Michael Ellerman
2008-01-21 6:21 ` Benjamin Herrenschmidt
2008-01-21 5:42 ` [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent() Michael Ellerman
2008-01-21 6:22 ` Benjamin Herrenschmidt
2008-01-21 6:20 ` [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup() Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2007-12-05 7:20 Michael Ellerman
2007-12-05 7:21 ` [PATCH 5/7] Have celleb use its own dma_direct_offset variable Michael Ellerman
2007-12-05 23:41 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).