All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] printk: fix double printing with earlycon
@ 2017-03-15 10:28 Aleksey Makarov
  2017-03-15 10:28 ` [PATCH v5 1/3] printk: fix name/type/scope of preferred_console var Aleksey Makarov
                   ` (6 more replies)
  0 siblings, 7 replies; 47+ messages in thread
From: Aleksey Makarov @ 2017-03-15 10:28 UTC (permalink / raw)
  To: linux-serial
  Cc: linux-kernel, Aleksey Makarov, Sudeep Holla, Greg Kroah-Hartman,
	Peter Hurley, Jiri Slaby, Robin Murphy, Steven Rostedt, Nair,
	Jayachandran, Sergey Senozhatsky, Petr Mladek

If a console was specified by ACPI SPCR table _and_ command line parameters like
"console=ttyAMA0" _and_ "earlycon" were specified, then log messages
appear twice.

This issue was addressed in the patch [1] but the approach was wrong and
a revert [2] was suggested.

First two patches "printk: fix name/type/scope of preferred_console var" and
"printk: rename selected_console -> preferred_console" were sent some
time ago as one patch "printk: fix name and type of some variables" [3].
They fix name/type/scope of some variables without changing the logic.

The real fix is in the second patch.  The root cause is that the code traverses
the list of specified consoles (the `console_cmdline` array) and stops at the
first match.  But it may happen that the same console is referred by
the elements of this array twice:

	pl011,mmio,0x87e024000000,115200 -- from SPCR
	ttyAMA0 -- from command line

but in this case `preferred_console` points to the second entry and
the flag CON_CONSDEV is not set, so bootconsole is not deregistered.

To fix that, introduce an invariant "The last non-braille console is always the
preferred one" on the entries of the console_cmdline array and don't try to
check for double entries.  Then traverse it in reverse order to be sure that if
the console is preferred then it will be the first matching entry.

v5:
- rewrite 3/3.  Insetead of rearranging the loop, introduce an invariant
  "The last non-braille console is always the preferred one" on the
  entries of the console_cmdline array and don't try to check for double
  entries.  Then traverse it in reverse order to be sure that if the console
  is preferred then it will be the first matching entry.
- add a better explanation from Petr Mladek for 2/3.

v4:
It was not sent upstream due to some problems in implementation of 3/3.
- add some Acked-by: and Reviewed-by: to 1/3 and 2/3
- v2 was closer to the original logic, even though v3 looked simpler.
  The problem is that newcon->setup() is called twice, firstly
  from newcon->match(), then explicitly.  And it could be called third time
  later in another call to newcon->match().  Implement correct sequence:
    1) try to match against preferred_console,
    2) if that fails check other entries of console_cmdline.
  Also move braille console matching/registration to a separate pass to simplify
  the code.

v3 (only for 3/3):
https://lkml.kernel.org/r/20170303154946.15399-1-aleksey.makarov@linaro.org
- v2 still changes the logic of the code and calls newcon->match() several
  times.  V3 fixes that.  It initially matches the console against
  the preferred_console entry, and then if that fails, against other entries.

v2:
https://lkml.kernel.org/r/20170302131153.22733-1-aleksey.makarov@linaro.org
- split the patch that renames `selected_console` and `preferred_console`
  into two patches (Steven Rostedt)
- add a comment explaining why we need a separate match to check for
  preferred_console (Steven Rostedt)
- v1 of this patchset changed the logic of console initialization a bit.
  That could lead to bugs/incompatibilities.  Use the exactly the same
  logic as in the original code.

v1:
https://lkml.kernel.org/r/20170301161347.4202-1-aleksey.makarov@linaro.org

[1] https://lkml.kernel.org/r/1485963998-921-1-git-send-email-sudeep.holla@arm.com
    commit aea9a80ba98a ("tty: serial: pl011: add ttyAMA for matching pl011 console")
[2] https://lkml.kernel.org/r/20170301152304.29635-1-aleksey.makarov@linaro.org
[3] https://lkml.kernel.org/r/1455299022-11641-2-git-send-email-aleksey.makarov@linaro.org

Aleksey Makarov (3):
  printk: fix name/type/scope of preferred_console var
  printk: rename selected_console -> preferred_console
  printk: fix double printing with earlycon

 kernel/printk/printk.c | 61 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 37 insertions(+), 24 deletions(-)

-- 
2.12.0

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

end of thread, other threads:[~2017-06-07  9:13 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-15 10:28 [PATCH v5 0/3] printk: fix double printing with earlycon Aleksey Makarov
2017-03-15 10:28 ` [PATCH v5 1/3] printk: fix name/type/scope of preferred_console var Aleksey Makarov
2017-03-15 10:28 ` [PATCH v5 2/3] printk: rename selected_console -> preferred_console Aleksey Makarov
2017-03-15 10:28 ` [PATCH v5 3/3] printk: fix double printing with earlycon Aleksey Makarov
2017-03-15 16:58   ` Petr Mladek
2017-03-16  7:30     ` Sergey Senozhatsky
2017-03-16 10:36     ` Aleksey Makarov
2017-03-16 13:54       ` Petr Mladek
2017-03-17 10:32         ` Aleksey Makarov
2017-03-17 11:43 ` [PATCH v6 " Aleksey Makarov
2017-03-17 13:34   ` Aleksey Makarov
2017-03-17 13:43 ` [PATCH v7 " Aleksey Makarov
2017-03-20  6:16   ` Sergey Senozhatsky
2017-03-20 10:03 ` [PATCH v8 " Aleksey Makarov
2017-03-27 14:14   ` Petr Mladek
2017-03-27 16:28     ` Aleksey Makarov
2017-03-28  2:04       ` Sergey Senozhatsky
2017-03-28 12:56         ` Petr Mladek
2017-03-30  5:55           ` Sergey Senozhatsky
2017-04-04 11:12             ` Petr Mladek
2017-04-05 18:26               ` Aleksey Makarov
2017-04-05 20:20 ` [PATCH v9 " Aleksey Makarov
2017-04-05 21:57   ` Andy Shevchenko
2017-04-06  4:44     ` Aleksey Makarov
2017-04-10 14:22   ` Petr Mladek
2017-04-10 18:00     ` Aleksey Makarov
2017-04-11  1:54       ` Sergey Senozhatsky
2017-04-11  7:43       ` Petr Mladek
2017-04-12  6:24         ` Aleksey Makarov
2017-05-09  8:29   ` Sabrina Dubroca
2017-05-11  8:24     ` Sergey Senozhatsky
2017-05-11  8:41       ` Sergey Senozhatsky
2017-05-11 11:32         ` Sergey Senozhatsky
2017-05-11 21:17           ` Aleksey Makarov
2017-05-12  1:11             ` Sergey Senozhatsky
2017-05-11 21:13         ` Aleksey Makarov
2017-05-12 12:57         ` Petr Mladek
2017-05-12 13:46           ` Petr Mladek
2017-05-14 21:01             ` Aleksey Makarov
2017-05-13 11:48           ` Sergey Senozhatsky
2017-05-14 20:37           ` Aleksey Makarov
2017-05-18 15:49             ` Petr Mladek
2017-05-26  9:37               ` Aleksey Makarov
2017-06-01 12:03                 ` Petr Mladek
2017-06-06 14:31                   ` Petr Mladek
2017-06-06 16:03                     ` Petr Mladek
2017-06-07  9:13                       ` Sergey Senozhatsky

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.