ARM: imx serial driver: fix resume
PATCH 1/1 ARM: imx serial driver: fix resume
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".
However calling "imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.
---
Volker did all the work on this, he just doesn't want to push his great contributions upstream, so I do it for him :)
drivers/serial/imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/serial/imx.c +2 -2
@@ -328,13 +328,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)struct circ_buf *xmit = &sport->port.state->xmit;while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +if (uart_circ_empty (xmit)) +break ;/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )
Signature · 1 line
1.7.0.4
PATCH 1/1 ARM: imx serial driver: fix resume
Quoted 12 lines · On Wed, 6 Oct 2010 18:57:16 +0200 Daniel Mack <[email protected]> wrote:
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "
drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".
Quoted 8 lines
However calling "
imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.Signed-off-by Volker Ernst <[email protected]>Cc Daniel Mack <[email protected]>
This should have been Signed-off-by:, as you were on the patch delivery path.
I made that change to my copy of the patch, thanks.
Quoted 1 line
Cc Andy Green <[email protected]>
PATCH 1/1 ARM: imx serial driver: fix resume
In reply to Daniel MackHello Daniel (and Volker),
Quoted 35 lines · Daniel Mack
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "
drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".However calling "
imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.Signed-off-by Volker Ernst <[email protected]>Cc Daniel Mack <[email protected]>Cc Andy Green <[email protected]>---
Volker did all the work on this, he just doesn't want to push his great contributions upstream, so I do it for him :)
drivers/serial/imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/serial/imx.c +0
-0
drivers/serial/imx.c static inline void imx_transmit_buffer(struct imx_port *sport) · line 332
Quoted 5 lines
drivers/serial/imx.c +2
-0@@ -328,13 +328,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)struct circ_buf *xmit = &sport->port.state->xmit;while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +if (uart_circ_empty (xmit)) +break ;
As readl is a hardware access and uart_circ_empty "only" needs RAM, I wonder if using
while (!uart_circ_empty(xmit) &&
!(readl(sport->port.membase + UTS) & UTS_TXFULL)) {would be a tad smarter.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 serial/imx: check that the buffer is non-empty before sending it out
From: Volker Ernst <[email protected]>
The .start_tx callback (imx_start_tx here) isn't only called when the buffer is non-empty. E.g. after resume or when handshaking is enabled and the other side starts to signal being ready.
So check for an empty puffer already before sending the first character. This prevents sending out stale (or uninitialised) data.
---
Hello,
as I didn't sent a patch, here comes my current version. Don't know if it makes it easier to test for you ...
I faked Daniel's SoB as Andrew said he did, compressed the changelog a bit and put the check in the while condition as I suggested.
Best regards
Uwe
drivers/serial/imx.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/serial/imx.c +2 -3
@@ -327,14 +327,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport) {struct circ_buf *xmit = &sport->port.state->xmit; -while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +while (!uart_circ_empty (xmit) && + !(readl (sport->port.membase +UTS ) &UTS_TXFULL )) {/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )
Signature · 1 line
1.7.2.3
PATCH 1/1 serial/imx: check that the buffer is non-empty before sending it out
Quoted 14 lines · Uwe Kleine-K?nig
From: Volker Ernst <[email protected]>
The .start_tx callback (
imx_start_txhere) isn't only called when the buffer is non-empty. E.g. after resume or when handshaking is enabled and the other side starts to signal being ready.So check for an empty puffer already before sending the first character. This prevents sending out stale (or uninitialised) data.
Signed-off-by Volker Ernst <[email protected]>Signed-off-by Daniel Mack <[email protected]>Cc Andy Green <[email protected]>[ukl: reword commit log, put check in while condition]Signed-off-by Uwe Kleine-K?nig <[email protected]>
Quoted 8 lines
---
Hello,as I didn't sent a patch, here comes my current version. Don't know if it makes it easier to test for you ...
I faked Daniel's SoB as Andrew said he did, compressed the changelog a bit and put the check in the while condition as I suggested.
FWIW, that looks good to me. Thanks for finishing the work :)
Daniel
Quoted 32 lines
drivers/serial/imx.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)drivers/serial/imx.c +2
-3@@ -327,14 +327,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport) {struct circ_buf *xmit = &sport->port.state->xmit; -while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +while (!uart_circ_empty (xmit) && + !(readl (sport->port.membase +UTS ) &UTS_TXFULL )) {/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )Signature · 7 lines
1.7.2.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 serial/imx: check that the buffer is non-empty before sending it out
Quoted 18 lines · Daniel Mack
Quoted 17 lines · Uwe Kleine-K?nig
From: Volker Ernst <[email protected]>
The .start_tx callback (
imx_start_txhere) isn't only called when the buffer is non-empty. E.g. after resume or when handshaking is enabled and the other side starts to signal being ready.So check for an empty puffer already before sending the first character. This prevents sending out stale (or uninitialised) data.
Signed-off-by Volker Ernst <[email protected]>Signed-off-by Daniel Mack <[email protected]>Cc Andy Green <[email protected]>[ukl: reword commit log, put check in while condition]Signed-off-by Uwe Kleine-K?nig <[email protected]>---
Hello,
Quoted 7 lines
Quoted 5 lines
as I didn't sent a patch, here comes my current version. Don't know if it makes it easier to test for you ...
I faked Daniel's SoB as Andrew said he did, compressed the changelog a bit and put the check in the while condition as I suggested.
FWIW, that looks good to me. Thanks for finishing the work :)
Nice, I've replaced the original patch in my tree with this one.
thanks,
greg k-h
PATCH 1/1 ARM: imx serial driver: fix resume
In reply to Daniel MackHallo Daniel und Volker,
Quoted 40 lines · Daniel Mack
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "
drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".However calling "
imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.Signed-off-by Volker Ernst <[email protected]>Cc Daniel Mack <[email protected]>Cc Andy Green <[email protected]>---
Volker did all the work on this, he just doesn't want to push his great contributions upstream, so I do it for him :)
drivers/serial/imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/serial/imx.c +2
-0@@ -328,13 +328,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)struct circ_buf *xmit = &sport->port.state->xmit;while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +if (uart_circ_empty (xmit)) +break ;
drivers/serial/imx.c static inline void imx_transmit_buffer(struct imx_port *sport) · line 340
Quoted 10 lines
drivers/serial/imx.c +0
-2/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )
I needed that patch now, too, though in a different situation. I havn't investigated the details yet, but I think the problem is that imx_transmit_buffer is called, too, when using handshaking and the other side starts to be ready.
You can count that as an Acked-by: me, preferably with the check added to the while condition as suggested in a different mail of this thread.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/1 ARM: imx serial driver: fix resume
Quoted 50 lines · Uwe Kleine-K?nig
Quoted 49 lines · Daniel Mack
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "
drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".However calling "
imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.Signed-off-by Volker Ernst <[email protected]>Cc Daniel Mack <[email protected]>Cc Andy Green <[email protected]>---
Volker did all the work on this, he just doesn't want to push his great contributions upstream, so I do it for him :)
drivers/serial/imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/serial/imx.c +2
-2@@ -328,13 +328,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)struct circ_buf *xmit = &sport->port.state->xmit;while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +if (uart_circ_empty (xmit)) +break ;/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }
Quoted 8 lines
drivers/serial/imx.c static inline void imx_transmit_buffer(struct imx_port *sport) · line 340
Quoted 1 line
drivers/serial/imx.c +0
-0if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )I needed that patch now, too, though in a different situation. I havn't investigated the details yet, but I think the problem is that
imx_transmit_bufferis called, too, when using handshaking and the other side starts to be ready.You can count that as an Acked-by: me, preferably with the check added to the while condition as suggested in a different mail of this thread.
Ok, thanks. However, I can not test this myself - Volker, can you try the patch Uwe sent along some days ago?
Thanks,
Daniel
PATCH 1/1 ARM: imx serial driver: fix resume
Quoted 57 lines · Daniel Mack
Quoted 56 lines · Uwe Kleine-K?nig
Quoted 40 lines · Daniel Mack
From: Volker Ernst <[email protected]>
I just came across a bug in the IMX31 serial driver which is still present in the newest kernels and which prevents successful resume-operation for the IMX31 serial ports.
What happens is that in "
drivers/serial/imx.c" on resume function "serial_imx_resume" gets called. This function in turn calls "uart_resume_port" (in the generic serial driver "serial_core.c"), which in turn calls "imx_start_tx" in "imx.c" (in case the SIO-port was really suspended) which in turn calls "imx_transmit_buffer".However calling "
imx_transmit_buffer" with an empty TX-fifo (as is usually the case) will result in the serial port starting to transmit (actually the old [already sent] tx-buffer), as there is no check if the tx-buffer is empty before starting to feed tx-fifo-data to the serial port hardware.Signed-off-by Volker Ernst <[email protected]>Cc Daniel Mack <[email protected]>Cc Andy Green <[email protected]>---
Volker did all the work on this, he just doesn't want to push his great contributions upstream, so I do it for him :)
drivers/serial/imx.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/serial/imx.c +2
-0@@ -328,13 +328,13 @@ static inline void imx_transmit_buffer(struct imx_port *sport)struct circ_buf *xmit = &sport->port.state->xmit;while (!(readl (sport->port.membase +UTS ) &UTS_TXFULL )) { +if (uart_circ_empty (xmit)) +break ;drivers/serial/imx.c static inline void imx_transmit_buffer(struct imx_port *sport) · line 340
Quoted 10 lines
drivers/serial/imx.c +0
-2/* send xmit->buf[xmit->tail] * out the port here */ writel (xmit->buf[xmit->tail], sport->port.membase +URTX0 ); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); sport->port.icount.tx++; -if (uart_circ_empty (xmit)) -break ; }if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )I needed that patch now, too, though in a different situation. I havn't investigated the details yet, but I think the problem is that
imx_transmit_bufferis called, too, when using handshaking and the other side starts to be ready.
Quoted 5 lines
Quoted 2 lines
You can count that as an Acked-by: me, preferably with the check added to the while condition as suggested in a different mail of this thread.
Ok, thanks. However, I can not test this myself - Volker, can you try the patch Uwe sent along some days ago?
I'm currently working on an other issue with the driver that will result in a few patches. So I can just pick up this patch en passant and look to get it into mainline.
Still a fixed patch or an Ack would be fine.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |