* [PATCH v3 0/6] LPUART fixes and improvements
@ 2019-08-05 18:56 Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 1/6] tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup() Andrey Smirnov
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:56 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Everyone:
This series contains fixes/improvements to LPUART dirver I came up
with recently as well as fixes picked up from Toradex and NXP Vybrid
repos.
Feedback is welcome!
Changes since [v2]:
- Series rebased on Greg's tty-testing branch
Changes since [v1]:
- Dropped "tty: serial: fsl_lpuart: Drop unnecessary sg_set_buf()
call" due to being a duplicate of "tty: serial: fsl_lpuart: remove
sg_set_buf() for sport->rx_sgl"
- Fixed build break in "tty: serial: fsl_lpuart: Introduce
lpuart_tx_dma_startup()"
Thanks,
Andrey Smirnov
[v2] lore.kernel.org/r/20190731173045.11718-1-andrew.smirnov@gmail.com
[v1] lore.kernel.org/r/20190729195226.8862-1-andrew.smirnov@gmail.com
Andrey Smirnov (6):
tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup()
tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup()
tty: serial: fsl_lpuart: Introduce lpuart32_configure()
tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable()
tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume()
tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabled
drivers/tty/serial/fsl_lpuart.c | 195 +++++++++++++++-----------------
1 file changed, 91 insertions(+), 104 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/6] tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup()
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
@ 2019-08-05 18:56 ` Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 2/6] tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup() Andrey Smirnov
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:56 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Code configure DMA TX path in lpuart_startup(), lpuart32_startup() and
lpuart_resume() is doing exactly the same thing, so move it into a
standalone subroutine.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 53 ++++++++++++++-------------------
1 file changed, 23 insertions(+), 30 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 0e09e6dc5ccb..9da4529ee223 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1435,6 +1435,26 @@ static void rx_dma_timer_init(struct lpuart_port *sport)
add_timer(&sport->lpuart_timer);
}
+static void lpuart_tx_dma_startup(struct lpuart_port *sport)
+{
+ u32 uartbaud;
+
+ if (sport->dma_tx_chan && !lpuart_dma_tx_request(&sport->port)) {
+ init_waitqueue_head(&sport->dma_wait);
+ sport->lpuart_dma_tx_use = true;
+ if (lpuart_is_32(sport)) {
+ uartbaud = lpuart32_read(&sport->port, UARTBAUD);
+ lpuart32_write(&sport->port,
+ uartbaud | UARTBAUD_TDMAE, UARTBAUD);
+ } else {
+ writeb(readb(sport->port.membase + UARTCR5) |
+ UARTCR5_TDMAS, sport->port.membase + UARTCR5);
+ }
+ } else {
+ sport->lpuart_dma_tx_use = false;
+ }
+}
+
static int lpuart_startup(struct uart_port *port)
{
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
@@ -1471,14 +1491,7 @@ static int lpuart_startup(struct uart_port *port)
sport->lpuart_dma_rx_use = false;
}
- if (sport->dma_tx_chan && !lpuart_dma_tx_request(port)) {
- init_waitqueue_head(&sport->dma_wait);
- sport->lpuart_dma_tx_use = true;
- temp = readb(port->membase + UARTCR5);
- writeb(temp | UARTCR5_TDMAS, port->membase + UARTCR5);
- } else {
- sport->lpuart_dma_tx_use = false;
- }
+ lpuart_tx_dma_startup(sport);
spin_unlock_irqrestore(&sport->port.lock, flags);
@@ -1521,14 +1534,7 @@ static int lpuart32_startup(struct uart_port *port)
sport->lpuart_dma_rx_use = false;
}
- if (sport->dma_tx_chan && !lpuart_dma_tx_request(port)) {
- init_waitqueue_head(&sport->dma_wait);
- sport->lpuart_dma_tx_use = true;
- temp = lpuart32_read(&sport->port, UARTBAUD);
- lpuart32_write(&sport->port, temp | UARTBAUD_TDMAE, UARTBAUD);
- } else {
- sport->lpuart_dma_tx_use = false;
- }
+ lpuart_tx_dma_startup(sport);
if (sport->lpuart_dma_rx_use) {
/* RXWATER must be 0 */
@@ -2577,20 +2583,7 @@ static int lpuart_resume(struct device *dev)
}
}
- if (sport->dma_tx_chan && !lpuart_dma_tx_request(&sport->port)) {
- init_waitqueue_head(&sport->dma_wait);
- sport->lpuart_dma_tx_use = true;
- if (lpuart_is_32(sport)) {
- temp = lpuart32_read(&sport->port, UARTBAUD);
- lpuart32_write(&sport->port,
- temp | UARTBAUD_TDMAE, UARTBAUD);
- } else {
- writeb(readb(sport->port.membase + UARTCR5) |
- UARTCR5_TDMAS, sport->port.membase + UARTCR5);
- }
- } else {
- sport->lpuart_dma_tx_use = false;
- }
+ lpuart_tx_dma_startup(sport);
if (lpuart_is_32(sport)) {
if (sport->lpuart_dma_rx_use) {
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/6] tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup()
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 1/6] tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup() Andrey Smirnov
@ 2019-08-05 18:56 ` Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 3/6] tty: serial: fsl_lpuart: Introduce lpuart32_configure() Andrey Smirnov
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:56 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Code doing initial DMA RX configuration in lpuart_startup() and
lpuart32_startup() is exactly the same, so move it into a standalone
subroutine.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 40 ++++++++++++++-------------------
1 file changed, 17 insertions(+), 23 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 9da4529ee223..4b59801a0a0c 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1455,6 +1455,21 @@ static void lpuart_tx_dma_startup(struct lpuart_port *sport)
}
}
+static void lpuart_rx_dma_startup(struct lpuart_port *sport)
+{
+ if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) {
+ /* set Rx DMA timeout */
+ sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT);
+ if (!sport->dma_rx_timeout)
+ sport->dma_rx_timeout = 1;
+
+ sport->lpuart_dma_rx_use = true;
+ rx_dma_timer_init(sport);
+ } else {
+ sport->lpuart_dma_rx_use = false;
+ }
+}
+
static int lpuart_startup(struct uart_port *port)
{
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
@@ -1479,18 +1494,7 @@ static int lpuart_startup(struct uart_port *port)
temp |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE;
writeb(temp, sport->port.membase + UARTCR2);
- if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) {
- /* set Rx DMA timeout */
- sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT);
- if (!sport->dma_rx_timeout)
- sport->dma_rx_timeout = 1;
-
- sport->lpuart_dma_rx_use = true;
- rx_dma_timer_init(sport);
- } else {
- sport->lpuart_dma_rx_use = false;
- }
-
+ lpuart_rx_dma_startup(sport);
lpuart_tx_dma_startup(sport);
spin_unlock_irqrestore(&sport->port.lock, flags);
@@ -1522,18 +1526,8 @@ static int lpuart32_startup(struct uart_port *port)
temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE;
lpuart32_write(&sport->port, temp, UARTCTRL);
- if (sport->dma_rx_chan && !lpuart_start_rx_dma(sport)) {
- /* set Rx DMA timeout */
- sport->dma_rx_timeout = msecs_to_jiffies(DMA_RX_TIMEOUT);
- if (!sport->dma_rx_timeout)
- sport->dma_rx_timeout = 1;
-
- sport->lpuart_dma_rx_use = true;
- rx_dma_timer_init(sport);
- } else {
- sport->lpuart_dma_rx_use = false;
- }
+ lpuart_rx_dma_startup(sport);
lpuart_tx_dma_startup(sport);
if (sport->lpuart_dma_rx_use) {
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/6] tty: serial: fsl_lpuart: Introduce lpuart32_configure()
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 1/6] tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup() Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 2/6] tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup() Andrey Smirnov
@ 2019-08-05 18:56 ` Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 4/6] tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable() Andrey Smirnov
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:56 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Code doing final steps of TX/RX configuration in lpuart32_startup()
and lpuart_resume() is identical, so move it into a standalone
subroutine.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 48 +++++++++++++++------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 4b59801a0a0c..1286daa1be79 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1502,6 +1502,24 @@ static int lpuart_startup(struct uart_port *port)
return 0;
}
+static void lpuart32_configure(struct lpuart_port *sport)
+{
+ unsigned long temp;
+
+ if (sport->lpuart_dma_rx_use) {
+ /* RXWATER must be 0 */
+ temp = lpuart32_read(&sport->port, UARTWATER);
+ temp &= ~(UARTWATER_WATER_MASK << UARTWATER_RXWATER_OFF);
+ lpuart32_write(&sport->port, temp, UARTWATER);
+ }
+ temp = lpuart32_read(&sport->port, UARTCTRL);
+ if (!sport->lpuart_dma_rx_use)
+ temp |= UARTCTRL_RIE;
+ if (!sport->lpuart_dma_tx_use)
+ temp |= UARTCTRL_TIE;
+ lpuart32_write(&sport->port, temp, UARTCTRL);
+}
+
static int lpuart32_startup(struct uart_port *port)
{
struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
@@ -1530,18 +1548,7 @@ static int lpuart32_startup(struct uart_port *port)
lpuart_rx_dma_startup(sport);
lpuart_tx_dma_startup(sport);
- if (sport->lpuart_dma_rx_use) {
- /* RXWATER must be 0 */
- temp = lpuart32_read(&sport->port, UARTWATER);
- temp &= ~(UARTWATER_WATER_MASK << UARTWATER_RXWATER_OFF);
- lpuart32_write(&sport->port, temp, UARTWATER);
- }
- temp = lpuart32_read(&sport->port, UARTCTRL);
- if (!sport->lpuart_dma_rx_use)
- temp |= UARTCTRL_RIE;
- if (!sport->lpuart_dma_tx_use)
- temp |= UARTCTRL_TIE;
- lpuart32_write(&sport->port, temp, UARTCTRL);
+ lpuart32_configure(sport);
spin_unlock_irqrestore(&sport->port.lock, flags);
return 0;
@@ -2579,21 +2586,8 @@ static int lpuart_resume(struct device *dev)
lpuart_tx_dma_startup(sport);
- if (lpuart_is_32(sport)) {
- if (sport->lpuart_dma_rx_use) {
- /* RXWATER must be 0 */
- temp = lpuart32_read(&sport->port, UARTWATER);
- temp &= ~(UARTWATER_WATER_MASK <<
- UARTWATER_RXWATER_OFF);
- lpuart32_write(&sport->port, temp, UARTWATER);
- }
- temp = lpuart32_read(&sport->port, UARTCTRL);
- if (!sport->lpuart_dma_rx_use)
- temp |= UARTCTRL_RIE;
- if (!sport->lpuart_dma_tx_use)
- temp |= UARTCTRL_TIE;
- lpuart32_write(&sport->port, temp, UARTCTRL);
- }
+ if (lpuart_is_32(sport))
+ lpuart32_configure(sport);
uart_resume_port(&lpuart_reg, &sport->port);
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/6] tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable()
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
` (2 preceding siblings ...)
2019-08-05 18:56 ` [PATCH v3 3/6] tty: serial: fsl_lpuart: Introduce lpuart32_configure() Andrey Smirnov
@ 2019-08-05 18:56 ` Andrey Smirnov
2019-08-05 18:57 ` [PATCH v3 5/6] tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume() Andrey Smirnov
2019-08-05 18:57 ` [PATCH v3 6/6] tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabled Andrey Smirnov
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:56 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Most users of lpuart*_setup_watermark() enable identical set of flags
right after the call, so combine those two action into a subroutine
and make use of it.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 50 ++++++++++++++++++---------------
1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 1286daa1be79..fb9961edce3a 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1403,6 +1403,17 @@ static void lpuart_setup_watermark(struct lpuart_port *sport)
writeb(cr2_saved, sport->port.membase + UARTCR2);
}
+static void lpuart_setup_watermark_enable(struct lpuart_port *sport)
+{
+ unsigned char cr2;
+
+ lpuart_setup_watermark(sport);
+
+ cr2 = readb(sport->port.membase + UARTCR2);
+ cr2 |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE;
+ writeb(cr2, sport->port.membase + UARTCR2);
+}
+
static void lpuart32_setup_watermark(struct lpuart_port *sport)
{
unsigned long val, ctrl;
@@ -1428,6 +1439,17 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport)
lpuart32_write(&sport->port, ctrl_saved, UARTCTRL);
}
+static void lpuart32_setup_watermark_enable(struct lpuart_port *sport)
+{
+ u32 temp;
+
+ lpuart32_setup_watermark(sport);
+
+ temp = lpuart32_read(&sport->port, UARTCTRL);
+ temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE;
+ lpuart32_write(&sport->port, temp, UARTCTRL);
+}
+
static void rx_dma_timer_init(struct lpuart_port *sport)
{
timer_setup(&sport->lpuart_timer, lpuart_timer_func, 0);
@@ -1488,11 +1510,7 @@ static int lpuart_startup(struct uart_port *port)
spin_lock_irqsave(&sport->port.lock, flags);
- lpuart_setup_watermark(sport);
-
- temp = readb(sport->port.membase + UARTCR2);
- temp |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE;
- writeb(temp, sport->port.membase + UARTCR2);
+ lpuart_setup_watermark_enable(sport);
lpuart_rx_dma_startup(sport);
lpuart_tx_dma_startup(sport);
@@ -1538,11 +1556,7 @@ static int lpuart32_startup(struct uart_port *port)
spin_lock_irqsave(&sport->port.lock, flags);
- lpuart32_setup_watermark(sport);
-
- temp = lpuart32_read(&sport->port, UARTCTRL);
- temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE;
- lpuart32_write(&sport->port, temp, UARTCTRL);
+ lpuart32_setup_watermark_enable(sport);
lpuart_rx_dma_startup(sport);
@@ -2558,22 +2572,14 @@ static int lpuart_resume(struct device *dev)
{
struct lpuart_port *sport = dev_get_drvdata(dev);
bool irq_wake = irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq));
- unsigned long temp;
if (sport->port.suspended && !irq_wake)
lpuart_enable_clks(sport);
- if (lpuart_is_32(sport)) {
- lpuart32_setup_watermark(sport);
- temp = lpuart32_read(&sport->port, UARTCTRL);
- temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE;
- lpuart32_write(&sport->port, temp, UARTCTRL);
- } else {
- lpuart_setup_watermark(sport);
- temp = readb(sport->port.membase + UARTCR2);
- temp |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE;
- writeb(temp, sport->port.membase + UARTCR2);
- }
+ if (lpuart_is_32(sport))
+ lpuart32_setup_watermark_enable(sport);
+ else
+ lpuart_setup_watermark_enable(sport);
if (sport->lpuart_dma_rx_use) {
if (irq_wake) {
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/6] tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume()
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
` (3 preceding siblings ...)
2019-08-05 18:56 ` [PATCH v3 4/6] tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable() Andrey Smirnov
@ 2019-08-05 18:57 ` Andrey Smirnov
2019-08-05 18:57 ` [PATCH v3 6/6] tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabled Andrey Smirnov
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:57 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
Enabling TIE in .startup() callback causes the driver to start (or at
least try) to transmit data before .start_tx() is called. Which, while
harmless (since TIE handler will immediately disable it), is a no-op
and shouldn't really happen. Drop UARTCR2_TIE from list of bits set in
lpuart_startup().
This change will also not enable TIE in .resume(), but it seems that,
similart to .startup(), transmit interrupt shouldn't be enabled there
either.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index fb9961edce3a..5c3cc1051aa8 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1410,7 +1410,7 @@ static void lpuart_setup_watermark_enable(struct lpuart_port *sport)
lpuart_setup_watermark(sport);
cr2 = readb(sport->port.membase + UARTCR2);
- cr2 |= UARTCR2_RIE | UARTCR2_TIE | UARTCR2_RE | UARTCR2_TE;
+ cr2 |= UARTCR2_RIE | UARTCR2_RE | UARTCR2_TE;
writeb(cr2, sport->port.membase + UARTCR2);
}
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 6/6] tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabled
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
` (4 preceding siblings ...)
2019-08-05 18:57 ` [PATCH v3 5/6] tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume() Andrey Smirnov
@ 2019-08-05 18:57 ` Andrey Smirnov
5 siblings, 0 replies; 7+ messages in thread
From: Andrey Smirnov @ 2019-08-05 18:57 UTC (permalink / raw)
To: linux-serial
Cc: Andrey Smirnov, Stefan Agner, Chris Healy, Cory Tusar,
Lucas Stach, Greg Kroah-Hartman, Jiri Slaby, linux-imx,
linux-kernel
In a mixed DMA/IRQ use-case (e.g.: DMA for TX, IRQ for RX), interrupt
handler might try to handle Rx/Tx condition it shouldn't. Change the
code to only handle TX/RX event if corresponding path isn't being
handled by DMA.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Cory Tusar <cory.tusar@zii.aero>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: linux-imx@nxp.com
Cc: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
drivers/tty/serial/fsl_lpuart.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 5c3cc1051aa8..3e17bb8a0b16 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -967,10 +967,10 @@ static irqreturn_t lpuart_int(int irq, void *dev_id)
sts = readb(sport->port.membase + UARTSR1);
- if (sts & UARTSR1_RDRF)
+ if (sts & UARTSR1_RDRF && !sport->lpuart_dma_rx_use)
lpuart_rxint(sport);
- if (sts & UARTSR1_TDRE)
+ if (sts & UARTSR1_TDRE && !sport->lpuart_dma_tx_use)
lpuart_txint(sport);
return IRQ_HANDLED;
--
2.21.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-08-05 18:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 18:56 [PATCH v3 0/6] LPUART fixes and improvements Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 1/6] tty: serial: fsl_lpuart: Introduce lpuart_tx_dma_startup() Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 2/6] tty: serial: fsl_lpuart: Introduce lpuart_rx_dma_startup() Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 3/6] tty: serial: fsl_lpuart: Introduce lpuart32_configure() Andrey Smirnov
2019-08-05 18:56 ` [PATCH v3 4/6] tty: serial: fsl_lpuart: Introduce lpuart*_setup_watermark_enable() Andrey Smirnov
2019-08-05 18:57 ` [PATCH v3 5/6] tty: serial: fsl_lpuart: Don't enable TIE in .startup() or .resume() Andrey Smirnov
2019-08-05 18:57 ` [PATCH v3 6/6] tty: serial: fsl_lpuart: Ignore TX/RX interrupts if DMA is enabled Andrey Smirnov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).