All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs
@ 2021-06-22 14:57 ` Vignesh Raghavendra
  0 siblings, 0 replies; 4+ messages in thread
From: Vignesh Raghavendra @ 2021-06-22 14:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Vignesh Raghavendra, Tony Lindgren, linux-serial, linux-omap,
	Linux ARM Mailing List, Jan Kiszka

On K3 family of SoCs (which includes AM654 SoC), it is observed that RX
TIMEOUT is signalled after RX FIFO has been drained, in which case a
dummy read of RX FIFO is required to clear RX TIMEOUT condition.
Otherwise, this would lead to an interrupt storm.

Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy
read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO.

Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller")
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
v2:
Restrict workaround to K3 family of devices only (ti,am654-uart) where
issue was reported.

v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com

 drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index c06631ced414..79418d4beb48 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -43,6 +43,7 @@
 #define UART_ERRATA_CLOCK_DISABLE	(1 << 3)
 #define	UART_HAS_EFR2			BIT(4)
 #define UART_HAS_RHR_IT_DIS		BIT(5)
+#define UART_RX_TIMEOUT_QUIRK		BIT(6)
 
 #define OMAP_UART_FCR_RX_TRIG		6
 #define OMAP_UART_FCR_TX_TRIG		4
@@ -104,6 +105,9 @@
 #define UART_OMAP_EFR2			0x23
 #define UART_OMAP_EFR2_TIMEOUT_BEHAVE	BIT(6)
 
+/* RX FIFO occupancy indicator */
+#define UART_OMAP_RX_LVL		0x64
+
 struct omap8250_priv {
 	int line;
 	u8 habit;
@@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port);
 static irqreturn_t omap8250_irq(int irq, void *dev_id)
 {
 	struct uart_port *port = dev_id;
+	struct omap8250_priv *priv = port->private_data;
 	struct uart_8250_port *up = up_to_u8250p(port);
 	unsigned int iir;
 	int ret;
@@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
 	serial8250_rpm_get(up);
 	iir = serial_port_in(port, UART_IIR);
 	ret = serial8250_handle_irq(port, iir);
+
+	/*
+	 * On K3 SoCs, it is observed that RX TIMEOUT is signalled after
+	 * FIFO has been drained, in which case a dummy read of RX FIFO
+	 * is required to clear RX TIMEOUT condition.
+	 */
+	if (priv->habit & UART_RX_TIMEOUT_QUIRK &&
+	    (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT &&
+	    serial_port_in(port, UART_OMAP_RX_LVL) == 0) {
+		serial_port_in(port, UART_RX);
+	}
+
 	serial8250_rpm_put(up);
 
 	return IRQ_RETVAL(ret);
@@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = {
 
 static struct omap8250_platdata am654_platdata = {
 	.dma_params	= &am654_dma,
-	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS,
+	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS |
+			  UART_RX_TIMEOUT_QUIRK,
 };
 
 static struct omap8250_platdata am33xx_platdata = {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs
@ 2021-06-22 14:57 ` Vignesh Raghavendra
  0 siblings, 0 replies; 4+ messages in thread
From: Vignesh Raghavendra @ 2021-06-22 14:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Vignesh Raghavendra, Tony Lindgren, linux-serial, linux-omap,
	Linux ARM Mailing List, Jan Kiszka

On K3 family of SoCs (which includes AM654 SoC), it is observed that RX
TIMEOUT is signalled after RX FIFO has been drained, in which case a
dummy read of RX FIFO is required to clear RX TIMEOUT condition.
Otherwise, this would lead to an interrupt storm.

Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy
read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO.

Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller")
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
v2:
Restrict workaround to K3 family of devices only (ti,am654-uart) where
issue was reported.

v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com

 drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index c06631ced414..79418d4beb48 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -43,6 +43,7 @@
 #define UART_ERRATA_CLOCK_DISABLE	(1 << 3)
 #define	UART_HAS_EFR2			BIT(4)
 #define UART_HAS_RHR_IT_DIS		BIT(5)
+#define UART_RX_TIMEOUT_QUIRK		BIT(6)
 
 #define OMAP_UART_FCR_RX_TRIG		6
 #define OMAP_UART_FCR_TX_TRIG		4
@@ -104,6 +105,9 @@
 #define UART_OMAP_EFR2			0x23
 #define UART_OMAP_EFR2_TIMEOUT_BEHAVE	BIT(6)
 
+/* RX FIFO occupancy indicator */
+#define UART_OMAP_RX_LVL		0x64
+
 struct omap8250_priv {
 	int line;
 	u8 habit;
@@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port);
 static irqreturn_t omap8250_irq(int irq, void *dev_id)
 {
 	struct uart_port *port = dev_id;
+	struct omap8250_priv *priv = port->private_data;
 	struct uart_8250_port *up = up_to_u8250p(port);
 	unsigned int iir;
 	int ret;
@@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
 	serial8250_rpm_get(up);
 	iir = serial_port_in(port, UART_IIR);
 	ret = serial8250_handle_irq(port, iir);
+
+	/*
+	 * On K3 SoCs, it is observed that RX TIMEOUT is signalled after
+	 * FIFO has been drained, in which case a dummy read of RX FIFO
+	 * is required to clear RX TIMEOUT condition.
+	 */
+	if (priv->habit & UART_RX_TIMEOUT_QUIRK &&
+	    (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT &&
+	    serial_port_in(port, UART_OMAP_RX_LVL) == 0) {
+		serial_port_in(port, UART_RX);
+	}
+
 	serial8250_rpm_put(up);
 
 	return IRQ_RETVAL(ret);
@@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = {
 
 static struct omap8250_platdata am654_platdata = {
 	.dma_params	= &am654_dma,
-	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS,
+	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS |
+			  UART_RX_TIMEOUT_QUIRK,
 };
 
 static struct omap8250_platdata am33xx_platdata = {
-- 
2.32.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs
  2021-06-22 14:57 ` Vignesh Raghavendra
@ 2021-06-22 22:56   ` Jan Kiszka
  -1 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2021-06-22 22:56 UTC (permalink / raw)
  To: Vignesh Raghavendra, Greg Kroah-Hartman, Jiri Slaby
  Cc: Tony Lindgren, linux-serial, linux-omap, Linux ARM Mailing List

On 22.06.21 16:57, Vignesh Raghavendra wrote:
> On K3 family of SoCs (which includes AM654 SoC), it is observed that RX
> TIMEOUT is signalled after RX FIFO has been drained, in which case a
> dummy read of RX FIFO is required to clear RX TIMEOUT condition.
> Otherwise, this would lead to an interrupt storm.
> 
> Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy
> read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO.
> 
> Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller")
> Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
> v2:
> Restrict workaround to K3 family of devices only (ti,am654-uart) where
> issue was reported.
> 
> v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com
> 
>  drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index c06631ced414..79418d4beb48 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -43,6 +43,7 @@
>  #define UART_ERRATA_CLOCK_DISABLE	(1 << 3)
>  #define	UART_HAS_EFR2			BIT(4)
>  #define UART_HAS_RHR_IT_DIS		BIT(5)
> +#define UART_RX_TIMEOUT_QUIRK		BIT(6)
>  
>  #define OMAP_UART_FCR_RX_TRIG		6
>  #define OMAP_UART_FCR_TX_TRIG		4
> @@ -104,6 +105,9 @@
>  #define UART_OMAP_EFR2			0x23
>  #define UART_OMAP_EFR2_TIMEOUT_BEHAVE	BIT(6)
>  
> +/* RX FIFO occupancy indicator */
> +#define UART_OMAP_RX_LVL		0x64
> +
>  struct omap8250_priv {
>  	int line;
>  	u8 habit;
> @@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port);
>  static irqreturn_t omap8250_irq(int irq, void *dev_id)
>  {
>  	struct uart_port *port = dev_id;
> +	struct omap8250_priv *priv = port->private_data;
>  	struct uart_8250_port *up = up_to_u8250p(port);
>  	unsigned int iir;
>  	int ret;
> @@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
>  	serial8250_rpm_get(up);
>  	iir = serial_port_in(port, UART_IIR);
>  	ret = serial8250_handle_irq(port, iir);
> +
> +	/*
> +	 * On K3 SoCs, it is observed that RX TIMEOUT is signalled after
> +	 * FIFO has been drained, in which case a dummy read of RX FIFO
> +	 * is required to clear RX TIMEOUT condition.
> +	 */
> +	if (priv->habit & UART_RX_TIMEOUT_QUIRK &&
> +	    (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT &&
> +	    serial_port_in(port, UART_OMAP_RX_LVL) == 0) {
> +		serial_port_in(port, UART_RX);
> +	}
> +
>  	serial8250_rpm_put(up);
>  
>  	return IRQ_RETVAL(ret);
> @@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = {
>  
>  static struct omap8250_platdata am654_platdata = {
>  	.dma_params	= &am654_dma,
> -	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS,
> +	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS |
> +			  UART_RX_TIMEOUT_QUIRK,
>  };
>  
>  static struct omap8250_platdata am33xx_platdata = {
> 

Tested-by: Jan Kiszka <jan.kiszka@siemens.com>

Thanks,
Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs
@ 2021-06-22 22:56   ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2021-06-22 22:56 UTC (permalink / raw)
  To: Vignesh Raghavendra, Greg Kroah-Hartman, Jiri Slaby
  Cc: Tony Lindgren, linux-serial, linux-omap, Linux ARM Mailing List

On 22.06.21 16:57, Vignesh Raghavendra wrote:
> On K3 family of SoCs (which includes AM654 SoC), it is observed that RX
> TIMEOUT is signalled after RX FIFO has been drained, in which case a
> dummy read of RX FIFO is required to clear RX TIMEOUT condition.
> Otherwise, this would lead to an interrupt storm.
> 
> Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy
> read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO.
> 
> Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller")
> Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> ---
> v2:
> Restrict workaround to K3 family of devices only (ti,am654-uart) where
> issue was reported.
> 
> v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com
> 
>  drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> index c06631ced414..79418d4beb48 100644
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -43,6 +43,7 @@
>  #define UART_ERRATA_CLOCK_DISABLE	(1 << 3)
>  #define	UART_HAS_EFR2			BIT(4)
>  #define UART_HAS_RHR_IT_DIS		BIT(5)
> +#define UART_RX_TIMEOUT_QUIRK		BIT(6)
>  
>  #define OMAP_UART_FCR_RX_TRIG		6
>  #define OMAP_UART_FCR_TX_TRIG		4
> @@ -104,6 +105,9 @@
>  #define UART_OMAP_EFR2			0x23
>  #define UART_OMAP_EFR2_TIMEOUT_BEHAVE	BIT(6)
>  
> +/* RX FIFO occupancy indicator */
> +#define UART_OMAP_RX_LVL		0x64
> +
>  struct omap8250_priv {
>  	int line;
>  	u8 habit;
> @@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port);
>  static irqreturn_t omap8250_irq(int irq, void *dev_id)
>  {
>  	struct uart_port *port = dev_id;
> +	struct omap8250_priv *priv = port->private_data;
>  	struct uart_8250_port *up = up_to_u8250p(port);
>  	unsigned int iir;
>  	int ret;
> @@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
>  	serial8250_rpm_get(up);
>  	iir = serial_port_in(port, UART_IIR);
>  	ret = serial8250_handle_irq(port, iir);
> +
> +	/*
> +	 * On K3 SoCs, it is observed that RX TIMEOUT is signalled after
> +	 * FIFO has been drained, in which case a dummy read of RX FIFO
> +	 * is required to clear RX TIMEOUT condition.
> +	 */
> +	if (priv->habit & UART_RX_TIMEOUT_QUIRK &&
> +	    (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT &&
> +	    serial_port_in(port, UART_OMAP_RX_LVL) == 0) {
> +		serial_port_in(port, UART_RX);
> +	}
> +
>  	serial8250_rpm_put(up);
>  
>  	return IRQ_RETVAL(ret);
> @@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = {
>  
>  static struct omap8250_platdata am654_platdata = {
>  	.dma_params	= &am654_dma,
> -	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS,
> +	.habit		= UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS |
> +			  UART_RX_TIMEOUT_QUIRK,
>  };
>  
>  static struct omap8250_platdata am33xx_platdata = {
> 

Tested-by: Jan Kiszka <jan.kiszka@siemens.com>

Thanks,
Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-22 23:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 14:57 [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs Vignesh Raghavendra
2021-06-22 14:57 ` Vignesh Raghavendra
2021-06-22 22:56 ` Jan Kiszka
2021-06-22 22:56   ` Jan Kiszka

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.