* [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags()
@ 2024-02-01 10:55 Jiri Slaby (SUSE)
2024-02-01 10:55 ` [PATCH v2 2/2] serial: mxs-auart: fix tx Jiri Slaby (SUSE)
2024-02-01 15:48 ` [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Emil Kronborg
0 siblings, 2 replies; 7+ messages in thread
From: Jiri Slaby (SUSE) @ 2024-02-01 10:55 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Emil Kronborg
And an enum with a flag: UART_TX_NOSTOP. To NOT call
__port->ops->stop_tx() when the circular buffer is empty. mxs-uart needs
this (see the next patch).
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Emil Kronborg <emil.kronborg@protonmail.com>
---
Notes:
[v2] fix/invert the condition
include/linux/serial_core.h | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 536b2581d3e2..55b1f3ba48ac 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -748,8 +748,17 @@ struct uart_driver {
void uart_write_wakeup(struct uart_port *port);
-#define __uart_port_tx(uport, ch, tx_ready, put_char, tx_done, for_test, \
- for_post) \
+/**
+ * enum UART_TX_FLAGS -- flags for uart_port_tx_flags()
+ *
+ * @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer
+ */
+enum UART_TX_FLAGS {
+ UART_TX_NOSTOP = BIT(0),
+};
+
+#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \
+ for_test, for_post) \
({ \
struct uart_port *__port = (uport); \
struct circ_buf *xmit = &__port->state->xmit; \
@@ -777,7 +786,7 @@ void uart_write_wakeup(struct uart_port *port);
if (pending < WAKEUP_CHARS) { \
uart_write_wakeup(__port); \
\
- if (pending == 0) \
+ if (!((flags) & UART_TX_NOSTOP) && pending == 0) \
__port->ops->stop_tx(__port); \
} \
\
@@ -812,7 +821,7 @@ void uart_write_wakeup(struct uart_port *port);
*/
#define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \
unsigned int __count = (count); \
- __uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \
+ __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \
__count--); \
})
@@ -826,8 +835,21 @@ void uart_write_wakeup(struct uart_port *port);
* See uart_port_tx_limited() for more details.
*/
#define uart_port_tx(port, ch, tx_ready, put_char) \
- __uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({}))
+ __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({}))
+
+/**
+ * uart_port_tx_flags -- transmit helper for uart_port with flags
+ * @port: uart port
+ * @ch: variable to store a character to be written to the HW
+ * @flags: %UART_TX_NOSTOP or similar
+ * @tx_ready: can HW accept more data function
+ * @put_char: function to write a character
+ *
+ * See uart_port_tx_limited() for more details.
+ */
+#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \
+ __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({}))
/*
* Baud rate helpers.
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] serial: mxs-auart: fix tx
2024-02-01 10:55 [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Jiri Slaby (SUSE)
@ 2024-02-01 10:55 ` Jiri Slaby (SUSE)
2024-02-01 12:05 ` Jiri Slaby
2024-02-01 15:49 ` Emil Kronborg
2024-02-01 15:48 ` [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Emil Kronborg
1 sibling, 2 replies; 7+ messages in thread
From: Jiri Slaby (SUSE) @ 2024-02-01 10:55 UTC (permalink / raw)
To: gregkh; +Cc: linux-serial, linux-kernel, Jiri Slaby (SUSE), Emil Kronborg
Emil reports:
After updating Linux on an i.MX28 board, serial communication over
AUART broke. When I TX from the board and measure on the TX pin, it
seems like the HW fifo is not emptied before the transmission is
stopped.
MXS performs weird things with stop_tx(). The driver makes it
conditional on uart_tx_stopped().
So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
to uart_port_tx_flags() and handle the stop on its own.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
---
drivers/tty/serial/mxs-auart.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 3ec725555bcc..4749331fe618 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -605,13 +605,16 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
return;
}
- pending = uart_port_tx(&s->port, ch,
+ pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
!(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
mxs_write(ch, s, REG_DATA));
if (pending)
mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
else
mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
+
+ if (uart_tx_stopped(&s->port))
+ mxs_auart_stop_tx(&s->port);
}
static void mxs_auart_rx_char(struct mxs_auart_port *s)
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] serial: mxs-auart: fix tx
2024-02-01 10:55 ` [PATCH v2 2/2] serial: mxs-auart: fix tx Jiri Slaby (SUSE)
@ 2024-02-01 12:05 ` Jiri Slaby
2024-02-01 14:57 ` Greg KH
2024-02-01 17:59 ` Stefan Wahren
2024-02-01 15:49 ` Emil Kronborg
1 sibling, 2 replies; 7+ messages in thread
From: Jiri Slaby @ 2024-02-01 12:05 UTC (permalink / raw)
To: gregkh
Cc: linux-serial, linux-kernel, Emil Kronborg, Shawn Guo,
Sascha Hauer, Uwe Kleine-König, Fabio Estevam,
NXP Linux Team, linux-arm-kernel@lists.infradead.org
On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
> Emil reports:
> After updating Linux on an i.MX28 board, serial communication over
> AUART broke. When I TX from the board and measure on the TX pin, it
> seems like the HW fifo is not emptied before the transmission is
> stopped.
>
> MXS performs weird things with stop_tx(). The driver makes it
> conditional on uart_tx_stopped().
>
> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> to uart_port_tx_flags() and handle the stop on its own.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
Am I unable to send a proper patch anymore?
I forgot to add mxs+arm maintainers:
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org
I can resend with those fixed, if you prefer...
> ---
> drivers/tty/serial/mxs-auart.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index 3ec725555bcc..4749331fe618 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -605,13 +605,16 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
> return;
> }
>
> - pending = uart_port_tx(&s->port, ch,
> + pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
> !(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
> mxs_write(ch, s, REG_DATA));
> if (pending)
> mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
> else
> mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
> +
> + if (uart_tx_stopped(&s->port))
> + mxs_auart_stop_tx(&s->port);
> }
>
> static void mxs_auart_rx_char(struct mxs_auart_port *s)
--
js
suse labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] serial: mxs-auart: fix tx
2024-02-01 12:05 ` Jiri Slaby
@ 2024-02-01 14:57 ` Greg KH
2024-02-01 17:59 ` Stefan Wahren
1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2024-02-01 14:57 UTC (permalink / raw)
To: Jiri Slaby
Cc: linux-serial, linux-kernel, Emil Kronborg, Shawn Guo,
Sascha Hauer, Uwe Kleine-König, Fabio Estevam,
NXP Linux Team, linux-arm-kernel@lists.infradead.org
On Thu, Feb 01, 2024 at 01:05:42PM +0100, Jiri Slaby wrote:
> On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
> > Emil reports:
> > After updating Linux on an i.MX28 board, serial communication over
> > AUART broke. When I TX from the board and measure on the TX pin, it
> > seems like the HW fifo is not emptied before the transmission is
> > stopped.
> >
> > MXS performs weird things with stop_tx(). The driver makes it
> > conditional on uart_tx_stopped().
> >
> > So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> > to uart_port_tx_flags() and handle the stop on its own.
> >
> > Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> > Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> > Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> > Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
>
> Am I unable to send a proper patch anymore?
>
> I forgot to add mxs+arm maintainers:
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP Linux Team <linux-imx@nxp.com>
> Cc: linux-arm-kernel@lists.infradead.org
>
> I can resend with those fixed, if you prefer...
Nah, this is fine, I'll take this as-is, thanks!
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags()
2024-02-01 10:55 [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Jiri Slaby (SUSE)
2024-02-01 10:55 ` [PATCH v2 2/2] serial: mxs-auart: fix tx Jiri Slaby (SUSE)
@ 2024-02-01 15:48 ` Emil Kronborg
1 sibling, 0 replies; 7+ messages in thread
From: Emil Kronborg @ 2024-02-01 15:48 UTC (permalink / raw)
To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel
On Thu, Feb 01, 2024 at 11:55 +0100, Jiri Slaby (SUSE) wrote:
> And an enum with a flag: UART_TX_NOSTOP. To NOT call
> __port->ops->stop_tx() when the circular buffer is empty. mxs-uart needs
> this (see the next patch).
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Cc: Emil Kronborg <emil.kronborg@protonmail.com>
> ---
>
> Notes:
> [v2] fix/invert the condition
>
> include/linux/serial_core.h | 32 +++++++++++++++++++++++++++-----
> 1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index 536b2581d3e2..55b1f3ba48ac 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -748,8 +748,17 @@ struct uart_driver {
>
> void uart_write_wakeup(struct uart_port *port);
>
> -#define __uart_port_tx(uport, ch, tx_ready, put_char, tx_done, for_test, \
> - for_post) \
> +/**
> + * enum UART_TX_FLAGS -- flags for uart_port_tx_flags()
> + *
> + * @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer
> + */
> +enum UART_TX_FLAGS {
> + UART_TX_NOSTOP = BIT(0),
> +};
> +
> +#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \
> + for_test, for_post) \
> ({ \
> struct uart_port *__port = (uport); \
> struct circ_buf *xmit = &__port->state->xmit; \
> @@ -777,7 +786,7 @@ void uart_write_wakeup(struct uart_port *port);
> if (pending < WAKEUP_CHARS) { \
> uart_write_wakeup(__port); \
> \
> - if (pending == 0) \
> + if (!((flags) & UART_TX_NOSTOP) && pending == 0) \
> __port->ops->stop_tx(__port); \
> } \
> \
> @@ -812,7 +821,7 @@ void uart_write_wakeup(struct uart_port *port);
> */
> #define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \
> unsigned int __count = (count); \
> - __uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \
> + __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \
> __count--); \
> })
>
> @@ -826,8 +835,21 @@ void uart_write_wakeup(struct uart_port *port);
> * See uart_port_tx_limited() for more details.
> */
> #define uart_port_tx(port, ch, tx_ready, put_char) \
> - __uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({}))
> + __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({}))
> +
>
> +/**
> + * uart_port_tx_flags -- transmit helper for uart_port with flags
> + * @port: uart port
> + * @ch: variable to store a character to be written to the HW
> + * @flags: %UART_TX_NOSTOP or similar
> + * @tx_ready: can HW accept more data function
> + * @put_char: function to write a character
> + *
> + * See uart_port_tx_limited() for more details.
> + */
> +#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \
> + __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({}))
> /*
> * Baud rate helpers.
> */
> --
> 2.43.0
>
Tested on i.MX28 board.
Tested-by: Emil Kronborg <emil.kronborg@protonmail.com>
--
Emil Kronborg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] serial: mxs-auart: fix tx
2024-02-01 10:55 ` [PATCH v2 2/2] serial: mxs-auart: fix tx Jiri Slaby (SUSE)
2024-02-01 12:05 ` Jiri Slaby
@ 2024-02-01 15:49 ` Emil Kronborg
1 sibling, 0 replies; 7+ messages in thread
From: Emil Kronborg @ 2024-02-01 15:49 UTC (permalink / raw)
To: Jiri Slaby (SUSE); +Cc: gregkh, linux-serial, linux-kernel
On Thu, Feb 01, 2024 at 11:55 +0100, Jiri Slaby (SUSE) wrote:
> Emil reports:
> After updating Linux on an i.MX28 board, serial communication over
> AUART broke. When I TX from the board and measure on the TX pin, it
> seems like the HW fifo is not emptied before the transmission is
> stopped.
>
> MXS performs weird things with stop_tx(). The driver makes it
> conditional on uart_tx_stopped().
>
> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
> to uart_port_tx_flags() and handle the stop on its own.
>
> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
> Closes: https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
> ---
> drivers/tty/serial/mxs-auart.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index 3ec725555bcc..4749331fe618 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -605,13 +605,16 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s)
> return;
> }
>
> - pending = uart_port_tx(&s->port, ch,
> + pending = uart_port_tx_flags(&s->port, ch, UART_TX_NOSTOP,
> !(mxs_read(s, REG_STAT) & AUART_STAT_TXFF),
> mxs_write(ch, s, REG_DATA));
> if (pending)
> mxs_set(AUART_INTR_TXIEN, s, REG_INTR);
> else
> mxs_clr(AUART_INTR_TXIEN, s, REG_INTR);
> +
> + if (uart_tx_stopped(&s->port))
> + mxs_auart_stop_tx(&s->port);
> }
>
> static void mxs_auart_rx_char(struct mxs_auart_port *s)
> --
> 2.43.0
>
Tested on i.MX28.
Tested-by: Emil Kronborg <emil.kronborg@protonmail.com>
--
Emil Kronborg
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] serial: mxs-auart: fix tx
2024-02-01 12:05 ` Jiri Slaby
2024-02-01 14:57 ` Greg KH
@ 2024-02-01 17:59 ` Stefan Wahren
1 sibling, 0 replies; 7+ messages in thread
From: Stefan Wahren @ 2024-02-01 17:59 UTC (permalink / raw)
To: Jiri Slaby, gregkh
Cc: linux-serial, linux-kernel, Emil Kronborg, Shawn Guo,
Sascha Hauer, Uwe Kleine-König, Fabio Estevam,
NXP Linux Team, linux-arm-kernel@lists.infradead.org
Am 01.02.24 um 13:05 schrieb Jiri Slaby:
> On 01. 02. 24, 11:55, Jiri Slaby (SUSE) wrote:
>> Emil reports:
>> After updating Linux on an i.MX28 board, serial communication over
>> AUART broke. When I TX from the board and measure on the TX pin, it
>> seems like the HW fifo is not emptied before the transmission is
>> stopped.
>>
>> MXS performs weird things with stop_tx(). The driver makes it
>> conditional on uart_tx_stopped().
>>
>> So the driver needs special handling. Pass the brand new UART_TX_NOSTOP
>> to uart_port_tx_flags() and handle the stop on its own.
>>
>> Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
>> Reported-by: Emil Kronborg <emil.kronborg@protonmail.com>
>> Fixes: 2d141e683e9a ("tty: serial: use uart_port_tx() helper")
>> Closes:
>> https://lore.kernel.org/all/miwgbnvy3hjpnricubg76ytpn7xoceehwahupy25bubbduu23s@om2lptpa26xw/
>
Tested-by: Stefan Wahren <wahrenst@gmx.net>
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-02-01 17:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 10:55 [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Jiri Slaby (SUSE)
2024-02-01 10:55 ` [PATCH v2 2/2] serial: mxs-auart: fix tx Jiri Slaby (SUSE)
2024-02-01 12:05 ` Jiri Slaby
2024-02-01 14:57 ` Greg KH
2024-02-01 17:59 ` Stefan Wahren
2024-02-01 15:49 ` Emil Kronborg
2024-02-01 15:48 ` [PATCH v2 1/2] serial: core: introduce uart_port_tx_flags() Emil Kronborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox