Re: [PATCH] tty: hvc: dcc: Detect JTAG connection only on CPU core 0
From: Greg Kroah-Hartman
Date: Tue Oct 13 2026 - 09:32:51 EST
On Mon, Oct 12, 2026 at 11:17:33PM +0800, shatyuka@xxxxxx wrote:
> From: Shatyuka <shatyuka@xxxxxx>
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@xxxxxx>
> ---
> 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