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=1796380265; b=d7qUZyiLRb5zRKYHLoEelHxMjYMsrAJ/xalMdMYOBBGOJIu33uq2C3W6gzBzMwAMYqwp iFPMYyqn6eDceChYuYlVX2uARY5VVLZvk8ndIw6itw0Ygub/wG9aqj6EiUfyivZPvA4B2 T5oFOaUbbWRler1w8nTpYq7BbHkCpOkEawkO5a6N1yl/FdNpCKXEsvFvEGUmyR3AJ379R a+jEsOIeyzWeGLwej1e5QFpk6AXAonWGFQj6Mnor0C21Jst2evh4DsNAjmNQbduIsX9VV LGBGsHOKUADKk93oNqM3BtlNLoD2x/5w5m0M+V58npzVwJ02O1a5k6oYw8+0iIoM9FA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380265; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Fb4+Ijka0s7M7jXpSFBx6ZH8wg4DEVWIyiOMKYoB1qk=; b=dmhvuHCt4WWVF+/Vf8iZ9RkD+HemXHJn5D4NM7ivAfNb2MtLjvCuvPMawF16zP3kHbKZ HyciR5jYsqf+53gcuTU4OLppS2rZcvqtZ/h2zjzS5zNVYZo4deB25lWicciC+i5c8tAc9 oUl9fnF55cn/QQcpaTnXkeCorFQsrGrX1ftt93O4J+/WDds1NwE+CYmEshbSs2eJTRYRD 7nQhfHuOuhSeIRXHDB+j/1Wr1yfAPyGZ27YFaYdgpe1iecj1xaJKg7EalR7Pxj6TQ+TBA 6hgZjxBEE7mIa6wdIcbou7PV580a9iCv+FpTSuaQbI0DARYXIzo6G2pOW1RluRCgd/g== 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="SLpJ/i35"; 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 219D4606A322; Fri, 4 Dec 2026 10:31:05 +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=SLpJ/i35 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6E941F00931; Fri, 4 Dec 2026 10:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796380264; bh=Fb4+Ijka0s7M7jXpSFBx6ZH8wg4DEVWIyiOMKYoB1qk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SLpJ/i35jhkvSbibgwR7ELtF/03ZYmD+SxudaSrNFBkkAct3HAk8cIp2qg53MFK7W RnwCrUODgCOaSbLw7o1dMYjXbiWCljlkkAFpLwwHZYjwW8FG3osplXk95HzZOQJ53o t+L5/tRhIszsS46T6iAE75K+xWJViVQ1sP3hMB6g167nYmSorDxz+HieWlcyNJBpRs AbxcwYHSeuIaccnLTQYjZz2vG0WXEQM9oJYQfY97KceC9brTS0EU9rFtWWN6wPI1d5 JQSXCj7tKocXyQP+Y81hzunkyDy9ROjehEFOThrds2c/Z1xXkGs+xUfcN+ka/5v+Jx rUPfvi8NesKog== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v14 6/8] serial: 8250: drain canceled TX DMA before reusing its buffer 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-6-b691fec8097d@gmail.com> References: <20261204-submit-serial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com> <20261204-submit-serial-8250-dma-cancel-v1-v14-6-b691fec8097d@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 10:31:01 +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 1 potential issue to consider: - [Medium] serial: 8250: duplicate uart_write_wakeup() on flushed TX DMA completion -- commit 51a77130997322f4f64bf1629b8c2f64b1ab9074 Author: James Hilliard serial: 8250: drain canceled TX DMA before reusing its buffer This commit reserves the flushed TX FIFO storage and defers clearing tx_running to a workqueue that synchronizes the terminated DMA channel befo= re completing the transfer and unblocking writers. > diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250= /8250_dma.c > index 43c55cb991a52..739a8238e4dec 100644 > --- a/drivers/tty/serial/8250/8250_dma.c > +++ b/drivers/tty/serial/8250/8250_dma.c > @@ -11,34 +11,79 @@ > =20 > #include "8250.h" > =20 > -static void __dma_tx_complete(void *param) > +static void serial8250_tx_dma_complete(struct uart_8250_port *p) > { > - struct uart_8250_port *p =3D param; > struct uart_8250_dma *dma =3D p->dma; > - unsigned long flags; > int ret; > =20 > - uart_port_lock_irqsave(&p->port, &flags); > - if (dma->shutting_down) > - goto out; > - > dma_sync_single_for_cpu(dmaengine_get_dma_device(dma->txchan), dma->tx_= addr, > UART_XMIT_SIZE, DMA_TO_DEVICE); > =20 > dma->tx_running =3D 0; > =20 > - uart_xmit_advance(&p->port, dma->tx_size); > + if (dma->tx_flushed) { > + p->port.icount.tx +=3D dma->tx_size; > + uart_xmit_unblock(&p->port); > + } else { > + uart_xmit_advance(&p->port, dma->tx_size); > + } > =20 > uart_write_wakeup_if_needed(&p->port); [Severity: Medium] Does this invoke uart_write_wakeup() twice on every flushed TX DMA completion? uart_xmit_unblock() already calls uart_write_wakeup(). Because p->port.lock remains held and the flushed FIFO is empty, the following uart_write_wakeup_if_needed() always calls uart_write_wakeup() a second tim= e. On SMP, a writer woken by the first wakeup can re-arm TTY_DO_WRITE_WAKEUP before spinning on p->port.lock in uart_write(), letting the second wakeup consume that bit prematurely: CPU0 CPU1 serial8250_tx_dma_complete() [holds p->port.lock] uart_xmit_unblock(&p->port) uart_write_wakeup() ttyport_write_buf() set_bit(TTY_DO_WRITE_WAKEUP, ...) uart_write() spin on p->port.lock uart_write_wakeup_if_needed() uart_write_wakeup() ttyport_write_wakeup() test_and_clear_bit(TTY_DO_WRITE_WAKEUP, ...) <-- spurious wakeup The same pattern appears in omap_8250_tx_dma_complete(), where uart_xmit_unblock() also runs before omap8250_restore_regs(), waking writers to spin on p->port.lock during register restoration and widening the window between the two wakeups. Moving uart_write_wakeup_if_needed() into the else branch, and calling uart_xmit_unblock() after omap8250_restore_regs() on OMAP, would avoid both issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-submit-ser= ial-8250-dma-cancel-v1-v14-0-b691fec8097d@gmail.com?part=3D6