Skip to contentSkip to conversation

IA64: Use early_parm to handle mvec_name and nomca

RFC In review Horms 5 participants 12 messages Mar 10, 2006 – Jun 4, 2006 TTY layer and serial drivers

lore
Share & tools
lore

Horms

author
#0 lore raw

RFC 1/1 IA64: Use early_parm to handle mvec_name and nomca

I'm not sure of the worthiness of this idea, so please consider it an RFC. Its key merits are:

* Reuse existing infrastructure
* Greatly tightens up the parsing of nomca
* Greatly simplifies the parsing of machvec

 setup.c |   47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

4ed9fbfd2b02aea51ee5848966465397eec5a1c6

arch/ia64/kernel/setup.c +24 -23
index 3258e09..53a60fa 100644
@@ -389,6 +389,24 @@ check_for_logical_procs (void)
 }
 #endif
 
+#ifdef CONFIG_IA64_GENERIC
+static const char *mvec_name = NULL;
+static __init int setup_mvec(char *s)
+{
+	mvec_name = s;
+	return 0;
+}
+early_param("machvec", setup_mvec);
+#endif
+
+static int nomca = 0;
+static __init int setup_nomca(char *s)
+{
+	nomca = 1;
+	return 0;
+}
+early_param("nomca", setup_nomca);
+
 void __init
 setup_arch (char **cmdline_p)
 {
@@ -402,35 +420,18 @@ setup_arch (char **cmdline_p)
 	efi_init();
 	io_port_init();
 
-#ifdef CONFIG_IA64_GENERIC
-	{
-		const char *mvec_name = strstr (*cmdline_p, "machvec=");
-		char str[64];
+	parse_early_param();
 
-		if (mvec_name) {
-			const char *end;
-			size_t len;
-
-			mvec_name += 8;
-			end = strchr (mvec_name, ' ');
-			if (end)
-				len = end - mvec_name;
-			else
-				len = strlen (mvec_name);
-			len = min(len, sizeof (str) - 1);
-			strncpy (str, mvec_name, len);
-			str[len] = '\0';
-			mvec_name = str;
-		} else
-			mvec_name = acpi_get_sysname();
+#ifdef CONFIG_IA64_GENERIC
+	if (!mvec_name)
+		machvec_init(acpi_get_sysname());
+	else
 		machvec_init(mvec_name);
-	}
 #endif
 
 	if (early_console_setup(*cmdline_p) = 0)
 		mark_bsp_online();
 
-	parse_early_param();
 #ifdef CONFIG_ACPI
 	/* Initialize the ACPI boot-time table parser */
 	acpi_table_init();
@@ -493,7 +494,7 @@ setup_arch (char **cmdline_p)
 #endif
 
 	/* enable IA-64 Machine Check Abort Handling unless disabled */
-	if (!strstr(saved_command_line, "nomca"))
+	if (!nomca)
 		ia64_mca_init();
 
 	platform_setup(cmdline_p);
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Horms" = Horms <[email protected]> writes:

Horms> I'm not sure of the worthiness of this idea, so please consider Horms> it an RFC. Its key merits are:

Hi Horms,

Rips out a lot of code so if it still works then I'd say it's a good win!

You get a D- for these two though:

Horms> +static const char *mvec_name = NULL;
Horms> +static int nomca = 0;

No need to initialize globals to zero as the BSS is cleared at boot.

Cheers,
Jes

author
#2 lore raw
In reply to Horms
Quoted 9 lines · Jes Sorensen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Horms" = Horms <[email protected]> writes:

Horms> I'm not sure of the worthiness of this idea, so please consider Horms> it an RFC. Its key merits are:

Hi Horms,

Rips out a lot of code so if it still works then I'd say it's a good win!

Thats pretty much what I was thinking. It does seem to work with the limited ammount of testing that I have done.

Quoted 6 lines

You get a D- for these two though:

Horms> +static const char *mvec_name = NULL;
Horms> +static int nomca = 0;

No need to initialize globals to zero as the BSS is cleared at boot.

Below is a fressh diff that resolves those initialisation problems.

I was actually thinking that the main drawback of this appoach was the extra space devoted to these variables. Marking them as __init made the linker very unhappy. Given their current delaration, will they just stick around forever?

Signature · 17 lines
Horms

IA64: Use early_parm to handle mvec_name and nomca

I'm not sure of the worthiness of this idea, so please consider it an RFC. 
Its key merits are:

* Reuse existing infrastructure
* Greatly tightens up the parsing of nomca
* Greatly simplifies the parsing of machvec

Signed-Off-By: Horms <[email protected]>

 setup.c |   47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

4ed9fbfd2b02aea51ee5848966465397eec5a1c6
arch/ia64/kernel/setup.c +24 -23
index 3258e09..53a60fa 100644
@@ -389,6 +389,24 @@ check_for_logical_procs (void)
 }
 #endif
 
+#ifdef CONFIG_IA64_GENERIC
+static const char *mvec_name = NULL;
+static __init int setup_mvec(char *s)
+{
+	mvec_name = s;
+	return 0;
+}
+early_param("machvec", setup_mvec);
+#endif
+
+static int nomca = 0;
+static __init int setup_nomca(char *s)
+{
+	nomca = 1;
+	return 0;
+}
+early_param("nomca", setup_nomca);
+
 void __init
 setup_arch (char **cmdline_p)
 {
@@ -402,35 +420,18 @@ setup_arch (char **cmdline_p)
 	efi_init();
 	io_port_init();
 
-#ifdef CONFIG_IA64_GENERIC
-	{
-		const char *mvec_name = strstr (*cmdline_p, "machvec=");
-		char str[64];
+	parse_early_param();
 
-		if (mvec_name) {
-			const char *end;
-			size_t len;
-
-			mvec_name += 8;
-			end = strchr (mvec_name, ' ');
-			if (end)
-				len = end - mvec_name;
-			else
-				len = strlen (mvec_name);
-			len = min(len, sizeof (str) - 1);
-			strncpy (str, mvec_name, len);
-			str[len] = '\0';
-			mvec_name = str;
-		} else
-			mvec_name = acpi_get_sysname();
+#ifdef CONFIG_IA64_GENERIC
+	if (!mvec_name)
+		machvec_init(acpi_get_sysname());
+	else
 		machvec_init(mvec_name);
-	}
 #endif
 
 	if (early_console_setup(*cmdline_p) = 0)
 		mark_bsp_online();
 
-	parse_early_param();
 #ifdef CONFIG_ACPI
 	/* Initialize the ACPI boot-time table parser */
 	acpi_table_init();
@@ -493,7 +494,7 @@ setup_arch (char **cmdline_p)
 #endif
 
 	/* enable IA-64 Machine Check Abort Handling unless disabled */
-	if (!strstr(saved_command_line, "nomca"))
+	if (!nomca)
 		ia64_mca_init();
 
 	platform_setup(cmdline_p);
#3 lore raw
In reply to Horms
Quoted 2 lines · Horms

Below is a fressh diff that resolves those initialisation problems.

You're still zero initializingn them in the new diff ;-(

Quoted 5 lines

I was actually thinking that the main drawback of this appoach was the extra space devoted to these variables. Marking them as __init made the linker very unhappy. Given their current delaration, will they just stick around forever?

Yous hould be able to mark them __init, otherwise they just end up sticking around forever as you say. Grep around some other code in the vicinity to see how it's declared if it causes problems.

Cheers,
Jes

#4 lore raw
In reply to Horms

Jes Sorensen wrote on Saturday, March 11, 2006 12:52 AM

Quoted 9 lines
Quoted 5 lines

I was actually thinking that the main drawback of this appoach was the extra space devoted to these variables. Marking them as __init made the linker very unhappy. Given their current delaration, will they just stick around forever?

Yous hould be able to mark them __init, otherwise they just end up sticking around forever as you say. Grep around some other code in the vicinity to see how it's declared if it causes problems.

You should use __initdata.

- Ken

author
#5 lore raw
In reply to Horms
Quoted 4 lines · Jes Sorensen
Quoted 1 line · Horms

Below is a fressh diff that resolves those initialisation problems.

You're still zero initializingn them in the new diff ;-(

Sorry, sent the wrong thing :(

[snip]

Quoted 7 lines · Kenneth W

Jes Sorensen wrote on Saturday, March 11, 2006 12:52 AM

Quoted 6 lines
Quoted 5 lines

I was actually thinking that the main drawback of this appoach was the extra space devoted to these variables. Marking them as __init made the linker very unhappy. Given their current delaration, will they just stick around forever?

Quoted 5 lines
Quoted 3 lines

Yous hould be able to mark them __init, otherwise they just end up sticking around forever as you say. Grep around some other code in the vicinity to see how it's declared if it causes problems.

You should use __initdata.

Thanks,

The patch below should address the BSS and __initdata deficiencies. I also did a bit more testing, and it does indeed seem to work.

Signature · 15 lines
Horms

IA64: Use early_parm to handle mvec_name and nomca

I'm not sure of the worthiness of this idea, so please consider it an RFC. 
Its key merits are:

* Reuse existing infrastructure
* Greatly tightens up the parsing of nomca
* Greatly simplifies the parsing of machvec

Signed-Off-By: Horms <[email protected]>

 setup.c |   47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)
arch/ia64/kernel/setup.c +24 -23
index 3258e09..afabe1b 100644
@@ -389,6 +389,24 @@ check_for_logical_procs (void)
 }
 #endif
 
