From: Mans Rullgard <mans@mansr.com>
To: jirislaby@kernel.org
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, linux-omap@vger.kernel.org
Subject: [PATCH 2/2] tty: serial: 8250_omap: use two-entry sg list for tx dma
Date: Tue, 6 May 2025 16:07:30 +0100 [thread overview]
Message-ID: <20250506150748.3162-2-mans@mansr.com> (raw)
In-Reply-To: <20250506150748.3162-1-mans@mansr.com>
On buffer wraparound, two sg entries are needed to transfer the full
contents of the kfifo.
This is equivalent to the change made to the 8250_dma driver in commit
59449c9dbdaa ("tty: serial: 8250_dma: use sgl with 2 nents to take care
of buffer wrap").
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
drivers/tty/serial/8250/8250_omap.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 180466e09605..66ba43a20725 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1152,9 +1152,11 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
struct omap8250_priv *priv = p->port.private_data;
struct tty_port *tport = &p->port.state->port;
struct dma_async_tx_descriptor *desc;
- struct scatterlist sg;
+ struct scatterlist *sg;
+ struct scatterlist sgl[2];
int skip_byte = -1;
int ret;
+ int i;
if (dma->tx_running)
return 0;
@@ -1208,18 +1210,22 @@ static int omap_8250_tx_dma(struct uart_8250_port *p)
skip_byte = c;
}
- sg_init_table(&sg, 1);
- kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, &sg, 1,
- UART_XMIT_SIZE, dma->tx_addr);
+ sg_init_table(sgl, ARRAY_SIZE(sgl));
+ ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, sgl, ARRAY_SIZE(sgl),
+ UART_XMIT_SIZE, dma->tx_addr);
- desc = dmaengine_prep_slave_sg(dma->txchan, &sg, 1, DMA_MEM_TO_DEV,
+ desc = dmaengine_prep_slave_sg(dma->txchan, sgl, ret, DMA_MEM_TO_DEV,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (!desc) {
ret = -EBUSY;
goto err;
}
- dma->tx_size = sg_dma_len(&sg);
+ dma->tx_size = 0;
+
+ for_each_sg(sgl, sg, ret, i)
+ dma->tx_size += sg_dma_len(sg);
+
dma->tx_running = 1;
desc->callback = omap_8250_dma_tx_complete;
--
2.49.0
next prev parent reply other threads:[~2025-05-06 15:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 15:07 [PATCH v2 1/2] tty: serial: 8250_omap: fix tx with dma Mans Rullgard
2025-05-06 15:07 ` Mans Rullgard [this message]
2025-05-07 6:05 ` Jiri Slaby
2025-05-07 7:49 ` Måns Rullgård
2025-05-07 8:09 ` Jiri Slaby
2025-05-07 10:56 ` Måns Rullgård
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=20250506150748.3162-2-mans@mansr.com \
--to=mans@mansr.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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
all inboxes | Powered by JetHome®