linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PPC64 Close firmware stdin
@ 2004-12-06  3:31 Paul Mackerras
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Mackerras @ 2004-12-06  3:31 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: anton, sfr, linux-kernel

Andrew & Linus,

We recently found a problem that was causing memory corruption during
boot on IBM POWER5 machines.  The problem was that the if you have a
USB keyboard and it is set to the input device for the firmware, it
will still be active when the kernel is started.  That means that the
OHCI controller has pointers to various memory areas that it polls for
transfers to do.  When we start using that same memory in the kernel,
bad things can happen.  (This isn't a problem on powermacs because the
Apple OF implements a "quiesce" call which turns off all the devices
it is using.)

This patch fixes the problem by calling the Open Firmware "close"
method for the input device.  Stephen Rothwell and I have verified
that doing this fixes the problem on the POWER5 machine where we
observed it.  I verified that this patch doesn't cause any problems on
powermacs.

I think this patch should go into 2.6.10 since it fixes a nasty memory
corruption bug that can cause rather subtle and hard-to-diagnose
problems during boot.  (The symptom on the POWER5 machine with the
particular kernel that we were using was that reading /proc/net/tcp
would oops, due to one of the pointers in tcp_ehash being corrupted.)

Signed-off-by: Paul Mackerras <paulus@samba.org>

--- linux-2.5/arch/ppc64/kernel/prom_init.c	2004-11-26 20:40:32.000000000 +1100
+++ g5-ppc64/arch/ppc64/kernel/prom_init.c	2004-12-04 14:54:08.000000000 +1100
@@ -1108,6 +1108,16 @@
 	}
 }
 
+static void __init prom_close_stdin(void)
+{
+	unsigned long offset = reloc_offset();
+	struct prom_t *_prom = PTRRELOC(&prom);
+	ihandle val;
+
+	if (prom_getprop(_prom->chosen, "stdin", &val, sizeof(val)) > 0)
+		call_prom("close", 1, 0, val);
+}
+
 static int __init prom_find_machine_type(void)
 {
 	unsigned long offset = reloc_offset();
@@ -1686,6 +1696,9 @@
        	prom_printf("copying OF device tree ...\n");
        	flatten_device_tree();
 
+	/* in case stdin is USB and still active on IBM machines... */
+	prom_close_stdin();
+
 	/*
 	 * Call OF "quiesce" method to shut down pending DMA's from
 	 * devices etc...

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

* Re: [PATCH] PPC64 Close firmware stdin
       [not found] <200412071904.iB7J4DOj023759@hera.kernel.org>
@ 2004-12-07 22:30 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2004-12-07 22:30 UTC (permalink / raw)
  To: Linux Kernel list; +Cc: Linus Torvalds

On Tue, 2004-12-07 at 18:15 +0000, Linux Kernel Mailing List wrote:
> ChangeSet 1.2146, 2004/12/07 10:15:41-08:00, paulus@samba.org
> 
> 	[PATCH] PPC64 Close firmware stdin

	.../...

I think you merged that one twice :)

Ben.

> 
> diff -Nru a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c
> --- a/arch/ppc64/kernel/prom_init.c	2004-12-07 11:04:26 -08:00
> +++ b/arch/ppc64/kernel/prom_init.c	2004-12-07 11:04:26 -08:00
> @@ -1118,6 +1118,16 @@
>  		call_prom("close", 1, 0, val);
>  }
>  
> +static void __init prom_close_stdin(void)
> +{
> +	unsigned long offset = reloc_offset();
> +	struct prom_t *_prom = PTRRELOC(&prom);
> +	ihandle val;
> +
> +	if (prom_getprop(_prom->chosen, "stdin", &val, sizeof(val)) > 0)
> +		call_prom("close", 1, 0, val);
> +}
> +
>  static int __init prom_find_machine_type(void)
>  {
>  	unsigned long offset = reloc_offset();
> @@ -1695,6 +1705,9 @@
>  	 */
>         	prom_printf("copying OF device tree ...\n");
>         	flatten_device_tree();
> +
> +	/* in case stdin is USB and still active on IBM machines... */
> +	prom_close_stdin();
>  
>  	/* in case stdin is USB and still active on IBM machines... */
>  	prom_close_stdin();
> -
> To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Benjamin Herrenschmidt <benh@kernel.crashing.org>


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

end of thread, other threads:[~2004-12-07 22:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06  3:31 [PATCH] PPC64 Close firmware stdin Paul Mackerras
     [not found] <200412071904.iB7J4DOj023759@hera.kernel.org>
2004-12-07 22:30 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).