[PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()

Subsystems: cell broadband engine architecture, linux for powerpc (32-bit and 64-bit), the rest

STALE6814d

14 messages, 2 authors, 2007-12-05 · open the first message on its own page

[PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:20:57

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 <redacted>
---
 arch/powerpc/platforms/cell/iommu.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index faabc3f..2edb1ad 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -495,9 +495,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 = &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
-- 
1.5.3.7.1.g4e596e

[PATCH 2/7] Add celleb_dma_dev_setup()

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:20:58

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 <redacted>
---
 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

Re: [PATCH 2/7] Add celleb_dma_dev_setup()

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:40:37

On Wednesday 05 December 2007, 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 <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

[PATCH 3/7] Use archdata.dma_data in dma_direct_ops

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:21:00

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 <redacted>
---
 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

Re: [PATCH 3/7] Use archdata.dma_data in dma_direct_ops

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:40:47

On Wednesday 05 December 2007, 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.

Signed-off-by: Michael Ellerman <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

[PATCH 4/7] Have cell use its own dma_direct_offset variable

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:21:01

Rather than using the global variable, have cell use its own variable to
store the direct DMA offset.

Signed-off-by: Michael Ellerman <redacted>
---
 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

Re: [PATCH 4/7] Have cell use its own dma_direct_offset variable

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:41:06

On Wednesday 05 December 2007, 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 <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

[PATCH 5/7] Have celleb use its own dma_direct_offset variable

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:21:03

Rather than using the global variable, have celleb use its own variable to
store the direct DMA offset.

Signed-off-by: Michael Ellerman <redacted>
---
 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

Re: [PATCH 5/7] Have celleb use its own dma_direct_offset variable

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:41:17

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 <redacted>
Arnd Bergmann [off-list ref]

[PATCH 6/7] Remove the global dma_direct_offset

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:21:05

We no longer need the global dma_direct_offset, update the comment to
reflect the new reality.

Signed-off-by: Michael Ellerman <redacted>
---
 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

Re: [PATCH 6/7] Remove the global dma_direct_offset

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:41:40

On Wednesday 05 December 2007, 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 <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

[PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent()

From: Michael Ellerman <hidden>
Date: 2007-12-05 07:21:07

Since commit c80d9133e99de1af607314107910a2a1645efb17 (Make direct DMA use
node local allocations) went in this comment makes no sense.

Signed-off-by: Michael Ellerman <redacted>
---
 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

Re: [PATCH 7/7] Remove bogus comment in dma_direct_alloc_coherent()

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:41:55

On Wednesday 05 December 2007, 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 <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>

Re: [PATCH 1/7] Set archdata.dma_data for direct DMA in cell_dma_dev_setup()

From: Arnd Bergmann <arnd@arndb.de>
Date: 2007-12-05 23:38:48

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 <redacted>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help