+#ifdef CONFIG_IA64_GENERIC
+static __initdata const char *mvec_name;
+static __init int setup_mvec(char *s)
+{
+	mvec_name = s;
+	return 0;
+}
+early_param("machvec", setup_mvec);
+#endif
+
+static __initdata int nomca;
+static __init int setup_nomca(char *s)
+{
+	nomca = 1;
+	return 0;
+}
+early_param("nomca", setup_nomca);
+
 void __init
 setup_arch (char **cmdline_p)
 {
@@ -402,35 +420,18 @@ setup_arch (char **cmdline_p)
 	efi_init();
 	io_port_init();
 
-#ifdef CONFIG_IA64_GENERIC
-	{
-		const char *mvec_name = strstr (*cmdline_p, "machvec=");
-		char str[64];
+	parse_early_param();
 
-		if (mvec_name) {
-			const char *end;
-			size_t len;
-
-			mvec_name += 8;
-			end = strchr (mvec_name, ' ');
-			if (end)
-				len = end - mvec_name;
-			else
-				len = strlen (mvec_name);
-			len = min(len, sizeof (str) - 1);
-			strncpy (str, mvec_name, len);
-			str[len] = '\0';
-			mvec_name = str;
-		} else
-			mvec_name = acpi_get_sysname();
+#ifdef CONFIG_IA64_GENERIC
+	if (!mvec_name)
+		machvec_init(acpi_get_sysname());
+	else
 		machvec_init(mvec_name);
-	}
 #endif
 
 	if (early_console_setup(*cmdline_p) = 0)
 		mark_bsp_online();
 
-	parse_early_param();
 #ifdef CONFIG_ACPI
 	/* Initialize the ACPI boot-time table parser */
 	acpi_table_init();
@@ -493,7 +494,7 @@ setup_arch (char **cmdline_p)
 #endif
 
 	/* enable IA-64 Machine Check Abort Handling unless disabled */
-	if (!strstr(saved_command_line, "nomca"))
+	if (!nomca)
 		ia64_mca_init();
 
 	platform_setup(cmdline_p);
author
#6 lore raw

IA64: Broken Serial Console

Hi,

I have noticed that the serial console on my ia64 machine seems to have broken since 2.6.16. Thanks to git bisect I have been able to track this problem down to 111c9bf8c5cfa92363b3719c8956d29368b5b9de

[SERIAL] remove 8250_acpi (replaced by 8250_pnp and PNPACPI)

With the combination of PNPACPI and 8250_pnp, we no longer need 8250_acpi.

I haven't had time to look into the code and I have to leave my desk shortly, so I thought I would post here to see if anyone has any ideas.

I am boot using the following command line:

console=tty0 console=uart,io,0x2f8 console=ttyS0

Althogh I'm pretty sure I really only need:

console=uart,io,0x2f8

A failed boot looks like this:

io scheduler anticipatory registered (default)
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled isa bounce pool size: 16 pages
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
mice: PS/2 mouse device common for all mice
EFI Variables Facility v0.08 2004-May-17
No ttyS device at I/O port 0x2f8 for console

And a successful boot looks like this:

io scheduler anticipatory registered (default)
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
acpi_serial_port: zero-length IO port range?
serial8250: ttyS0 at I/O 0x3f8 (irq = 44) is a 16550A
acpi_serial_port: zero-length IO port range?
serial8250: ttyS1 at I/O 0x2f8 (irq = 45) is a 16550A
isa bounce pool size: 16 pages
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
mice: PS/2 mouse device common for all mice
EFI Variables Facility v0.08 2004-May-17
Adding console on ttyS1 at I/O port 0x2f8 (options '115200')

prompt #

The machine in question is a Trus64-21. Sorry I don't have an English link handy, but if you need me to dig up details please ask.

http://www.plathome.co.jp/factory/ser/tru_ita64_21.html

Signature · 1 line
Horms                                           http://www.vergenet.net/~horms/
#7 lore raw

Re: IA64: Broken Serial Console

Quoted 9 lines · Horms

I have noticed that the serial console on my ia64 machine seems to have broken since 2.6.16. Thanks to git bisect I have been able to track this problem down to 111c9bf8c5cfa92363b3719c8956d29368b5b9de

[SERIAL] remove 8250_acpi (replaced by 8250_pnp and PNPACPI)

With the combination of PNPACPI and 8250_pnp, we no longer need 8250_acpi.

Quoted 6 lines

I haven't had time to look into the code and I have to leave my desk shortly, so I thought I would post here to see if anyone has any ideas.

Well, does your config have PNPACPI and SERIAL_8250_PNP enabled?

author
#8 lore raw

Re: IA64: Broken Serial Console

Quoted 10 lines · Matthew Wilcox
Quoted 9 lines · Horms

I have noticed that the serial console on my ia64 machine seems to have broken since 2.6.16. Thanks to git bisect I have been able to track this problem down to 111c9bf8c5cfa92363b3719c8956d29368b5b9de

[SERIAL] remove 8250_acpi (replaced by 8250_pnp and PNPACPI)

With the combination of PNPACPI and 8250_pnp, we no longer need 8250_acpi.

Quoted 8 lines
Quoted 6 lines

I haven't had time to look into the code and I have to leave my desk shortly, so I thought I would post here to see if anyone has any ideas.

Well, does your config have PNPACPI and SERIAL_8250_PNP enabled?

Thanks, adding those options (obviously) solved the problem.

Signature · 1 line
Horms                                           http://www.vergenet.net/~horms/
#9 lore raw

Re: IA64: Broken Serial Console

In reply to Horms
Quoted 10 lines

I am boot using the following command line:

console=tty0 console=uart,io,0x2f8 console=ttyS0

Althogh I'm pretty sure I really only need:

console=uart,io,0x2f8

Have you tried the following parameters ?

console=uart,io,0x2f8,115200n8

#10 lore raw
In reply to Horms

Horms wrote on Sunday, March 12, 2006 8:08 PM

Quoted 8 lines

IA64: Use early_parm to handle mvec_name and nomca

I'm not sure of the worthiness of this idea, so please consider it an RFC. Its key merits are:

* Reuse existing infrastructure
* Greatly tightens up the parsing of nomca
* Greatly simplifies the parsing of machvec

It is kind of odd though that parse_early_param() is called twice, once from init/main.c:start_kernel and once from arch/ia64/kernel/ setup.c:setup_arch. Though you are not the one introduces that Oddity.

The other thing is that the code you changed are going to be thrown away after initialization, so I take your motivation of the patch is in some form of uncluttered the source code?

If I were you, I would put machvec code into machvec.c, like this:

 machvec.c |   17 ++++++++++++++---
 setup.c   |   30 +++++-------------------------
 2 files changed, 19 insertions(+), 28 deletions(-)
arch/ia64/kernel/machvec.c renamed from arch/ia64/kernel/machvec.c.orig +14 -3
@@ -14,6 +14,14 @@
 struct ia64_machine_vector ia64_mv;
 EXPORT_SYMBOL(ia64_mv);
 
+static __initdata const char *mvec_name;
+static __init int setup_mvec(char *s)
+{
+	mvec_name = s;
+	return 0;
+}
+early_param("machvec", setup_mvec);
+
 static struct ia64_machine_vector * __init
 lookup_machvec (const char *name)
 {
@@ -33,10 +41,13 @@ machvec_init (const char *name)
 {
 	struct ia64_machine_vector *mv;
 
+	if (!name)
+		name = mvec_name ? mvec_name : acpi_get_sysname();
 	mv = lookup_machvec(name);
-	if (!mv) {
-		panic("generic kernel failed to find machine vector for platform %s!", name);
-	}
+	if (!mv)
+		panic("generic kernel failed to find machine vector for"
+		      " platform %s!", name);
+
 	ia64_mv = *mv;
 	printk(KERN_INFO "booting generic kernel on platform %s\n", name);
 }
arch/ia64/kernel/setup.c renamed from arch/ia64/kernel/setup.c.orig +5 -25
@@ -402,35 +402,15 @@ setup_arch (char **cmdline_p)
 	efi_init();
 	io_port_init();
 
-#ifdef CONFIG_IA64_GENERIC
-	{
-		const char *mvec_name = strstr (*cmdline_p, "machvec=");
-		char str[64];
-
-		if (mvec_name) {
-			const char *end;
-			size_t len;
-
-			mvec_name += 8;
-			end = strchr (mvec_name, ' ');
-			if (end)
-				len = end - mvec_name;
-			else
-				len = strlen (mvec_name);
-			len = min(len, sizeof (str) - 1);
-			strncpy (str, mvec_name, len);
-			str[len] = '\0';
-			mvec_name = str;
-		} else
-			mvec_name = acpi_get_sysname();
-		machvec_init(mvec_name);
-	}
-#endif
-
 	if (early_console_setup(*cmdline_p) = 0)
 		mark_bsp_online();
 
 	parse_early_param();
+
+#ifdef CONFIG_IA64_GENERIC
+	machvec_init(NULL);
+#endif
+
 #ifdef CONFIG_ACPI
 	/* Initialize the ACPI boot-time table parser */
 	acpi_table_init();
author
#11 lore raw
In reply to Horms
Quoted 6 lines · Kenneth W

Horms wrote on Sunday, March 12, 2006 8:08 PM

Quoted 5 lines

IA64: Use early_parm to handle mvec_name and nomca

I'm not sure of the worthiness of this idea, so please consider it an RFC. Its key merits are:

Quoted 8 lines
Quoted 3 lines

* Reuse existing infrastructure
* Greatly tightens up the parsing of nomca
* Greatly simplifies the parsing of machvec

It is kind of odd though that parse_early_param() is called twice, once from init/main.c:start_kernel and once from arch/ia64/kernel/ setup.c:setup_arch. Though you are not the one introduces that Oddity.

Yes, that is odd. I guess the arch/ia64/kernel/setup.c one could be removed. That is, unless the init/main.c is called too late. I'll investigate that.

Quoted 3 lines

The other thing is that the code you changed are going to be thrown away after initialization, so I take your motivation of the patch is in some form of uncluttered the source code?

Yes. It seems to me that the parsing is greatly simplified with this approach.

Quoted 1 line

If I were you, I would put machvec code into machvec.c, like this:

That is an excellent idea.

Signature · 1 line
Horms