All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PowerPC: boot: Parse chosen/cmdline-timeout parameter
@ 2014-09-09 14:40 Simon Kågström
  2014-09-23  8:56 ` Simon Kågström
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Kågström @ 2014-09-09 14:40 UTC (permalink / raw)
  To: linuxppc-dev, grant.likely, geert, scottwood

A 5 second timeout during boot might be too long, so make it
configurable. Run the loop at least once to let the user stop the boot
by holding a key pressed.

The property is added to the chosen node, e.g.,

	chosen {
		bootargs = "console=ttyUL0 root=/dev/ram0";
		linux,stdout-path = "/plb@0/serial@46000000";
		linux,cmdline-timeout = <100>;
	} ;

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---

ChangeLog:

v2:
- Rename the property linux,cmdline-timeout (Grant Likely)
- Run the loop at least once to allow (Grant Likely)

 arch/powerpc/boot/main.c   |   11 ++++++++++-
 arch/powerpc/boot/ops.h    |    2 +-
 arch/powerpc/boot/serial.c |    6 +++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index a28f021..c1931bb 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -144,13 +144,22 @@ static char cmdline[COMMAND_LINE_SIZE]
 
 static void prep_cmdline(void *chosen)
 {
+	unsigned int getline_timeout = 5000;
+	int v;
+	int n;
+
+	/* Wait-for-input time */
+	n = getprop(chosen, "linux,cmdline-timeout", &v, sizeof(v));
+	if (n == sizeof(v))
+		getline_timeout = v;
+
 	if (cmdline[0] == '\0')
 		getprop(chosen, "bootargs", cmdline, COMMAND_LINE_SIZE-1);
 
 	printf("\n\rLinux/PowerPC load: %s", cmdline);
 	/* If possible, edit the command line */
 	if (console_ops.edit_cmdline)
-		console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE);
+		console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE, getline_timeout);
 	printf("\n\r");
 
 	/* Put the command line back into the devtree for the kernel */
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index b3218ce..c42ea70 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -58,7 +58,7 @@ extern struct dt_ops dt_ops;
 struct console_ops {
 	int	(*open)(void);
 	void	(*write)(const char *buf, int len);
-	void	(*edit_cmdline)(char *buf, int len);
+	void	(*edit_cmdline)(char *buf, int len, unsigned int getline_timeout);
 	void	(*close)(void);
 	void	*data;
 };
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index f2156f0..167ee94 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -33,7 +33,7 @@ static void serial_write(const char *buf, int len)
 		scdp->putc(*buf++);
 }
 
-static void serial_edit_cmdline(char *buf, int len)
+static void serial_edit_cmdline(char *buf, int len, unsigned int timeout)
 {
 	int timer = 0, count;
 	char ch, *cp;
@@ -44,7 +44,7 @@ static void serial_edit_cmdline(char *buf, int len)
 	cp = &buf[count];
 	count++;
 
-	while (timer++ < 5*1000) {
+	do {
 		if (scdp->tstc()) {
 			while (((ch = scdp->getc()) != '\n') && (ch != '\r')) {
 				/* Test for backspace/delete */
@@ -70,7 +70,7 @@ static void serial_edit_cmdline(char *buf, int len)
 			break;  /* Exit 'timer' loop */
 		}
 		udelay(1000);  /* 1 msec */
-	}
+	} while (timer++ < timeout);
 	*cp = 0;
 }
 
-- 
1.7.9.6

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

* Re: [PATCH v2] PowerPC: boot: Parse chosen/cmdline-timeout parameter
  2014-09-09 14:40 [PATCH v2] PowerPC: boot: Parse chosen/cmdline-timeout parameter Simon Kågström
@ 2014-09-23  8:56 ` Simon Kågström
  2014-09-23  9:43   ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Kågström @ 2014-09-23  8:56 UTC (permalink / raw)
  To: linuxppc-dev, grant.likely, geert, scottwood

Hi again!

On Tue, 9 Sep 2014 16:40:06 +0200
Simon K=C3=A5gstr=C3=B6m <simon.kagstrom@netinsight.net> wrote:

> A 5 second timeout during boot might be too long, so make it
> configurable. Run the loop at least once to let the user stop the boot
> by holding a key pressed.
>=20
> The property is added to the chosen node, e.g.,
>=20
> 	chosen {
> 		bootargs =3D "console=3DttyUL0 root=3D/dev/ram0";
> 		linux,stdout-path =3D "/plb@0/serial@46000000";
> 		linux,cmdline-timeout =3D <100>;
> 	} ;
>=20
> Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
> ---
>=20
> ChangeLog:
>=20
> v2:
> - Rename the property linux,cmdline-timeout (Grant Likely)
> - Run the loop at least once to allow (Grant Likely)

Sorry to bother the list, but it would be nice if this patch could
trickle down into some tree if it's seen as acceptable. So consider
this a ping :-)

>  arch/powerpc/boot/main.c   |   11 ++++++++++-
>  arch/powerpc/boot/ops.h    |    2 +-
>  arch/powerpc/boot/serial.c |    6 +++---
>  3 files changed, 14 insertions(+), 5 deletions(-)

[...]

Thanks,
// Simon

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

* Re: [PATCH v2] PowerPC: boot: Parse chosen/cmdline-timeout parameter
  2014-09-23  8:56 ` Simon Kågström
@ 2014-09-23  9:43   ` Michael Ellerman
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2014-09-23  9:43 UTC (permalink / raw)
  To: Simon Kågström; +Cc: grant.likely, geert, linuxppc-dev, scottwood

On Tue, 2014-09-23 at 10:56 +0200, Simon Kågström wrote:
> Hi again!
> 
> On Tue, 9 Sep 2014 16:40:06 +0200
> Simon Kågström <simon.kagstrom@netinsight.net> wrote:
> 
> > A 5 second timeout during boot might be too long, so make it
> > configurable. Run the loop at least once to let the user stop the boot
> > by holding a key pressed.
> 
> Sorry to bother the list, but it would be nice if this patch could
> trickle down into some tree if it's seen as acceptable. So consider
> this a ping :-)

Yeah looks sane to me.

Personally I've never used that feature, I guess I don't have many (any?)
machines with real serial which seems to be a requirement for it to work.

I'll put it in my next tomorrow unless Scott or anyone else objects.

cheers

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

end of thread, other threads:[~2014-09-23  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-09 14:40 [PATCH v2] PowerPC: boot: Parse chosen/cmdline-timeout parameter Simon Kågström
2014-09-23  8:56 ` Simon Kågström
2014-09-23  9:43   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.