From: sashiko-bot@kernel.org
To: "Magnus Lindholm" <linmag7@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v4 10/10] hvc: add an M3000 firmware console backend
Date: Sun, 18 Oct 2026 14:09:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-176185@kernel.org> (raw)
In-Reply-To: <20261018134738.1016106-11-linmag7@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] hvc: hvc_m3000 fails to register console when CONFIG_VT_CONSOLE=y
- [Low] tty: hvc_m3000: ineffective window size initialization in m3000_tty_init()
--
commit 7a0bedd3c2b41c2e4d2aba3f69c932366fc243a8
Author: Magnus Lindholm <linmag7@gmail.com>
hvc: add an M3000 firmware console backend
This commit adds an HVC console backend for the Fujitsu M3000 (IKKAKU
platform) using the Open Firmware pseudo-console via the SPARC p1275
interface. It registers hvc0 after validating the firmware model and console
endpoints, polling input with a timer while the TTY is open.
> diff --git a/drivers/tty/hvc/hvc_m3000.c b/drivers/tty/hvc/hvc_m3000.c
> new file mode 100644
> index 0000000000000..e2150d4793080
> --- /dev/null
> +++ b/drivers/tty/hvc/hvc_m3000.c
> @@ -0,0 +1,202 @@
[ ... ]
> +static int __init m3000_console_init(void)
> +{
> + struct m3000_console *con = &m3000_consoles[0];
> + phandle node;
> + int ret;
> +
> + if (tlb_type != sparc64_vii)
> + return -ENODEV;
> + if (!m3000_property_matches(prom_finddevice("/"), "model", "IKKAKU"))
> + return -ENODEV;
> + con->stdin = prom_getint(prom_chosen_node, "stdin");
> + if (!con->stdin || con->stdin == -1 || !prom_stdout || prom_stdout == -1)
> + return -ENODEV;
> + node = prom_inst2pkg(prom_stdout);
> + if (!m3000_property_matches(node, "name", "pseudo-console"))
> + return -ENODEV;
> + node = prom_inst2pkg(con->stdin);
> + if (!m3000_property_matches(node, "name", "pseudo-console"))
> + return -ENODEV;
> + ret = hvc_instantiate(0, 0, &m3000_ops);
> + if (ret < 0)
> + return ret;
> + con->ready = true;
> + return 0;
> +}
> +console_initcall(m3000_console_init);
[Severity: Medium]
When booting with CONFIG_VT_CONSOLE=y (which is enabled in sparc64_defconfig)
and without an explicit console=hvc0 command-line parameter, will hvc0 fail
to register as the kernel console here?
During console_init(), con_init() in drivers/tty/vt/vt.c runs before the hvc
console initcalls because vt/ precedes hvc/ in drivers/tty/Makefile. With no
preferred console selected yet, register_console(&vt_console_driver) enables
tty0 (backed by dummy_con) via try_enable_default_console() and unregisters
prom_early_console.
Next, hvc_console_init() in drivers/tty/hvc/hvc_console.c runs (linked before
hvc_m3000.o in drivers/tty/hvc/Makefile) and calls
register_console(&hvc_console). In kernel/printk/printk.c:register_console():
if (preferred_console < 0) {
if (hlist_empty(&console_list) || !console_first()->device ||
console_first()->flags & CON_BOOT) {
try_enable_default_console(newcon);
}
}
Because console_first() is now vt_console_driver (which has a non-NULL
.device and does not have CON_BOOT set), try_enable_default_console() is
skipped and hvc_console.index remains -1.
When m3000_console_init() then runs and calls
hvc_instantiate(0, 0, &m3000_ops) -> hvc_check_console(0):
if (index == hvc_console.index)
register_console(&hvc_console);
Because hvc_console.index is -1 rather than 0, and add_preferred_console()
was never called, register_console(&hvc_console) is not invoked, leaving the
system without kernel console output after prom_early_console is unregistered.
Should m3000_console_init() call add_preferred_console("hvc", 0, NULL) before
hvc_instantiate() (or before hvc_console_init() runs) when Open Firmware's
stdout/stdin are verified to be pseudo-console?
> +
> +static int __init m3000_tty_init(void)
> +{
> + struct m3000_console *con = &m3000_consoles[0];
> + struct hvc_struct *hp;
> +
> + if (!con->ready)
> + return -ENODEV;
> + timer_setup(&con->poll_timer, m3000_poll_tick, 0);
> + hp = hvc_alloc(0, 0, &m3000_ops, sizeof(con->buffer));
> + if (IS_ERR(hp))
> + return PTR_ERR(hp);
> + hp->ws.ws_row = 24;
> + hp->ws.ws_col = 80;
> + return 0;
> +}
> +device_initcall(m3000_tty_init);
[Severity: Low]
Does setting hp->ws.ws_row and hp->ws.ws_col directly in m3000_tty_init()
actually propagate the 80x24 window size to the TTY when /dev/hvc0 is opened?
In drivers/tty/hvc/hvc_console.c, neither hvc_install() nor hvc_open() reads
hp->ws. The only consumer of hp->ws is the workqueue callback
hvc_set_winsz():
tty = tty_port_tty_get(&hp->port);
if (!tty)
return;
spin_lock_irqsave(&hp->lock, hvc_flags);
ws = hp->ws;
spin_unlock_irqrestore(&hp->lock, hvc_flags);
tty_do_resize(tty, &ws);
hvc_set_winsz() only runs when hp->tty_resize is scheduled via hvc_resize()
or __hvc_resize(), and requires a tty_struct to already be attached to
hp->port (which happens in hvc_open() via tty_port_tty_set() right before
hp->ops->notifier_add is called).
Should this use hvc_resize(hp, ws) inside m3000_open() instead so that
hvc_set_winsz() is scheduled once the TTY is attached?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261018134738.1016106-1-linmag7@gmail.com?part=10
prev parent reply other threads:[~2026-10-18 14:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 13:45 [PATCH v4 00/10] sparc64: add Fujitsu M3000 support Magnus Lindholm
2026-10-18 13:45 ` [PATCH v4 01/10] sparc64: return from the generic clear_page implementation Magnus Lindholm
2026-10-18 13:52 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 02/10] sparc64: honor queued spinlock layout in secondary startup Magnus Lindholm
2026-10-18 14:01 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 03/10] sparc64: avoid huge kernel PUD mappings with small hardware pages Magnus Lindholm
2026-10-18 13:53 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 04/10] sparc64: stop IRQ setup when descriptor allocation fails Magnus Lindholm
2026-10-18 13:52 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 05/10] sparc64: validate Fire register properties before initialization Magnus Lindholm
2026-10-18 13:52 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 06/10] sparc64: retain the DMA segment start across SG entries Magnus Lindholm
2026-10-18 13:52 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 07/10] sparc64: zero newly allocated IOMMU page tables Magnus Lindholm
2026-10-18 13:52 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 08/10] sparc64: add SPARC64 VII CPU, MMU and SMP support Magnus Lindholm
2026-10-18 14:22 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 09/10] sparc64: add M3000 Oberon PCIe support Magnus Lindholm
2026-10-18 13:57 ` sashiko-bot
2026-10-18 13:45 ` [PATCH v4 10/10] hvc: add an M3000 firmware console backend Magnus Lindholm
2026-10-18 14:09 ` sashiko-bot [this message]
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=sashiko-outbox-176185@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linmag7@gmail.com \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.