serial: mxs-auart: wait for DMA buffer to flush before shutdown
Subsystems (2)
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.
https://jira.digi.com/browse/DEL-616
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +15 -1
@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; } +static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize; +while (!mxs_auart_tx_empty (u) && to--) +mdelay (1 ); -if (auart_dma_enabled (s))mxs_auart_dma_exit (s); + } + +/* Wait for transmitter to become empty ... */ + to = u->timeout; +while ((readl (port->membase +AUART_STAT ) &AUART_STAT_BUSY ) && to--) +mdelay (1 );writel (AUART_CTRL2_UARTEN , u->membase +AUART_CTRL2_CLR );
Signature · 1 line
1.8.4
Hello Hector,
Quoted 9 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>
What is this? This isn't available in public DNS.
Quoted 12 lines
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }
drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeout is the time needed to send one char, right? UART_XMIT_SIZE is the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:
u->timeout * min(UART_XMIT_SIZE, u->fifosize)
Can you explain, maybe in a comment along the code for the next person not understanding?
I wonder if the individual driver is the right place this must be fixed in or if there should be (or even exists) some help form the serial framework?!
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Uwe,
Quoted 9 lines · Uwe Kleine-König
Hello Hector,
Quoted 6 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.
Quoted 4 lines
Quoted 3 lines
Signed-off-by Hector Palacios <[email protected]>What is this? This isn't available in public DNS.
Sorry, copy&paste error. I'll remove it.
Quoted 27 lines
Quoted 12 lines
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:
Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
u->timeout is *not* the time needed to send one char but the time needed to flush the complete port fifo (see uart_update_timeout() in serial_core.c where it is set). UART_XMIT_SIZE is the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
Quoted 3 lines
I wonder if the individual driver is the right place this must be fixed in or if there should be (or even exists) some help form the serial framework?!
Good question, the issue should exit in other DMA drivers as well.
Best regards,
--
Hector Palacios
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Hello,
Quoted 38 lines · Hector Palacios
Quoted 37 lines · Uwe Kleine-K?nig
Quoted 21 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>[...]
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:
Quoted 8 lines
Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).
Ah, right. (BTW, uart_update_timeout should better round up instead of round down, i.e.
- port->timeout = (HZ * bits) / baud + HZ/50;
+ port->timeout = DIV_ROUND_UP(HZ * bits, baud) + HZ/50;
)
Quoted 3 lines
UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
ditto here, better round up. Although I think using a completion could shorten the timeout considerably because there are often less than UART_XMIT_SIZE chars in the buffer?!
Quoted 5 lines
Quoted 3 lines
I wonder if the individual driver is the right place this must be fixed in or if there should be (or even exists) some help form the serial framework?!
Good question, the issue should exit in other DMA drivers as well.
Added Jiri and lakml to Cc:. Maybe someone can say something about that topic?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Hello Uwe,
Quoted 55 lines · Uwe Kleine-K?nig
Hello,
Quoted 38 lines · Hector Palacios
Quoted 37 lines · Uwe Kleine-K?nig
Quoted 21 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>[...]
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:Quoted 8 lines
Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).Ah, right. (BTW,
uart_update_timeoutshould better round up instead of round down, i.e.(quoted diff) +1
-1- port->timeout = (HZ * bits) / baud + HZ/50; + port->timeout = DIV_ROUND_UP(HZ * bits, baud) + HZ/50;)
Quoted 6 lines
Quoted 3 lines
UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.ditto here, better round up. Although I think using a completion could shorten the timeout considerably because there are often less than
UART_XMIT_SIZEchars in the buffer?!
I'm not really waiting the full timeout. I'm checking for TX fifo empty every 1ms and for a maximum of 'to' ms.
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
I wonder if the individual driver is the right place this must be fixed in or if there should be (or even exists) some help form the serial framework?!
Good question, the issue should exit in other DMA drivers as well.
Added Jiri and lakml to Cc:. Maybe someone can say something about that topic?
Best regards
Uwe
Best regards,
--
Hector Palacios
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Hello Hector,
Quoted 28 lines · Hector Palacios
Quoted 27 lines · Uwe Kleine-K?nig
Quoted 9 lines · Hector Palacios
Quoted 8 lines · Uwe Kleine-K?nig
drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 2 lines · Hector Palacios
drivers/tty/serial/mxs-auart.c +2
-0+/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:Quoted 8 lines
Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).Ah, right. (BTW,
uart_update_timeoutshould better round up instead of round down, i.e.(quoted diff) +1
-1- port->timeout = (HZ * bits) / baud + HZ/50; + port->timeout = DIV_ROUND_UP(HZ * bits, baud) + HZ/50;)
Quoted 3 lines
UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
Quoted 6 lines
Quoted 3 lines
ditto here, better round up. Although I think using a completion could shorten the timeout considerably because there are often less than
UART_XMIT_SIZEchars in the buffer?!I'm not really waiting the full timeout. I'm checking for TX fifo empty every 1ms and for a maximum of 'to' ms.
Correct. Still using DIV_ROUND_UP would be better, right?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Hi Uwe,
Quoted 31 lines · Uwe Kleine-K?nig
Hello Hector,
Quoted 28 lines · Hector Palacios
Quoted 27 lines · Uwe Kleine-K?nig
Quoted 9 lines · Hector Palacios
Quoted 8 lines · Uwe Kleine-K?nig
drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 2 lines · Hector Palacios
drivers/tty/serial/mxs-auart.c +2
-0+/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:Quoted 8 lines
Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).Ah, right. (BTW,
uart_update_timeoutshould better round up instead of round down, i.e.(quoted diff) +1
-1- port->timeout = (HZ * bits) / baud + HZ/50; + port->timeout = DIV_ROUND_UP(HZ * bits, baud) + HZ/50;)
Quoted 3 lines
UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
ditto here, better round up. Although I think using a completion could shorten the timeout considerably because there are often less than
UART_XMIT_SIZEchars in the buffer?!I'm not really waiting the full timeout. I'm checking for TX fifo empty every 1ms and for a maximum of 'to' ms.
Correct. Still using
DIV_ROUND_UPwould be better, right?
I think it is not really needed, after all the code is adding HZ/50 of slop which acts like a round up, doesn't it?
/* * Figure the timeout to send the above number of bits. * Add .02 seconds of slop */ port->timeout = (HZ * bits) / baud + HZ/50;
Best regards,
--
Hector Palacios
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Hi Hector,
Quoted 20 lines · Hector Palacios
Quoted 11 lines · Uwe Kleine-K?nig
Quoted 10 lines · Hector Palacios
Quoted 9 lines · Uwe Kleine-K?nig
Ah, right. (BTW,
uart_update_timeoutshould better round up instead of round down, i.e.(quoted diff) +1
-1- port->timeout = (HZ * bits) / baud + HZ/50; + port->timeout = DIV_ROUND_UP(HZ * bits, baud) + HZ/50;)
Quoted 3 lines
UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
ditto here, better round up. Although I think using a completion could shorten the timeout considerably because there are often less than
UART_XMIT_SIZEchars in the buffer?!I'm not really waiting the full timeout. I'm checking for TX fifo empty every 1ms and for a maximum of 'to' ms.
Correct. Still using
DIV_ROUND_UPwould be better, right?
Quoted 8 lines
I think it is not really needed, after all the code is adding HZ/50 of slop which acts like a round up, doesn't it?
/* * Figure the timeout to send the above number of bits. * Add .02 seconds of slop */ port->timeout = (HZ * bits) / baud + HZ/50;
According to my understanding (which could well be wrong) the slop of HZ/50 isn't there to fix rounding issues in the previous division. But yes, if it's calculated generously there is no technical need to fix the rounding issue.
Still it might be worth to fix it to be a better reference. I don't care much.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Hello Hector,
Quoted 43 lines · Hector Palacios
Quoted 37 lines · Uwe Kleine-König
Hello Hector,
Quoted 19 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
Quoted 6 lines
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
Another thought: Does that mean that from the framework's POV the fifosize is UART_XMIT_SIZE instead in the DMA case? That would enable you to just use u->timeout.
Best regards
Uwe
Signature · 6 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 serial: mxs-auart: wait for DMA buffer to flush before shutdown
Quoted 52 lines · Uwe Kleine-K?nig
Hello Hector,
Quoted 43 lines · Hector Palacios
Quoted 37 lines · Uwe Kleine-K?nig
Hello Hector,
Quoted 19 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +0
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; }drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 762
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-0+static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
u->timeoutis the time needed to send one char, right?UART_XMIT_SIZEis the size of the circular buffer, fifosize is the size of the fifo. I don't get what you get by dividing by the fifosize. I would have expected something like:Quoted 4 lines
u->timeout * min(UART_XMIT_SIZE, u->fifosize)Can you explain, maybe in a comment along the code for the next person not understanding?
Quoted 6 lines
u->timeoutis *not* the time needed to send one char but the time needed to flush the complete port fifo (seeuart_update_timeout()inserial_core.cwhere it is set).UART_XMIT_SIZEis the number of bytes in the DMA buffer, so I divide the max number of bytes in the FIFO by the FIFO size and multiply by the FIFO timeout.
Quoted 3 lines
Another thought: Does that mean that from the framework's POV the fifosize is
UART_XMIT_SIZEinstead in the DMA case? That would enable you to just useu->timeout.
Hum, I think you hit the point.
I just saw they do this in amba_pl011.c driver:
/* The DMA buffer is now the FIFO the TTY subsystem can use */ uap->port.fifosize = PL011_DMA_BUFFER_SIZE;
I'll rework the patch and try.
Best regards,
--
Hector Palacios
Dear Hector Palacios,
Quoted 9 lines
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>
The link doesn't work. Otherwise makes sense
Quoted 25 lines
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/tty/serial/mxs-auart.cindex f85b8e6..0d8b2ca 100644drivers/tty/serial/mxs-auart.c +9
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; } +static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize; +while (!mxs_auart_tx_empty (u) && to--) +mdelay (1 );
drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 774
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +6
-1-if (auart_dma_enabled (s))mxs_auart_dma_exit (s); + } + +/* Wait for transmitter to become empty ... */ + to = u->timeout; +while ((readl (port->membase +AUART_STAT ) &AUART_STAT_BUSY ) && to--) +mdelay (1 );writel (AUART_CTRL2_UARTEN , u->membase +AUART_CTRL2_CLR );
Best regards,
Marek Vasut
Quoted 31 lines · Hector Palacios
The shutdown function was not waiting for the DMA buffer to flush before disabling the AUART. This lead to many bytes not being transferred (specially at low baudrates), as they were still in the DMA buffer when the AUART was shutdown.
This patch also adds the check for the BUSY flag.Signed-off-by Hector Palacios <[email protected]>https://jira.digi.com/browse/DEL-616
--- drivers/tty/serial/mxs-auart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/tty/serial/mxs-auart.c +7
-0@@ -750,12 +750,26 @@ static int mxs_auart_startup(struct uart_port *u)return 0 ; } +static unsigned int mxs_auart_tx_empty (struct uart_port *u); +static void mxs_auart_shutdown (struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +unsigned int to; + +if (auart_dma_enabled (s)) { +/* Wait enough time to flush DMA buffer completely */ + to = u->timeout *UART_XMIT_SIZE / u->fifosize;
drivers/tty/serial/mxs-auart.c static int mxs_auart_startup(struct uart_port *u) · line 771
Quoted 10 lines
drivers/tty/serial/mxs-auart.c +7
-1+while (!mxs_auart_tx_empty (u) && to--) +mdelay (1 ); -if (auart_dma_enabled (s))mxs_auart_dma_exit (s); + } + +/* Wait for transmitter to become empty ... */ + to = u->timeout; +while ((readl (port->membase +AUART_STAT ) &AUART_STAT_BUSY ) && to--)
Just noticed a bug. It should be u->membase. I'll fix it in V2.
Best regards,
--
Hector Palacios