Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: linux-serial@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v5 2/5] serial: serialize asynchronous write wakeups with the port lock
Date: Sat, 24 Oct 2026 06:50:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-183574@kernel.org> (raw)
In-Reply-To: <20261024-submit-serial-8250-dma-cancel-v1-v5-2-9e52968928d2@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] serial: clps711x: deadlock between uart_clps711x_int_tx() and stop_tx()
--

commit dc0a2d4e309be9916a0d844a2a8caf7397942a8f
Author: James Hilliard <james.hilliard1@gmail.com>

serial: serialize asynchronous write wakeups with the port lock

This commit acquires the UART port lock around asynchronous write wakeups
and transmit helpers in several serial drivers so that uart_write_wakeup()
is serialized with port-locked serial-core state changes.

> diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
> index 83186bf500027..054b9d8359de2 100644
> --- a/drivers/tty/serial/clps711x.c
> +++ b/drivers/tty/serial/clps711x.c
> @@ -174,8 +174,10 @@ static irqreturn_t uart_clps711x_int_tx(int irq, void *dev_id)
>  			break;
>  	}
>  
> -	if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
> -		uart_write_wakeup(port);
> +	scoped_guard(uart_port_lock_irqsave, port) {
> +		if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
> +			uart_write_wakeup(port);
> +	}

[Severity: High]
Can acquiring port->lock in uart_clps711x_int_tx() deadlock with
uart_clps711x_stop_tx()?

The serial core invokes uart_ops->stop_tx() (uart_clps711x_stop_tx()) with
port->lock held, for example during uart_stop(), uart_flush_buffer(), or
uart_port_shutdown(). Inside uart_clps711x_stop_tx(), it calls synchronous
disable_irq(port->irq) while holding port->lock:

drivers/tty/serial/clps711x.c:uart_clps711x_stop_tx() {
	struct clps711x_port *s = dev_get_drvdata(port->dev);

	if (s->tx_enabled) {
		disable_irq(port->irq);
		s->tx_enabled = 0;
	}
}

If uart_clps711x_int_tx() is running concurrently (on another CPU or in a
threaded interrupt handler) and attempts to acquire port->lock while
uart_clps711x_stop_tx() holds port->lock and waits inside
disable_irq(port->irq) for the interrupt handler to complete, won't both
contexts deadlock waiting on each other?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261024-submit-serial-8250-dma-cancel-v1-v5-0-9e52968928d2@gmail.com?part=2

  reply	other threads:[~2026-10-24  6:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  6:40 [PATCH v5 0/5] serial: 8250: serialize DMA cancellation with buffer reuse James Hilliard
2026-10-24  6:40 ` [PATCH v5 1/5] serial: 8250_omap: separate locked TX DMA completion processing James Hilliard
2026-10-24  6:40 ` [PATCH v5 2/5] serial: serialize asynchronous write wakeups with the port lock James Hilliard
2026-10-24  6:50   ` sashiko-bot [this message]
2026-10-25  5:10   ` Maciej W. Rozycki
2026-10-25 15:09     ` Andy Shevchenko
2026-10-25 20:25       ` James Hilliard
2026-10-25 20:44         ` Andy Shevchenko
2026-10-25 22:11           ` James Hilliard
2026-10-26  9:31             ` Andy Shevchenko
2026-10-26 16:45               ` James Hilliard
2026-10-26 19:53                 ` Andy Shevchenko
2026-10-26 19:59                   ` James Hilliard
2026-10-26 20:17                     ` Greg Kroah-Hartman
2026-10-26 20:24                       ` James Hilliard
2026-10-26 20:40                         ` Greg Kroah-Hartman
2026-10-26 20:49                           ` James Hilliard
2026-10-26 21:23                             ` Andy Shevchenko
2026-10-26 21:36                             ` Maciej W. Rozycki
2026-10-26 20:18                     ` Andy Shevchenko
2026-10-25 18:47     ` James Hilliard
2026-10-24  6:40 ` [PATCH v5 3/5] serial: core: allow drivers to reserve flushed transmit storage James Hilliard
2026-10-24  6:40 ` [PATCH v5 4/5] serial: 8250: drain canceled TX DMA before reusing its buffer James Hilliard
2026-10-24  6:40 ` [PATCH v5 5/5] serial: 8250: retire canceled RX DMA before reusing the receive buffer James Hilliard
2026-10-24  7:24   ` sashiko-bot

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-183574@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=james.hilliard1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox