public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters
@ 2013-10-17 19:46 Geert Uytterhoeven
  2013-11-25 16:16 ` Geert Uytterhoeven
       [not found] ` <CAMuHMdUUvzc1eGhJjqye7aOcNQoGgOEfT=TDLQgbef6-0vT=qQ@mail.gmail.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-10-17 19:46 UTC (permalink / raw)
  To: linux-m68k; +Cc: linux-kernel, Geert Uytterhoeven

Since commit d6713b4091a99fa2af2fabdcd2f3fb97f32ecf2e ("m68k: early
parameter support"), the user can specify multiple debug consoles using the
"debug=" kernel command line parameter.
However, as the struct console object was shared, it would actually register
the same console object multiple times, causing the following warning:

WARNING: CPU: 0 PID: 0 at kernel/printk/printk.c:2233 register_console+0x36/0x2b6()
console 'debug0' already registered

Note that only the console corresponding to the last "debug=" parameter became
active, as the .write() method was overwritten before registration.

Use separate console objects to allow using multiple debug consoles.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Notes:
  1. This patch was only compile-tested.
  2. Do we want to fix it this way? Alternatives are:
       a. Reject a second debug= parameter by checking for a non-NULL .write()
          method
	  => only the first debug console will be used,
       b. Skip console registration in case of a non-NULL .write() method
          => only the last debug console will be used,
  3. Atari has a similar issue, with even more (4) debug consoles.

 arch/m68k/amiga/config.c |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 049ef8605314..b975eefba30f 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -107,12 +107,6 @@ static void amiga_mem_console_write(struct console *co, const char *b,
 static void amiga_heartbeat(int on);
 #endif
 
-static struct console amiga_console_driver = {
-	.name	= "debug",
-	.flags	= CON_PRINTBUFFER,
-	.index	= -1,
-};
-
 
     /*
      *  Motherboard Resources present in all Amiga models
@@ -624,6 +618,13 @@ static void amiga_mem_console_write(struct console *co, const char *s,
 	}
 }
 
+static struct console amiga_mem_console = {
+	.name	= "debug",
+	.write	= amiga_mem_console_write,
+	.flags	= CON_PRINTBUFFER,
+	.index	= -1,
+};
+
 static int __init amiga_savekmsg_setup(char *arg)
 {
 	if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
@@ -642,8 +643,7 @@ static int __init amiga_savekmsg_setup(char *arg)
 	savekmsg->magicptr = ZTWO_PADDR(savekmsg);
 	savekmsg->size = 0;
 
-	amiga_console_driver.write = amiga_mem_console_write;
-	register_console(&amiga_console_driver);
+	register_console(&amiga_mem_console);
 	return 0;
 }
 
@@ -723,12 +723,18 @@ void amiga_serial_gets(struct console *co, char *s, int len)
 }
 #endif
 
+static struct console amiga_serial_console = {
+	.name	= "debug",
+	.write	= amiga_serial_console_write,
+	.flags	= CON_PRINTBUFFER,
+	.index	= -1,
+};
+
 static int __init amiga_debug_setup(char *arg)
 {
 	if (MACH_IS_AMIGA && !strcmp(arg, "ser")) {
 		/* no initialization required (?) */
-		amiga_console_driver.write = amiga_serial_console_write;
-		register_console(&amiga_console_driver);
+		register_console(&amiga_serial_console);
 	}
 	return 0;
 }
-- 
1.7.9.5

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

* Re: [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters
  2013-10-17 19:46 [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters Geert Uytterhoeven
@ 2013-11-25 16:16 ` Geert Uytterhoeven
       [not found] ` <CAMuHMdUUvzc1eGhJjqye7aOcNQoGgOEfT=TDLQgbef6-0vT=qQ@mail.gmail.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-11-25 16:16 UTC (permalink / raw)
  To: linux-m68k; +Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven

On Thu, Oct 17, 2013 at 9:46 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Since commit d6713b4091a99fa2af2fabdcd2f3fb97f32ecf2e ("m68k: early
> parameter support"), the user can specify multiple debug consoles using the
> "debug=" kernel command line parameter.
> However, as the struct console object was shared, it would actually register
> the same console object multiple times, causing the following warning:
>
> WARNING: CPU: 0 PID: 0 at kernel/printk/printk.c:2233 register_console+0x36/0x2b6()
> console 'debug0' already registered
>
> Note that only the console corresponding to the last "debug=" parameter became
> active, as the .write() method was overwritten before registration.
>
> Use separate console objects to allow using multiple debug consoles.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Notes:
>   1. This patch was only compile-tested.
>   2. Do we want to fix it this way? Alternatives are:
>        a. Reject a second debug= parameter by checking for a non-NULL .write()
>           method
>           => only the first debug console will be used,
>        b. Skip console registration in case of a non-NULL .write() method
>           => only the last debug console will be used,
>   3. Atari has a similar issue, with even more (4) debug consoles.

No opinions?

Gr{oetje,eeting}s,

                        Geert

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

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters
       [not found] ` <CAMuHMdUUvzc1eGhJjqye7aOcNQoGgOEfT=TDLQgbef6-0vT=qQ@mail.gmail.com>
@ 2013-11-25 19:03   ` Andreas Schwab
       [not found]   ` <87fvqkpam2.fsf@igel.home>
  1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2013-11-25 19:03 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, linux-kernel@vger.kernel.org

Geert Uytterhoeven <geert@linux-m68k.org> writes:

>>   2. Do we want to fix it this way? Alternatives are:
>>        a. Reject a second debug= parameter by checking for a non-NULL .write()
>>           method
>>           => only the first debug console will be used,
>>        b. Skip console registration in case of a non-NULL .write() method
>>           => only the last debug console will be used,
>>   3. Atari has a similar issue, with even more (4) debug consoles.

2b is backward compatible.

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	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters
       [not found]   ` <87fvqkpam2.fsf@igel.home>
@ 2013-12-01 11:15     ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-12-01 11:15 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linux-m68k, linux-kernel@vger.kernel.org

On Mon, Nov 25, 2013 at 8:03 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>>   2. Do we want to fix it this way? Alternatives are:
>>>        a. Reject a second debug= parameter by checking for a non-NULL .write()
>>>           method
>>>           => only the first debug console will be used,
>>>        b. Skip console registration in case of a non-NULL .write() method
>>>           => only the last debug console will be used,
>>>   3. Atari has a similar issue, with even more (4) debug consoles.
>
> 2b is backward compatible.

Thanks, good point!

Gr{oetje,eeting}s,

                        Geert

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

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2013-12-01 11:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-17 19:46 [PATCH/RFC] m68k/amiga: Fix specifying multiple debug= parameters Geert Uytterhoeven
2013-11-25 16:16 ` Geert Uytterhoeven
     [not found] ` <CAMuHMdUUvzc1eGhJjqye7aOcNQoGgOEfT=TDLQgbef6-0vT=qQ@mail.gmail.com>
2013-11-25 19:03   ` Andreas Schwab
     [not found]   ` <87fvqkpam2.fsf@igel.home>
2013-12-01 11:15     ` Geert Uytterhoeven

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