From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, linux-can@vger.kernel.org,
kernel@pengutronix.de,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
linux-stable <stable@vger.kernel.org>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 2/7] can: rcar_canfd: fix possible IRQ storm on high load
Date: Wed, 24 Jul 2019 15:03:17 +0200 [thread overview]
Message-ID: <20190724130322.31702-3-mkl@pengutronix.de> (raw)
In-Reply-To: <20190724130322.31702-1-mkl@pengutronix.de>
From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
We have observed rcar_canfd driver entering IRQ storm under high load,
with following scenario:
- rcar_canfd_global_interrupt() in entered due to Rx available,
- napi_schedule_prep() is called, and sets NAPIF_STATE_SCHED in state
- Rx fifo interrupts are masked,
- rcar_canfd_global_interrupt() is entered again, this time due to
error interrupt (e.g. due to overflow),
- since scheduled napi poller has not yet executed, condition for calling
napi_schedule_prep() from rcar_canfd_global_interrupt() remains true,
thus napi_schedule_prep() gets called and sets NAPIF_STATE_MISSED flag
in state,
- later, napi poller function rcar_canfd_rx_poll() gets executed, and
calls napi_complete_done(),
- due to NAPIF_STATE_MISSED flag in state, this call does not clear
NAPIF_STATE_SCHED flag from state,
- on return from napi_complete_done(), rcar_canfd_rx_poll() unmasks Rx
interrutps,
- Rx interrupt happens, rcar_canfd_global_interrupt() gets called
and calls napi_schedule_prep(),
- since NAPIF_STATE_SCHED is set in state at this time, this call
returns false,
- due to that false return, rcar_canfd_global_interrupt() returns
without masking Rx interrupt
- and this results into IRQ storm: unmasked Rx interrupt happens again
and again is misprocessed in the same way.
This patch fixes that scenario by unmasking Rx interrupts only when
napi_complete_done() returns true, which means it has cleared
NAPIF_STATE_SCHED in state.
Fixes: dd3bd23eb438 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/rcar/rcar_canfd.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index 05410008aa6b..de34a4b82d4a 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -1508,10 +1508,11 @@ static int rcar_canfd_rx_poll(struct napi_struct *napi, int quota)
/* All packets processed */
if (num_pkts < quota) {
- napi_complete_done(napi, num_pkts);
- /* Enable Rx FIFO interrupts */
- rcar_canfd_set_bit(priv->base, RCANFD_RFCC(ridx),
- RCANFD_RFCC_RFIE);
+ if (napi_complete_done(napi, num_pkts)) {
+ /* Enable Rx FIFO interrupts */
+ rcar_canfd_set_bit(priv->base, RCANFD_RFCC(ridx),
+ RCANFD_RFCC_RFIE);
+ }
}
return num_pkts;
}
--
2.20.1
next prev parent reply other threads:[~2019-07-24 13:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-24 13:03 pull-request: can 2019-07-24 Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 1/7] can: dev: call netif_carrier_off() in register_candev() Marc Kleine-Budde
2019-07-24 13:03 ` Marc Kleine-Budde [this message]
[not found] ` <20190724210328.D91DF21873@mail.kernel.org>
2019-07-25 13:29 ` [PATCH 2/7] can: rcar_canfd: fix possible IRQ storm on high load Nikita Yushchenko
2019-07-25 13:41 ` Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 3/7] can: mcp251x: add error check when wq alloc failed Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 4/7] can: flexcan: fix an use-after-free in flexcan_setup_stop_mode() Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 5/7] can: flexcan: fix stop mode acknowledgment Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 6/7] can: peak_usb: fix potential double kfree_skb() Marc Kleine-Budde
2019-07-24 13:03 ` [PATCH 7/7] can: gw: Fix error path of cgw_module_init Marc Kleine-Budde
2019-07-24 21:15 ` pull-request: can 2019-07-24 David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190724130322.31702-3-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikita.yoush@cogentembedded.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox