From: sashiko-bot@kernel.org
To: "Petr Mladek" <pmladek@suse.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH 2/2] braille: nbcon: Use nbcon atomic console callbacks
Date: Tue, 22 Sep 2026 07:37:27 +0000 [thread overview]
Message-ID: <20260922073728.2ADCD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922072558.98854-3-pmladek@suse.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] braille: operator precedence bug disables braille atomic write
- [High] braille: infinite spinlock in braille_write() during same-CPU unsafe takeover
--
commit a7f38c0383481bd6ad9c244405d8d201d604569b
Author: Petr Mladek <pmladek@suse.com>
braille: nbcon: Use nbcon atomic console callbacks
This commit adapts the braille console driver to support the new NBCON API.
It introduces logic to acquire the nbcon console ownership before printing
and uses the atomic write callback to output the buffer. The serial8250
driver is also adjusted to skip prepending newlines for braille consoles.
> diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c
> --- a/drivers/accessibility/braille/braille_console.c
> +++ b/drivers/accessibility/braille/braille_console.c
> @@ -62,14 +62,32 @@ static void braille_write(u16 *buf)
[ ... ]
> + if (braille_co->flags & CON_NBCON) {
> + /*
> + * Braille console might be called from unknown context via
> + * vt_console_print() from console_unlock() from printk().
> + * Use the atomic callback and synchronize it just using
> + * the console context. Disable interrupts to prevent a nested
> + * call into the driver code which might cause a deadlock when
> + * trying to acquire the console ownership, see
> + * __nbcon_atomic_flush_pending_con().
> + */
> + local_irq_save(flags);
> + while (!nbcon_braille_try_acquire(braille_co, &wctxt))
> + cpu_relax();
[Severity: High]
Could this loop become an infinite spinlock if triggered from a nested
context on the same CPU?
If an interrupt preempts the underlying nbcon console driver (such as 8250)
while it is in an unsafe region, and that interrupt triggers a printk(),
the legacy VT console might be flushed via console_unlock(), eventually
calling braille_write().
Since local interrupts are disabled here, the preempted nbcon context on
this same CPU can never resume to release the console. Because
nbcon_context_try_acquire() rejects handovers to the same CPU when the
console is in an unsafe state, won't this loop spin indefinitely?
[ ... ]
> - braille_co->write(braille_co, data, c - data);
> + if (braille_co->flags & CON_NBCON) {
> + if (braille_co->write_atomic &&
> + !braille_co->flags & CON_NBCON_ATOMIC_UNSAFE) {
[Severity: High]
Does this operator precedence evaluate as intended?
Because the logical not (!) operator has higher precedence than the bitwise
and (&) operator, this expression parses as:
(!braille_co->flags) & CON_NBCON_ATOMIC_UNSAFE
Since braille_co->flags is known to be non-zero (as CON_NBCON was just
checked above), evaluating the logical not against the flags yields 0. This
makes the condition permanently false, which bypasses the braille atomic
write callback unconditionally.
Should this be grouped with parentheses to evaluate the bitwise and first?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922072558.98854-1-pmladek@suse.com?part=2
next prev parent reply other threads:[~2026-09-22 7:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 7:25 [PATCH 0/2] braille: nbcon: Allow using a serial driver converted to nbcon API as a Braille console Petr Mladek
2026-09-22 7:25 ` [PATCH 1/2] printk: nbcon: Introduce Braille helpers Petr Mladek
2026-09-22 7:32 ` sashiko-bot
2026-09-25 13:48 ` John Ogness
2026-09-25 14:34 ` Petr Mladek
2026-09-27 18:47 ` Samuel Thibault
2026-09-22 7:25 ` [PATCH 2/2] braille: nbcon: Use nbcon atomic console callbacks Petr Mladek
2026-09-22 7:37 ` sashiko-bot [this message]
2026-09-23 14:39 ` Petr Mladek
2026-09-25 14:34 ` John Ogness
2026-09-24 23:53 ` [PATCH 0/2] braille: nbcon: Allow using a serial driver converted to nbcon API as a Braille console Samuel Thibault
2026-09-25 13:08 ` John Ogness
2026-09-25 14:10 ` Petr Mladek
2026-09-25 14:36 ` John Ogness
2026-09-25 14:49 ` Petr Mladek
2026-09-25 15:05 ` John Ogness
2026-09-25 15:41 ` Petr Mladek
2026-09-25 19:05 ` John Ogness
2026-09-29 12:52 ` Petr Mladek
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=20260922073728.2ADCD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pmladek@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox