devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Cernekee <cernekee@gmail.com>
To: gregkh@linuxfoundation.org, jslaby@suse.cz, robh@kernel.org,
	grant.likely@linaro.org
Cc: geert@linux-m68k.org, f.fainelli@gmail.com, mbizon@freebox.fr,
	jogo@openwrt.org, linux-mips@linux-mips.org,
	linux-serial@vger.kernel.org, devicetree@vger.kernel.org
Subject: [PATCH V2 7/9] tty: serial: of-serial: Suppress warnings if OF earlycon is invoked twice
Date: Mon, 20 Oct 2014 13:54:06 -0700	[thread overview]
Message-ID: <1413838448-29464-8-git-send-email-cernekee@gmail.com> (raw)
In-Reply-To: <1413838448-29464-1-git-send-email-cernekee@gmail.com>

Specifying "earlycon earlycon" on the kernel command line yields this
warning:

    bootconsole [uart0] enabled
    ------------[ cut here ]------------
    WARNING: CPU: 0 PID: 0 at kernel/printk/printk.c:2391 register_console+0x244/0x3fc()
    console 'uart0' already registered
    CPU: 0 PID: 0 Comm: swapper Not tainted 3.18.0-rc1+ #2
    Stack : 00000000 00000004 80af0000 80af0000 00000000 00000000 00000000 00000000
              80ad4e12 00000036 00000000 00000000 00010000 805abe88 805606b4 805abae7
              00000000 00000000 80ad38d8 805abe88 8055f304 43d42d03 9988c6a1 804e2710
              805b0000 80032854 00000000 00000000 8056492c 80599c84 80599c84 805606b4
              00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
              ...
    Call Trace:
    [<8001a22c>] show_stack+0x64/0x7c
    [<804e47d8>] dump_stack+0xc8/0xfc
    [<80032aa8>] warn_slowpath_common+0x7c/0xac
    [<80032b38>] warn_slowpath_fmt+0x2c/0x38
    [<80076524>] register_console+0x244/0x3fc
    [<805d8314>] of_setup_earlycon+0x74/0x98
    [<805daa40>] early_init_dt_scan_chosen_serial+0x104/0x134
    [<805c51a0>] do_early_param+0xc4/0x13c
    [<8004efa0>] parse_args+0x284/0x444
    [<805c56cc>] parse_early_options+0x34/0x40
    [<805c5714>] parse_early_param+0x3c/0x58
    [<805c87a4>] setup_arch+0xec/0x6e4
    [<805c57d4>] start_kernel+0x94/0x458

    ---[ end trace dc8fa200cb88537f ]---

In this case the duplicate "earlycon" was entered directly, but there are
other cases where this could happen inadvertently:

 - Some platforms allow user bootargs to be concatenated with builtin
   bootargs, e.g. CONFIG_CMDLINE_EXTEND.

 - Other platforms may want to hardwire earlycon to ON, so it isn't
   nice if a user manually specifying "earlycon" on the command line sees
   a big scary warning.

So, we will treat "earlycon" as a flag, and if happens to be requested
multiple times the kernel will not print any warnings.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 drivers/of/fdt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1ffca8..20193cc 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -755,6 +755,11 @@ int __init early_init_dt_scan_chosen_serial(void)
 	int l;
 	const struct of_device_id *match = __earlycon_of_table;
 	const void *fdt = initial_boot_params;
+	static int done;
+
+	if (done)
+		return -EBUSY;
+	done = 1;
 
 	offset = fdt_path_offset(fdt, "/chosen");
 	if (offset < 0)
@@ -792,10 +797,9 @@ int __init early_init_dt_scan_chosen_serial(void)
 
 static int __init setup_of_earlycon(char *buf)
 {
-	if (buf)
-		return 0;
-
-	return early_init_dt_scan_chosen_serial();
+	if (!buf)
+		early_init_dt_scan_chosen_serial();
+	return 0;
 }
 early_param("earlycon", setup_of_earlycon);
 #endif
-- 
2.1.1


  parent reply	other threads:[~2014-10-20 20:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 20:53 [PATCH V2 0/9] bcm63xx_uart and of-serial updates Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 1/9] tty: serial: bcm63xx: Allow bcm63xx_uart to be built on other platforms Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 2/9] tty: serial: bcm63xx: Update the Kconfig help text Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 3/9] tty: serial: bcm63xx: Fix typo in MODULE_DESCRIPTION Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 4/9] Documentation: DT: Add entries for bcm63xx UART Kevin Cernekee
2014-10-20 21:20   ` Arnd Bergmann
2014-10-20 21:25     ` Arnd Bergmann
2014-10-20 22:53       ` Florian Fainelli
2014-10-21  5:49         ` Arnd Bergmann
2014-10-20 20:54 ` [PATCH V2 5/9] tty: serial: bcm63xx: Enable DT earlycon support Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 6/9] tty: serial: bcm63xx: Eliminate unnecessary request/release functions Kevin Cernekee
2014-10-20 20:54 ` Kevin Cernekee [this message]
2014-10-20 20:54 ` [PATCH V2 8/9] tty: serial: of-serial: Allow OF earlycon to default to "on" Kevin Cernekee
2014-10-20 20:54 ` [PATCH V2 9/9] MAINTAINERS: Add entry for rp2 (Rocketport Express/Infinity) driver Kevin Cernekee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413838448-29464-8-git-send-email-cernekee@gmail.com \
    --to=cernekee@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jogo@openwrt.org \
    --cc=jslaby@suse.cz \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mbizon@freebox.fr \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).