LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 16:33 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-m32r-ja, linux-mips, linux-m32r, linux-ia64, linux-parisc,
	linux-s390, linux-hexagon, linux-sh, jejb, x86, linux, dhowells,
	linux390, linux-am33-list, cmetcalf, linux-alpha, sparclinux,
	uclinux-dist-devel, tglx, linuxppc-dev, linux-arm-kernel

Although there have been numerous complaints about the complexity of
parallel programming (especially over the past 5-10 years), the plain
truth is that the incremental complexity of parallel programming over
that of sequential programming is not as large as is commonly believed.
Despite that you might have heard, the mind-numbing complexity of modern
computer systems is not due so much to there being multiple CPUs, but
rather to there being any CPUs at all.  In short, for the ultimate in
computer-system simplicity, the optimal choice is NR_CPUS=0.

This commit therefore limits kernel builds to zero CPUs.  This change
has the beneficial side effect of rendering all kernel bugs harmless.
Furthermore, this commit enables additional beneficial changes, for
example, the removal of those parts of the kernel that are not needed
when there are zero CPUs.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---

 alpha/Kconfig                     |   11 ++++++-----
 arm/Kconfig                       |    6 +++---
 blackfin/Kconfig                  |    3 ++-
 hexagon/Kconfig                   |    9 +++++----
 ia64/Kconfig                      |    9 +++++----
 m32r/Kconfig                      |   10 ++++++----
 mips/Kconfig                      |   21 +++++++++++----------
 mn10300/Kconfig                   |    3 ++-
 parisc/Kconfig                    |    6 +++---
 powerpc/platforms/Kconfig.cputype |    8 ++++----
 s390/Kconfig                      |   12 +++++++-----
 sh/Kconfig                        |   11 ++++++-----
 sparc/Kconfig                     |    8 ++++----
 tile/Kconfig                      |    9 +++++----
 x86/Kconfig                       |   16 +++++++++-------
 15 files changed, 78 insertions(+), 64 deletions(-)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 56a4df9..1766b4a 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -541,14 +541,15 @@ config HAVE_DEC_LOCK
 	default y
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	range 2 32
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "32" if ALPHA_GENERIC || ALPHA_MARVEL
-	default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
+	default "0" if ALPHA_GENERIC || ALPHA_MARVEL
+	default "0" if !ALPHA_GENERIC && !ALPHA_MARVEL
 	help
 	  MARVEL support can handle a maximum of 32 CPUs, all the others
-          with working support have a maximum of 4 CPUs.
+          with working support have a maximum of 4 CPUs.  But why take
+	  chances?  Just stick with zero CPUs.
 
 config ARCH_DISCONTIGMEM_ENABLE
 	bool "Discontiguous Memory Support (EXPERIMENTAL)"
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a48aecc..1f07a3a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1551,10 +1551,10 @@ config PAGE_OFFSET
 	default 0xC0000000
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	range 2 32
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "4"
+	default "0"
 
 config HOTPLUG_CPU
 	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index abe5a9e..6a78549 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -241,7 +241,8 @@ config SMP
 config NR_CPUS
 	int
 	depends on SMP
-	default 2 if BF561
+	range 0 0
+	default 0 if BF561
 
 config HOTPLUG_CPU
 	bool "Support for hot-pluggable CPUs"
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 9059e39..daab009 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -158,13 +158,14 @@ config SMP
 
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP
-	range 2 6 if SMP
-	default "1" if !SMP
-	default "6" if SMP
+	range 0 0 if SMP
+	default "0" if !SMP
+	default "0" if SMP
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 6 and the
-	  minimum value which makes sense is 2.
+	  minimum value which makes sense is 2.  But a limit of zero is
+	  so much safer!
 
 	  This is purely to save memory - each supported CPU adds
 	  approximately eight kilobytes to the kernel image.
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index bd72669..fea0e6d 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -373,16 +373,17 @@ config SMP
 	  If you don't know what to do here, say N.
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-4096)"
-	range 2 4096
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "4096"
+	default "0"
 	help
 	  You should set this to the number of CPUs in your system, but
 	  keep in mind that a kernel compiled for, e.g., 2 CPUs will boot but
 	  only use 2 CPUs on a >2 CPU system.  Setting this to a value larger
 	  than 64 will cause the use of a CPU mask array, causing a small
-	  performance hit.
+	  performance hit.  And setting it larger than zero risks all
+	  manner of software bugs, so we just play it safe.
 
 config HOTPLUG_CPU
 	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index ef80a65..68b9e88 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -300,14 +300,16 @@ config CHIP_M32700_TS1
 	default n
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	range 2 32
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "2"
+	default "0"
 	help
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 32 and the
-	  minimum value which makes sense is 2.
+	  minimum value which makes sense is 2.  Zero may not make sense,
+	  but given that there is much in this world that does not make
+	  sense, zero it is!
 
 	  This is purely to save memory - each supported CPU adds
 	  approximately eight kilobytes to the kernel image.
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5ab6e89..3d7d06c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2192,16 +2192,16 @@ config NR_CPUS_DEFAULT_64
 	bool
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-64)"
-	range 1 64 if NR_CPUS_DEFAULT_1
+	int "Maximum number of CPUs (0-0)"
+	range 0 0 if NR_CPUS_DEFAULT_1
 	depends on SMP
-	default "1" if NR_CPUS_DEFAULT_1
-	default "2" if NR_CPUS_DEFAULT_2
-	default "4" if NR_CPUS_DEFAULT_4
-	default "8" if NR_CPUS_DEFAULT_8
-	default "16" if NR_CPUS_DEFAULT_16
-	default "32" if NR_CPUS_DEFAULT_32
-	default "64" if NR_CPUS_DEFAULT_64
+	default "0" if NR_CPUS_DEFAULT_1
+	default "0" if NR_CPUS_DEFAULT_2
+	default "0" if NR_CPUS_DEFAULT_4
+	default "0" if NR_CPUS_DEFAULT_8
+	default "0" if NR_CPUS_DEFAULT_16
+	default "0" if NR_CPUS_DEFAULT_32
+	default "0" if NR_CPUS_DEFAULT_64
 	help
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 32 for 32-bit
@@ -2212,7 +2212,8 @@ config NR_CPUS
 	  This is purely to save memory - each supported CPU adds
 	  approximately eight kilobytes to the kernel image.  For best
 	  performance should round up your number of processors to the next
-	  power of two.
+	  power of two.  And just think how much more memory we will
+	  save by setting the limit to zero!
 
 source "kernel/time/Kconfig"
 
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 8f1c40d..85fc112 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -201,7 +201,8 @@ config SMP
 config NR_CPUS
 	int
 	depends on SMP
-	default "2"
+	range 0 0
+	default "0"
 
 source "kernel/Kconfig.preempt"
 
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 242a1b7..358eaf8 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -254,10 +254,10 @@ config HPUX
 	depends on !64BIT
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	range 2 32
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "32"
+	default "0"
 
 endmenu
 
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 425db18..5e607e0 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -356,11 +356,11 @@ config SMP
 	  If you don't know what to do here, say N.
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-8192)"
-	range 2 8192
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "32" if PPC64
-	default "4"
+	default "0" if PPC64
+	default "0"
 
 config NOT_COHERENT_CACHE
 	bool
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index d172758..f9bc067 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -169,15 +169,17 @@ config SMP
 	  Even if you don't know what to do here, say Y.
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-64)"
-	range 2 64
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "32" if !64BIT
-	default "64" if 64BIT
+	default "0" if !64BIT
+	default "0" if 64BIT
 	help
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 64 and the
-	  minimum value which makes sense is 2.
+	  minimum value which makes sense is 2.  The minimal value that
+	  makes sense might well be 2, but we all know that the only
+	  -sane- value is zero!
 
 	  This is purely to save memory - each supported CPU adds
 	  approximately sixteen kilobytes to the kernel image.
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 713fb58..5ddc7c0 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -705,18 +705,19 @@ config SMP
 	  If you don't know what to do here, say N.
 
 config NR_CPUS
-	int "Maximum number of CPUs (2-32)"
-	range 2 32
+	int "Maximum number of CPUs (0-0)"
+	range 0 0
 	depends on SMP
-	default "4" if CPU_SUBTYPE_SHX3
-	default "2"
+	default "0" if CPU_SUBTYPE_SHX3
+	default "0"
 	help
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 32 and the
 	  minimum value which makes sense is 2.
 
 	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
+	  approximately eight kilobytes to the kernel image.  Debloating
+	  is the way, NR_CPUS to zero today!!!
 
 config HOTPLUG_CPU
 	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index ca5580e..0de9f0f 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -177,10 +177,10 @@ config SMP
 config NR_CPUS
 	int "Maximum number of CPUs"
 	depends on SMP
-	range 2 32 if SPARC32
-	range 2 1024 if SPARC64
-	default 32 if SPARC32
-	default 64 if SPARC64
+	range 0 0 if SPARC32
+	range 0 0 if SPARC64
+	default 0 if SPARC32
+	default 0 if SPARC64
 
 source kernel/Kconfig.hz
 
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 11270ca..a05112c 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -126,14 +126,15 @@ source "init/Kconfig"
 menu "Tilera-specific configuration"
 
 config NR_CPUS
-	int "Maximum number of tiles (2-255)"
-	range 2 255
+	int "Maximum number of tiles (0-0)"
+	range 0 0
 	depends on SMP
-	default "64"
+	default "0"
 	---help---
 	  Building with 64 is the recommended value, but a slightly
 	  smaller kernel memory footprint results from using a smaller
-	  value on chips with fewer tiles.
+	  value on chips with fewer tiles.  To minimize both memory
+	  footprint and bugs, use zero and only zero.
 
 source "kernel/time/Kconfig"
 
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5bed94e..a6977f2 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -773,19 +773,21 @@ config MAXSMP
 
 config NR_CPUS
 	int "Maximum number of CPUs" if SMP && !MAXSMP
-	range 2 8 if SMP && X86_32 && !X86_BIGSMP
-	range 2 512 if SMP && !MAXSMP
-	default "1" if !SMP
-	default "4096" if MAXSMP
-	default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
-	default "8" if SMP
+	range 0 0 if SMP && X86_32 && !X86_BIGSMP
+	range 0 0 if SMP && !MAXSMP
+	default "0" if !SMP
+	default "0" if MAXSMP
+	default "0" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
+	default "0" if SMP
 	---help---
 	  This allows you to specify the maximum number of CPUs which this
 	  kernel will support.  The maximum supported value is 512 and the
 	  minimum value which makes sense is 2.
 
 	  This is purely to save memory - each supported CPU adds
-	  approximately eight kilobytes to the kernel image.
+	  approximately eight kilobytes to the kernel image.  But
+	  the first supported CPU brings a lot of bugs with it, so
+	  for ultimate reliability, set the number of CPUs to zero.
 
 config SCHED_SMT
 	bool "SMT (Hyperthreading) scheduler support"

^ permalink raw reply related

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Geert Uytterhoeven @ 2012-03-31 16:40 UTC (permalink / raw)
  To: paulmck
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, linux-m68k, uclinux-dist-devel, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, linux390, linuxppc-dev
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

Hi Paul,

On Sat, Mar 31, 2012 at 18:33, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all. =C2=A0In short, for the ultimate i=
n
> computer-system simplicity, the optimal choice is NR_CPUS=3D0.
>
> This commit therefore limits kernel builds to zero CPUs. =C2=A0This chang=
e
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>
> =C2=A0alpha/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 | =C2=A0 11 ++++++-----
> =C2=A0arm/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A06 +++---
> =C2=A0blackfin/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0| =C2=A0 =C2=A03 ++-
> =C2=A0hexagon/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 | =C2=A0 =C2=A09 +++++----
> =C2=A0ia64/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A09 +++++----
> =C2=A0m32r/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 10 ++++++----
> =C2=A0mips/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 21 +++++++++++----------
> =C2=A0mn10300/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 | =C2=A0 =C2=A03 ++-
> =C2=A0parisc/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A06 +++---
> =C2=A0powerpc/platforms/Kconfig.cputype | =C2=A0 =C2=A08 ++++----
> =C2=A0s390/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 12 +++++++-----
> =C2=A0sh/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 11 ++++++-----
> =C2=A0sparc/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A08 ++++----
> =C2=A0tile/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A09 +++++----
> =C2=A0x86/Kconfig =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 16 +++++++++-------
> =C2=A015 files changed, 78 insertions(+), 64 deletions(-)

You forgot to fix half of the architectures, a.o. m68k?

Gr{oetje,eeting}s,

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 Geert (still at GMT+2)

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k=
.org

In personal conversations with technical people, I call myself a hacker. Bu=
t
when I'm talking to journalists I just say "programmer" or something like t=
hat.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -- Linus Torvalds

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 16:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, linux-m68k, uclinux-dist-devel, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, linux390, linuxppc-dev
In-Reply-To: <CAMuHMdWTB+_AtqM6JixY=Oo_zmzX_dNxnivpARBYSbPJzp4t6A@mail.gmail.com>

On Sat, Mar 31, 2012 at 06:40:30PM +0200, Geert Uytterhoeven wrote:
> Hi Paul,
> 
> On Sat, Mar 31, 2012 at 18:33, Paul E. McKenney
> <paulmck@linux.vnet.ibm.com> wrote:
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> >
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> >
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > ---
> >
> >  alpha/Kconfig                     |   11 ++++++-----
> >  arm/Kconfig                       |    6 +++---
> >  blackfin/Kconfig                  |    3 ++-
> >  hexagon/Kconfig                   |    9 +++++----
> >  ia64/Kconfig                      |    9 +++++----
> >  m32r/Kconfig                      |   10 ++++++----
> >  mips/Kconfig                      |   21 +++++++++++----------
> >  mn10300/Kconfig                   |    3 ++-
> >  parisc/Kconfig                    |    6 +++---
> >  powerpc/platforms/Kconfig.cputype |    8 ++++----
> >  s390/Kconfig                      |   12 +++++++-----
> >  sh/Kconfig                        |   11 ++++++-----
> >  sparc/Kconfig                     |    8 ++++----
> >  tile/Kconfig                      |    9 +++++----
> >  x86/Kconfig                       |   16 +++++++++-------
> >  15 files changed, 78 insertions(+), 64 deletions(-)
> 
> You forgot to fix half of the architectures, a.o. m68k?

I must confess that I fixed only the SMP-capable architectures.

I of course would welcome additions for UP-only architectures.

							Thanx, Paul

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Linas Vepstas @ 2012-03-31 19:57 UTC (permalink / raw)
  To: paulmck
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

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

Hi,

I didn't actually try to compile the patch below; it didn't look like C
code so I wasn't sure what compiler to run it through.  I guess maybe its
python?  However, I'm very sure that the patches are completely correct,
because I read them, and I also know that Paul is a trustworthy programmer.
 Thus, please add my ack

Ack'ed by: Linas Vepstas <linasvepstas@gmail.com>


On 31 March 2012 11:33, Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:

> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all.  In short, for the ultimate in
> computer-system simplicity, the optimal choice is NR_CPUS=0.
>
> This commit therefore limits kernel builds to zero CPUs.  This change
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
>
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>
>  alpha/Kconfig                     |   11 ++++++-----
>  arm/Kconfig                       |    6 +++---
>  blackfin/Kconfig                  |    3 ++-
>  hexagon/Kconfig                   |    9 +++++----
>  ia64/Kconfig                      |    9 +++++----
>  m32r/Kconfig                      |   10 ++++++----
>  mips/Kconfig                      |   21 +++++++++++----------
>  mn10300/Kconfig                   |    3 ++-
>  parisc/Kconfig                    |    6 +++---
>  powerpc/platforms/Kconfig.cputype |    8 ++++----
>  s390/Kconfig                      |   12 +++++++-----
>  sh/Kconfig                        |   11 ++++++-----
>  sparc/Kconfig                     |    8 ++++----
>  tile/Kconfig                      |    9 +++++----
>  x86/Kconfig                       |   16 +++++++++-------
>  15 files changed, 78 insertions(+), 64 deletions(-)
>
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index 56a4df9..1766b4a 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -541,14 +541,15 @@ config HAVE_DEC_LOCK
>        default y
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-32)"
> -       range 2 32
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "32" if ALPHA_GENERIC || ALPHA_MARVEL
> -       default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
> +       default "0" if ALPHA_GENERIC || ALPHA_MARVEL
> +       default "0" if !ALPHA_GENERIC && !ALPHA_MARVEL
>        help
>          MARVEL support can handle a maximum of 32 CPUs, all the others
> -          with working support have a maximum of 4 CPUs.
> +          with working support have a maximum of 4 CPUs.  But why take
> +         chances?  Just stick with zero CPUs.
>
>  config ARCH_DISCONTIGMEM_ENABLE
>        bool "Discontiguous Memory Support (EXPERIMENTAL)"
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a48aecc..1f07a3a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1551,10 +1551,10 @@ config PAGE_OFFSET
>        default 0xC0000000
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-32)"
> -       range 2 32
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "4"
> +       default "0"
>
>  config HOTPLUG_CPU
>        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
> index abe5a9e..6a78549 100644
> --- a/arch/blackfin/Kconfig
> +++ b/arch/blackfin/Kconfig
> @@ -241,7 +241,8 @@ config SMP
>  config NR_CPUS
>        int
>        depends on SMP
> -       default 2 if BF561
> +       range 0 0
> +       default 0 if BF561
>
>  config HOTPLUG_CPU
>        bool "Support for hot-pluggable CPUs"
> diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
> index 9059e39..daab009 100644
> --- a/arch/hexagon/Kconfig
> +++ b/arch/hexagon/Kconfig
> @@ -158,13 +158,14 @@ config SMP
>
>  config NR_CPUS
>        int "Maximum number of CPUs" if SMP
> -       range 2 6 if SMP
> -       default "1" if !SMP
> -       default "6" if SMP
> +       range 0 0 if SMP
> +       default "0" if !SMP
> +       default "0" if SMP
>        ---help---
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 6 and the
> -         minimum value which makes sense is 2.
> +         minimum value which makes sense is 2.  But a limit of zero is
> +         so much safer!
>
>          This is purely to save memory - each supported CPU adds
>          approximately eight kilobytes to the kernel image.
> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> index bd72669..fea0e6d 100644
> --- a/arch/ia64/Kconfig
> +++ b/arch/ia64/Kconfig
> @@ -373,16 +373,17 @@ config SMP
>          If you don't know what to do here, say N.
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-4096)"
> -       range 2 4096
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "4096"
> +       default "0"
>        help
>          You should set this to the number of CPUs in your system, but
>          keep in mind that a kernel compiled for, e.g., 2 CPUs will boot
> but
>          only use 2 CPUs on a >2 CPU system.  Setting this to a value
> larger
>          than 64 will cause the use of a CPU mask array, causing a small
> -         performance hit.
> +         performance hit.  And setting it larger than zero risks all
> +         manner of software bugs, so we just play it safe.
>
>  config HOTPLUG_CPU
>        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
> index ef80a65..68b9e88 100644
> --- a/arch/m32r/Kconfig
> +++ b/arch/m32r/Kconfig
> @@ -300,14 +300,16 @@ config CHIP_M32700_TS1
>        default n
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-32)"
> -       range 2 32
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "2"
> +       default "0"
>        help
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 32 and the
> -         minimum value which makes sense is 2.
> +         minimum value which makes sense is 2.  Zero may not make sense,
> +         but given that there is much in this world that does not make
> +         sense, zero it is!
>
>          This is purely to save memory - each supported CPU adds
>          approximately eight kilobytes to the kernel image.
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 5ab6e89..3d7d06c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2192,16 +2192,16 @@ config NR_CPUS_DEFAULT_64
>        bool
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-64)"
> -       range 1 64 if NR_CPUS_DEFAULT_1
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0 if NR_CPUS_DEFAULT_1
>        depends on SMP
> -       default "1" if NR_CPUS_DEFAULT_1
> -       default "2" if NR_CPUS_DEFAULT_2
> -       default "4" if NR_CPUS_DEFAULT_4
> -       default "8" if NR_CPUS_DEFAULT_8
> -       default "16" if NR_CPUS_DEFAULT_16
> -       default "32" if NR_CPUS_DEFAULT_32
> -       default "64" if NR_CPUS_DEFAULT_64
> +       default "0" if NR_CPUS_DEFAULT_1
> +       default "0" if NR_CPUS_DEFAULT_2
> +       default "0" if NR_CPUS_DEFAULT_4
> +       default "0" if NR_CPUS_DEFAULT_8
> +       default "0" if NR_CPUS_DEFAULT_16
> +       default "0" if NR_CPUS_DEFAULT_32
> +       default "0" if NR_CPUS_DEFAULT_64
>        help
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 32 for 32-bit
> @@ -2212,7 +2212,8 @@ config NR_CPUS
>          This is purely to save memory - each supported CPU adds
>          approximately eight kilobytes to the kernel image.  For best
>          performance should round up your number of processors to the next
> -         power of two.
> +         power of two.  And just think how much more memory we will
> +         save by setting the limit to zero!
>
>  source "kernel/time/Kconfig"
>
> diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
> index 8f1c40d..85fc112 100644
> --- a/arch/mn10300/Kconfig
> +++ b/arch/mn10300/Kconfig
> @@ -201,7 +201,8 @@ config SMP
>  config NR_CPUS
>        int
>        depends on SMP
> -       default "2"
> +       range 0 0
> +       default "0"
>
>  source "kernel/Kconfig.preempt"
>
> diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> index 242a1b7..358eaf8 100644
> --- a/arch/parisc/Kconfig
> +++ b/arch/parisc/Kconfig
> @@ -254,10 +254,10 @@ config HPUX
>        depends on !64BIT
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-32)"
> -       range 2 32
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "32"
> +       default "0"
>
>  endmenu
>
> diff --git a/arch/powerpc/platforms/Kconfig.cputype
> b/arch/powerpc/platforms/Kconfig.cputype
> index 425db18..5e607e0 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -356,11 +356,11 @@ config SMP
>          If you don't know what to do here, say N.
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-8192)"
> -       range 2 8192
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "32" if PPC64
> -       default "4"
> +       default "0" if PPC64
> +       default "0"
>
>  config NOT_COHERENT_CACHE
>        bool
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index d172758..f9bc067 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -169,15 +169,17 @@ config SMP
>          Even if you don't know what to do here, say Y.
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-64)"
> -       range 2 64
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "32" if !64BIT
> -       default "64" if 64BIT
> +       default "0" if !64BIT
> +       default "0" if 64BIT
>        help
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 64 and the
> -         minimum value which makes sense is 2.
> +         minimum value which makes sense is 2.  The minimal value that
> +         makes sense might well be 2, but we all know that the only
> +         -sane- value is zero!
>
>          This is purely to save memory - each supported CPU adds
>          approximately sixteen kilobytes to the kernel image.
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 713fb58..5ddc7c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -705,18 +705,19 @@ config SMP
>          If you don't know what to do here, say N.
>
>  config NR_CPUS
> -       int "Maximum number of CPUs (2-32)"
> -       range 2 32
> +       int "Maximum number of CPUs (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "4" if CPU_SUBTYPE_SHX3
> -       default "2"
> +       default "0" if CPU_SUBTYPE_SHX3
> +       default "0"
>        help
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 32 and the
>          minimum value which makes sense is 2.
>
>          This is purely to save memory - each supported CPU adds
> -         approximately eight kilobytes to the kernel image.
> +         approximately eight kilobytes to the kernel image.  Debloating
> +         is the way, NR_CPUS to zero today!!!
>
>  config HOTPLUG_CPU
>        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index ca5580e..0de9f0f 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -177,10 +177,10 @@ config SMP
>  config NR_CPUS
>        int "Maximum number of CPUs"
>        depends on SMP
> -       range 2 32 if SPARC32
> -       range 2 1024 if SPARC64
> -       default 32 if SPARC32
> -       default 64 if SPARC64
> +       range 0 0 if SPARC32
> +       range 0 0 if SPARC64
> +       default 0 if SPARC32
> +       default 0 if SPARC64
>
>  source kernel/Kconfig.hz
>
> diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
> index 11270ca..a05112c 100644
> --- a/arch/tile/Kconfig
> +++ b/arch/tile/Kconfig
> @@ -126,14 +126,15 @@ source "init/Kconfig"
>  menu "Tilera-specific configuration"
>
>  config NR_CPUS
> -       int "Maximum number of tiles (2-255)"
> -       range 2 255
> +       int "Maximum number of tiles (0-0)"
> +       range 0 0
>        depends on SMP
> -       default "64"
> +       default "0"
>        ---help---
>          Building with 64 is the recommended value, but a slightly
>          smaller kernel memory footprint results from using a smaller
> -         value on chips with fewer tiles.
> +         value on chips with fewer tiles.  To minimize both memory
> +         footprint and bugs, use zero and only zero.
>
>  source "kernel/time/Kconfig"
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 5bed94e..a6977f2 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -773,19 +773,21 @@ config MAXSMP
>
>  config NR_CPUS
>        int "Maximum number of CPUs" if SMP && !MAXSMP
> -       range 2 8 if SMP && X86_32 && !X86_BIGSMP
> -       range 2 512 if SMP && !MAXSMP
> -       default "1" if !SMP
> -       default "4096" if MAXSMP
> -       default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP ||
> X86_ES7000)
> -       default "8" if SMP
> +       range 0 0 if SMP && X86_32 && !X86_BIGSMP
> +       range 0 0 if SMP && !MAXSMP
> +       default "0" if !SMP
> +       default "0" if MAXSMP
> +       default "0" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP ||
> X86_ES7000)
> +       default "0" if SMP
>        ---help---
>          This allows you to specify the maximum number of CPUs which this
>          kernel will support.  The maximum supported value is 512 and the
>          minimum value which makes sense is 2.
>
>          This is purely to save memory - each supported CPU adds
> -         approximately eight kilobytes to the kernel image.
> +         approximately eight kilobytes to the kernel image.  But
> +         the first supported CPU brings a lot of bugs with it, so
> +         for ultimate reliability, set the number of CPUs to zero.
>
>  config SCHED_SMT
>        bool "SMT (Hyperthreading) scheduler support"
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[-- Attachment #2: Type: text/html, Size: 19166 bytes --]

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Linas Vepstas @ 2012-03-31 20:15 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

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


Hi,

I didn't actually try to compile the patch below; it didn't look like
C code so I wasn't sure what compiler to run it through.  I guess maybe
its python?  However, I'm very sure that the patches are completely
correct, because I read them, and I also know Paul.  And I've heard of
Thomas Gleixner.

Thus, please add my ack --

Ack'ed by: Linas Vepstas <linasvepstas@gmail.com>


On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney was heard to remark:
> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all.  In short, for the ultimate in
> computer-system simplicity, the optimal choice is NR_CPUS=0.
> 
> This commit therefore limits kernel builds to zero CPUs.  This change
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> 
>  alpha/Kconfig                     |   11 ++++++-----
>  arm/Kconfig                       |    6 +++---
>  blackfin/Kconfig                  |    3 ++-
>  hexagon/Kconfig                   |    9 +++++----
>  ia64/Kconfig                      |    9 +++++----
>  m32r/Kconfig                      |   10 ++++++----
>  mips/Kconfig                      |   21 +++++++++++----------
>  mn10300/Kconfig                   |    3 ++-
>  parisc/Kconfig                    |    6 +++---
>  powerpc/platforms/Kconfig.cputype |    8 ++++----
>  s390/Kconfig                      |   12 +++++++-----
>  sh/Kconfig                        |   11 ++++++-----
>  sparc/Kconfig                     |    8 ++++----
>  tile/Kconfig                      |    9 +++++----
>  x86/Kconfig                       |   16 +++++++++-------
>  15 files changed, 78 insertions(+), 64 deletions(-)
> 
> diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> index 56a4df9..1766b4a 100644
> --- a/arch/alpha/Kconfig
> +++ b/arch/alpha/Kconfig
> @@ -541,14 +541,15 @@ config HAVE_DEC_LOCK
>  	default y
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-32)"
> -	range 2 32
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "32" if ALPHA_GENERIC || ALPHA_MARVEL
> -	default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
> +	default "0" if ALPHA_GENERIC || ALPHA_MARVEL
> +	default "0" if !ALPHA_GENERIC && !ALPHA_MARVEL
>  	help
>  	  MARVEL support can handle a maximum of 32 CPUs, all the others
> -          with working support have a maximum of 4 CPUs.
> +          with working support have a maximum of 4 CPUs.  But why take
> +	  chances?  Just stick with zero CPUs.
>  
>  config ARCH_DISCONTIGMEM_ENABLE
>  	bool "Discontiguous Memory Support (EXPERIMENTAL)"
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index a48aecc..1f07a3a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1551,10 +1551,10 @@ config PAGE_OFFSET
>  	default 0xC0000000
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-32)"
> -	range 2 32
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "4"
> +	default "0"
>  
>  config HOTPLUG_CPU
>  	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
> index abe5a9e..6a78549 100644
> --- a/arch/blackfin/Kconfig
> +++ b/arch/blackfin/Kconfig
> @@ -241,7 +241,8 @@ config SMP
>  config NR_CPUS
>  	int
>  	depends on SMP
> -	default 2 if BF561
> +	range 0 0
> +	default 0 if BF561
>  
>  config HOTPLUG_CPU
>  	bool "Support for hot-pluggable CPUs"
> diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
> index 9059e39..daab009 100644
> --- a/arch/hexagon/Kconfig
> +++ b/arch/hexagon/Kconfig
> @@ -158,13 +158,14 @@ config SMP
>  
>  config NR_CPUS
>  	int "Maximum number of CPUs" if SMP
> -	range 2 6 if SMP
> -	default "1" if !SMP
> -	default "6" if SMP
> +	range 0 0 if SMP
> +	default "0" if !SMP
> +	default "0" if SMP
>  	---help---
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 6 and the
> -	  minimum value which makes sense is 2.
> +	  minimum value which makes sense is 2.  But a limit of zero is
> +	  so much safer!
>  
>  	  This is purely to save memory - each supported CPU adds
>  	  approximately eight kilobytes to the kernel image.
> diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> index bd72669..fea0e6d 100644
> --- a/arch/ia64/Kconfig
> +++ b/arch/ia64/Kconfig
> @@ -373,16 +373,17 @@ config SMP
>  	  If you don't know what to do here, say N.
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-4096)"
> -	range 2 4096
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "4096"
> +	default "0"
>  	help
>  	  You should set this to the number of CPUs in your system, but
>  	  keep in mind that a kernel compiled for, e.g., 2 CPUs will boot but
>  	  only use 2 CPUs on a >2 CPU system.  Setting this to a value larger
>  	  than 64 will cause the use of a CPU mask array, causing a small
> -	  performance hit.
> +	  performance hit.  And setting it larger than zero risks all
> +	  manner of software bugs, so we just play it safe.
>  
>  config HOTPLUG_CPU
>  	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
> index ef80a65..68b9e88 100644
> --- a/arch/m32r/Kconfig
> +++ b/arch/m32r/Kconfig
> @@ -300,14 +300,16 @@ config CHIP_M32700_TS1
>  	default n
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-32)"
> -	range 2 32
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "2"
> +	default "0"
>  	help
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 32 and the
> -	  minimum value which makes sense is 2.
> +	  minimum value which makes sense is 2.  Zero may not make sense,
> +	  but given that there is much in this world that does not make
> +	  sense, zero it is!
>  
>  	  This is purely to save memory - each supported CPU adds
>  	  approximately eight kilobytes to the kernel image.
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index 5ab6e89..3d7d06c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -2192,16 +2192,16 @@ config NR_CPUS_DEFAULT_64
>  	bool
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-64)"
> -	range 1 64 if NR_CPUS_DEFAULT_1
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0 if NR_CPUS_DEFAULT_1
>  	depends on SMP
> -	default "1" if NR_CPUS_DEFAULT_1
> -	default "2" if NR_CPUS_DEFAULT_2
> -	default "4" if NR_CPUS_DEFAULT_4
> -	default "8" if NR_CPUS_DEFAULT_8
> -	default "16" if NR_CPUS_DEFAULT_16
> -	default "32" if NR_CPUS_DEFAULT_32
> -	default "64" if NR_CPUS_DEFAULT_64
> +	default "0" if NR_CPUS_DEFAULT_1
> +	default "0" if NR_CPUS_DEFAULT_2
> +	default "0" if NR_CPUS_DEFAULT_4
> +	default "0" if NR_CPUS_DEFAULT_8
> +	default "0" if NR_CPUS_DEFAULT_16
> +	default "0" if NR_CPUS_DEFAULT_32
> +	default "0" if NR_CPUS_DEFAULT_64
>  	help
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 32 for 32-bit
> @@ -2212,7 +2212,8 @@ config NR_CPUS
>  	  This is purely to save memory - each supported CPU adds
>  	  approximately eight kilobytes to the kernel image.  For best
>  	  performance should round up your number of processors to the next
> -	  power of two.
> +	  power of two.  And just think how much more memory we will
> +	  save by setting the limit to zero!
>  
>  source "kernel/time/Kconfig"
>  
> diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
> index 8f1c40d..85fc112 100644
> --- a/arch/mn10300/Kconfig
> +++ b/arch/mn10300/Kconfig
> @@ -201,7 +201,8 @@ config SMP
>  config NR_CPUS
>  	int
>  	depends on SMP
> -	default "2"
> +	range 0 0
> +	default "0"
>  
>  source "kernel/Kconfig.preempt"
>  
> diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> index 242a1b7..358eaf8 100644
> --- a/arch/parisc/Kconfig
> +++ b/arch/parisc/Kconfig
> @@ -254,10 +254,10 @@ config HPUX
>  	depends on !64BIT
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-32)"
> -	range 2 32
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "32"
> +	default "0"
>  
>  endmenu
>  
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index 425db18..5e607e0 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -356,11 +356,11 @@ config SMP
>  	  If you don't know what to do here, say N.
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-8192)"
> -	range 2 8192
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "32" if PPC64
> -	default "4"
> +	default "0" if PPC64
> +	default "0"
>  
>  config NOT_COHERENT_CACHE
>  	bool
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index d172758..f9bc067 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -169,15 +169,17 @@ config SMP
>  	  Even if you don't know what to do here, say Y.
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-64)"
> -	range 2 64
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "32" if !64BIT
> -	default "64" if 64BIT
> +	default "0" if !64BIT
> +	default "0" if 64BIT
>  	help
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 64 and the
> -	  minimum value which makes sense is 2.
> +	  minimum value which makes sense is 2.  The minimal value that
> +	  makes sense might well be 2, but we all know that the only
> +	  -sane- value is zero!
>  
>  	  This is purely to save memory - each supported CPU adds
>  	  approximately sixteen kilobytes to the kernel image.
> diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> index 713fb58..5ddc7c0 100644
> --- a/arch/sh/Kconfig
> +++ b/arch/sh/Kconfig
> @@ -705,18 +705,19 @@ config SMP
>  	  If you don't know what to do here, say N.
>  
>  config NR_CPUS
> -	int "Maximum number of CPUs (2-32)"
> -	range 2 32
> +	int "Maximum number of CPUs (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "4" if CPU_SUBTYPE_SHX3
> -	default "2"
> +	default "0" if CPU_SUBTYPE_SHX3
> +	default "0"
>  	help
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 32 and the
>  	  minimum value which makes sense is 2.
>  
>  	  This is purely to save memory - each supported CPU adds
> -	  approximately eight kilobytes to the kernel image.
> +	  approximately eight kilobytes to the kernel image.  Debloating
> +	  is the way, NR_CPUS to zero today!!!
>  
>  config HOTPLUG_CPU
>  	bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index ca5580e..0de9f0f 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -177,10 +177,10 @@ config SMP
>  config NR_CPUS
>  	int "Maximum number of CPUs"
>  	depends on SMP
> -	range 2 32 if SPARC32
> -	range 2 1024 if SPARC64
> -	default 32 if SPARC32
> -	default 64 if SPARC64
> +	range 0 0 if SPARC32
> +	range 0 0 if SPARC64
> +	default 0 if SPARC32
> +	default 0 if SPARC64
>  
>  source kernel/Kconfig.hz
>  
> diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
> index 11270ca..a05112c 100644
> --- a/arch/tile/Kconfig
> +++ b/arch/tile/Kconfig
> @@ -126,14 +126,15 @@ source "init/Kconfig"
>  menu "Tilera-specific configuration"
>  
>  config NR_CPUS
> -	int "Maximum number of tiles (2-255)"
> -	range 2 255
> +	int "Maximum number of tiles (0-0)"
> +	range 0 0
>  	depends on SMP
> -	default "64"
> +	default "0"
>  	---help---
>  	  Building with 64 is the recommended value, but a slightly
>  	  smaller kernel memory footprint results from using a smaller
> -	  value on chips with fewer tiles.
> +	  value on chips with fewer tiles.  To minimize both memory
> +	  footprint and bugs, use zero and only zero.
>  
>  source "kernel/time/Kconfig"
>  
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 5bed94e..a6977f2 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -773,19 +773,21 @@ config MAXSMP
>  
>  config NR_CPUS
>  	int "Maximum number of CPUs" if SMP && !MAXSMP
> -	range 2 8 if SMP && X86_32 && !X86_BIGSMP
> -	range 2 512 if SMP && !MAXSMP
> -	default "1" if !SMP
> -	default "4096" if MAXSMP
> -	default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
> -	default "8" if SMP
> +	range 0 0 if SMP && X86_32 && !X86_BIGSMP
> +	range 0 0 if SMP && !MAXSMP
> +	default "0" if !SMP
> +	default "0" if MAXSMP
> +	default "0" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
> +	default "0" if SMP
>  	---help---
>  	  This allows you to specify the maximum number of CPUs which this
>  	  kernel will support.  The maximum supported value is 512 and the
>  	  minimum value which makes sense is 2.
>  
>  	  This is purely to save memory - each supported CPU adds
> -	  approximately eight kilobytes to the kernel image.
> +	  approximately eight kilobytes to the kernel image.  But
> +	  the first supported CPU brings a lot of bugs with it, so
> +	  for ultimate reliability, set the number of CPUs to zero.
>  
>  config SCHED_SMT
>  	bool "SMT (Hyperthreading) scheduler support"
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 20:14 UTC (permalink / raw)
  To: Linas Vepstas
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <CAHrUA35Bz68DtP-Znr=-+U+6P9CONXzN=9JdMXRfRwmVV9fy=Q@mail.gmail.com>

On Sat, Mar 31, 2012 at 02:57:46PM -0500, Linas Vepstas wrote:
> Hi,
> 
> I didn't actually try to compile the patch below; it didn't look like C
> code so I wasn't sure what compiler to run it through.  I guess maybe its
> python?  However, I'm very sure that the patches are completely correct,
> because I read them, and I also know that Paul is a trustworthy programmer.
>  Thus, please add my ack
> 
> Ack'ed by: Linas Vepstas <linasvepstas@gmail.com>

It is Linux-kernel Kconfig language, which processed during kernel
builds.  I have added your Acked-by.  ;-)

							Thanx, Paul

> On 31 March 2012 11:33, Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote:
> 
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> >
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> >
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > ---
> >
> >  alpha/Kconfig                     |   11 ++++++-----
> >  arm/Kconfig                       |    6 +++---
> >  blackfin/Kconfig                  |    3 ++-
> >  hexagon/Kconfig                   |    9 +++++----
> >  ia64/Kconfig                      |    9 +++++----
> >  m32r/Kconfig                      |   10 ++++++----
> >  mips/Kconfig                      |   21 +++++++++++----------
> >  mn10300/Kconfig                   |    3 ++-
> >  parisc/Kconfig                    |    6 +++---
> >  powerpc/platforms/Kconfig.cputype |    8 ++++----
> >  s390/Kconfig                      |   12 +++++++-----
> >  sh/Kconfig                        |   11 ++++++-----
> >  sparc/Kconfig                     |    8 ++++----
> >  tile/Kconfig                      |    9 +++++----
> >  x86/Kconfig                       |   16 +++++++++-------
> >  15 files changed, 78 insertions(+), 64 deletions(-)
> >
> > diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
> > index 56a4df9..1766b4a 100644
> > --- a/arch/alpha/Kconfig
> > +++ b/arch/alpha/Kconfig
> > @@ -541,14 +541,15 @@ config HAVE_DEC_LOCK
> >        default y
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-32)"
> > -       range 2 32
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "32" if ALPHA_GENERIC || ALPHA_MARVEL
> > -       default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
> > +       default "0" if ALPHA_GENERIC || ALPHA_MARVEL
> > +       default "0" if !ALPHA_GENERIC && !ALPHA_MARVEL
> >        help
> >          MARVEL support can handle a maximum of 32 CPUs, all the others
> > -          with working support have a maximum of 4 CPUs.
> > +          with working support have a maximum of 4 CPUs.  But why take
> > +         chances?  Just stick with zero CPUs.
> >
> >  config ARCH_DISCONTIGMEM_ENABLE
> >        bool "Discontiguous Memory Support (EXPERIMENTAL)"
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index a48aecc..1f07a3a 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1551,10 +1551,10 @@ config PAGE_OFFSET
> >        default 0xC0000000
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-32)"
> > -       range 2 32
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "4"
> > +       default "0"
> >
> >  config HOTPLUG_CPU
> >        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> > diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
> > index abe5a9e..6a78549 100644
> > --- a/arch/blackfin/Kconfig
> > +++ b/arch/blackfin/Kconfig
> > @@ -241,7 +241,8 @@ config SMP
> >  config NR_CPUS
> >        int
> >        depends on SMP
> > -       default 2 if BF561
> > +       range 0 0
> > +       default 0 if BF561
> >
> >  config HOTPLUG_CPU
> >        bool "Support for hot-pluggable CPUs"
> > diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
> > index 9059e39..daab009 100644
> > --- a/arch/hexagon/Kconfig
> > +++ b/arch/hexagon/Kconfig
> > @@ -158,13 +158,14 @@ config SMP
> >
> >  config NR_CPUS
> >        int "Maximum number of CPUs" if SMP
> > -       range 2 6 if SMP
> > -       default "1" if !SMP
> > -       default "6" if SMP
> > +       range 0 0 if SMP
> > +       default "0" if !SMP
> > +       default "0" if SMP
> >        ---help---
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 6 and the
> > -         minimum value which makes sense is 2.
> > +         minimum value which makes sense is 2.  But a limit of zero is
> > +         so much safer!
> >
> >          This is purely to save memory - each supported CPU adds
> >          approximately eight kilobytes to the kernel image.
> > diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
> > index bd72669..fea0e6d 100644
> > --- a/arch/ia64/Kconfig
> > +++ b/arch/ia64/Kconfig
> > @@ -373,16 +373,17 @@ config SMP
> >          If you don't know what to do here, say N.
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-4096)"
> > -       range 2 4096
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "4096"
> > +       default "0"
> >        help
> >          You should set this to the number of CPUs in your system, but
> >          keep in mind that a kernel compiled for, e.g., 2 CPUs will boot
> > but
> >          only use 2 CPUs on a >2 CPU system.  Setting this to a value
> > larger
> >          than 64 will cause the use of a CPU mask array, causing a small
> > -         performance hit.
> > +         performance hit.  And setting it larger than zero risks all
> > +         manner of software bugs, so we just play it safe.
> >
> >  config HOTPLUG_CPU
> >        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> > diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
> > index ef80a65..68b9e88 100644
> > --- a/arch/m32r/Kconfig
> > +++ b/arch/m32r/Kconfig
> > @@ -300,14 +300,16 @@ config CHIP_M32700_TS1
> >        default n
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-32)"
> > -       range 2 32
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "2"
> > +       default "0"
> >        help
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 32 and the
> > -         minimum value which makes sense is 2.
> > +         minimum value which makes sense is 2.  Zero may not make sense,
> > +         but given that there is much in this world that does not make
> > +         sense, zero it is!
> >
> >          This is purely to save memory - each supported CPU adds
> >          approximately eight kilobytes to the kernel image.
> > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > index 5ab6e89..3d7d06c 100644
> > --- a/arch/mips/Kconfig
> > +++ b/arch/mips/Kconfig
> > @@ -2192,16 +2192,16 @@ config NR_CPUS_DEFAULT_64
> >        bool
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-64)"
> > -       range 1 64 if NR_CPUS_DEFAULT_1
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0 if NR_CPUS_DEFAULT_1
> >        depends on SMP
> > -       default "1" if NR_CPUS_DEFAULT_1
> > -       default "2" if NR_CPUS_DEFAULT_2
> > -       default "4" if NR_CPUS_DEFAULT_4
> > -       default "8" if NR_CPUS_DEFAULT_8
> > -       default "16" if NR_CPUS_DEFAULT_16
> > -       default "32" if NR_CPUS_DEFAULT_32
> > -       default "64" if NR_CPUS_DEFAULT_64
> > +       default "0" if NR_CPUS_DEFAULT_1
> > +       default "0" if NR_CPUS_DEFAULT_2
> > +       default "0" if NR_CPUS_DEFAULT_4
> > +       default "0" if NR_CPUS_DEFAULT_8
> > +       default "0" if NR_CPUS_DEFAULT_16
> > +       default "0" if NR_CPUS_DEFAULT_32
> > +       default "0" if NR_CPUS_DEFAULT_64
> >        help
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 32 for 32-bit
> > @@ -2212,7 +2212,8 @@ config NR_CPUS
> >          This is purely to save memory - each supported CPU adds
> >          approximately eight kilobytes to the kernel image.  For best
> >          performance should round up your number of processors to the next
> > -         power of two.
> > +         power of two.  And just think how much more memory we will
> > +         save by setting the limit to zero!
> >
> >  source "kernel/time/Kconfig"
> >
> > diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
> > index 8f1c40d..85fc112 100644
> > --- a/arch/mn10300/Kconfig
> > +++ b/arch/mn10300/Kconfig
> > @@ -201,7 +201,8 @@ config SMP
> >  config NR_CPUS
> >        int
> >        depends on SMP
> > -       default "2"
> > +       range 0 0
> > +       default "0"
> >
> >  source "kernel/Kconfig.preempt"
> >
> > diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> > index 242a1b7..358eaf8 100644
> > --- a/arch/parisc/Kconfig
> > +++ b/arch/parisc/Kconfig
> > @@ -254,10 +254,10 @@ config HPUX
> >        depends on !64BIT
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-32)"
> > -       range 2 32
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "32"
> > +       default "0"
> >
> >  endmenu
> >
> > diff --git a/arch/powerpc/platforms/Kconfig.cputype
> > b/arch/powerpc/platforms/Kconfig.cputype
> > index 425db18..5e607e0 100644
> > --- a/arch/powerpc/platforms/Kconfig.cputype
> > +++ b/arch/powerpc/platforms/Kconfig.cputype
> > @@ -356,11 +356,11 @@ config SMP
> >          If you don't know what to do here, say N.
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-8192)"
> > -       range 2 8192
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "32" if PPC64
> > -       default "4"
> > +       default "0" if PPC64
> > +       default "0"
> >
> >  config NOT_COHERENT_CACHE
> >        bool
> > diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> > index d172758..f9bc067 100644
> > --- a/arch/s390/Kconfig
> > +++ b/arch/s390/Kconfig
> > @@ -169,15 +169,17 @@ config SMP
> >          Even if you don't know what to do here, say Y.
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-64)"
> > -       range 2 64
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "32" if !64BIT
> > -       default "64" if 64BIT
> > +       default "0" if !64BIT
> > +       default "0" if 64BIT
> >        help
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 64 and the
> > -         minimum value which makes sense is 2.
> > +         minimum value which makes sense is 2.  The minimal value that
> > +         makes sense might well be 2, but we all know that the only
> > +         -sane- value is zero!
> >
> >          This is purely to save memory - each supported CPU adds
> >          approximately sixteen kilobytes to the kernel image.
> > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
> > index 713fb58..5ddc7c0 100644
> > --- a/arch/sh/Kconfig
> > +++ b/arch/sh/Kconfig
> > @@ -705,18 +705,19 @@ config SMP
> >          If you don't know what to do here, say N.
> >
> >  config NR_CPUS
> > -       int "Maximum number of CPUs (2-32)"
> > -       range 2 32
> > +       int "Maximum number of CPUs (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "4" if CPU_SUBTYPE_SHX3
> > -       default "2"
> > +       default "0" if CPU_SUBTYPE_SHX3
> > +       default "0"
> >        help
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 32 and the
> >          minimum value which makes sense is 2.
> >
> >          This is purely to save memory - each supported CPU adds
> > -         approximately eight kilobytes to the kernel image.
> > +         approximately eight kilobytes to the kernel image.  Debloating
> > +         is the way, NR_CPUS to zero today!!!
> >
> >  config HOTPLUG_CPU
> >        bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
> > diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> > index ca5580e..0de9f0f 100644
> > --- a/arch/sparc/Kconfig
> > +++ b/arch/sparc/Kconfig
> > @@ -177,10 +177,10 @@ config SMP
> >  config NR_CPUS
> >        int "Maximum number of CPUs"
> >        depends on SMP
> > -       range 2 32 if SPARC32
> > -       range 2 1024 if SPARC64
> > -       default 32 if SPARC32
> > -       default 64 if SPARC64
> > +       range 0 0 if SPARC32
> > +       range 0 0 if SPARC64
> > +       default 0 if SPARC32
> > +       default 0 if SPARC64
> >
> >  source kernel/Kconfig.hz
> >
> > diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
> > index 11270ca..a05112c 100644
> > --- a/arch/tile/Kconfig
> > +++ b/arch/tile/Kconfig
> > @@ -126,14 +126,15 @@ source "init/Kconfig"
> >  menu "Tilera-specific configuration"
> >
> >  config NR_CPUS
> > -       int "Maximum number of tiles (2-255)"
> > -       range 2 255
> > +       int "Maximum number of tiles (0-0)"
> > +       range 0 0
> >        depends on SMP
> > -       default "64"
> > +       default "0"
> >        ---help---
> >          Building with 64 is the recommended value, but a slightly
> >          smaller kernel memory footprint results from using a smaller
> > -         value on chips with fewer tiles.
> > +         value on chips with fewer tiles.  To minimize both memory
> > +         footprint and bugs, use zero and only zero.
> >
> >  source "kernel/time/Kconfig"
> >
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index 5bed94e..a6977f2 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -773,19 +773,21 @@ config MAXSMP
> >
> >  config NR_CPUS
> >        int "Maximum number of CPUs" if SMP && !MAXSMP
> > -       range 2 8 if SMP && X86_32 && !X86_BIGSMP
> > -       range 2 512 if SMP && !MAXSMP
> > -       default "1" if !SMP
> > -       default "4096" if MAXSMP
> > -       default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP ||
> > X86_ES7000)
> > -       default "8" if SMP
> > +       range 0 0 if SMP && X86_32 && !X86_BIGSMP
> > +       range 0 0 if SMP && !MAXSMP
> > +       default "0" if !SMP
> > +       default "0" if MAXSMP
> > +       default "0" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP ||
> > X86_ES7000)
> > +       default "0" if SMP
> >        ---help---
> >          This allows you to specify the maximum number of CPUs which this
> >          kernel will support.  The maximum supported value is 512 and the
> >          minimum value which makes sense is 2.
> >
> >          This is purely to save memory - each supported CPU adds
> > -         approximately eight kilobytes to the kernel image.
> > +         approximately eight kilobytes to the kernel image.  But
> > +         the first supported CPU brings a lot of bugs with it, so
> > +         for ultimate reliability, set the number of CPUs to zero.
> >
> >  config SCHED_SMT
> >        bool "SMT (Hyperthreading) scheduler support"
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Randy Dunlap @ 2012-03-31 20:25 UTC (permalink / raw)
  To: Linas Vepstas
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, Paul E. McKenney, cmetcalf, uclinux-dist-devel, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, linux390, linuxppc-dev
In-Reply-To: <20120331201500.GA27640@linas.org>

On 03/31/2012 01:15 PM, Linas Vepstas wrote:

> 
> Hi,
> 
> I didn't actually try to compile the patch below; it didn't look like
> C code so I wasn't sure what compiler to run it through.  I guess maybe
> its python?  However, I'm very sure that the patches are completely
> correct, because I read them, and I also know Paul.  And I've heard of
> Thomas Gleixner.


x86_64 defconfig has many build errors and warnings.  :(

back to my abacus.

-- 
~Randy

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 20:43 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, Linas Vepstas, cmetcalf, uclinux-dist-devel, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, linux390, linuxppc-dev
In-Reply-To: <4F77681E.5010608@xenotime.net>

On Sat, Mar 31, 2012 at 01:25:02PM -0700, Randy Dunlap wrote:
> On 03/31/2012 01:15 PM, Linas Vepstas wrote:
> 
> > 
> > Hi,
> > 
> > I didn't actually try to compile the patch below; it didn't look like
> > C code so I wasn't sure what compiler to run it through.  I guess maybe
> > its python?  However, I'm very sure that the patches are completely
> > correct, because I read them, and I also know Paul.  And I've heard of
> > Thomas Gleixner.
> 
> 
> x86_64 defconfig has many build errors and warnings.  :(

I suggest removing the code containing the errors and warnings.  I bet
that the offending code is not needed when running with zero CPUs.

> back to my abacus.

;-)

							Thanx, Paul

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Eric Dumazet @ 2012-03-31 21:00 UTC (permalink / raw)
  To: paulmck
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

On Sun, 2012-04-01 at 00:33 +0800, Paul E. McKenney wrote:
> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all.  In short, for the ultimate in
> computer-system simplicity, the optimal choice is NR_CPUS=0.
> 
> This commit therefore limits kernel builds to zero CPUs.  This change
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> ---

Hmm... I believe you could go one step forward and allow negative values
as well. Antimatter was proven to exist after all.

Hint : nr_cpu_ids is an "int", not an "unsigned int"

Bonus: Existing bugs become "must have" features.

Of course there is no hurry and this can wait 365 days.

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 21:21 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <1333227608.2325.4054.camel@edumazet-glaptop>

On Sat, Mar 31, 2012 at 11:00:08PM +0200, Eric Dumazet wrote:
> On Sun, 2012-04-01 at 00:33 +0800, Paul E. McKenney wrote:
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> > 
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > ---
> 
> Hmm... I believe you could go one step forward and allow negative values
> as well. Antimatter was proven to exist after all.
> 
> Hint : nr_cpu_ids is an "int", not an "unsigned int"
> 
> Bonus: Existing bugs become "must have" features.

;-) ;-) ;-)

> Of course there is no hurry and this can wait 365 days.

James Bottomley suggested imaginary numbers of CPUs some time back,
and I suppose there is no reason you cannot have fractional numbers of
CPUs, and perhaps irrational numbers as well.  Of course, these last two
would require use of floating-point arithmetic (or something similar)
in the kernel.  So I guess we have at several years worth.  Over to you
for the negative numbers.  ;-)

							Thanx, Paul

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Lorenz Kolb @ 2012-03-31 22:19 UTC (permalink / raw)
  To: paulmck
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, Eric Dumazet,
	linux-hexagon, x86, jejb, cmetcalf, linux390, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, uclinux-dist-devel, linuxppc-dev
In-Reply-To: <20120331212149.GI2450@linux.vnet.ibm.com>

With that patchset in mind, I am working on a really huge patch, which 
will greatly simplify the Linux kernel  for the real problem of having 
that number of CPUs.

That patch will have a lot of changes all over the architectures, so 
what will be the best way to post it? Should I split it architecture 
dependend and into one generic part.

Currently it is a large blob of millions of changes, but will greatly 
simplify the Linux kernel.

Regards,

Lorenz Kolb

Am 31.03.2012 23:21, schrieb Paul E. McKenney:
> On Sat, Mar 31, 2012 at 11:00:08PM +0200, Eric Dumazet wrote:
>    
>> On Sun, 2012-04-01 at 00:33 +0800, Paul E. McKenney wrote:
>>      
>>> Although there have been numerous complaints about the complexity of
>>> parallel programming (especially over the past 5-10 years), the plain
>>> truth is that the incremental complexity of parallel programming over
>>> that of sequential programming is not as large as is commonly believed.
>>> Despite that you might have heard, the mind-numbing complexity of modern
>>> computer systems is not due so much to there being multiple CPUs, but
>>> rather to there being any CPUs at all.  In short, for the ultimate in
>>> computer-system simplicity, the optimal choice is NR_CPUS=0.
>>>
>>> This commit therefore limits kernel builds to zero CPUs.  This change
>>> has the beneficial side effect of rendering all kernel bugs harmless.
>>> Furthermore, this commit enables additional beneficial changes, for
>>> example, the removal of those parts of the kernel that are not needed
>>> when there are zero CPUs.
>>>
>>> Signed-off-by: Paul E. McKenney<paulmck@linux.vnet.ibm.com>
>>> Reviewed-by: Thomas Gleixner<tglx@linutronix.de>
>>> ---
>>>        
>> Hmm... I believe you could go one step forward and allow negative values
>> as well. Antimatter was proven to exist after all.
>>
>> Hint : nr_cpu_ids is an "int", not an "unsigned int"
>>
>> Bonus: Existing bugs become "must have" features.
>>      
> ;-) ;-) ;-)
>
>    
>> Of course there is no hurry and this can wait 365 days.
>>      
> James Bottomley suggested imaginary numbers of CPUs some time back,
> and I suppose there is no reason you cannot have fractional numbers of
> CPUs, and perhaps irrational numbers as well.  Of course, these last two
> would require use of floating-point arithmetic (or something similar)
> in the kernel.  So I guess we have at several years worth.  Over to you
> for the negative numbers.  ;-)
>
> 							Thanx, Paul
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>    

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Russell King - ARM Linux @ 2012-03-31 22:32 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-m32r-ja, linux-mips, linux-m32r, linux-ia64, linux-parisc,
	linux-s390, linux-hexagon, linux-sh, linux-kernel, x86, jejb,
	dhowells, linux390, linux-am33-list, cmetcalf, linux-alpha,
	sparclinux, uclinux-dist-devel, tglx, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all.  In short, for the ultimate in
> computer-system simplicity, the optimal choice is NR_CPUS=0.
> 
> This commit therefore limits kernel builds to zero CPUs.  This change
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Great work, but I don't think you've gone far enough with this.

What would really help is if you could consolidate all these NR_CPUS
definitions into one place so we don't have essentially the same thing
scattered across all these architectures.  We're already doing this on
ARM across our platforms, and its about time such an approach was taken
across the entire kernel tree.

It looks like the MIPS solution would be the best one to pick.
Could you rework your patch to do this please?

While you're at it, you might like to consider that having zero CPUs
makes all this architecture support redundant, so maybe you've missed
a trick there - according to my count, we could get rid of almost 3
million lines of code from arch.  We could replace all that with a
single standard implementation.

Bah, maybe I shouldn't have pushed that bpf_jit code for ARM after all...

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-03-31 22:34 UTC (permalink / raw)
  To: Lorenz Kolb
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, Eric Dumazet,
	linux-hexagon, x86, jejb, cmetcalf, linux390, tglx,
	linux-arm-kernel, linux-m32r, linux-parisc, linux-kernel,
	linux-alpha, uclinux-dist-devel, linuxppc-dev
In-Reply-To: <4F7782ED.7050407@lkmail.de>

On Sun, Apr 01, 2012 at 12:19:25AM +0200, Lorenz Kolb wrote:
> With that patchset in mind, I am working on a really huge patch,
> which will greatly simplify the Linux kernel  for the real problem
> of having that number of CPUs.
> 
> That patch will have a lot of changes all over the architectures, so
> what will be the best way to post it? Should I split it architecture
> dependend and into one generic part.
> 
> Currently it is a large blob of millions of changes, but will
> greatly simplify the Linux kernel.

Perhaps a branch on a public git tree?  If you are doing what I suspect
you are, you will end up with a very large patch set.  ;-)

							Thanx, Paul

> Regards,
> 
> Lorenz Kolb
> 
> Am 31.03.2012 23:21, schrieb Paul E. McKenney:
> >On Sat, Mar 31, 2012 at 11:00:08PM +0200, Eric Dumazet wrote:
> >>On Sun, 2012-04-01 at 00:33 +0800, Paul E. McKenney wrote:
> >>>Although there have been numerous complaints about the complexity of
> >>>parallel programming (especially over the past 5-10 years), the plain
> >>>truth is that the incremental complexity of parallel programming over
> >>>that of sequential programming is not as large as is commonly believed.
> >>>Despite that you might have heard, the mind-numbing complexity of modern
> >>>computer systems is not due so much to there being multiple CPUs, but
> >>>rather to there being any CPUs at all.  In short, for the ultimate in
> >>>computer-system simplicity, the optimal choice is NR_CPUS=0.
> >>>
> >>>This commit therefore limits kernel builds to zero CPUs.  This change
> >>>has the beneficial side effect of rendering all kernel bugs harmless.
> >>>Furthermore, this commit enables additional beneficial changes, for
> >>>example, the removal of those parts of the kernel that are not needed
> >>>when there are zero CPUs.
> >>>
> >>>Signed-off-by: Paul E. McKenney<paulmck@linux.vnet.ibm.com>
> >>>Reviewed-by: Thomas Gleixner<tglx@linutronix.de>
> >>>---
> >>Hmm... I believe you could go one step forward and allow negative values
> >>as well. Antimatter was proven to exist after all.
> >>
> >>Hint : nr_cpu_ids is an "int", not an "unsigned int"
> >>
> >>Bonus: Existing bugs become "must have" features.
> >;-) ;-) ;-)
> >
> >>Of course there is no hurry and this can wait 365 days.
> >James Bottomley suggested imaginary numbers of CPUs some time back,
> >and I suppose there is no reason you cannot have fractional numbers of
> >CPUs, and perhaps irrational numbers as well.  Of course, these last two
> >would require use of floating-point arithmetic (or something similar)
> >in the kernel.  So I guess we have at several years worth.  Over to you
> >for the negative numbers.  ;-)
> >
> >							Thanx, Paul
> >
> >_______________________________________________
> >Linuxppc-dev mailing list
> >Linuxppc-dev@lists.ozlabs.org
> >https://lists.ozlabs.org/listinfo/linuxppc-dev
> 

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-04-01  1:22 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-m32r-ja, linux-mips, linux-m32r, linux-ia64, linux-parisc,
	linux-s390, linux-hexagon, linux-sh, linux-kernel, x86, jejb,
	dhowells, linux390, linux-am33-list, cmetcalf, linux-alpha,
	sparclinux, uclinux-dist-devel, tglx, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20120331223200.GA32482@n2100.arm.linux.org.uk>

On Sat, Mar 31, 2012 at 11:32:00PM +0100, Russell King - ARM Linux wrote:
> On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> > 
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Great work, but I don't think you've gone far enough with this.
> 
> What would really help is if you could consolidate all these NR_CPUS
> definitions into one place so we don't have essentially the same thing
> scattered across all these architectures.  We're already doing this on
> ARM across our platforms, and its about time such an approach was taken
> across the entire kernel tree.
> 
> It looks like the MIPS solution would be the best one to pick.
> Could you rework your patch to do this please?
> 
> While you're at it, you might like to consider that having zero CPUs
> makes all this architecture support redundant, so maybe you've missed
> a trick there - according to my count, we could get rid of almost 3
> million lines of code from arch.  We could replace all that with a
> single standard implementation.
> 
> Bah, maybe I shouldn't have pushed that bpf_jit code for ARM after all...

;-) ;-) ;-)

							Thanx, Paul

^ permalink raw reply

* [RFC] PS3 updates for the highmem region
From: Geoff Levand @ 2012-04-01  3:05 UTC (permalink / raw)
  To: Andre Heider, Hector Martin, Nathan Whitehorn; +Cc: linuxppc-dev, cbe-oss-dev

Hi All,

I've rebased and reworked the PS3 highmem patches that Hector and Andre have
submitted.  They are now against Linux-3.3, and I plan for them to go upstream
for Linux-3.5.  I'll rebase them again once a few 3.4-rc's are out.

This work needs to be tested more, especially needed is testing of the passing of
data in the highmem region.  Please test and report.

Nathan, these patches fix the well known node names, so it would be best
if you could add support to test for pre-allocated highmem regions in
your FreeBSD port.

-Geoff

The following changes since commit c16fa4f2ad19908a47c63d8fa436a1178438c7e7:

  Linux 3.3 (2012-03-18 16:15:34 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git for-powerpc

for you to fetch changes up to aab56ec9e2989fc9960cae3927534cb81173dff5:

  powerpc/ps3: Refresh ps3_defconfig (2012-03-31 18:25:20 -0700)

----------------------------------------------------------------
Andre Heider (3):
      powerpc/ps3: Add highmem repository read routines
      powerpc/ps3: Use highmem region from repository
      powerpc/ps3: Remove MEMORY_HOTPLUG requirement

Geoff Levand (5):
      powerpc/ps3: Correct lv1 repository routine names
      powerpc/ps3: Add PS3 repository write support
      powerpc/ps3: Add highmem repository write routines
      powerpc/ps3: Minor Kconfig cleanup
      powerpc/ps3: Refresh ps3_defconfig

Hector Martin (1):
      powerpc/ps3: Add highmem region memory early

 arch/powerpc/configs/ps3_defconfig      |    8 +-
 arch/powerpc/include/asm/lv1call.h      |    4 +-
 arch/powerpc/platforms/ps3/Kconfig      |   22 +++-
 arch/powerpc/platforms/ps3/mm.c         |   77 ++++++------
 arch/powerpc/platforms/ps3/platform.h   |   16 +++
 arch/powerpc/platforms/ps3/repository.c |  198 +++++++++++++++++++++++++++++++
 6 files changed, 277 insertions(+), 48 deletions(-)

^ permalink raw reply

* [RFC] powerpc/fsl-pci: Document the "fsl, has-isa" property for Freescale PCI
From: Jia Hongtao @ 2012-04-01  6:56 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: devicetree-discuss, b38951

If PCI is primary bus we should set isa_io/mem_base when parsing PCI bridge
resources from device tree. The previous way to check the primary bus based
on a hard-coded address named primary_phb_addr. Now we add a property named
"fsl,has-isa" into device tree. In kernel we use this property to find out
the bus is primary or not. This way is more flexible.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 .../devicetree/bindings/powerpc/fsl/pci.txt        |   36 ++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/powerpc/fsl/pci.txt

diff --git a/Documentation/devicetree/bindings/powerpc/fsl/pci.txt b/Documentation/devicetree/bindings/powerpc/fsl/pci.txt
new file mode 100644
index 0000000..7b18090
--- /dev/null
+++ b/Documentation/devicetree/bindings/powerpc/fsl/pci.txt
@@ -0,0 +1,36 @@
+* Freescale PCI
+
+Freescale PCI specific property:
+- fsl,has-isa : If PCI is primary bus we should set isa_io/mem_base when
+                parsing PCI bridge resources. This property is an indicator
+                to inform kernel the PCI is primary.
+
+Example (MPC8572DS)
+	&pci0 {
+		compatible = "fsl,mpc8548-pcie";
+		device_type = "pci";
+		#size-cells = <2>;
+		#address-cells = <3>;
+		bus-range = <0 255>;
+		clock-frequency = <33333333>;
+		interrupts = <24 2 0 0>;
+		fsl,has-isa;
+
+		pcie@0 {
+			reg = <0 0 0 0 0>;
+		#interrupt-cells = <1>;
+		#size-cells = <2>;
+		#address-cells = <3>;
+			device_type = "pci";
+			interrupts = <24 2 0 0>;
+			interrupt-map-mask = <0xf800 0 0 7>;
+
+			interrupt-map = <
+				/* IDSEL 0x0 */
+				0000 0x0 0x0 0x1 &mpic 0x8 0x1 0x0 0x0
+				0000 0x0 0x0 0x2 &mpic 0x9 0x1 0x0 0x0
+				0000 0x0 0x0 0x3 &mpic 0xa 0x1 0x0 0x0
+				0000 0x0 0x0 0x4 &mpic 0xb 0x1 0x0 0x0
+				>;
+		};
+	};
-- 
1.7.5.1

^ permalink raw reply related

* [PATCH v2 1/4] powerpc/fsl-pci: Unify pci/pcie initialization code
From: Jia Hongtao @ 2012-04-01  6:55 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: b38951

We unified the Freescale pci/pcie initialization by changing the fsl_pci
to a platform driver.

In previous version pci/pcie initialization is in platform code which
Initialize pci bridge base on EP/RC or host/agent settings.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/sysdev/fsl_pci.c |   59 +++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_pci.h |    1 +
 2 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 6073288..e3175b3 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -807,3 +807,62 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
 
 	return 0;
 }
+
+static const struct of_device_id pci_ids[] = {
+	{ .compatible = "fsl,mpc8540-pci", },
+	{ .compatible = "fsl,mpc8548-pcie", },
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{ .compatible = "fsl,p1022-pcie", },
+	{ .compatible = "fsl,p1010-pcie", },
+	{ .compatible = "fsl,p1023-pcie", },
+	{ .compatible = "fsl,p4080-pcie", },
+	{ .compatible = "fsl,qoriq-pcie-v2.3", },
+	{ .compatible = "fsl,qoriq-pcie-v2.2", },
+	{},
+};
+
+int primary_phb_addr;
+static int __devinit fsl_pci_probe(struct platform_device *pdev)
+{
+	struct pci_controller *hose;
+	int ret;
+	bool is_primary;
+
+	if (of_match_node(pci_ids, pdev->dev.of_node)) {
+		struct resource rsrc;
+		of_address_to_resource(pdev->dev.of_node, 0, &rsrc);
+		is_primary = ((rsrc.start & 0xfffff) == primary_phb_addr);
+		ret = fsl_add_bridge(pdev->dev.of_node, is_primary);
+
+#ifdef CONFIG_SWIOTLB
+		hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+		/*
+		 * if we couldn't map all of DRAM via the dma windows
+		 * we need SWIOTLB to handle buffers located outside of
+		 * dma capable memory region
+		 */
+		if (memblock_end_of_DRAM() > hose->dma_window_base_cur
+				+ hose->dma_window_size) {
+			ppc_swiotlb_enable = 1;
+			set_pci_dma_ops(&swiotlb_dma_ops);
+			ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
+		}
+#endif
+	}
+
+	return 0;
+}
+
+static struct platform_driver fsl_pci_driver = {
+	.driver = {
+		.name = "fsl-pci",
+		.of_match_table = pci_ids,
+	},
+	.probe = fsl_pci_probe,
+};
+
+static int __init fsl_pci_init(void)
+{
+	return platform_driver_register(&fsl_pci_driver);
+}
+arch_initcall(fsl_pci_init);
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index a39ed5c..df9fc44 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -88,6 +88,7 @@ struct ccsr_pci {
 	__be32	pex_err_cap_r3;		/* 0x.e34 - PCIE error capture register 0 */
 };
 
+extern int primary_phb_addr;
 extern int fsl_add_bridge(struct device_node *dev, int is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
 extern int mpc83xx_add_bridge(struct device_node *dev);
-- 
1.7.5.1

^ permalink raw reply related

* [PATCH v2 2/4] powerpc/fsl-pci: Using common pci/pcie initialization for all boards
From: Jia Hongtao @ 2012-04-01  6:55 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: b38951
In-Reply-To: <1333263331-23881-1-git-send-email-B38951@freescale.com>

Including all 85xx and 86xx platforms.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/platforms/85xx/common.c       |   18 ++++++++
 arch/powerpc/platforms/85xx/corenet_ds.c   |   27 +------------
 arch/powerpc/platforms/85xx/corenet_ds.h   |    1 +
 arch/powerpc/platforms/85xx/ge_imp3a.c     |   34 +--------------
 arch/powerpc/platforms/85xx/mpc8536_ds.c   |   40 ++++-------------
 arch/powerpc/platforms/85xx/mpc85xx.h      |    1 +
 arch/powerpc/platforms/85xx/mpc85xx_ads.c  |   17 ++++----
 arch/powerpc/platforms/85xx/mpc85xx_cds.c  |   24 ++++------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c   |   33 ++------------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c  |   62 +++++++++++++--------------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c  |   13 ++----
 arch/powerpc/platforms/85xx/p1010rdb.c     |   13 +-----
 arch/powerpc/platforms/85xx/p1022_ds.c     |   29 +------------
 arch/powerpc/platforms/85xx/p1023_rds.c    |    6 +--
 arch/powerpc/platforms/85xx/p2041_rdb.c    |    1 +
 arch/powerpc/platforms/85xx/p3041_ds.c     |    1 +
 arch/powerpc/platforms/85xx/p3060_qds.c    |    1 +
 arch/powerpc/platforms/85xx/p4080_ds.c     |    1 +
 arch/powerpc/platforms/85xx/p5020_ds.c     |    1 +
 arch/powerpc/platforms/85xx/sbc8548.c      |   27 ++++--------
 arch/powerpc/platforms/85xx/sbc8560.c      |   19 ++++----
 arch/powerpc/platforms/85xx/socrates.c     |   16 +++----
 arch/powerpc/platforms/85xx/stx_gp3.c      |   19 ++++----
 arch/powerpc/platforms/85xx/tqm85xx.c      |   29 ++++---------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c  |   25 ++---------
 arch/powerpc/platforms/86xx/gef_ppc9a.c    |   24 +++++++----
 arch/powerpc/platforms/86xx/gef_sbc310.c   |   24 +++++++----
 arch/powerpc/platforms/86xx/gef_sbc610.c   |   24 +++++++----
 arch/powerpc/platforms/86xx/mpc8610_hpcd.c |   31 +++++++-------
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |   45 +++++++-------------
 arch/powerpc/platforms/86xx/sbc8641d.c     |   20 +++++----
 31 files changed, 237 insertions(+), 389 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/common.c b/arch/powerpc/platforms/85xx/common.c
index 9fef530..2c91272 100644
--- a/arch/powerpc/platforms/85xx/common.c
+++ b/arch/powerpc/platforms/85xx/common.c
@@ -28,6 +28,24 @@ int __init mpc85xx_common_publish_devices(void)
 {
 	return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);
 }
+
+static struct of_device_id __initdata mpc85xx_pci_ids[] = {
+	{ .compatible = "fsl,mpc8540-pci", },
+	{ .compatible = "fsl,mpc8548-pcie", },
+	{ .compatible = "fsl,p1022-pcie", },
+	{ .compatible = "fsl,p1010-pcie", },
+	{ .compatible = "fsl,p1023-pcie", },
+	{ .compatible = "fsl,p4080-pcie", },
+	{ .compatible = "fsl,qoriq-pcie-v2.3", },
+	{ .compatible = "fsl,qoriq-pcie-v2.2", },
+	{},
+};
+
+int __init mpc85xx_pci_publish_devices(void)
+{
+	return of_platform_bus_probe(NULL, mpc85xx_pci_ids, NULL);
+}
+
 #ifdef CONFIG_CPM2
 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 {
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index df69e99..a21a075 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -53,36 +53,17 @@ void __init corenet_ds_pic_init(void)
  */
 void __init corenet_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	mpc85xx_smp_init();
 
 #ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,p4080-pcie") ||
-		    of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2")) {
-			fsl_add_bridge(np, 0);
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-
 #ifdef CONFIG_PPC64
 	pci_devs_phb_init();
 #endif
 #endif
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 	pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
 }
@@ -94,12 +75,6 @@ static const struct of_device_id of_device_ids[] __devinitconst = {
 	{
 		.compatible	= "fsl,srio",
 	},
-	{
-		.compatible	= "fsl,p4080-pcie",
-	},
-	{
-		.compatible	= "fsl,qoriq-pcie-v2.2",
-	},
 	/* The following two are for the Freescale hypervisor */
 	{
 		.name		= "hypervisor",
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.h b/arch/powerpc/platforms/85xx/corenet_ds.h
index ddd700b..89700e6 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.h
+++ b/arch/powerpc/platforms/85xx/corenet_ds.h
@@ -15,5 +15,6 @@
 extern void __init corenet_ds_pic_init(void);
 extern void __init corenet_ds_setup_arch(void);
 extern int __init corenet_ds_publish_devices(void);
+extern int __init mpc85xx_pci_publish_devices(void);
 
 #endif
diff --git a/arch/powerpc/platforms/85xx/ge_imp3a.c b/arch/powerpc/platforms/85xx/ge_imp3a.c
index d50056f..43f7142 100644
--- a/arch/powerpc/platforms/85xx/ge_imp3a.c
+++ b/arch/powerpc/platforms/85xx/ge_imp3a.c
@@ -85,52 +85,21 @@ void __init ge_imp3a_pic_init(void)
 	of_node_put(cascade_node);
 }
 
-#ifdef CONFIG_PCI
-static int primary_phb_addr;
-#endif	/* CONFIG_PCI */
-
 /*
  * Setup the architecture
  */
 static void __init ge_imp3a_setup_arch(void)
 {
 	struct device_node *regs;
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
 
 	if (ppc_md.progress)
 		ppc_md.progress("ge_imp3a_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
-		    of_device_is_compatible(np, "fsl,p2020-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == primary_phb_addr)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-#endif
-
 	mpc85xx_smp_init();
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 
 	/* Remap basic board registers */
@@ -226,6 +195,7 @@ static int __init ge_imp3a_probe(void)
 	return 0;
 }
 
+machine_arch_initcall(p1022_ds, mpc85xx_pci_publish_devices);
 machine_device_initcall(ge_imp3a, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index f588726..e9fc274 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -47,40 +47,12 @@ void __init mpc8536_ds_pic_init(void)
  */
 static void __init mpc8536_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc8536_ds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-
-#endif
-
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 
 	printk("MPC8536 DS board from Freescale Semiconductor\n");
@@ -88,6 +60,7 @@ static void __init mpc8536_ds_setup_arch(void)
 
 machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
 
+machine_arch_initcall(mpc8536_ds, mpc85xx_pci_publish_devices);
 machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
 
 /*
@@ -97,7 +70,14 @@ static int __init mpc8536_ds_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	return of_flat_dt_is_compatible(root, "fsl,mpc8536ds");
+	if (of_flat_dt_is_compatible(root, "fsl,mpc8536ds")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(mpc8536_ds) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 2aa7c5d..4ebdbb7 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -1,6 +1,7 @@
 #ifndef MPC85xx_H
 #define MPC85xx_H
 extern int mpc85xx_common_publish_devices(void);
+extern int mpc85xx_pci_publish_devices(void);
 
 #ifdef CONFIG_CPM2
 extern void mpc85xx_cpm2_pic_init(void);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index d19f675..f590df8 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -138,10 +138,6 @@ static void __init init_ioports(void)
 
 static void __init mpc85xx_ads_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
 
@@ -151,9 +147,6 @@ static void __init mpc85xx_ads_setup_arch(void)
 #endif
 
 #ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 }
@@ -174,6 +167,7 @@ static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
+machine_arch_initcall(mpc85xx_ads, mpc85xx_pci_publish_devices);
 machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
 
 /*
@@ -183,7 +177,14 @@ static int __init mpc85xx_ads_probe(void)
 {
         unsigned long root = of_get_flat_dt_root();
 
-        return of_flat_dt_is_compatible(root, "MPC85xxADS");
+	if (of_flat_dt_is_compatible(root, "MPC85xxADS")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(mpc85xx_ads) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index ab5f0bf1..2bb6b9c 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -310,18 +310,6 @@ static void __init mpc85xx_cds_setup_arch(void)
 	}
 
 #ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
-
 	ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
@@ -351,12 +339,20 @@ static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
  */
 static int __init mpc85xx_cds_probe(void)
 {
-        unsigned long root = of_get_flat_dt_root();
+	unsigned long root = of_get_flat_dt_root();
 
-        return of_flat_dt_is_compatible(root, "MPC85xxCDS");
+	if (of_flat_dt_is_compatible(root, "MPC85xxCDS")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 machine_device_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);
+machine_arch_initcall(mpc85xx_cds, mpc85xx_pci_publish_devices);
 
 define_machine(mpc85xx_cds) {
 	.name		= "MPC85xx CDS",
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 6e23e3e..e33a8cf 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -115,7 +115,6 @@ void __init mpc85xx_ds_pic_init(void)
 }
 
 #ifdef CONFIG_PCI
-static int primary_phb_addr;
 extern int uli_exclude_device(struct pci_controller *hose,
 				u_char bus, u_char devfn);
 
@@ -141,44 +140,18 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
  */
 static void __init mpc85xx_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
 
 #ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
-		    of_device_is_compatible(np, "fsl,p2020-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == primary_phb_addr)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 
 	mpc85xx_smp_init();
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 
 	printk("MPC85xx DS board from Freescale Semiconductor\n");
@@ -205,6 +178,10 @@ machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
 machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
 machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
 
+machine_arch_initcall(mpc8544_ds, mpc85xx_pci_publish_devices);
+machine_arch_initcall(mpc8572_ds, mpc85xx_pci_publish_devices);
+machine_arch_initcall(p2020_ds, mpc85xx_pci_publish_devices);
+
 machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index e82f06f..6170d5f 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -328,43 +328,16 @@ static void __init mpc85xx_mds_qeic_init(void) { }
 
 static void __init mpc85xx_mds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct pci_controller *hose;
-	struct device_node *np;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-#endif
-
 	mpc85xx_smp_init();
 
 	mpc85xx_mds_qe_init();
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 }
 
@@ -423,6 +396,10 @@ machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices);
 machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices);
 machine_device_initcall(p1021_mds, mpc85xx_common_publish_devices);
 
+machine_arch_initcall(mpc8568_mds, mpc85xx_pci_publish_devices);
+machine_arch_initcall(mpc8569_mds, mpc85xx_pci_publish_devices);
+machine_arch_initcall(p1021_mds, mpc85xx_pci_publish_devices);
+
 machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
@@ -440,9 +417,16 @@ static void __init mpc85xx_mds_pic_init(void)
 
 static int __init mpc85xx_mds_probe(void)
 {
-        unsigned long root = of_get_flat_dt_root();
+	unsigned long root = of_get_flat_dt_root();
 
-        return of_flat_dt_is_compatible(root, "MPC85xxMDS");
+	if (of_flat_dt_is_compatible(root, "MPC85xxMDS")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(mpc8568_mds) {
@@ -463,7 +447,14 @@ static int __init mpc8569_mds_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	return of_flat_dt_is_compatible(root, "fsl,MPC8569EMDS");
+	if (of_flat_dt_is_compatible(root, "fsl,MPC8569EMDS")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(mpc8569_mds) {
@@ -484,7 +475,14 @@ static int __init p1021_mds_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	return of_flat_dt_is_compatible(root, "fsl,P1021MDS");
+	if (of_flat_dt_is_compatible(root, "fsl,P1021MDS")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 1a66c3d..453a935 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -87,21 +87,13 @@ void __init mpc85xx_rdb_pic_init(void)
  */
 static void __init mpc85xx_rdb_setup_arch(void)
 {
-#if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE)
+#ifdef CONFIG_QUICC_ENGINE
 	struct device_node *np;
 #endif
 
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
-			fsl_add_bridge(np, 0);
-	}
-
-#endif
-
 	mpc85xx_smp_init();
 
 #ifdef CONFIG_QUICC_ENGINE
@@ -171,6 +163,9 @@ machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices);
 machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices);
 machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices);
 
+machine_arch_initcall(p2020_rdb, mpc85xx_pci_publish_devices);
+machine_arch_initcall(p1020_rdb, mpc85xx_pci_publish_devices);
+
 /*
  * Called very early, device-tree isn't unflattened
  */
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index d8bd656..ad9987c 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -47,25 +47,14 @@ void __init p1010_rdb_pic_init(void)
  */
 static void __init p1010_rdb_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("p1010_rdb_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,p1010-pcie"))
-			fsl_add_bridge(np, 0);
-	}
-
-#endif
-
 	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
 }
 
 machine_device_initcall(p1010_rdb, mpc85xx_common_publish_devices);
+machine_arch_initcall(p1010_rdb, mpc85xx_pci_publish_devices);
 machine_arch_initcall(p1010_rdb, swiotlb_setup_bus_notifier);
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index e74b7cd..a8c4118 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -385,32 +385,9 @@ early_param("video", early_video_setup);
  */
 static void __init p1022_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("p1022_ds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,p1022-pcie") {
-		struct resource rsrc;
-		struct pci_controller *hose;
-
-		of_address_to_resource(np, 0, &rsrc);
-
-		if ((rsrc.start & 0xfffff) == 0x8000)
-			fsl_add_bridge(np, 1);
-		else
-			fsl_add_bridge(np, 0);
-
-		hose = pci_find_hose_for_OF_device(np);
-		max = min(max, hose->dma_window_base_cur +
-			  hose->dma_window_size);
-	}
-#endif
-
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 	diu_ops.get_pixel_format	= p1022ds_get_pixel_format;
 	diu_ops.set_gamma_table		= p1022ds_set_gamma_table;
@@ -450,11 +427,8 @@ static void __init p1022_ds_setup_arch(void)
 	mpc85xx_smp_init();
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 
 	pr_info("Freescale P1022 DS reference board\n");
@@ -473,6 +447,7 @@ static int __init p1022_ds_publish_devices(void)
 }
 machine_device_initcall(p1022_ds, p1022_ds_publish_devices);
 
+machine_arch_initcall(p1022_ds, mpc85xx_pci_publish_devices);
 machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier);
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 6b07398..c62303c 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -81,15 +81,11 @@ static void __init mpc85xx_rds_setup_arch(void)
 		}
 	}
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,p1023-pcie")
-		fsl_add_bridge(np, 0);
-#endif
-
 	mpc85xx_smp_init();
 }
 
 machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
+machine_arch_initcall(p1023_rds, mpc85xx_pci_publish_devices);
 
 static void __init mpc85xx_rds_pic_init(void)
 {
diff --git a/arch/powerpc/platforms/85xx/p2041_rdb.c b/arch/powerpc/platforms/85xx/p2041_rdb.c
index eda6ed5..5123400 100644
--- a/arch/powerpc/platforms/85xx/p2041_rdb.c
+++ b/arch/powerpc/platforms/85xx/p2041_rdb.c
@@ -81,6 +81,7 @@ define_machine(p2041_rdb) {
 	.power_save		= e500_idle,
 };
 
+machine_arch_initcall(p2041_rdb, mpc85xx_pci_publish_devices);
 machine_device_initcall(p2041_rdb, corenet_ds_publish_devices);
 
 #ifdef CONFIG_SWIOTLB
diff --git a/arch/powerpc/platforms/85xx/p3041_ds.c b/arch/powerpc/platforms/85xx/p3041_ds.c
index 96d99a3..aa0dd29 100644
--- a/arch/powerpc/platforms/85xx/p3041_ds.c
+++ b/arch/powerpc/platforms/85xx/p3041_ds.c
@@ -83,6 +83,7 @@ define_machine(p3041_ds) {
 	.power_save		= e500_idle,
 };
 
+machine_arch_initcall(p3041_ds, mpc85xx_pci_publish_devices);
 machine_device_initcall(p3041_ds, corenet_ds_publish_devices);
 
 #ifdef CONFIG_SWIOTLB
diff --git a/arch/powerpc/platforms/85xx/p3060_qds.c b/arch/powerpc/platforms/85xx/p3060_qds.c
index 081cf4a..51aece5 100644
--- a/arch/powerpc/platforms/85xx/p3060_qds.c
+++ b/arch/powerpc/platforms/85xx/p3060_qds.c
@@ -70,6 +70,7 @@ define_machine(p3060_qds) {
 	.power_save		= e500_idle,
 };
 
+machine_arch_initcall(p3060_qds, mpc85xx_pci_publish_devices);
 machine_device_initcall(p3060_qds, corenet_ds_publish_devices);
 
 #ifdef CONFIG_SWIOTLB
diff --git a/arch/powerpc/platforms/85xx/p4080_ds.c b/arch/powerpc/platforms/85xx/p4080_ds.c
index d1b21d7..e6b52e8 100644
--- a/arch/powerpc/platforms/85xx/p4080_ds.c
+++ b/arch/powerpc/platforms/85xx/p4080_ds.c
@@ -82,6 +82,7 @@ define_machine(p4080_ds) {
 	.power_save		= e500_idle,
 };
 
+machine_arch_initcall(p4080_ds, mpc85xx_pci_publish_devices);
 machine_device_initcall(p4080_ds, corenet_ds_publish_devices);
 #ifdef CONFIG_SWIOTLB
 machine_arch_initcall(p4080_ds, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/p5020_ds.c b/arch/powerpc/platforms/85xx/p5020_ds.c
index e8cba50..77953cc 100644
--- a/arch/powerpc/platforms/85xx/p5020_ds.c
+++ b/arch/powerpc/platforms/85xx/p5020_ds.c
@@ -92,6 +92,7 @@ define_machine(p5020_ds) {
 #endif
 };
 
+machine_arch_initcall(p5020_ds, mpc85xx_pci_publish_devices);
 machine_device_initcall(p5020_ds, corenet_ds_publish_devices);
 
 #ifdef CONFIG_SWIOTLB
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 1677b8a..9049994 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -89,26 +89,9 @@ static int __init sbc8548_hw_rev(void)
  */
 static void __init sbc8548_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("sbc8548_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
-#endif
 	sbc_rev = sbc8548_hw_rev();
 }
 
@@ -129,6 +112,7 @@ static void sbc8548_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
+machine_arch_initcall(sbc8548, mpc85xx_pci_publish_devices);
 machine_device_initcall(sbc8548, mpc85xx_common_publish_devices);
 
 /*
@@ -138,7 +122,14 @@ static int __init sbc8548_probe(void)
 {
         unsigned long root = of_get_flat_dt_root();
 
-        return of_flat_dt_is_compatible(root, "SBC8548");
+	if (of_flat_dt_is_compatible(root, "SBC8548")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(sbc8548) {
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 3c3bbcc..c62692d 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -127,10 +127,6 @@ static void __init init_ioports(void)
 
 static void __init sbc8560_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("sbc8560_setup_arch()", 0);
 
@@ -138,11 +134,6 @@ static void __init sbc8560_setup_arch(void)
 	cpm2_reset();
 	init_ioports();
 #endif
-
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
 }
 
 static void sbc8560_show_cpuinfo(struct seq_file *m)
@@ -161,6 +152,7 @@ static void sbc8560_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
+machine_arch_initcall(sbc8560, mpc85xx_pci_publish_devices);
 machine_device_initcall(sbc8560, mpc85xx_common_publish_devices);
 
 /*
@@ -170,7 +162,14 @@ static int __init sbc8560_probe(void)
 {
         unsigned long root = of_get_flat_dt_root();
 
-        return of_flat_dt_is_compatible(root, "SBC8560");
+	if (of_flat_dt_is_compatible(root, "SBC8560")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 #ifdef CONFIG_RTC_DRV_M48T59
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index b719192..eb94e586 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -67,19 +67,11 @@ static void __init socrates_pic_init(void)
  */
 static void __init socrates_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("socrates_setup_arch()", 0);
-
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
 }
 
+machine_arch_initcall(socrates, mpc85xx_pci_publish_devices);
 machine_device_initcall(socrates, mpc85xx_common_publish_devices);
 
 /*
@@ -89,8 +81,12 @@ static int __init socrates_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "abb,socrates"))
+	if (of_flat_dt_is_compatible(root, "abb,socrates")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
 		return 1;
+	}
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 27ca3a7..92d2c3b 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -61,21 +61,12 @@ static void __init stx_gp3_pic_init(void)
  */
 static void __init stx_gp3_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("stx_gp3_setup_arch()", 0);
 
 #ifdef CONFIG_CPM2
 	cpm2_reset();
 #endif
-
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
 }
 
 static void stx_gp3_show_cpuinfo(struct seq_file *m)
@@ -94,6 +85,7 @@ static void stx_gp3_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
+machine_arch_initcall(stx_gp3, mpc85xx_pci_publish_devices);
 machine_device_initcall(stx_gp3, mpc85xx_common_publish_devices);
 
 /*
@@ -103,7 +95,14 @@ static int __init stx_gp3_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	return of_flat_dt_is_compatible(root, "stx,gp3-8560");
+	if (of_flat_dt_is_compatible(root, "stx,gp3-8560")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(stx_gp3) {
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index d7504ce..c8e2599 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -60,31 +60,12 @@ static void __init tqm85xx_pic_init(void)
  */
 static void __init tqm85xx_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("tqm85xx_setup_arch()", 0);
 
 #ifdef CONFIG_CPM2
 	cpm2_reset();
 #endif
-
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			if (!of_address_to_resource(np, 0, &rsrc)) {
-				if ((rsrc.start & 0xfffff) == 0x8000)
-					fsl_add_bridge(np, 1);
-				else
-					fsl_add_bridge(np, 0);
-			}
-		}
-	}
-#endif
 }
 
 static void tqm85xx_show_cpuinfo(struct seq_file *m)
@@ -124,6 +105,7 @@ static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,
 		tqm85xx_ti1520_fixup);
 
