From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380224; b=Z6lDt/rHjVY8Uveo6soh/4x1rFOIsEDW5dirqt9DYL7YTH7tNKMEtKz8ATiSXjRikhJc MDLRSf73Zh3To7if6AwB6kAJ+vcjSb0quihoXoih9jt1s7mC0/LBo0kj8osOB0D354OSH eP9UNCg1zLRJTFwcXfaxtZqNe883BaIXF7rH08ntb3yMbtmSO2DW75oCOLWVjTdJeZ3GH YlfzY56TwN5kdAncEFzXfhOQVXOi9MMoSeyrvBWk56KneNnsOqRxKBpfLu0yW6zfm60j/ 4FpmW9IrqexZNkb3KJuT3UmjsNnjZO3cx5LxIS8QvKkX7Cc/aSZSdGrcUpd3l2QHYrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380224; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Y1/M2WFMw1cPjbcPKLJvDsoCq5gUhk0dGt3wxqn+5v8=; b=yngWhqwRX6BUOq6Cw2EaiFYP/mDCNvVFv8zhd8Dkp8ob+/W5u2cJVOYFjn74kl94y/ee A+KufJS4chbqdfcp4/dDvfBjPq1Hs0TSWXjFkzxjdClrvaeKb76w/yZYzUe2rMoriknTM 6rCILMhgMyU8sXeX6lfQXap1pAjd9b+yK2yCbeBR4QfDWdd6Nmqg3bCsgV6bOukKtaO9V evQaHiLXHS05B8cN5Kqt6qITErcxrW5LT5fya8KhggQBpjMDazQfc8O6QiNdDPe//vrYO jjpdOcOR+o9nlIEZY2upvf/ppduDXuF80X8oKGPbST9g9EHK/xDUo9nhb0RdYpgrMMA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BMTXNy2X; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48490606A32D; Fri, 4 Dec 2026 10:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BMTXNy2X Received: by smtp.kernel.org (Postfix) with ESMTPSA id E42241F00934; Fri, 4 Dec 2026 10:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380224; bh=Y1/M2WFMw1cPjbcPKLJvDsoCq5gUhk0dGt3wxqn+5v8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BMTXNy2XUjkBWwRsmwzCWhJcn3SrdOnC1BpIZFp2akDADekaOTLql4cWs8XepUl/i K2TEMQzmGwLHCQ/H9Pi1exooxrTV0V0WSfTg4Tv4go5z5nGAVY9mMQ25GjJe786EWC 6EJs2rdBEaMhbPQQ4+HbMmrcFPaN5xhESSXzr6UUnPs5GmKQNSs/k/knxhlmkp1oSv pAUyqF2x1WY7ddnAJ+H+oLAigGhUgs1ri385BXHI9V4GEcy4jY+OfKDInZAhf8l2Vw YmE8NleN2Rwk79on0/JpeLFlSGusWUfcUB0yYQonwPXhPuClHPSBp3XUvcss3wDW6/ qimkN/0UdgaBQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 2/8] serial: serialize asynchronous write wakeups with the port lock Reply-To: sashiko-reviews@lists.linux.dev To: "James Hilliard" Cc: linux-serial@vger.kernel.org, imx@lists.linux.dev, Frank.Li@kernel.org In-Reply-To: <20261204-submit-serial-8250-dma-cancel-v1-v14-2-b691fec8097d@gmail.com> References: <20261204-submit-serial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com> <20261204-submit-serial-8250-dma-cancel-v1-v14-2-b691fec8097d@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:30:23 +0000 X-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] serial: zs: deadlock from calling schedule_work() in zs_console_write() - [Medium] serial: sb1250-duart: 20ms IRQ-off spin in sbd_set_termios() - [Medium] serial: atmel: IRQ-disabling lock held across full RX/TX tasklet execution -- commit 99c0892280c906bd3d8025ef585adcd610824380 Author: James Hilliard serial: serialize asynchronous write wakeups with the port lock This commit adds UART port locking around asynchronous write wakeups, modem-status handling, and transmit paths across 20 serial drivers, and defers DECstation ZS transmit restarts after console output to a workqueue. > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel= _serial.c > index c3880259e3bce..4c3a6e10d92f2 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c [ ... ] > @@ -1702,10 +1704,9 @@ static void atmel_tasklet_rx_func(struct tasklet_s= truct *t) > tasklet_rx); > struct uart_port *port =3D &atmel_port->uart; > =20 > - /* The interrupt handler does not take the lock */ > - uart_port_lock(port); > + guard(uart_port_lock_irqsave)(port); > + > atmel_port->schedule_rx(port); > - uart_port_unlock(port); > } > =20 > static void atmel_tasklet_tx_func(struct tasklet_struct *t) > @@ -1714,10 +1715,9 @@ static void atmel_tasklet_tx_func(struct tasklet_s= truct *t) > tasklet_tx); > struct uart_port *port =3D &atmel_port->uart; > =20 > - /* The interrupt handler does not take the lock */ > - uart_port_lock(port); > + guard(uart_port_lock_irqsave)(port); > + > atmel_port->schedule_tx(port); > - uart_port_unlock(port); > } [Severity: Medium] Does holding uart_port_lock_irqsave() across the full schedule_rx() and schedule_tx() callbacks regress hardirq latency and risk RX overruns? Every RX and TX tasklet run now keeps local hardware interrupts disabled across expensive hot-path work. In atmel_rx_from_dma(), dmaengine_tx_statu= s() busy-waits for the hardware FIFO flush in at_xdmac_tx_status(), followed by two 4KB non-coherent DMA cache syncs and tty_insert_flip_string(). In PIO mode, atmel_rx_from_ring() drains up to 1024 buffered characters with local interrupts masked. On single-core AT91/SAMA5 SoCs, that prevents hardirq atmel_rx_chars() from emptying the 1-byte RHR and risks hardware RX overruns. Narrowing the port lock inside the schedule_rx() and schedule_tx() paths so DMA status polling, cache syncs, and flip-buffer work run with interrupts enabled would avoid this regression. [ ... ] > diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb125= 0-duart.c > index b4e1b90e59608..55179e5dcb51c 100644 > --- a/drivers/tty/serial/sb1250-duart.c > +++ b/drivers/tty/serial/sb1250-duart.c [ ... ] > @@ -611,7 +617,7 @@ static void sbd_set_termios(struct uart_port *uport, = struct ktermios *termios, > else > aux &=3D ~M_DUART_CTS_CHNG_ENA; > =20 > - uart_port_lock(uport); > + guard(uart_port_lock_irqsave)(uport); > =20 > if (sport->tx_stopped) > command |=3D M_DUART_TX_DIS; > @@ -632,8 +638,6 @@ static void sbd_set_termios(struct uart_port *uport, = struct ktermios *termios, > write_sbdchn(sport, R_DUART_AUXCTL_X, aux | oldaux); > =20 > write_sbdchn(sport, R_DUART_CMD, command); > - > - uart_port_unlock(uport); > } [Severity: Medium] Can switching sbd_set_termios() to uart_port_lock_irqsave() disable local hardware interrupts for over 20 ms? Inside this critical section, sbd_set_termios() calls sbd_line_drain() when !sport->tx_stopped. sbd_line_drain() busy-waits with udelay(2) for up to 10,000 iterations waiting for M_DUART_TX_EMT without dropping the lock or re-enabling interrupts. At low baud rates while the TX FIFO is draining, this stalls all local interrupts on the CPU, causing timer latency spikes and RX overruns on other ports. Dropping and reacquiring the lock around udelay(2) in sbd_line_drain(), as zs_line_drain() does, would avoid the long IRQ-off spi= n. [ ... ] > diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c > index 8f92b4129a385..6126dee0301d9 100644 > --- a/drivers/tty/serial/zs.c > +++ b/drivers/tty/serial/zs.c [ ... ] > @@ -1161,9 +1204,12 @@ static void zs_console_write(struct console *co, c= onst char *s, > zport->regs[1] |=3D TxINT_ENAB; > write_zsreg(zport, R1, zport->regs[1]); > =20 > - /* Resume any transmission as the TxIP bit won't be set. */ > + /* > + * TxIP won't be set. Defer the restart: console output may be > + * called with the port lock held, and TX must acquire it first. > + */ > if (!zport->tx_stopped) > - zs_raw_transmit_chars(zport); > + schedule_work(&zport->tx_work); > } > spin_unlock_irqrestore(&scc->zlock, flags); > } [Severity: High] Could calling schedule_work() from zs_console_write() deadlock the kernel? zs_console_write() is a legacy console->write callback invoked synchronously from printk(), WARN_ON(), and panic paths with interrupts disabled. Calling schedule_work() acquires workqueue pool->lock and scheduler locks (p->pi_lo= ck and rq->__lock) while holding scc->zlock. If any warning, oops, or panic prints while pool->lock or a scheduler lock = is held, it recurses into zs_console_write() and deadlocks: destroy_workqueue() raw_spin_lock_irq(&pwq->pool->lock) WARN_ON(pwq_busy(pwq)) printk() -> console_emit_next_record() -> zs_console_write() spin_lock_irqsave(&scc->zlock, flags) schedule_work(&zport->tx_work) __queue_work() raw_spin_lock(&pool->lock) <-- spins forever Since zs_tx_work() does not sleep, deferring the TX restart with lockless irq_work_queue() and synchronizing with irq_work_sync() (as in qcom_geni_serial.c) would avoid taking workqueue or scheduler locks from console output. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-submit-ser= ial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com?part=3D2