Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: shatyuka@qq.com
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty: hvc: dcc: Detect JTAG connection only on CPU core 0
Date: Tue, 13 Oct 2026 15:05:46 +0200	[thread overview]
Message-ID: <2026101305-maritime-wilder-2006@gregkh> (raw)
In-Reply-To: <tencent_323D31BEC6A1CD2A843E2E48242C774ECE09@qq.com>

On Mon, Oct 12, 2026 at 11:17:33PM +0800, shatyuka@qq.com wrote:
> From: Shatyuka <shatyuka@qq.com>

Real name please.

> 
> On SMP, migration can occur inside hvc_dcc_check() during
> device_initcall, so the CPU writing the probe character and the CPU
> reading the TXfull status may not be the same, which can hang the
> system.
> 
> Commit 4419da5d5d4b1788568b ("tty: hvc: dcc: Bind driver to CPU core0
> for reads and writes") cached the DCC availability detected on core 0
> during console_initcall. However, this is not sufficient: if DCC is
> not detected as available and another CPU later calls
> hvc_dcc_check(), the check is not actually performed on core 0.
> 
> 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.
> 
> Signed-off-by: Shatyuka <shatyuka@qq.com>
> ---
>  drivers/tty/hvc/hvc_dcc.c | 30 ++++++++----------------------
>  1 file changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
> index dfc5c9c38f07..fc8dcbce9b5b 100644
> --- a/drivers/tty/hvc/hvc_dcc.c
> +++ b/drivers/tty/hvc/hvc_dcc.c
> @@ -29,6 +29,9 @@ static DEFINE_SPINLOCK(dcc_lock);
>  static DEFINE_KFIFO(inbuf, u8, DCC_INBUF_SIZE);
>  static DEFINE_KFIFO(outbuf, u8, DCC_OUTBUF_SIZE);
>  
> +/* Cached result of hvc_dcc_check() */
> +static bool dcc_core0_available;

Shouldn't this be per-device?

And how was this tested?

thanks,

greg k-h

  parent reply	other threads:[~2026-10-13 13:05 UTC|newest]

Thread overview: 4+ 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
2026-10-13 13:05 ` Greg Kroah-Hartman [this message]
2026-10-13 14:53   ` shatyuka

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=2026101305-maritime-wilder-2006@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --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