+machine_arch_initcall(tqm85xx, mpc85xx_pci_publish_devices);
 machine_device_initcall(tqm85xx, mpc85xx_common_publish_devices);
 
 static const char *board[] __initdata = {
@@ -140,7 +122,14 @@ static const char *board[] __initdata = {
  */
 static int __init tqm85xx_probe(void)
 {
-	return of_flat_dt_match(of_get_flat_dt_root(), board);
+	if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
+		return 1;
+	}
+
+	return 0;
 }
 
 define_machine(tqm85xx) {
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 503c215..f5ef6b5 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -112,18 +112,11 @@ static void xes_mpc85xx_fixups(void)
 	}
 }
 
-#ifdef CONFIG_PCI
-static int primary_phb_addr;
-#endif
-
 /*
  * Setup the architecture
  */
 static void __init xes_mpc85xx_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
 	struct device_node *root;
 	const char *model = "Unknown";
 
@@ -138,20 +131,6 @@ static void __init xes_mpc85xx_setup_arch(void)
 
 	xes_mpc85xx_fixups();
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == primary_phb_addr)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
-#endif
-
 	mpc85xx_smp_init();
 }
 
@@ -159,6 +138,10 @@ machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
 machine_device_initcall(xes_mpc8548, mpc85xx_common_publish_devices);
 machine_device_initcall(xes_mpc8540, mpc85xx_common_publish_devices);
 
+machine_arch_initcall(xes_mpc8572, mpc85xx_pci_publish_devices);
+machine_arch_initcall(xes_mpc8548, mpc85xx_pci_publish_devices);
+machine_arch_initcall(xes_mpc8540, mpc85xx_pci_publish_devices);
+
 /*
  * Called very early, device-tree isn't unflattened
  */
diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c b/arch/powerpc/platforms/86xx/gef_ppc9a.c
index ed58b6c..d27ab58 100644
--- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
+++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
@@ -74,13 +74,6 @@ static void __init gef_ppc9a_init_irq(void)
 static void __init gef_ppc9a_setup_arch(void)
 {
 	struct device_node *regs;
-#ifdef CONFIG_PCI
-	struct device_node *np;
-
-	for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
-		fsl_add_bridge(np, 1);
-	}
-#endif
 
 	printk(KERN_INFO "GE Intelligent Platforms PPC9A 6U VME SBC\n");
 
@@ -197,8 +190,12 @@ static int __init gef_ppc9a_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "gef,ppc9a"))
+	if (of_flat_dt_is_compatible(root, "gef,ppc9a")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
 		return 1;
+	}
 
 	return 0;
 }
@@ -219,6 +216,17 @@ static long __init mpc86xx_time_init(void)
 	return 0;
 }
 
+static struct of_device_id __initdata gef_ppc9a_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init gef_ppc9a_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, gef_ppc9a_pci_ids, NULL);
+}
+machine_arch_initcall(gef_ppc9a, gef_ppc9a_publish_pci_device);
+
 static __initdata struct of_device_id of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "gianfar", },
diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c b/arch/powerpc/platforms/86xx/gef_sbc310.c
index 710db69..1659013 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc310.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
@@ -74,13 +74,6 @@ static void __init gef_sbc310_init_irq(void)
 static void __init gef_sbc310_setup_arch(void)
 {
 	struct device_node *regs;
-#ifdef CONFIG_PCI
-	struct device_node *np;
-
-	for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
-		fsl_add_bridge(np, 1);
-	}
-#endif
 
 	printk(KERN_INFO "GE Intelligent Platforms SBC310 6U VPX SBC\n");
 
@@ -185,8 +178,12 @@ static int __init gef_sbc310_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "gef,sbc310"))
+	if (of_flat_dt_is_compatible(root, "gef,sbc310")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
 		return 1;
+	}
 
 	return 0;
 }
@@ -207,6 +204,17 @@ static long __init mpc86xx_time_init(void)
 	return 0;
 }
 
+static struct of_device_id __initdata gef_sbc310_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init gef_sbc310_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, gef_sbc310_pci_ids, NULL);
+}
+machine_arch_initcall(gef_sbc310, gef_sbc310_publish_pci_device);
+
 static __initdata struct of_device_id of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "gianfar", },
diff --git a/arch/powerpc/platforms/86xx/gef_sbc610.c b/arch/powerpc/platforms/86xx/gef_sbc610.c
index 4a13d2f..a7bba61 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc610.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc610.c
@@ -74,13 +74,6 @@ static void __init gef_sbc610_init_irq(void)
 static void __init gef_sbc610_setup_arch(void)
 {
 	struct device_node *regs;
-#ifdef CONFIG_PCI
-	struct device_node *np;
-
-	for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
-		fsl_add_bridge(np, 1);
-	}
-#endif
 
 	printk(KERN_INFO "GE Intelligent Platforms SBC610 6U VPX SBC\n");
 
@@ -174,8 +167,12 @@ static int __init gef_sbc610_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "gef,sbc610"))
+	if (of_flat_dt_is_compatible(root, "gef,sbc610")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
 		return 1;
+	}
 
 	return 0;
 }
@@ -196,6 +193,17 @@ static long __init mpc86xx_time_init(void)
 	return 0;
 }
 
+static struct of_device_id __initdata gef_sbc610_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init gef_sbc610_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, gef_sbc610_pci_ids, NULL);
+}
+machine_arch_initcall(gef_sbc610, gef_sbc610_publish_pci_device);
+
 static __initdata struct of_device_id of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "gianfar", },
diff --git a/arch/powerpc/platforms/86xx/mpc8610_hpcd.c b/arch/powerpc/platforms/86xx/mpc8610_hpcd.c
index b8b1f33..4946ed5 100644
--- a/arch/powerpc/platforms/86xx/mpc8610_hpcd.c
+++ b/arch/powerpc/platforms/86xx/mpc8610_hpcd.c
@@ -86,6 +86,17 @@ static void __init mpc8610_suspend_init(void)
 static inline void mpc8610_suspend_init(void) { }
 #endif /* CONFIG_SUSPEND */
 
+static struct of_device_id __initdata mpc86xx_hpcd_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init mpc86xx_hpcd_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, mpc86xx_hpcd_pci_ids, NULL);
+}
+machine_arch_initcall(mpc86xx_hpcd, mpc86xx_hpcd_publish_pci_device);
+
 static struct of_device_id __initdata mpc8610_ids[] = {
 	{ .compatible = "fsl,mpc8610-immr", },
 	{ .compatible = "fsl,mpc8610-guts", },
@@ -279,25 +290,11 @@ mpc8610hpcd_valid_monitor_port(enum fsl_diu_monitor_port port)
 static void __init mpc86xx_hpcd_setup_arch(void)
 {
 	struct resource r;
-	struct device_node *np;
 	unsigned char *pixis;
 
 	if (ppc_md.progress)
 		ppc_md.progress("mpc86xx_hpcd_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8610-pci")
-		    || of_device_is_compatible(np, "fsl,mpc8641-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0xa000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-        }
-#endif
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 	diu_ops.get_pixel_format	= mpc8610hpcd_get_pixel_format;
 	diu_ops.set_gamma_table		= mpc8610hpcd_set_gamma_table;
@@ -331,8 +328,12 @@ static int __init mpc86xx_hpcd_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "fsl,MPC8610HPCD"))
+	if (of_flat_dt_is_compatible(root, "fsl,MPC8610HPCD")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0xa000;
+#endif
 		return 1;	/* Looks good */
+	}
 
 	return 0;
 }
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 569262c..165dd40 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -70,30 +70,11 @@ static int mpc86xx_exclude_device(struct pci_controller *hose,
 static void __init
 mpc86xx_hpcn_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
 
 #ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
-		struct resource rsrc;
-		of_address_to_resource(np, 0, &rsrc);
-		if ((rsrc.start & 0xfffff) == 0x8000)
-			fsl_add_bridge(np, 1);
-		else
-			fsl_add_bridge(np, 0);
-		hose = pci_find_hose_for_OF_device(np);
-		max = min(max, hose->dma_window_base_cur +
-			  hose->dma_window_size);
-	}
-
 	ppc_md.pci_exclude_device = mpc86xx_exclude_device;
-
 #endif
 
 	printk("MPC86xx HPCN board from Freescale Semiconductor\n");
@@ -103,11 +84,8 @@ mpc86xx_hpcn_setup_arch(void)
 #endif
 
 #ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
+	if (memblock_end_of_DRAM() > 0xffffffff)
 		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
 #endif
 }
 
@@ -130,12 +108,10 @@ static int __init mpc86xx_hpcn_probe(void)
 {
 	unsigned long root = of_get_flat_dt_root();
 
-	if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
-		return 1;	/* Looks good */
-
-	/* Be nice and don't give silent boot death.  Delete this in 2.6.27 */
-	if (of_flat_dt_is_compatible(root, "mpc86xx")) {
-		pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
+	if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn")) {
+#ifdef CONFIG_PCI
+		primary_phb_addr = 0x8000;
+#endif
 		return 1;
 	}
 
@@ -159,6 +135,17 @@ mpc86xx_time_init(void)
 	return 0;
 }
 
+static struct of_device_id __initdata mpc86xx_hpcn_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init mpc86xx_hpcn_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, mpc86xx_hpcn_pci_ids, NULL);
+}
+machine_arch_initcall(mpc86xx_hpcn, mpc86xx_hpcn_publish_pci_device);
+
 static __initdata struct of_device_id of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "fsl,srio", },
diff --git a/arch/powerpc/platforms/86xx/sbc8641d.c b/arch/powerpc/platforms/86xx/sbc8641d.c
index 51c8f33..1226949 100644
--- a/arch/powerpc/platforms/86xx/sbc8641d.c
+++ b/arch/powerpc/platforms/86xx/sbc8641d.c
@@ -39,18 +39,9 @@
 static void __init
 sbc8641_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("sbc8641_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie")
-		fsl_add_bridge(np, 0);
-#endif
-
 	printk("SBC8641 board from Wind River\n");
 
 #ifdef CONFIG_SMP
@@ -100,6 +91,17 @@ mpc86xx_time_init(void)
 	return 0;
 }
 
+static struct of_device_id __initdata sbc8641_pci_ids[] = {
+	{ .compatible = "fsl,mpc8641-pcie", },
+	{},
+};
+
+static int __init sbc8641_publish_pci_device(void)
+{
+	return of_platform_bus_probe(NULL, sbc8641_pci_ids, NULL);
+}
+machine_arch_initcall(sbc8641, sbc8641_publish_pci_device);
+
 static __initdata struct of_device_id of_bus_ids[] = {
 	{ .compatible = "simple-bus", },
 	{ .compatible = "gianfar", },
-- 
1.7.5.1

^ permalink raw reply related

* [PATCH v2 4/4] powerpc/fsl-pci: Add pci inbound/outbound PM support
From: Jia Hongtao @ 2012-04-01  6:55 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: b38951
In-Reply-To: <1333263331-23881-1-git-send-email-B38951@freescale.com>

Power supply for PCI inbound/outbound window registers is off when system
go to deep-sleep state. We save the values of registers before suspend
and restore to registers after resume.

Signed-off-by: Jiang Yutang <b14898@freescale.com>
Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/include/asm/pci-bridge.h |    2 +-
 arch/powerpc/sysdev/fsl_pci.c         |  121 +++++++++++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_pci.h         |   10 +++
 3 files changed, 132 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 5d48765..a7668b2 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -89,9 +89,9 @@ struct pci_controller {
 
 #ifdef CONFIG_PPC64
 	unsigned long buid;
+#endif	/* CONFIG_PPC64 */
 
 	void *private_data;
-#endif	/* CONFIG_PPC64 */
 };
 
 /* These are used for config access before all the PCI probing
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 81b6fc8..07fa1af 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -856,12 +856,133 @@ static int __devinit fsl_pci_probe(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_SUSPEND
+
+#define PCI_POW_PIW_OFFSET	0xc00
+#define PCI_POW_PIW_SIZE	0x200
+#define PCI_POW_NUMBER		5
+
+static int fsl_pci_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct pci_controller *hose;
+	struct pci_outbound_window_regs *pci_saved_pow;
+	struct pci_inbound_window_regs *pci_saved_piw, *temp_piw;
+	struct resource pci_rsrc;
+	unsigned int i;
+	struct fsl_pci_private_data *sus_info;
+
+	hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+	of_address_to_resource(pdev->dev.of_node, 0, &pci_rsrc);
+
+	sus_info = kmalloc(
+			sizeof(struct fsl_pci_private_data), GFP_KERNEL);
+	if (!sus_info)
+		return -ENOMEM;
+
+	hose->private_data = sus_info;
+
+	sus_info->pci_pow = ioremap(pci_rsrc.start + PCI_POW_PIW_OFFSET,
+			PCI_POW_PIW_SIZE);
+	if (!sus_info->pci_pow) {
+		dev_err(&pdev->dev, "pci outbound/inbound windows ioremap error!\n");
+		goto err1;
+	}
+
+	sus_info->pci_piw = (struct pci_inbound_window_regs *)
+		((void *)sus_info->pci_pow + PCI_POW_PIW_SIZE) - 1;
+
+	if (of_device_is_compatible(pdev->dev.of_node, "fsl,qoriq-pcie-v2.2"))
+		sus_info->inbound_num = 4;
+	else
+		sus_info->inbound_num = 3;
+
+	sus_info->saved_regs = kmalloc(
+		sizeof(struct pci_outbound_window_regs) * PCI_POW_NUMBER +
+		sizeof(struct pci_inbound_window_regs) * sus_info->inbound_num,
+		GFP_KERNEL);
+	if (!sus_info->saved_regs)
+		goto err2;
+
+	pci_saved_pow = sus_info->saved_regs;
+	for (i = 0; i < PCI_POW_NUMBER; i++) {
+		pci_saved_pow[i].potar = in_be32(&sus_info->pci_pow[i].potar);
+		pci_saved_pow[i].potear = in_be32(&sus_info->pci_pow[i].potear);
+		pci_saved_pow[i].powbar = in_be32(&sus_info->pci_pow[i].powbar);
+		pci_saved_pow[i].powar = in_be32(&sus_info->pci_pow[i].powar);
+	}
+
+	pci_saved_piw = (struct pci_inbound_window_regs *)
+		(pci_saved_pow + PCI_POW_NUMBER);
+	temp_piw = sus_info->pci_piw;
+	for (i = 0; i < sus_info->inbound_num; i++, temp_piw--) {
+		pci_saved_piw[i].pitar = in_be32(&temp_piw->pitar);
+		pci_saved_piw[i].piwbar = in_be32(&temp_piw->piwbar);
+		pci_saved_piw[i].piwbear = in_be32(&temp_piw->piwbear);
+		pci_saved_piw[i].piwar = in_be32(&temp_piw->piwar);
+	}
+
+	return 0;
+
+err2:
+	iounmap(sus_info->pci_pow);
+
+err1:
+	kfree(sus_info);
+	return -ENOMEM;
+}
+
+static int fsl_pci_resume(struct platform_device *pdev)
+{
+	struct pci_controller *hose;
+	struct pci_outbound_window_regs *pci_saved_pow;
+	struct pci_inbound_window_regs *pci_saved_piw, *temp_piw;
+	unsigned int i;
+	struct fsl_pci_private_data *sus_info;
+
+	hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+	sus_info = (struct fsl_pci_private_data *)hose->private_data;
+
+	if (!sus_info->pci_pow || !sus_info->pci_piw || !sus_info->saved_regs)
+		return 0;
+
+	pci_saved_pow = sus_info->saved_regs;
+	for (i = 0; i < PCI_POW_NUMBER; i++) {
+		out_be32(&sus_info->pci_pow[i].potar, pci_saved_pow[i].potar);
+		out_be32(&sus_info->pci_pow[i].potear, pci_saved_pow[i].potear);
+		out_be32(&sus_info->pci_pow[i].powbar, pci_saved_pow[i].powbar);
+		out_be32(&sus_info->pci_pow[i].powar, pci_saved_pow[i].powar);
+	}
+
+	pci_saved_piw = (struct pci_inbound_window_regs *)
+		(pci_saved_pow + PCI_POW_NUMBER);
+	temp_piw = sus_info->pci_piw;
+	for (i = 0; i < sus_info->inbound_num; i++, temp_piw--) {
+		out_be32(&temp_piw->pitar, pci_saved_piw[i].pitar);
+		out_be32(&temp_piw->piwbar, pci_saved_piw[i].piwbar);
+		out_be32(&temp_piw->piwbear, pci_saved_piw[i].piwbear);
+		out_be32(&temp_piw->piwar, pci_saved_piw[i].piwar);
+	}
+	iounmap(sus_info->pci_pow);
+	kfree(sus_info->saved_regs);
+	sus_info->saved_regs = NULL;
+	kfree(sus_info);
+	sus_info = NULL;
+	hose->private_data = NULL;
+
+	return 0;
+}
+#endif
+
 static struct platform_driver fsl_pci_driver = {
 	.driver = {
 		.name = "fsl-pci",
 		.of_match_table = pci_ids,
 	},
 	.probe = fsl_pci_probe,
+#ifdef CONFIG_SUSPEND
+	.suspend	= fsl_pci_suspend,
+	.resume		= fsl_pci_resume,
+#endif
 };
 
 static int __init fsl_pci_init(void)
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index df9fc44..1093e24 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -88,6 +88,16 @@ struct ccsr_pci {
 	__be32	pex_err_cap_r3;		/* 0x.e34 - PCIE error capture register 0 */
 };
 
