linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: check cache coherency of kernel vs firmware
@ 2007-05-02 21:59 Dale Farnsworth
  2007-05-03  3:28 ` Stephen Rothwell
  2007-05-04 21:16 ` Dale Farnsworth
  0 siblings, 2 replies; 4+ messages in thread
From: Dale Farnsworth @ 2007-05-02 21:59 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linuxppc-dev

This function verifies that the cache coherency setting of the kernel
(CONFIG_NOT_COHERENT_CACHE) matches that left by the firmware, as
indicated by coherency-off device tree property.

It's only needed on platforms where cache-coherency can be enabled or
disabled by firmware, e.g. mv64x60-based platforms.

Signed-of-by: Dale Farnsworth <dale@farnsworth.org>

---
 arch/powerpc/Kconfig                       |    3 +
 arch/powerpc/kernel/setup-common.c         |   41 +++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/Kconfig |    1 
 3 files changed, 45 insertions(+)

Index: linux-2.6-powerpc-df/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/kernel/setup-common.c
+++ linux-2.6-powerpc-df/arch/powerpc/kernel/setup-common.c
@@ -530,3 +530,44 @@ void __init setup_panic(void)
 {
 	atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
 }
+
+#ifdef CONFIG_CHECK_CACHE_COHERENCY
+/*
+ * For platforms that have configurable cache-coherency.  This function
+ * checks that the cache coherency setting of the kernel matches the setting
+ * left by the firmware, as indicated in the device tree.  Since a mismatch
+ * will eventually result in DMA failures, we print * and error and call
+ * BUG() in that case.
+ */
+
+#ifdef CONFIG_NOT_COHERENT_CACHE
+#define KERNEL_COHERENCY	0
+#else
+#define KERNEL_COHERENCY	1
+#endif
+
+static int __init check_cache_coherency(void)
+{
+	struct device_node *np;
+	const void *prop;
+	int devtree_coherency;
+
+	np = of_find_node_by_path("/");
+	prop = of_get_property(np, "coherency-off", NULL);
+	of_node_put(np);
+
+	devtree_coherency = prop ? 0 : 1;
+
+	if (devtree_coherency != KERNEL_COHERENCY) {
+		printk(KERN_ERR
+			"kernel coherency:%s != device tree_coherency:%s\n",
+			KERNEL_COHERENCY ? "on" : "off",
+			devtree_coherency ? "on" : "off");
+		BUG();
+	}
+
+	return 0;
+}
+
+late_initcall(check_cache_coherency);
+#endif /* CONFIG_CHECK_CACHE_COHERENCY */
Index: linux-2.6-powerpc-df/arch/powerpc/Kconfig
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/Kconfig
+++ linux-2.6-powerpc-df/arch/powerpc/Kconfig
@@ -373,6 +373,9 @@ config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || 8xx || E200
 	default y
+
+config CHECK_COHERENT_CACHE
+	bool
 endmenu
 
 source "init/Kconfig"
Index: linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/platforms/embedded6xx/Kconfig
+++ linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -41,6 +41,7 @@ config MPC10X_BRIDGE
 config MV64X60
 	bool
 	select PPC_INDIRECT_PCI
+	select CHECK_COHERENT_CACHE
 
 config MPC10X_OPENPIC
 	bool

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: check cache coherency of kernel vs firmware
  2007-05-02 21:59 [PATCH] powerpc: check cache coherency of kernel vs firmware Dale Farnsworth
@ 2007-05-03  3:28 ` Stephen Rothwell
  2007-05-03  5:08   ` 
  2007-05-04 21:16 ` Dale Farnsworth
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Rothwell @ 2007-05-03  3:28 UTC (permalink / raw)
  To: Dale Farnsworth; +Cc: Linuxppc-dev, Paul Mackerras

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]

On Wed, 2 May 2007 14:59:38 -0700 "Dale Farnsworth" <dale@farnsworth.org> wrote:
>
> +#ifdef CONFIG_CHECK_CACHE_COHERENCY
> +#endif /* CONFIG_CHECK_CACHE_COHERENCY */

These ...

> +config CHECK_COHERENT_CACHE

don't match this.
--
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc: check cache coherency of kernel vs firmware
  2007-05-03  3:28 ` Stephen Rothwell
@ 2007-05-03  5:08   ` 
  0 siblings, 0 replies; 4+ messages in thread
From:  @ 2007-05-03  5:08 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Linuxppc-dev, Paul Mackerras

On Thu, May 03, 2007 at 01:28:24PM +1000, Stephen Rothwell wrote:
> On Wed, 2 May 2007 14:59:38 -0700 "Dale Farnsworth" <dale@farnsworth.org> wrote:
> >
> > +#ifdef CONFIG_CHECK_CACHE_COHERENCY
> > +#endif /* CONFIG_CHECK_CACHE_COHERENCY */
> 
> These ...
> 
> > +config CHECK_COHERENT_CACHE
> 
> don't match this.

Oops.  Brown paper bag time.

Thanks,
-Dale

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] powerpc: check cache coherency of kernel vs firmware
  2007-05-02 21:59 [PATCH] powerpc: check cache coherency of kernel vs firmware Dale Farnsworth
  2007-05-03  3:28 ` Stephen Rothwell
@ 2007-05-04 21:16 ` Dale Farnsworth
  1 sibling, 0 replies; 4+ messages in thread
From: Dale Farnsworth @ 2007-05-04 21:16 UTC (permalink / raw)
  To: Linuxppc-dev; +Cc: Stephen Rothwell, Paul Mackerras

check_cache_coherency() verifies that the cache coherency setting of
the kernel (CONFIG_NOT_COHERENT_CACHE) matches that left by the firmware,
as indicated by coherency-off device tree property.

Signed-off-by: Dale Farnsworth <dale@farnsworth.org>

---
New, improved!  Now with matching config var names.  Thanks Stephen.

 arch/powerpc/Kconfig                       |    3 +
 arch/powerpc/kernel/setup-common.c         |   41 +++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/Kconfig |    1 
 3 files changed, 45 insertions(+)

Index: linux-2.6-powerpc-df/arch/powerpc/kernel/setup-common.c
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/kernel/setup-common.c
+++ linux-2.6-powerpc-df/arch/powerpc/kernel/setup-common.c
@@ -530,3 +530,44 @@ void __init setup_panic(void)
 {
 	atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
 }
+
+#ifdef CONFIG_CHECK_CACHE_COHERENCY
+/*
+ * For platforms that have configurable cache-coherency.  This function
+ * checks that the cache coherency setting of the kernel matches the setting
+ * left by the firmware, as indicated in the device tree.  Since a mismatch
+ * will eventually result in DMA failures, we print * and error and call
+ * BUG() in that case.
+ */
+
+#ifdef CONFIG_NOT_COHERENT_CACHE
+#define KERNEL_COHERENCY	0
+#else
+#define KERNEL_COHERENCY	1
+#endif
+
+static int __init check_cache_coherency(void)
+{
+	struct device_node *np;
+	const void *prop;
+	int devtree_coherency;
+
+	np = of_find_node_by_path("/");
+	prop = of_get_property(np, "coherency-off", NULL);
+	of_node_put(np);
+
+	devtree_coherency = prop ? 0 : 1;
+
+	if (devtree_coherency != KERNEL_COHERENCY) {
+		printk(KERN_ERR
+			"kernel coherency:%s != device tree_coherency:%s\n",
+			KERNEL_COHERENCY ? "on" : "off",
+			devtree_coherency ? "on" : "off");
+		BUG();
+	}
+
+	return 0;
+}
+
+late_initcall(check_cache_coherency);
+#endif /* CONFIG_CHECK_CACHE_COHERENCY */
Index: linux-2.6-powerpc-df/arch/powerpc/Kconfig
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/Kconfig
+++ linux-2.6-powerpc-df/arch/powerpc/Kconfig
@@ -373,6 +373,9 @@ config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || 8xx || E200
 	default y
+
+config CONFIG_CHECK_CACHE_COHERENCY
+	bool
 endmenu
 
 source "init/Kconfig"
Index: linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
===================================================================
--- linux-2.6-powerpc-df.orig/arch/powerpc/platforms/embedded6xx/Kconfig
+++ linux-2.6-powerpc-df/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -41,6 +41,7 @@ config MPC10X_BRIDGE
 config MV64X60
 	bool
 	select PPC_INDIRECT_PCI
+	select CONFIG_CHECK_CACHE_COHERENCY
 
 config MPC10X_OPENPIC
 	bool

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-05-04 21:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-02 21:59 [PATCH] powerpc: check cache coherency of kernel vs firmware Dale Farnsworth
2007-05-03  3:28 ` Stephen Rothwell
2007-05-03  5:08   ` 
2007-05-04 21:16 ` Dale Farnsworth

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).