Linux Serial subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: shatyuka@qq.com
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: hvc: dcc: Detect JTAG connection only on CPU core 0
Date: Mon, 12 Oct 2026 15:30:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-168336@kernel.org> (raw)
In-Reply-To: <tencent_323D31BEC6A1CD2A843E2E48242C774ECE09@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tty: hvc: dcc: Meaningful code and commit message mismatch
--

commit 0189cf9a56296b2c974669020e309b13432dff40
Author: Shatyuka <shatyuka@qq.com>

tty: hvc: dcc: Detect JTAG connection only on CPU core 0

This commit aims to prevent system hangs caused by SMP migration during JTAG
DCC detection by caching the availability status. It simplifies the logic by
performing the check once and reusing the cached value.

>    Multiple checks are unnecessary: nobody is going to plug/unplug JTAG
>    during kernel boot and expect it to work. Cache the return value of
>    hvc_dcc_check() from device_initcall and reuse the cached value during
>    console_initcall. This avoids complex SMP-related code and ensures the
>    result is always from core 0.

[Severity: Medium]
Is the direction of the caching described correctly here?

The code implementation seems to do the opposite: it caches the value during
console_initcall and reuses it during device_initcall.

> diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
> index dfc5c9c38f074..fc8dcbce9b5b1 100644
> --- a/drivers/tty/hvc/hvc_dcc.c
> +++ b/drivers/tty/hvc/hvc_dcc.c

[ ... ]

> @@ -265,7 +250,8 @@ static int __init hvc_dcc_console_init(void)
>  {
>  	int ret;
>  
> -	if (!hvc_dcc_check())
> +	dcc_core0_available = hvc_dcc_check();
> +	if (!dcc_core0_available)
>  		return -ENODEV;

[Severity: Medium]
Is the return value of hvc_dcc_check() actually cached here in
hvc_dcc_console_init() during console_initcall, contradicting the commit
message?

>  
>  	/* Returns -1 if error */
> @@ -279,7 +265,7 @@ static int __init hvc_dcc_init(void)
>  {
>  	struct hvc_struct *p;
>  
> -	if (!hvc_dcc_check())
> +	if (!dcc_core0_available)
>  		return -ENODEV;

[Severity: Medium]
Could this be the exact reverse of what is stated in the commit message,
since the cached value is reused here in hvc_dcc_init() during
device_initcall?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_323D31BEC6A1CD2A843E2E48242C774ECE09@qq.com?part=1

      reply	other threads:[~2026-10-12 15:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 15:17 [PATCH] tty: hvc: dcc: Detect JTAG connection only on CPU core 0 shatyuka
2026-10-12 15:30 ` 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-168336@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shatyuka@qq.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