From: Jia Hongtao <B38951@freescale.com>
To: <linuxppc-dev@lists.ozlabs.org>, <galak@kernel.crashing.org>
Cc: B07421@freescale.com, b38951@freescale.com
Subject: [PATCH V5 2/3] powerpc/swiotlb: Enable at early stage and disable if not necessary
Date: Fri, 3 Aug 2012 18:14:10 +0800 [thread overview]
Message-ID: <1343988851-884-3-git-send-email-B38951@freescale.com> (raw)
In-Reply-To: <1343988851-884-1-git-send-email-B38951@freescale.com>
Remove the dependency on PCI initialization for SWIOTLB initialization.
So that PCI can be initialized at proper time.
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.
All boards are converted to fit this change.
Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
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 | 1 +
arch/powerpc/sysdev/fsl_pci.c | 5 +----
7 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
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);
extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
+#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
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 = 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 = 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 = 0, codesize, initsize, datasize, bsssize;
#ifdef CONFIG_SWIOTLB
- if (ppc_swiotlb_enable)
- swiotlb_init(1);
+ swiotlb_init(0);
#endif
num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
diff --git a/arch/powerpc/platforms/44x/currituck.c b/arch/powerpc/platforms/44x/currituck.c
index 9f6c33d..6bd89a0 100644
--- a/arch/powerpc/platforms/44x/currituck.c
+++ b/arch/powerpc/platforms/44x/currituck.c
@@ -21,7 +21,6 @@
*/
#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)
/* No need to check the DMA config as we /know/ our windows are all of
* RAM. Lets hope that doesn't change */
-#ifdef CONFIG_SWIOTLB
- if ((memblock_end_of_DRAM() - 1) > 0xffffffff) {
- ppc_swiotlb_enable = 1;
- set_pci_dma_ops(&swiotlb_dma_ops);
- ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
- }
-#endif
+ swiotlb_detect_4g();
+
ppc47x_smp_init();
}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
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);
+ swiotlb_detect_4g();
mpc85xx_ds_pci_init();
mpc85xx_smp_init();
diff --git a/arch/powerpc/platforms/85xx/qemu_e500.c b/arch/powerpc/platforms/85xx/qemu_e500.c
index 95a2e53..3c5490c 100644
--- a/arch/powerpc/platforms/85xx/qemu_e500.c
+++ b/arch/powerpc/platforms/85xx/qemu_e500.c
@@ -42,6 +42,7 @@ static void __init qemu_e500_setup_arch(void)
ppc_md.progress("qemu_e500_setup_arch()", 0);
fsl_pci_init();
+ swiotlb_detect_4g();
mpc85xx_smp_init();
}
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
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 = 1;
- set_pci_dma_ops(&swiotlb_dma_ops);
- ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
- }
#endif
}
#endif
--
1.7.5.1
next prev parent reply other threads:[~2012-08-03 10:39 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 10:14 [PATCH V5 0/3] PCI patch set description Jia Hongtao
2012-08-03 10:14 ` [PATCH V5 1/3] powerpc/fsl-pci: Only scan PCI bus if configured as a host Jia Hongtao
2012-08-03 13:57 ` Kumar Gala
2012-08-03 10:14 ` Jia Hongtao [this message]
2012-08-08 19:03 ` [PATCH V5 2/3] powerpc/swiotlb: Enable at early stage and disable if not necessary Kumar Gala
2012-08-09 5:57 ` Tony Breeds
2012-08-10 12:58 ` Kumar Gala
2012-08-03 10:14 ` [PATCH V5 3/3] powerpc/fsl-pci: Unify pci/pcie initialization code Jia Hongtao
2012-08-03 16:27 ` Scott Wood
2012-08-06 3:07 ` Jia Hongtao-B38951
2012-08-06 15:09 ` Scott Wood
2012-08-07 4:20 ` Li Yang
2012-08-07 15:24 ` Scott Wood
2012-08-08 9:03 ` Jia Hongtao-B38951
2012-08-08 15:58 ` Scott Wood
2012-08-08 19:04 ` Gala Kumar-B11780
2012-08-10 8:47 ` Jia Hongtao-B38951
2012-08-10 16:00 ` Scott Wood
2012-08-15 9:22 ` Jia Hongtao-B38951
2012-08-15 17:45 ` Scott Wood
2012-08-09 3:48 ` Jia Hongtao-B38951
2012-08-09 17:00 ` Scott Wood
2012-08-07 8:09 ` Jia Hongtao-B38951
2012-08-07 15:28 ` Scott Wood
2012-08-08 9:39 ` Jia Hongtao-B38951
2012-08-08 16:02 ` Scott Wood
2012-08-09 3:48 ` Jia Hongtao-B38951
2012-08-09 22:20 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343988851-884-3-git-send-email-B38951@freescale.com \
--to=b38951@freescale.com \
--cc=B07421@freescale.com \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).