Thread (26 messages) 26 messages, 5 authors, 2012-08-10

Re: [PATCH V4 2/3] powerpc/swiotlb: Enable at early stage and disable if not necessary

flat view

From: Kumar Gala <hidden>
Date: 2012-08-02 12:54:42

On Aug 2, 2012, at 6:42 AM, Jia Hongtao wrote:
Remove the dependency on PCI initialization for SWIOTLB =
initialization.
So that PCI can be initialized at proper time.
=20
SWIOTLB is partly determined by PCI inbound/outbound map which is =
assigned
in PCI initialization. But swiotlb_init() should be done at the stage =
of
mem_init() which is much earlier than PCI initialization. So we =
reserve the
memory for SWIOTLB first and free it if not necessary.
=20
All boards are converted to fit this change.
=20
Signed-off-by: Jia Hongtao <redacted>
Signed-off-by: Li Yang <redacted>
---
This doesn't seem like it addresses our issue w/regards to not being =
able to map all of memory from PCI.

arch/powerpc/include/asm/swiotlb.h       |    6 ++++++
arch/powerpc/kernel/dma-swiotlb.c        |   20 ++++++++++++++++++++
arch/powerpc/mm/mem.c                    |    3 +--
arch/powerpc/platforms/44x/currituck.c   |   10 ++--------
arch/powerpc/platforms/85xx/mpc85xx_ds.c |    1 +
arch/powerpc/platforms/85xx/qemu_e500.c  |    2 +-
arch/powerpc/sysdev/fsl_pci.c            |    5 +----
7 files changed, 32 insertions(+), 15 deletions(-)
Don't we also want to update all these:

arch/powerpc/platforms/85xx/corenet_ds.c:               =
ppc_swiotlb_enable =3D 1;
arch/powerpc/platforms/85xx/ge_imp3a.c:         ppc_swiotlb_enable =3D =
1;
arch/powerpc/platforms/85xx/mpc8536_ds.c:               =
ppc_swiotlb_enable =3D 1;
arch/powerpc/platforms/85xx/mpc85xx_mds.c:              =
ppc_swiotlb_enable =3D 1;
arch/powerpc/platforms/85xx/p1022_ds.c:         ppc_swiotlb_enable =3D =
1;
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c:             =
ppc_swiotlb_enable =3D 1;

quoted hunk ↗ jump to hunk
=20
diff --git a/arch/powerpc/include/asm/swiotlb.h =
b/arch/powerpc/include/asm/swiotlb.h
quoted hunk ↗ jump to hunk
index 8979d4c..de99d6e 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -22,4 +22,10 @@ int __init swiotlb_setup_bus_notifier(void);
=20
extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
=20
+#ifdef CONFIG_SWIOTLB
+void swiotlb_detect_4g(void);
+#else
+static inline void swiotlb_detect_4g(void) {}
+#endif
+
#endif /* __ASM_SWIOTLB_H */
diff --git a/arch/powerpc/kernel/dma-swiotlb.c =
b/arch/powerpc/kernel/dma-swiotlb.c
quoted hunk ↗ jump to hunk
index 4ab88da..aa85550 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -104,3 +104,23 @@ int __init swiotlb_setup_bus_notifier(void)
			      &ppc_swiotlb_plat_bus_notifier);
	return 0;
}
+
+void swiotlb_detect_4g(void)
+{
+	if ((memblock_end_of_DRAM() - 1) > 0xffffffff)
+		ppc_swiotlb_enable =3D 1;
+}
+
+static int __init swiotlb_late_init(void)
+{
+	if (ppc_swiotlb_enable) {
+		swiotlb_print_info();
+		set_pci_dma_ops(&swiotlb_dma_ops);
+		ppc_md.pci_dma_dev_setup =3D pci_dma_dev_setup_swiotlb;
+	} else {
+		swiotlb_free();
+	}
+
+	return 0;
+}
+subsys_initcall(swiotlb_late_init);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index baaafde..f23c4e0 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -300,8 +300,7 @@ void __init mem_init(void)
	unsigned long reservedpages =3D 0, codesize, initsize, datasize, =
bsssize;
quoted hunk ↗ jump to hunk
=20
#ifdef CONFIG_SWIOTLB
-	if (ppc_swiotlb_enable)
-		swiotlb_init(1);
+	swiotlb_init(0);
#endif
=20
	num_physpages =3D memblock_phys_mem_size() >> PAGE_SHIFT;
diff --git a/arch/powerpc/platforms/44x/currituck.c =
b/arch/powerpc/platforms/44x/currituck.c
quoted hunk ↗ jump to hunk
index 9f6c33d..6bd89a0 100644
--- a/arch/powerpc/platforms/44x/currituck.c
+++ b/arch/powerpc/platforms/44x/currituck.c
@@ -21,7 +21,6 @@
 */
=20
#include <linux/init.h>
-#include <linux/memblock.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/rtc.h>
@@ -159,13 +158,8 @@ static void __init ppc47x_setup_arch(void)
=20
	/* No need to check the DMA config as we /know/ our windows are =
all of
quoted hunk ↗ jump to hunk
 	 * RAM.  Lets hope that doesn't change */
-#ifdef CONFIG_SWIOTLB
-	if ((memblock_end_of_DRAM() - 1) > 0xffffffff) {
-		ppc_swiotlb_enable =3D 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup =3D pci_dma_dev_setup_swiotlb;
-	}
-#endif
+	swiotlb_detect_4g();
+
	ppc47x_smp_init();
}
=20
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c =
b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
quoted hunk ↗ jump to hunk
index 6d3265f..56f8c8f 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -159,6 +159,7 @@ static void __init mpc85xx_ds_setup_arch(void)
	if (ppc_md.progress)
		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
=20
+	swiotlb_detect_4g();
	mpc85xx_ds_pci_init();
	mpc85xx_smp_init();
=20
diff --git a/arch/powerpc/platforms/85xx/qemu_e500.c =
b/arch/powerpc/platforms/85xx/qemu_e500.c
quoted hunk ↗ jump to hunk
index 95a2e53..04260cd 100644
--- a/arch/powerpc/platforms/85xx/qemu_e500.c
+++ b/arch/powerpc/platforms/85xx/qemu_e500.c
@@ -41,7 +41,7 @@ static void __init qemu_e500_setup_arch(void)
{
	ppc_md.progress("qemu_e500_setup_arch()", 0);
=20
-	fsl_pci_init();
+	swiotlb_detect_4g();
removing fsl_pci_init() seems wrong.
quoted hunk ↗ jump to hunk
	mpc85xx_smp_init();
}
=20
diff --git a/arch/powerpc/sysdev/fsl_pci.c =
b/arch/powerpc/sysdev/fsl_pci.c
quoted hunk ↗ jump to hunk
index 6938792..da7a3d7 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -872,11 +872,8 @@ void __devinit fsl_pci_init(void)
	 * we need SWIOTLB to handle buffers located outside of
	 * dma capable memory region
	 */
-	if (memblock_end_of_DRAM() - 1 > max) {
+	if (memblock_end_of_DRAM() - 1 > max)
		ppc_swiotlb_enable =3D 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup =3D pci_dma_dev_setup_swiotlb;
-	}
#endif
}
#endif
--=20
1.7.5.1
=20
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help