All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31 14:33 Biju Das
  2022-11-01  7:43 ` Pavel Machek
  0 siblings, 1 reply; 12+ messages in thread
From: Biju Das @ 2022-10-31 14:33 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org#5.15.y
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 5.15 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/1667194204110137@kroah.com/T/#u
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 2f44c567ebd7..9991bb475ae1 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1106,11 +1106,13 @@ static void rcar_canfd_handle_global_receive(struct rcar_canfd_global *gpriv, u3
 {
 	struct rcar_canfd_channel *priv = gpriv->ch[ch];
 	u32 ridx = ch + RCANFD_RFFIFO_IDX;
-	u32 sts;
+	u32 sts, cc;
 
 	/* Handle Rx interrupts */
 	sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-	if (likely(sts & RCANFD_RFSTS_RFIF)) {
+	cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+	if (likely(sts & RCANFD_RFSTS_RFIF &&
+		   cc & RCANFD_RFCC_RFIE)) {
 		if (napi_schedule_prep(&priv->napi)) {
 			/* Disable Rx FIFO interrupts */
 			rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* Re: [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-10-31 14:33 [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
@ 2022-11-01  7:43 ` Pavel Machek
  2022-11-01  7:59   ` Biju Das
  0 siblings, 1 reply; 12+ messages in thread
From: Pavel Machek @ 2022-11-01  7:43 UTC (permalink / raw)
  To: Biju Das
  Cc: Wolfgang Grandegger, gregkh, Marc Kleine-Budde, Lad Prabhakar,
	Pavel Machek, Sasha Levin, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, linux-renesas-soc, stable

[-- Attachment #1: Type: text/plain, Size: 979 bytes --]

Hi!

> Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
> Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
> Cc: stable@vger.kernel.org#5.15.y
> [mkl: adjust commit message]

I got 7 or so copies of this, with slightly different Cc: lines.

AFAICT this is supposed to be stable kernel submission. In such case,
I'd expect [PATCH 4.14, 4.19, 5.10] in the subject line, and original
sign-off block from the mainline patch.

OTOH if it has Fixes tag (and it does) or Cc: stable (it has both),
normally there's no need to do separate submission to stable, as Greg
handles these automatically?

Thanks and best regards,
								Pavel
									
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* RE: [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-11-01  7:43 ` Pavel Machek
@ 2022-11-01  7:59   ` Biju Das
  2022-11-01 12:36     ` Bagas Sanjaya
  0 siblings, 1 reply; 12+ messages in thread
From: Biju Das @ 2022-11-01  7:59 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Wolfgang Grandegger, gregkh, Marc Kleine-Budde,
	Prabhakar Mahadev Lad, Sasha Levin, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, linux-renesas-soc, stable

Hi Pavel,

Thanks for the feedback.

> Subject: Re: [PATCH] can: rcar_canfd:
> rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO
> receive
> 
> Hi!
> 
> > Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD
> > driver")
> > Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Link:
> > https://lore.kernel.org/all/20221025155657.1426948-2-
> biju.das.jz@bp.re
> > nesas.com
> > Cc: stable@vger.kernel.org#5.15.y
> > [mkl: adjust commit message]
> 
> I got 7 or so copies of this, with slightly different Cc: lines.

I followed option 1 mentioned in [1]

[1] https://www.kernel.org/doc/html/v5.10/process/stable-kernel-rules.html


> 
> AFAICT this is supposed to be stable kernel submission. In such case,
> I'd expect [PATCH 4.14, 4.19, 5.10] in the subject line, and original
> sign-off block from the mainline patch.

OK. Maybe [1] needs updating.

> 
> OTOH if it has Fixes tag (and it does) or Cc: stable (it has both),
> normally there's no need to do separate submission to stable, as Greg
> handles these automatically?

I got merge conflict mails for 4.9, 4.14, 4.19, 5.4, 5.10 and 5.15 stable.
I thought, I need to fix the conflicts and resend. Am I missing anything?? Please let me know.

Cheers,
biju








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

* Re: [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-11-01  7:59   ` Biju Das
@ 2022-11-01 12:36     ` Bagas Sanjaya
  2022-11-01 13:32       ` gregkh
  0 siblings, 1 reply; 12+ messages in thread
From: Bagas Sanjaya @ 2022-11-01 12:36 UTC (permalink / raw)
  To: Biju Das, Pavel Machek
  Cc: Wolfgang Grandegger, gregkh, Marc Kleine-Budde,
	Prabhakar Mahadev Lad, Sasha Levin, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, linux-renesas-soc, stable

On 11/1/22 14:59, Biju Das wrote:
>> I got 7 or so copies of this, with slightly different Cc: lines.
> 
> I followed option 1 mentioned in [1]
> > [1] https://www.kernel.org/doc/html/v5.10/process/stable-kernel-rules.html
> 
> 
>>
>> AFAICT this is supposed to be stable kernel submission. In such case,
>> I'd expect [PATCH 4.14, 4.19, 5.10] in the subject line, and original
>> sign-off block from the mainline patch.
> 
> OK. Maybe [1] needs updating.

The documentation says (in this case the third option applies):

> Send the patch, after verifying that it follows the above rules, to> stable@vger.kernel.org. You must note the upstream commit ID in the
> changelog of your submission, as well as the kernel version you wish
> it to be applied to.

It doesn't specify how to mark desired target branch, unfortunately.

> 
>>
>> OTOH if it has Fixes tag (and it does) or Cc: stable (it has both),
>> normally there's no need to do separate submission to stable, as Greg
>> handles these automatically?
> 
> I got merge conflict mails for 4.9, 4.14, 4.19, 5.4, 5.10 and 5.15 stable.
> I thought, I need to fix the conflicts and resend. Am I missing anything?? Please let me know.
> 

The upstream commit didn't apply cleanly to *all* stable branches due
to conflicts, right?

Thanks.

-- 
An old man doll... just what I always wanted! - Clara


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

* Re: [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-11-01 12:36     ` Bagas Sanjaya
@ 2022-11-01 13:32       ` gregkh
  0 siblings, 0 replies; 12+ messages in thread
From: gregkh @ 2022-11-01 13:32 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: Biju Das, Pavel Machek, Wolfgang Grandegger, Marc Kleine-Budde,
	Prabhakar Mahadev Lad, Sasha Levin, linux-can, netdev,
	Geert Uytterhoeven, Chris Paterson, linux-renesas-soc, stable

On Tue, Nov 01, 2022 at 07:36:20PM +0700, Bagas Sanjaya wrote:
> On 11/1/22 14:59, Biju Das wrote:
> >> I got 7 or so copies of this, with slightly different Cc: lines.
> > 
> > I followed option 1 mentioned in [1]
> > > [1] https://www.kernel.org/doc/html/v5.10/process/stable-kernel-rules.html
> > 
> > 
> >>
> >> AFAICT this is supposed to be stable kernel submission. In such case,
> >> I'd expect [PATCH 4.14, 4.19, 5.10] in the subject line, and original
> >> sign-off block from the mainline patch.
> > 
> > OK. Maybe [1] needs updating.
> 
> The documentation says (in this case the third option applies):
> 
> > Send the patch, after verifying that it follows the above rules, to> stable@vger.kernel.org. You must note the upstream commit ID in the
> > changelog of your submission, as well as the kernel version you wish
> > it to be applied to.
> 
> It doesn't specify how to mark desired target branch, unfortunately.

And that's fine, the submitter did the right thing here and gave me all
of the information that I need.  Please do not confuse people, there is
nothing wrong with the submission as-is.

thanks,

greg k-h

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

* Re: [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
  2022-10-31  9:04 Biju Das
@ 2022-11-02  1:36 ` Greg KH
  0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2022-11-02  1:36 UTC (permalink / raw)
  To: Biju Das
  Cc: Wolfgang Grandegger, Marc Kleine-Budde, Lad Prabhakar,
	Pavel Machek, Sasha Levin, linux-can, netdev, Geert Uytterhoeven,
	Chris Paterson, linux-renesas-soc, stable

On Mon, Oct 31, 2022 at 09:04:20AM +0000, Biju Das wrote:
> commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.
> 
> We are seeing an IRQ storm on the global receive IRQ line under heavy
> CAN bus load conditions with both CAN channels enabled.
> 
> Conditions:
> 
> The global receive IRQ line is shared between can0 and can1, either of
> the channels can trigger interrupt while the other channel's IRQ line
> is disabled (RFIE).
> 
> When global a receive IRQ interrupt occurs, we mask the interrupt in
> the IRQ handler. Clearing and unmasking of the interrupt is happening
> in rx_poll(). There is a race condition where rx_poll() unmasks the
> interrupt, but the next IRQ handler does not mask the IRQ due to
> NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
> can1 is triggering RX interrupt, the delay in rx_poll() processing
> results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.
> 
> This patch fixes the issue by checking IRQ active and enabled before
> handling the IRQ on a particular channel.
> 
> Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
> Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
> Cc: stable@vger.kernel.org # 4.9.x
> [mkl: adjust commit message]
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> [biju: removed gpriv from RCANFD_RFCC_RFIE macro]
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> Resending to 4.9 with confilcts[1] fixed
> [1] https://lore.kernel.org/stable/OS0PR01MB59226F2443DFCE7C5D73778786379@OS0PR01MB5922.jpnprd01.prod.outlook.com/T/#t
> ---
>  drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

All now queued up, thanks.

greg k-h

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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31 13:26 Biju Das
  0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2022-10-31 13:26 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org#5.10.y
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 5.10 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/166719420523255@kroah.com/T/#u
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 67f0f14e2bf4..c61534a2a2d3 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1075,7 +1075,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1093,7 +1093,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31 12:50 Biju Das
  0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2022-10-31 12:50 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org # 5.4.y
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 5.4 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/1667194206150167@kroah.com/T/#u
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index d4e9815ca26f..eed69e7e95ad 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1075,7 +1075,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1093,7 +1093,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31 11:50 Biju Das
  0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2022-10-31 11:50 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org # 4.19.y
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 4.19 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/16671942077080@kroah.com/T/#u
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a1634834b640..cb1388267fe0 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1079,7 +1079,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1097,7 +1097,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31  9:35 Biju Das
  0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2022-10-31  9:35 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org # 4.14.y
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 4.14 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/1667194208232105@kroah.com/T/#u
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a1634834b640..cb1388267fe0 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1079,7 +1079,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1097,7 +1097,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31  9:04 Biju Das
  2022-11-02  1:36 ` Greg KH
  0 siblings, 1 reply; 12+ messages in thread
From: Biju Das @ 2022-10-31  9:04 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org # 4.9.x
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 4.9 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/OS0PR01MB59226F2443DFCE7C5D73778786379@OS0PR01MB5922.jpnprd01.prod.outlook.com/T/#t
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a127c853a4e9..694a3354554f 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1079,7 +1079,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1097,7 +1097,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

* [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive
@ 2022-10-31  9:02 Biju Das
  0 siblings, 0 replies; 12+ messages in thread
From: Biju Das @ 2022-10-31  9:02 UTC (permalink / raw)
  To: Wolfgang Grandegger, gregkh, Marc Kleine-Budde
  Cc: Biju Das, Lad Prabhakar, Pavel Machek, Sasha Levin, linux-can,
	netdev, Geert Uytterhoeven, Chris Paterson, linux-renesas-soc,
	stable, #,
	4.9.x

commit 702de2c21eed04c67cefaaedc248ef16e5f6b293 upstream.

We are seeing an IRQ storm on the global receive IRQ line under heavy
CAN bus load conditions with both CAN channels enabled.

Conditions:

The global receive IRQ line is shared between can0 and can1, either of
the channels can trigger interrupt while the other channel's IRQ line
is disabled (RFIE).

When global a receive IRQ interrupt occurs, we mask the interrupt in
the IRQ handler. Clearing and unmasking of the interrupt is happening
in rx_poll(). There is a race condition where rx_poll() unmasks the
interrupt, but the next IRQ handler does not mask the IRQ due to
NAPIF_STATE_MISSED flag (e.g.: can0 RX FIFO interrupt is disabled and
can1 is triggering RX interrupt, the delay in rx_poll() processing
results in setting NAPIF_STATE_MISSED flag) leading to an IRQ storm.

This patch fixes the issue by checking IRQ active and enabled before
handling the IRQ on a particular channel.

Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/all/20221025155657.1426948-2-biju.das.jz@bp.renesas.com
Cc: stable@vger.kernel.org
[mkl: adjust commit message]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
[biju: removed gpriv from RCANFD_RFCC_RFIE macro]
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Resending to 4.9 with confilcts[1] fixed
[1] https://lore.kernel.org/stable/OS0PR01MB59226F2443DFCE7C5D73778786379@OS0PR01MB5922.jpnprd01.prod.outlook.com/T/#t
---
 drivers/net/can/rcar/rcar_canfd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index a127c853a4e9..694a3354554f 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1079,7 +1079,7 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 	struct rcar_canfd_global *gpriv = dev_id;
 	struct net_device *ndev;
 	struct rcar_canfd_channel *priv;
-	u32 sts, gerfl;
+	u32 sts, cc, gerfl;
 	u32 ch, ridx;
 
 	/* Global error interrupts still indicate a condition specific
@@ -1097,7 +1097,9 @@ static irqreturn_t rcar_canfd_global_interrupt(int irq, void *dev_id)
 
 		/* Handle Rx interrupts */
 		sts = rcar_canfd_read(priv->base, RCANFD_RFSTS(ridx));
-		if (likely(sts & RCANFD_RFSTS_RFIF)) {
+		cc = rcar_canfd_read(priv->base, RCANFD_RFCC(ridx));
+		if (likely(sts & RCANFD_RFSTS_RFIF &&
+			   cc & RCANFD_RFCC_RFIE)) {
 			if (napi_schedule_prep(&priv->napi)) {
 				/* Disable Rx FIFO interrupts */
 				rcar_canfd_clear_bit(priv->base,
-- 
2.25.1


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

end of thread, other threads:[~2022-11-02  1:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31 14:33 [PATCH] can: rcar_canfd: rcar_canfd_handle_global_receive(): fix IRQ storm on global FIFO receive Biju Das
2022-11-01  7:43 ` Pavel Machek
2022-11-01  7:59   ` Biju Das
2022-11-01 12:36     ` Bagas Sanjaya
2022-11-01 13:32       ` gregkh
  -- strict thread matches above, loose matches on Subject: below --
2022-10-31 13:26 Biju Das
2022-10-31 12:50 Biju Das
2022-10-31 11:50 Biju Das
2022-10-31  9:35 Biju Das
2022-10-31  9:04 Biju Das
2022-11-02  1:36 ` Greg KH
2022-10-31  9:02 Biju Das

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.