diff mbox series

[1/2] net: fec: don't ack masked interrupt events

Message ID 20171206172459.14059-1-l.stach@pengutronix.de
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [1/2] net: fec: don't ack masked interrupt events | expand

Commit Message

Lucas Stach Dec. 6, 2017, 5:24 p.m. UTC
The FEC doesn't have a real interrupt status register, that takes
into account the mask status of the IRQ. The driver reads the raw
interrupt event register, which also reports events for masked
IRQs.

The driver needs to apply the current mask itself, to avoid acking
IRQs that are currently masked, as NAPI relies on the masking to
hide the IRQs. The current behavior of just acking all interrupts
regardless of their mask status opens the driver up the "rotting
packet" race-window, as described in the original NAPI-HOWTO, which
has been observed in the wild.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Miller Dec. 6, 2017, 8:47 p.m. UTC | #1
From: Lucas Stach <l.stach@pengutronix.de>
Date: Wed,  6 Dec 2017 18:24:58 +0100

> The FEC doesn't have a real interrupt status register, that takes
> into account the mask status of the IRQ. The driver reads the raw
> interrupt event register, which also reports events for masked
> IRQs.
> 
> The driver needs to apply the current mask itself, to avoid acking
> IRQs that are currently masked, as NAPI relies on the masking to
> hide the IRQs. The current behavior of just acking all interrupts
> regardless of their mask status opens the driver up the "rotting
> packet" race-window, as described in the original NAPI-HOWTO, which
> has been observed in the wild.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 610573855213..0b70c07eb703 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1584,7 +1584,8 @@ fec_enet_interrupt(int irq, void *dev_id)
>  	uint int_events;
>  	irqreturn_t ret = IRQ_NONE;
>  
> -	int_events = readl(fep->hwp + FEC_IEVENT);
> +	int_events = readl_relaxed(fep->hwp + FEC_IEVENT) &
> +	             readl_relaxed(fep->hwp + FEC_IMASK);

Adding a full new MMIO register read to every interrupt is going to make
interrupts significantly more expensive.

You should cache this mask in software in order to avoid the expensive
MMIO read.

Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 610573855213..0b70c07eb703 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1584,7 +1584,8 @@  fec_enet_interrupt(int irq, void *dev_id)
 	uint int_events;
 	irqreturn_t ret = IRQ_NONE;
 
-	int_events = readl(fep->hwp + FEC_IEVENT);
+	int_events = readl_relaxed(fep->hwp + FEC_IEVENT) &
+	             readl_relaxed(fep->hwp + FEC_IMASK);
 	writel(int_events, fep->hwp + FEC_IEVENT);
 	fec_enet_collect_events(fep, int_events);