From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v3] serial: 8250: calculate TX length before preparing DMA flow control
Date: Fri, 04 Dec 2026 10:17:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-249584@kernel.org> (raw)
In-Reply-To: <20261204-submit-serial-8250-dma-tx-length-v1-v3-1-7a6250992bd6@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] serial: 8250: multi-SG TX wrap breaks RZ/N1 peripheral DMA flow
control
--
commit 657ef7e8d98bc808e1f5202a741d3828179f07d3
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250: calculate TX length before preparing DMA flow control
This commit moves serial8250_do_prepare_tx_dma() after the scatterlist
length summation in serial8250_tx_dma() so dma->tx_size reflects the
current transfer.
> diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
> index 1da605cc86011..2dc47adafec05 100644
> --- a/drivers/tty/serial/8250/8250_dma.c
> +++ b/drivers/tty/serial/8250/8250_dma.c
> @@ -110,8 +110,6 @@ int serial8250_tx_dma(struct uart_8250_port *p)
> return 0;
> }
>
> - serial8250_do_prepare_tx_dma(p);
> -
> sg_init_table(sgl, ARRAY_SIZE(sgl));
>
> ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, sgl, ARRAY_SIZE(sgl),
> @@ -122,6 +120,8 @@ int serial8250_tx_dma(struct uart_8250_port *p)
> for_each_sg(sgl, sg, ret, i)
> dma->tx_size += sg_dma_len(sg);
>
> + serial8250_do_prepare_tx_dma(p);
> +
> desc = dmaengine_prep_slave_sg(dma->txchan, sgl, ret,
> DMA_MEM_TO_DEV,
> DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
[Severity: High]
Can this read past the end of the TX kfifo buffer and stall TX DMA when
pending data wraps around UART_XMIT_SIZE?
When tport->xmit_fifo wraps, kfifo_dma_out_prepare_mapped() populates
both entries of sgl with two non-contiguous segments and returns 2.
Summing both into dma->tx_size makes dw8250_prepare_tx_dma() program
RZN1_UART_TDMACR for a single UART block covering both segments.
Meanwhile, dwc_prep_slave_sg() in drivers/dma/dw/core.c configures
DW_DMA_FC_P_M2P because dma->txconf.device_fc is set, and chains two
LLI descriptors with DWC_CTLL_INT_EN only on the second one.
In peripheral-flow-controller mode, the DW-AHB-DMAC ends an LLI on the
peripheral's dma_last handshake rather than the segment length. During
the first LLI, it reads past dma->tx_addr + UART_XMIT_SIZE into adjacent
kernel memory and transmits those bytes over the UART.
Once the UART asserts dma_last after the combined length, the DMAC moves
to the second LLI and stalls waiting for requests from the completed
UART block, so __dma_tx_complete() never runs and dma->tx_running stays
set.
Limiting kfifo_dma_out_prepare_mapped() to 1 entry when
dma->txconf.device_fc is set would keep each flow-controlled block
contiguous and let __dma_tx_complete() submit the wrapped remainder next.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-serial-8250-dma-tx-length-v1-v3-1-7a6250992bd6@gmail.com?part=1
prev parent reply other threads:[~2026-12-04 10:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:56 [PATCH v3] serial: 8250: calculate TX length before preparing DMA flow control James Hilliard
2026-12-04 10:17 ` sashiko-bot [this message]
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-249584@kernel.org \
--to=sashiko-bot@kernel.org \
--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