* [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
@ 2022-08-30 13:13 Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 1/3] serial: Create uart_xmit_advance() Ilpo Järvinen
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2022-08-30 13:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, Andy Shevchenko
Cc: linux-kernel, Ilpo Järvinen
Add uart_xmit_advance() helper to handle circular xmit buffer
advancement + accounting of Tx'ed bytes. Use it to fix a few drivers
that previously lacked to accounting for DMA Tx.
Greg,
I've a another series on top this which is tty-next material making the
rest of the drivers to use uart_xmit_advance(). That series obviously
depends on the patch 1/3 of this series so if you end up putting these
3 patches into tty-linus, I'll need it to be merged into tty-next at
some point (I'm not in a big hurry with this so if you choose to delay
the merge, it's not a big deal).
v2:
- Correct tags
Ilpo Järvinen (3):
serial: Create uart_xmit_advance()
serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
drivers/tty/serial/serial-tegra.c | 5 ++---
drivers/tty/serial/tegra-tcu.c | 2 +-
include/linux/serial_core.h | 17 +++++++++++++++++
3 files changed, 20 insertions(+), 4 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] serial: Create uart_xmit_advance()
2022-08-30 13:13 [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
@ 2022-08-30 13:13 ` Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 2/3] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Ilpo Järvinen
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2022-08-30 13:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, Andy Shevchenko,
linux-kernel
Cc: Ilpo Järvinen, Andy Shevchenko
A very common pattern in the drivers is to advance xmit tail
index and do bookkeeping of Tx'ed characters. Create
uart_xmit_advance() to handle it.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
include/linux/serial_core.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index aef3145f2032..ffc7b8cb7a7f 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -616,6 +616,23 @@ struct uart_state {
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
+/**
+ * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars
+ * @up: uart_port structure describing the port
+ * @chars: number of characters sent
+ *
+ * This function advances the tail of circular xmit buffer by the number of
+ * @chars transmitted and handles accounting of transmitted bytes (into
+ * @up's icount.tx).
+ */
+static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars)
+{
+ struct circ_buf *xmit = &up->state->xmit;
+
+ xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1);
+ up->icount.tx += chars;
+}
+
struct module;
struct tty_driver;
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
2022-08-30 13:13 [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 1/3] serial: Create uart_xmit_advance() Ilpo Järvinen
@ 2022-08-30 13:13 ` Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 3/3] serial: tegra-tcu: " Ilpo Järvinen
2022-08-30 13:19 ` [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
3 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2022-08-30 13:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, Andy Shevchenko,
Laxman Dewangan, Thierry Reding, Jonathan Hunter, Alan Cox,
Stephen Warren, linux-tegra, linux-kernel
Cc: Ilpo Järvinen, stable, Andy Shevchenko
DMA complete & stop paths did not correctly account Tx'ed characters
into icount.tx. Using uart_xmit_advance() fixes the problem.
Cc: <stable@vger.kernel.org> # serial: Create uart_xmit_advance()
Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/serial-tegra.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index ad4f3567ff90..a5748e41483b 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -525,7 +525,7 @@ static void tegra_uart_tx_dma_complete(void *args)
count = tup->tx_bytes_requested - state.residue;
async_tx_ack(tup->tx_dma_desc);
spin_lock_irqsave(&tup->uport.lock, flags);
- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1);
+ uart_xmit_advance(&tup->uport, count);
tup->tx_in_progress = 0;
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(&tup->uport);
@@ -613,7 +613,6 @@ static unsigned int tegra_uart_tx_empty(struct uart_port *u)
static void tegra_uart_stop_tx(struct uart_port *u)
{
struct tegra_uart_port *tup = to_tegra_uport(u);
- struct circ_buf *xmit = &tup->uport.state->xmit;
struct dma_tx_state state;
unsigned int count;
@@ -624,7 +623,7 @@ static void tegra_uart_stop_tx(struct uart_port *u)
dmaengine_tx_status(tup->tx_dma_chan, tup->tx_cookie, &state);
count = tup->tx_bytes_requested - state.residue;
async_tx_ack(tup->tx_dma_desc);
- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1);
+ uart_xmit_advance(&tup->uport, count);
tup->tx_in_progress = 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
2022-08-30 13:13 [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 1/3] serial: Create uart_xmit_advance() Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 2/3] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Ilpo Järvinen
@ 2022-08-30 13:13 ` Ilpo Järvinen
2022-09-15 12:26 ` Thierry Reding
2022-08-30 13:19 ` [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
3 siblings, 1 reply; 9+ messages in thread
From: Ilpo Järvinen @ 2022-08-30 13:13 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, linux-serial, Andy Shevchenko,
Thierry Reding, Jonathan Hunter, linux-tegra, linux-kernel
Cc: Ilpo Järvinen, stable, Andy Shevchenko
Tx'ing does not correctly account Tx'ed characters into icount.tx.
Using uart_xmit_advance() fixes the problem.
Cc: <stable@vger.kernel.org> # serial: Create uart_xmit_advance()
Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/tegra-tcu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/tegra-tcu.c b/drivers/tty/serial/tegra-tcu.c
index 4877c54c613d..889b701ba7c6 100644
--- a/drivers/tty/serial/tegra-tcu.c
+++ b/drivers/tty/serial/tegra-tcu.c
@@ -101,7 +101,7 @@ static void tegra_tcu_uart_start_tx(struct uart_port *port)
break;
tegra_tcu_write(tcu, &xmit->buf[xmit->tail], count);
- xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1);
+ uart_xmit_advance(port, count);
}
uart_write_wakeup(port);
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
2022-08-30 13:13 [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
` (2 preceding siblings ...)
2022-08-30 13:13 ` [PATCH v2 3/3] serial: tegra-tcu: " Ilpo Järvinen
@ 2022-08-30 13:19 ` Ilpo Järvinen
2022-09-01 14:00 ` Greg Kroah-Hartman
3 siblings, 1 reply; 9+ messages in thread
From: Ilpo Järvinen @ 2022-08-30 13:19 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: linux-serial, Andy Shevchenko, LKML
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
On Tue, 30 Aug 2022, Ilpo Järvinen wrote:
> Add uart_xmit_advance() helper to handle circular xmit buffer
> advancement + accounting of Tx'ed bytes. Use it to fix a few drivers
> that previously lacked to accounting for DMA Tx.
>
> Greg,
> I've a another series on top this which is tty-next material making the
> rest of the drivers to use uart_xmit_advance(). That series obviously
> depends on the patch 1/3 of this series so if you end up putting these
> 3 patches into tty-linus, I'll need it to be merged into tty-next at
> some point (I'm not in a big hurry with this so if you choose to delay
> the merge, it's not a big deal).
This merge, btw, is no longer that important because I agreed with Jiri to
wait for his tx loop rewrite series.
--
i.
> v2:
> - Correct tags
>
> Ilpo Järvinen (3):
> serial: Create uart_xmit_advance()
> serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting
> serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
>
> drivers/tty/serial/serial-tegra.c | 5 ++---
> drivers/tty/serial/tegra-tcu.c | 2 +-
> include/linux/serial_core.h | 17 +++++++++++++++++
> 3 files changed, 20 insertions(+), 4 deletions(-)
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
2022-08-30 13:19 ` [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
@ 2022-09-01 14:00 ` Greg Kroah-Hartman
2022-09-01 14:15 ` Ilpo Järvinen
0 siblings, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-01 14:00 UTC (permalink / raw)
To: Ilpo Järvinen; +Cc: Jiri Slaby, linux-serial, Andy Shevchenko, LKML
On Tue, Aug 30, 2022 at 04:19:40PM +0300, Ilpo Järvinen wrote:
> On Tue, 30 Aug 2022, Ilpo Järvinen wrote:
>
> > Add uart_xmit_advance() helper to handle circular xmit buffer
> > advancement + accounting of Tx'ed bytes. Use it to fix a few drivers
> > that previously lacked to accounting for DMA Tx.
> >
> > Greg,
> > I've a another series on top this which is tty-next material making the
> > rest of the drivers to use uart_xmit_advance(). That series obviously
> > depends on the patch 1/3 of this series so if you end up putting these
> > 3 patches into tty-linus, I'll need it to be merged into tty-next at
> > some point (I'm not in a big hurry with this so if you choose to delay
> > the merge, it's not a big deal).
>
> This merge, btw, is no longer that important because I agreed with Jiri to
> wait for his tx loop rewrite series.
Ok, I'll drop this series for now.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
2022-09-01 14:00 ` Greg Kroah-Hartman
@ 2022-09-01 14:15 ` Ilpo Järvinen
2022-09-01 14:33 ` Greg Kroah-Hartman
0 siblings, 1 reply; 9+ messages in thread
From: Ilpo Järvinen @ 2022-09-01 14:15 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, Andy Shevchenko, LKML
[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]
On Thu, 1 Sep 2022, Greg Kroah-Hartman wrote:
> On Tue, Aug 30, 2022 at 04:19:40PM +0300, Ilpo Järvinen wrote:
> > On Tue, 30 Aug 2022, Ilpo Järvinen wrote:
> >
> > > Add uart_xmit_advance() helper to handle circular xmit buffer
> > > advancement + accounting of Tx'ed bytes. Use it to fix a few drivers
> > > that previously lacked to accounting for DMA Tx.
> > >
> > > Greg,
> > > I've a another series on top this which is tty-next material making the
> > > rest of the drivers to use uart_xmit_advance(). That series obviously
> > > depends on the patch 1/3 of this series so if you end up putting these
> > > 3 patches into tty-linus, I'll need it to be merged into tty-next at
> > > some point (I'm not in a big hurry with this so if you choose to delay
> > > the merge, it's not a big deal).
> >
> > This merge, btw, is no longer that important because I agreed with Jiri to
> > wait for his tx loop rewrite series.
>
> Ok, I'll drop this series for now.
It's not what I meant.
I've a follow-up series on top of this which depeds on uart_xmit_advance()
being available (thus I'd have need it in tty-next). However, now I'm
postponing the follow-up series while Jiri sorts out the tx loops.
This first part of the series and Jiri's tx loop series don't even touch
the same files.
I guess I should resend these if you dropped these from your queue?
--
i.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series)
2022-09-01 14:15 ` Ilpo Järvinen
@ 2022-09-01 14:33 ` Greg Kroah-Hartman
0 siblings, 0 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2022-09-01 14:33 UTC (permalink / raw)
To: Ilpo Järvinen; +Cc: Jiri Slaby, linux-serial, Andy Shevchenko, LKML
On Thu, Sep 01, 2022 at 05:15:11PM +0300, Ilpo Järvinen wrote:
> On Thu, 1 Sep 2022, Greg Kroah-Hartman wrote:
>
> > On Tue, Aug 30, 2022 at 04:19:40PM +0300, Ilpo Järvinen wrote:
> > > On Tue, 30 Aug 2022, Ilpo Järvinen wrote:
> > >
> > > > Add uart_xmit_advance() helper to handle circular xmit buffer
> > > > advancement + accounting of Tx'ed bytes. Use it to fix a few drivers
> > > > that previously lacked to accounting for DMA Tx.
> > > >
> > > > Greg,
> > > > I've a another series on top this which is tty-next material making the
> > > > rest of the drivers to use uart_xmit_advance(). That series obviously
> > > > depends on the patch 1/3 of this series so if you end up putting these
> > > > 3 patches into tty-linus, I'll need it to be merged into tty-next at
> > > > some point (I'm not in a big hurry with this so if you choose to delay
> > > > the merge, it's not a big deal).
> > >
> > > This merge, btw, is no longer that important because I agreed with Jiri to
> > > wait for his tx loop rewrite series.
> >
> > Ok, I'll drop this series for now.
>
> It's not what I meant.
>
> I've a follow-up series on top of this which depeds on uart_xmit_advance()
> being available (thus I'd have need it in tty-next). However, now I'm
> postponing the follow-up series while Jiri sorts out the tx loops.
>
> This first part of the series and Jiri's tx loop series don't even touch
> the same files.
>
> I guess I should resend these if you dropped these from your queue?
Yes please, sorry, I was confused.
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] serial: tegra-tcu: Use uart_xmit_advance(), fixes icount.tx accounting
2022-08-30 13:13 ` [PATCH v2 3/3] serial: tegra-tcu: " Ilpo Järvinen
@ 2022-09-15 12:26 ` Thierry Reding
0 siblings, 0 replies; 9+ messages in thread
From: Thierry Reding @ 2022-09-15 12:26 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, Andy Shevchenko,
Jonathan Hunter, linux-tegra, linux-kernel, stable,
Andy Shevchenko
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
On Tue, Aug 30, 2022 at 04:13:43PM +0300, Ilpo Järvinen wrote:
> Tx'ing does not correctly account Tx'ed characters into icount.tx.
> Using uart_xmit_advance() fixes the problem.
>
> Cc: <stable@vger.kernel.org> # serial: Create uart_xmit_advance()
> Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> drivers/tty/serial/tegra-tcu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-15 12:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 13:13 [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 1/3] serial: Create uart_xmit_advance() Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 2/3] serial: tegra: Use uart_xmit_advance(), fixes icount.tx accounting Ilpo Järvinen
2022-08-30 13:13 ` [PATCH v2 3/3] serial: tegra-tcu: " Ilpo Järvinen
2022-09-15 12:26 ` Thierry Reding
2022-08-30 13:19 ` [PATCH v2 0/3] serial: Add uart_xmit_advance() + fixes part (of a larger patch series) Ilpo Järvinen
2022-09-01 14:00 ` Greg Kroah-Hartman
2022-09-01 14:15 ` Ilpo Järvinen
2022-09-01 14:33 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.