+
+#ifdef CONFIG_SUSPEND
+struct fsl_pci_private_data {
+	int inbound_num;
+	struct pci_outbound_window_regs __iomem *pci_pow;
+	struct pci_inbound_window_regs __iomem *pci_piw;
+	void *saved_regs;
+};
+#endif
+
 extern int primary_phb_addr;
 extern int fsl_add_bridge(struct device_node *dev, int is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
-- 
1.7.5.1

^ permalink raw reply related

* [PATCH v2 3/4] powerpc/fsl-pci: Only scan PCI bus if configured as a host
From: Jia Hongtao @ 2012-04-01  6:55 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: b38951
In-Reply-To: <1333263331-23881-1-git-send-email-B38951@freescale.com>

If we're an agent/end-point or fsl_add_bridge doesn't succeed due to some
resource failure we should not scan the PCI bus. We change fsl_add_bridge()
to return -ENODEV in the case we're an agent/end-point.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/sysdev/fsl_pci.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index e3175b3..81b6fc8 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -465,7 +465,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary)
 			iounmap(hose->cfg_data);
 		iounmap(hose->cfg_addr);
 		pcibios_free_controller(hose);
-		return 0;
+		return -ENODEV;
 	}
 
 	setup_pci_cmd(hose);
@@ -835,17 +835,20 @@ static int __devinit fsl_pci_probe(struct platform_device *pdev)
 		ret = fsl_add_bridge(pdev->dev.of_node, is_primary);
 
 #ifdef CONFIG_SWIOTLB
-		hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
-		/*
-		 * if we couldn't map all of DRAM via the dma windows
-		 * we need SWIOTLB to handle buffers located outside of
-		 * dma capable memory region
-		 */
-		if (memblock_end_of_DRAM() > hose->dma_window_base_cur
-				+ hose->dma_window_size) {
-			ppc_swiotlb_enable = 1;
-			set_pci_dma_ops(&swiotlb_dma_ops);
-			ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
+		if (ret == 0) {
+			hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+			/*
+			 * if we couldn't map all of DRAM via the dma windows
+			 * we need SWIOTLB to handle buffers located outside of
+			 * dma capable memory region
+			 */
+			if (memblock_end_of_DRAM() > hose->dma_window_base_cur
+					+ hose->dma_window_size) {
+				ppc_swiotlb_enable = 1;
+				set_pci_dma_ops(&swiotlb_dma_ops);
+				ppc_md.pci_dma_dev_setup =
+					pci_dma_dev_setup_swiotlb;
+			}
 		}
 #endif
 	}
-- 
1.7.5.1

^ permalink raw reply related

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Borislav Petkov @ 2012-04-01 10:04 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-sh, dhowells,
	sparclinux, linux-s390, linux-am33-list, linux, linux-hexagon,
	x86, jejb, cmetcalf, uclinux-dist-devel, tglx, linux-arm-kernel,
	linux-m32r, linux-parisc, linux-kernel, linux-alpha, linux390,
	linuxppc-dev
In-Reply-To: <20120331163321.GA15809@linux.vnet.ibm.com>

On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> Although there have been numerous complaints about the complexity of
> parallel programming (especially over the past 5-10 years), the plain
> truth is that the incremental complexity of parallel programming over
> that of sequential programming is not as large as is commonly believed.
> Despite that you might have heard, the mind-numbing complexity of modern
> computer systems is not due so much to there being multiple CPUs, but
> rather to there being any CPUs at all.  In short, for the ultimate in
> computer-system simplicity, the optimal choice is NR_CPUS=0.
> 
> This commit therefore limits kernel builds to zero CPUs.  This change
> has the beneficial side effect of rendering all kernel bugs harmless.
> Furthermore, this commit enables additional beneficial changes, for
> example, the removal of those parts of the kernel that are not needed
> when there are zero CPUs.
> 
> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Looks good, thanks for doing that.

Btw, I just got confirmation from hw folk that we can actually give you
hardware support for that code with an upcoming CPU which has NR_CPUS=0
cores.

Oh, and additionally, we can disable some of those so getting into the
negative is also doable from the hw perspective, so feel free to explore
that side of the problem too.

ACK.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Thomas Gleixner @ 2012-04-01 17:34 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: linux-m32r-ja, linux-mips, linux-m32r, linux-ia64, linux-parisc,
	linux-s390, linux-hexagon, linux-sh, linux-kernel, cmetcalf, jejb,
	dhowells, linux390, linux-am33-list, linux-alpha, sparclinux,
	uclinux-dist-devel, x86, Paul E. McKenney, linuxppc-dev,
	linux-arm-kernel
In-Reply-To: <20120331223200.GA32482@n2100.arm.linux.org.uk>

On Sat, 31 Mar 2012, Russell King - ARM Linux wrote:

> On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> > 
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Great work, but I don't think you've gone far enough with this.
> 
> What would really help is if you could consolidate all these NR_CPUS
> definitions into one place so we don't have essentially the same thing
> scattered across all these architectures.  We're already doing this on
> ARM across our platforms, and its about time such an approach was taken
> across the entire kernel tree.
> 
> It looks like the MIPS solution would be the best one to pick.
> Could you rework your patch to do this please?
> 
> While you're at it, you might like to consider that having zero CPUs
> makes all this architecture support redundant, so maybe you've missed
> a trick there - according to my count, we could get rid of almost 3
> million lines of code from arch.  We could replace all that with a
> single standard implementation.

For a first step we can deprecated arch/ and make it depend on
CONFIG_STAGING. That way we can have it around a bit for sentimental
reasons w/o having a lot of churn.

Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Index: tip/Makefile
===================================================================
--- tip.orig/Makefile
+++ tip/Makefile
@@ -564,7 +564,9 @@ else
 KBUILD_CFLAGS	+= -O2
 endif
 
+ifdef CONFIG_ARCH_SUPPORT
 include $(srctree)/arch/$(SRCARCH)/Makefile
+endif
 
 ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
Index: tip/drivers/staging/Kconfig
===================================================================
--- tip.orig/drivers/staging/Kconfig
+++ tip/drivers/staging/Kconfig
@@ -1,6 +1,10 @@
+config ARCH_SUPPORT
+	bool
+
 menuconfig STAGING
 	bool "Staging drivers"
 	default n
+	select ARCH_SUPPORT
 	---help---
 	  This option allows you to select a number of drivers that are
 	  not of the "normal" Linux kernel quality level.  These drivers
Index: tip/Documentation/feature-removal-schedule.txt
===================================================================
--- tip.orig/Documentation/feature-removal-schedule.txt
+++ tip/Documentation/feature-removal-schedule.txt
@@ -537,3 +537,13 @@ When:	3.6
 Why:	setitimer is not returning -EFAULT if user pointer is NULL. This
 	violates the spec.
 Who:	Sasikantha Babu <sasikanth.v19@gmail.com>
+
+-----------------------------
+
+What:	Remove arch
+When:	April 1st 2013
+Why:    NR_CPUS=0 made arch/ obsolete. Keep it around a bit for
+	sentimental reasons.
+Who:	paulmck,tglx.rmk
+
+	

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-04-01 18:11 UTC (permalink / raw)
  To: Borislav Petkov, linux-kernel, linux-alpha, linux-arm-kernel,
	uclinux-dist-devel, linux-hexagon, linux-ia64, linux-m32r,
	linux-m32r-ja, linux-mips, linux-am33-list, linux-parisc,
	linuxppc-dev, linux-s390, linux-sh, sparclinux, tglx, linux,
	dhowells, jejb, linux390, x86, cmetcalf
In-Reply-To: <20120401100448.GD14848@liondog.tnic>

On Sun, Apr 01, 2012 at 12:04:48PM +0200, Borislav Petkov wrote:
> On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> > Although there have been numerous complaints about the complexity of
> > parallel programming (especially over the past 5-10 years), the plain
> > truth is that the incremental complexity of parallel programming over
> > that of sequential programming is not as large as is commonly believed.
> > Despite that you might have heard, the mind-numbing complexity of modern
> > computer systems is not due so much to there being multiple CPUs, but
> > rather to there being any CPUs at all.  In short, for the ultimate in
> > computer-system simplicity, the optimal choice is NR_CPUS=0.
> > 
> > This commit therefore limits kernel builds to zero CPUs.  This change
> > has the beneficial side effect of rendering all kernel bugs harmless.
> > Furthermore, this commit enables additional beneficial changes, for
> > example, the removal of those parts of the kernel that are not needed
> > when there are zero CPUs.
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> 
> Looks good, thanks for doing that.
> 
> Btw, I just got confirmation from hw folk that we can actually give you
> hardware support for that code with an upcoming CPU which has NR_CPUS=0
> cores.
> 
> Oh, and additionally, we can disable some of those so getting into the
> negative is also doable from the hw perspective, so feel free to explore
> that side of the problem too.
> 
> ACK.

Cute!  ;-)

							Thanx, Paul

^ permalink raw reply

* Re: [PATCH RFC] Simplify the Linux kernel by reducing its state space
From: Paul E. McKenney @ 2012-04-01 18:12 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-m32r-ja, linux-mips, linux-ia64, linux-m32r,
	Russell King - ARM Linux, linux-parisc, linux-s390, linux-hexagon,
	linux-sh, linux-kernel, cmetcalf, jejb, dhowells, linux390,
	linux-am33-list, linux-alpha, sparclinux, uclinux-dist-devel, x86,
	linuxppc-dev, linux-arm-kernel
In-Reply-To: <alpine.LFD.2.02.1204011930010.2542@ionos>

On Sun, Apr 01, 2012 at 07:34:55PM +0200, Thomas Gleixner wrote:
> On Sat, 31 Mar 2012, Russell King - ARM Linux wrote:
> 
> > On Sun, Apr 01, 2012 at 12:33:21AM +0800, Paul E. McKenney wrote:
> > > Although there have been numerous complaints about the complexity of
> > > parallel programming (especially over the past 5-10 years), the plain
> > > truth is that the incremental complexity of parallel programming over
> > > that of sequential programming is not as large as is commonly believed.
> > > Despite that you might have heard, the mind-numbing complexity of modern
> > > computer systems is not due so much to there being multiple CPUs, but
> > > rather to there being any CPUs at all.  In short, for the ultimate in
> > > computer-system simplicity, the optimal choice is NR_CPUS=0.
> > > 
> > > This commit therefore limits kernel builds to zero CPUs.  This change
> > > has the beneficial side effect of rendering all kernel bugs harmless.
> > > Furthermore, this commit enables additional beneficial changes, for
> > > example, the removal of those parts of the kernel that are not needed
> > > when there are zero CPUs.
> > > 
> > > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > > Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
> > 
> > Great work, but I don't think you've gone far enough with this.
> > 
> > What would really help is if you could consolidate all these NR_CPUS
> > definitions into one place so we don't have essentially the same thing
> > scattered across all these architectures.  We're already doing this on
> > ARM across our platforms, and its about time such an approach was taken
> > across the entire kernel tree.
> > 
> > It looks like the MIPS solution would be the best one to pick.
> > Could you rework your patch to do this please?
> > 
> > While you're at it, you might like to consider that having zero CPUs
> > makes all this architecture support redundant, so maybe you've missed
> > a trick there - according to my count, we could get rid of almost 3
> > million lines of code from arch.  We could replace all that with a
> > single standard implementation.
> 
> For a first step we can deprecated arch/ and make it depend on
> CONFIG_STAGING. That way we can have it around a bit for sentimental
> reasons w/o having a lot of churn.
> 
> Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

;-) ;-) ;-)

Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

							Thanx, Paul

> Index: tip/Makefile
> ===================================================================
> --- tip.orig/Makefile
> +++ tip/Makefile
> @@ -564,7 +564,9 @@ else
>  KBUILD_CFLAGS	+= -O2
>  endif
> 
> +ifdef CONFIG_ARCH_SUPPORT
>  include $(srctree)/arch/$(SRCARCH)/Makefile
> +endif
> 
>  ifneq ($(CONFIG_FRAME_WARN),0)
>  KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
> Index: tip/drivers/staging/Kconfig
> ===================================================================
> --- tip.orig/drivers/staging/Kconfig
> +++ tip/drivers/staging/Kconfig
> @@ -1,6 +1,10 @@
> +config ARCH_SUPPORT
> +	bool
> +
>  menuconfig STAGING
>  	bool "Staging drivers"
>  	default n
> +	select ARCH_SUPPORT
>  	---help---
>  	  This option allows you to select a number of drivers that are
>  	  not of the "normal" Linux kernel quality level.  These drivers
> Index: tip/Documentation/feature-removal-schedule.txt
> ===================================================================
> --- tip.orig/Documentation/feature-removal-schedule.txt
> +++ tip/Documentation/feature-removal-schedule.txt
> @@ -537,3 +537,13 @@ When:	3.6
>  Why:	setitimer is not returning -EFAULT if user pointer is NULL. This
>  	violates the spec.
>  Who:	Sasikantha Babu <sasikanth.v19@gmail.com>
> +
> +-----------------------------
> +
> +What:	Remove arch
> +When:	April 1st 2013
> +Why:    NR_CPUS=0 made arch/ obsolete. Keep it around a bit for
> +	sentimental reasons.
> +Who:	paulmck,tglx.rmk
> +
> +	
> 

^ permalink raw reply

* Re: [PATCH v5 06/27] irq_domain/powerpc: eliminate irq_map; use irq_alloc_desc() instead
From: Andreas Schwab @ 2012-04-01 21:27 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss, linux-kernel, Milton Miller, Rob Herring,
	Thomas Gleixner, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1329383368-12122-7-git-send-email-grant.likely@secretlab.ca>

Grant Likely <grant.likely@secretlab.ca> writes:

> This patch drops the powerpc-specific irq_map table and replaces it with
> directly using the irq_alloc_desc()/irq_free_desc() interfaces for allocating
> and freeing irq_desc structures.

This breaks irqs on PowerMac G5.  I see lost irq errors from the sata
driver.

Note that the breakage only started after the series was merged into
mainline.  But when transplanted upon the parent of the merge this is
the commit that was blamed by bisect.  So something changed between
v3.3-rc3 and the merge of this series that broke it.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox