From: Jisheng Zhang <jszhang@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: [PATCH] tty: hvc: riscv_sbi: instantiate the legcay console earlier
Date: Mon, 14 Oct 2024 08:08:57 +0800 [thread overview]
Message-ID: <20241014000857.3032-1-jszhang@kernel.org> (raw)
The hvc_instantiate() is an early console discovery mechanism, it is
usually called before allocating hvc terminal devices. In fact, if
we check hvc_riscv_sbi's hvc_instantiate() return value, we'll find
that it's -1. So the calling hvc_instantiate() is too late.
We can remove the hvc_instantiate() to only rely on the hvc_alloc() to
register the kernel console. We can also move its calling earlier so
the kernel console is registered earlier, so that we can get kernel
console msg earlier. We take the 2nd choice in this patch.
Before the patch:
[ 0.367440] printk: legacy console [hvc0] enabled
[ 0.401397] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
After the patch:
[ 0.004665] printk: legacy console [hvc0] enabled
[ 0.050183] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=100000)
As can be seen, now the kernel console is registered much earlier before
the BogoMIPS calibrating.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
drivers/tty/hvc/hvc_riscv_sbi.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/hvc/hvc_riscv_sbi.c b/drivers/tty/hvc/hvc_riscv_sbi.c
index cede8a572594..d2ecfbf7c84a 100644
--- a/drivers/tty/hvc/hvc_riscv_sbi.c
+++ b/drivers/tty/hvc/hvc_riscv_sbi.c
@@ -68,12 +68,10 @@ static int __init hvc_sbi_init(void)
err = PTR_ERR_OR_ZERO(hvc_alloc(0, 0, &hvc_sbi_dbcn_ops, 256));
if (err)
return err;
- hvc_instantiate(0, 0, &hvc_sbi_dbcn_ops);
} else if (IS_ENABLED(CONFIG_RISCV_SBI_V01)) {
err = PTR_ERR_OR_ZERO(hvc_alloc(0, 0, &hvc_sbi_v01_ops, 256));
if (err)
return err;
- hvc_instantiate(0, 0, &hvc_sbi_v01_ops);
} else {
return -ENODEV;
}
@@ -81,3 +79,18 @@ static int __init hvc_sbi_init(void)
return 0;
}
device_initcall(hvc_sbi_init);
+
+static int __init hvc_sbi_console_init(void)
+{
+ int err;
+
+ if (sbi_debug_console_available)
+ err = hvc_instantiate(0, 0, &hvc_sbi_dbcn_ops);
+ else if (IS_ENABLED(CONFIG_RISCV_SBI_V01))
+ err = hvc_instantiate(0, 0, &hvc_sbi_v01_ops);
+ else
+ return -ENODEV;
+
+ return err < 0 ? -ENODEV : 0;
+}
+console_initcall(hvc_sbi_console_init);
--
2.45.2
next reply other threads:[~2024-10-14 1:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 0:08 Jisheng Zhang [this message]
2024-10-14 6:10 ` [PATCH] tty: hvc: riscv_sbi: instantiate the legcay console earlier Greg Kroah-Hartman
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=20241014000857.3032-1-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/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).