diff mbox

[v2,3/7] tty/serial: convert 8250 to generic earlycon

Message ID CAL_JsqKux+BTHeYo6XEzzQMAFJZHVjbURM973oHT=t698GbJbA@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Herring April 28, 2014, 11:20 p.m. UTC
On Sat, Apr 26, 2014 at 1:19 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Apr 18, 2014 at 3:19 PM, Rob Herring <robherring2@gmail.com> wrote:
>> From: Rob Herring <robh@kernel.org>
>>
>> With the generic earlycon infrastructure in place, convert the 8250
>> early console to use it.
>>
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: Jiri Slaby <jslaby@suse.cz>
>> ---
>>  drivers/tty/serial/8250/8250_early.c | 138 ++++-------------------------------
>>  drivers/tty/serial/8250/Kconfig      |   1 +
>>  2 files changed, 16 insertions(+), 123 deletions(-)
>
> Hi Greg, Rob
>
> This one in tty-next breaks booting: "console=uart8250,io,0x3f8,115200".
> No early console and regular console anymore.
>
> It should produce "early con and regular con".

This is what I get for running checkpatch and converting
simple_strtoul to kstrto* which are not so equivalent. kstrto* will
not convert things such as 115200n8 to a number.

Greg, Do you want a fix or for me to respin the series? The fix looks like this:

        if (!options)
@@ -64,25 +64,19 @@ static int __init parse_options(struct
earlycon_device *device,
        if (mmio || mmio32) {
                port->iotype = (mmio ? UPIO_MEM : UPIO_MEM32);
                options += mmio ? 5 : 7;
-               ret = kstrtoul(options, 0, &addr);
-               if (ret)
-                       return ret;
+               addr = simple_strtoul(options, NULL, 0);
                port->mapbase = addr;
                if (mmio32)
                        port->regshift = 2;
        } else if (!strncmp(options, "io,", 3)) {
                port->iotype = UPIO_PORT;
                options += 3;
-               ret = kstrtoul(options, 0, &addr);
-               if (ret)
-                       return ret;
+               addr = simple_strtoul(options, NULL, 0);
                port->iobase = addr;
                mmio = 0;
        } else if (!strncmp(options, "0x", 2)) {
                port->iotype = UPIO_MEM;
-               ret = kstrtoul(options, 0, &addr);
-               if (ret)
-                       return ret;
+               addr = simple_strtoul(options, NULL, 0);
                port->mapbase = addr;
        } else {
                return -EINVAL;
@@ -93,9 +87,7 @@ static int __init parse_options(struct
earlycon_device *device,
        options = strchr(options, ',');
        if (options) {
                options++;
-               ret = kstrtouint(options, 0, &device->baud);
-               if (ret)
-                       return ret;
+               device->baud = simple_strtoul(options, NULL, 0);
                length = min(strcspn(options, " ") + 1,
                             (size_t)(sizeof(device->options)));
                strlcpy(device->options, options, length);

Comments

Greg Kroah-Hartman May 3, 2014, 10:07 p.m. UTC | #1
On Mon, Apr 28, 2014 at 06:20:53PM -0500, Rob Herring wrote:
> On Sat, Apr 26, 2014 at 1:19 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> > On Fri, Apr 18, 2014 at 3:19 PM, Rob Herring <robherring2@gmail.com> wrote:
> >> From: Rob Herring <robh@kernel.org>
> >>
> >> With the generic earlycon infrastructure in place, convert the 8250
> >> early console to use it.
> >>
> >> Signed-off-by: Rob Herring <robh@kernel.org>
> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >> Cc: Jiri Slaby <jslaby@suse.cz>
> >> ---
> >>  drivers/tty/serial/8250/8250_early.c | 138 ++++-------------------------------
> >>  drivers/tty/serial/8250/Kconfig      |   1 +
> >>  2 files changed, 16 insertions(+), 123 deletions(-)
> >
> > Hi Greg, Rob
> >
> > This one in tty-next breaks booting: "console=uart8250,io,0x3f8,115200".
> > No early console and regular console anymore.
> >
> > It should produce "early con and regular con".
> 
> This is what I get for running checkpatch and converting
> simple_strtoul to kstrto* which are not so equivalent. kstrto* will
> not convert things such as 115200n8 to a number.
> 
> Greg, Do you want a fix or for me to respin the series? The fix looks like this:

As this is in my tree now (right?), I need a fix to apply to it.

thanks,

greg k-h
Greg Kroah-Hartman May 3, 2014, 10:16 p.m. UTC | #2
On Sat, May 03, 2014 at 06:07:31PM -0400, Greg Kroah-Hartman wrote:
> On Mon, Apr 28, 2014 at 06:20:53PM -0500, Rob Herring wrote:
> > On Sat, Apr 26, 2014 at 1:19 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> > > On Fri, Apr 18, 2014 at 3:19 PM, Rob Herring <robherring2@gmail.com> wrote:
> > >> From: Rob Herring <robh@kernel.org>
> > >>
> > >> With the generic earlycon infrastructure in place, convert the 8250
> > >> early console to use it.
> > >>
> > >> Signed-off-by: Rob Herring <robh@kernel.org>
> > >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > >> Cc: Jiri Slaby <jslaby@suse.cz>
> > >> ---
> > >>  drivers/tty/serial/8250/8250_early.c | 138 ++++-------------------------------
> > >>  drivers/tty/serial/8250/Kconfig      |   1 +
> > >>  2 files changed, 16 insertions(+), 123 deletions(-)
> > >
> > > Hi Greg, Rob
> > >
> > > This one in tty-next breaks booting: "console=uart8250,io,0x3f8,115200".
> > > No early console and regular console anymore.
> > >
> > > It should produce "early con and regular con".
> > 
> > This is what I get for running checkpatch and converting
> > simple_strtoul to kstrto* which are not so equivalent. kstrto* will
> > not convert things such as 115200n8 to a number.
> > 
> > Greg, Do you want a fix or for me to respin the series? The fix looks like this:
> 
> As this is in my tree now (right?), I need a fix to apply to it.

Nevermind, you already sent it...
Tony Luck June 9, 2014, 10:25 p.m. UTC | #3
On Sat, May 3, 2014 at 3:16 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>> > >>  drivers/tty/serial/8250/8250_early.c | 138 ++++-------------------------------
>> > >>  drivers/tty/serial/8250/Kconfig      |   1 +
>> > >>  2 files changed, 16 insertions(+), 123 deletions(-)
>> > >
>> > > Hi Greg, Rob
>> > >
>> > > This one in tty-next breaks booting: "console=uart8250,io,0x3f8,115200".
>> > > No early console and regular console anymore.
>> > >
>> > > It should produce "early con and regular con".
>> >
>> > This is what I get for running checkpatch and converting
>> > simple_strtoul to kstrto* which are not so equivalent. kstrto* will
>> > not convert things such as 115200n8 to a number.
>> >
>> > Greg, Do you want a fix or for me to respin the series? The fix looks like this:
>>
>> As this is in my tree now (right?), I need a fix to apply to it.
>
> Nevermind, you already sent it...

Linus' tree (HEAD=963649d735c8) is spitting out all sorts of garbage
on the serial console - as if the baud rate is being periodically set
to something weird, and then back to 112500.  I see over a dozen
blocks of junk interspersed with good output.

This in on ia64 with "console=uart,io,0x3f8" on the command line.

git bisect pointed me here:

d2fd6810a823bcde1ee232668f5689837aafa772 is first bad commit
commit d2fd6810a823bcde1ee232668f5689837aafa772
Author: Rob Herring <robh@kernel.org>
Date:   Fri Apr 18 17:19:56 2014 -0500

    tty/serial: convert 8250 to generic earlycon

-Tony
Tony Luck June 9, 2014, 10:35 p.m. UTC | #4
On Mon, Jun 9, 2014 at 3:25 PM, Tony Luck <tony.luck@gmail.com> wrote:
> Linus' tree (HEAD=963649d735c8) is spitting out all sorts of garbage
> on the serial console - as if the baud rate is being periodically set
> to something weird, and then back to 112500.  I see over a dozen
> blocks of junk interspersed with good output.

Ah - it seems that I need to be more specific on the cmdline

     console=uart8250,io,0x3f8,115200

makes all the garbage disappear.

Do I need to update: Documentation/ia64/serial.txt
which has the example of "console=uart,io,0x3f8"?

-Tony
Rob Herring June 9, 2014, 10:36 p.m. UTC | #5
On Mon, Jun 9, 2014 at 5:25 PM, Tony Luck <tony.luck@gmail.com> wrote:
> On Sat, May 3, 2014 at 3:16 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>>> > >>  drivers/tty/serial/8250/8250_early.c | 138 ++++-------------------------------
>>> > >>  drivers/tty/serial/8250/Kconfig      |   1 +
>>> > >>  2 files changed, 16 insertions(+), 123 deletions(-)
>>> > >
>>> > > Hi Greg, Rob
>>> > >
>>> > > This one in tty-next breaks booting: "console=uart8250,io,0x3f8,115200".
>>> > > No early console and regular console anymore.
>>> > >
>>> > > It should produce "early con and regular con".
>>> >
>>> > This is what I get for running checkpatch and converting
>>> > simple_strtoul to kstrto* which are not so equivalent. kstrto* will
>>> > not convert things such as 115200n8 to a number.
>>> >
>>> > Greg, Do you want a fix or for me to respin the series? The fix looks like this:
>>>
>>> As this is in my tree now (right?), I need a fix to apply to it.
>>
>> Nevermind, you already sent it...
>
> Linus' tree (HEAD=963649d735c8) is spitting out all sorts of garbage
> on the serial console - as if the baud rate is being periodically set
> to something weird, and then back to 112500.  I see over a dozen
> blocks of junk interspersed with good output.

Is there any correlation of the garbage to printks of console enabled messages?

>
> This in on ia64 with "console=uart,io,0x3f8" on the command line.

Does "console=ttyS0,115200" or "console=uart,io,0x3f8,115200" work?

You will need this fix for the 2nd one to work:

commit e26f1db9b8d74617519e50b41749900d0a257406
Author: Rob Herring <robh@kernel.org>
Date:   Wed Apr 30 19:48:29 2014 -0500

    tty/serial: fix generic earlycon option parsing

Rob

>
> git bisect pointed me here:
>
> d2fd6810a823bcde1ee232668f5689837aafa772 is first bad commit
> commit d2fd6810a823bcde1ee232668f5689837aafa772
> Author: Rob Herring <robh@kernel.org>
> Date:   Fri Apr 18 17:19:56 2014 -0500
>
>     tty/serial: convert 8250 to generic earlycon
>
> -Tony
Rob Herring June 9, 2014, 11:18 p.m. UTC | #6
On Mon, Jun 9, 2014 at 5:35 PM, Tony Luck <tony.luck@gmail.com> wrote:
> On Mon, Jun 9, 2014 at 3:25 PM, Tony Luck <tony.luck@gmail.com> wrote:
>> Linus' tree (HEAD=963649d735c8) is spitting out all sorts of garbage
>> on the serial console - as if the baud rate is being periodically set
>> to something weird, and then back to 112500.  I see over a dozen
>> blocks of junk interspersed with good output.
>
> Ah - it seems that I need to be more specific on the cmdline
>
>      console=uart8250,io,0x3f8,115200
>
> makes all the garbage disappear.
>
> Do I need to update: Documentation/ia64/serial.txt
> which has the example of "console=uart,io,0x3f8"?

It should do auto detect of the baud-rate if it is not specified which
for 8250 is just reading the baud-rate divider and calculating the
baud-rate using the uart clock. It should just reprogram the divider
with the same divider value. I don't see anything obvious why this
would have broken.

Rob
Tony Luck June 10, 2014, 8:52 p.m. UTC | #7
On Mon, Jun 9, 2014 at 4:18 PM, Rob Herring <robherring2@gmail.com> wrote:
> It should do auto detect of the baud-rate if it is not specified which
> for 8250 is just reading the baud-rate divider and calculating the
> baud-rate using the uart clock. It should just reprogram the divider
> with the same divider value. I don't see anything obvious why this
> would have broken.

Something very weird is happening.  Output is good so long as I put the
trailing ",115200" on the command line.

But I made early_serial8250_setup() printk() the return value it got
from probe_baud() - in case is was somehow getting 115201 or some
other silly value ... nope. Exactly 115200.

I also can't explain why the "noise" comes and goes a dozen
times during boot,

Does some other place in the kernel look at the "uart..." command
line argument?

-Tony
Rob Herring June 10, 2014, 10:38 p.m. UTC | #8
On Tue, Jun 10, 2014 at 3:52 PM, Tony Luck <tony.luck@gmail.com> wrote:
> On Mon, Jun 9, 2014 at 4:18 PM, Rob Herring <robherring2@gmail.com> wrote:
>> It should do auto detect of the baud-rate if it is not specified which
>> for 8250 is just reading the baud-rate divider and calculating the
>> baud-rate using the uart clock. It should just reprogram the divider
>> with the same divider value. I don't see anything obvious why this
>> would have broken.
>
> Something very weird is happening.  Output is good so long as I put the
> trailing ",115200" on the command line.
>
> But I made early_serial8250_setup() printk() the return value it got
> from probe_baud() - in case is was somehow getting 115201 or some
> other silly value ... nope. Exactly 115200.
>
> I also can't explain why the "noise" comes and goes a dozen
> times during boot,
>
> Does some other place in the kernel look at the "uart..." command
> line argument?

Would you be using drivers/firmware/pcdp.c as that is ia64 only? That
shouldn't have an impact that I can see.

Can you print the options string in serial8250_console_setup? Maybe it
is getting lost when the real console is setup.

Rob
diff mbox

Patch

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 73bf1e2..c92e830 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -53,7 +53,7 @@  static int __init parse_options(struct
earlycon_device *device,
                                char *options)
 {
        struct uart_port *port = &device->port;
-       int mmio, mmio32, length, ret;
+       int mmio, mmio32, length;
        unsigned long addr;