* [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
@ 2024-09-09 23:19 Sean Anderson
2024-09-10 0:56 ` Nelson, Shannon
2024-09-11 1:58 ` Jakub Kicinski
0 siblings, 2 replies; 6+ messages in thread
From: Sean Anderson @ 2024-09-09 23:19 UTC (permalink / raw)
To: Radhey Shyam Pandey, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev
Cc: Robert Hancock, linux-kernel, Michal Simek, linux-arm-kernel,
Sean Anderson
As advised by Documentation/networking/napi.rst, masking IRQs after
calling napi_schedule can be racy. Avoid this by only masking/scheduling
if napi_schedule_prep returns true. Additionally, since we are running
in an IRQ context we can use the irqoff variant as well.
Fixes: 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
Fixes: cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 9eb300fc3590..4f67072d5149 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1222,9 +1222,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
u32 cr = lp->tx_dma_cr;
cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
- axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
-
- napi_schedule(&lp->napi_tx);
+ if (napi_schedule_prep(&lp->napi_tx)) {
+ axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
+ __napi_schedule_irqoff(&lp->napi_tx);
+ }
}
return IRQ_HANDLED;
@@ -1266,9 +1267,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
u32 cr = lp->rx_dma_cr;
cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
- axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
-
- napi_schedule(&lp->napi_rx);
+ if (napi_schedule_prep(&lp->napi_rx)) {
+ axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
+ __napi_schedule_irqoff(&lp->napi_rx);
+ }
}
return IRQ_HANDLED;
--
2.35.1.1320.gc452695387.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
2024-09-09 23:19 [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps Sean Anderson
@ 2024-09-10 0:56 ` Nelson, Shannon
2024-09-11 1:58 ` Jakub Kicinski
1 sibling, 0 replies; 6+ messages in thread
From: Nelson, Shannon @ 2024-09-10 0:56 UTC (permalink / raw)
To: Sean Anderson, Radhey Shyam Pandey, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev
Cc: Robert Hancock, linux-kernel, Michal Simek, linux-arm-kernel
On 9/9/2024 4:19 PM, Sean Anderson wrote:
>
> As advised by Documentation/networking/napi.rst, masking IRQs after
> calling napi_schedule can be racy. Avoid this by only masking/scheduling
> if napi_schedule_prep returns true. Additionally, since we are running
> in an IRQ context we can use the irqoff variant as well.
>
> Fixes: 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")
> Fixes: cc37610caaf8 ("net: axienet: implement NAPI and GRO receive")
> Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
> ---
>
> drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 9eb300fc3590..4f67072d5149 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -1222,9 +1222,10 @@ static irqreturn_t axienet_tx_irq(int irq, void *_ndev)
> u32 cr = lp->tx_dma_cr;
>
> cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
> - axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
> -
> - napi_schedule(&lp->napi_tx);
> + if (napi_schedule_prep(&lp->napi_tx)) {
> + axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, cr);
> + __napi_schedule_irqoff(&lp->napi_tx);
> + }
> }
>
> return IRQ_HANDLED;
> @@ -1266,9 +1267,10 @@ static irqreturn_t axienet_rx_irq(int irq, void *_ndev)
> u32 cr = lp->rx_dma_cr;
>
> cr &= ~(XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_DELAY_MASK);
> - axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
> -
> - napi_schedule(&lp->napi_rx);
> + if (napi_schedule_prep(&lp->napi_rx)) {
> + axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, cr);
> + __napi_schedule_irqoff(&lp->napi_rx);
> + }
> }
>
> return IRQ_HANDLED;
> --
> 2.35.1.1320.gc452695387.dirty
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
2024-09-09 23:19 [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps Sean Anderson
2024-09-10 0:56 ` Nelson, Shannon
@ 2024-09-11 1:58 ` Jakub Kicinski
2024-09-12 14:23 ` Sean Anderson
1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-09-11 1:58 UTC (permalink / raw)
To: Sean Anderson
Cc: Radhey Shyam Pandey, David S . Miller, Eric Dumazet, Paolo Abeni,
netdev, Robert Hancock, linux-kernel, Michal Simek,
linux-arm-kernel
On Mon, 9 Sep 2024 19:19:04 -0400 Sean Anderson wrote:
> Additionally, since we are running
> in an IRQ context we can use the irqoff variant as well.
The _irqoff variant is a bit of a minefield. It causes issues if kernel
is built with forced IRQ threading. With datacenter NICs forced
threading is never used so we look the other way. Since this is a fix
and driver is embedded I reckon we should stick to __napi_schedule().
--
pw-bot: cr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
2024-09-11 1:58 ` Jakub Kicinski
@ 2024-09-12 14:23 ` Sean Anderson
2024-09-12 15:43 ` Jakub Kicinski
0 siblings, 1 reply; 6+ messages in thread
From: Sean Anderson @ 2024-09-12 14:23 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Radhey Shyam Pandey, David S . Miller, Eric Dumazet, Paolo Abeni,
netdev, Robert Hancock, linux-kernel, Michal Simek,
linux-arm-kernel
On 9/10/24 21:58, Jakub Kicinski wrote:
> On Mon, 9 Sep 2024 19:19:04 -0400 Sean Anderson wrote:
>> Additionally, since we are running
>> in an IRQ context we can use the irqoff variant as well.
>
> The _irqoff variant is a bit of a minefield. It causes issues if kernel
> is built with forced IRQ threading. With datacenter NICs forced
> threading is never used so we look the other way. Since this is a fix
> and driver is embedded I reckon we should stick to __napi_schedule().
Does it?
__napi_schedule_irqoff selects between __napi_schedule and
____napi_schedule based on whether PREEMPT_RT is enabled. Is there some
other way to force IRQ threading?
--Sean
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
2024-09-12 14:23 ` Sean Anderson
@ 2024-09-12 15:43 ` Jakub Kicinski
2024-09-12 16:07 ` Sean Anderson
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-09-12 15:43 UTC (permalink / raw)
To: Sean Anderson
Cc: Radhey Shyam Pandey, David S . Miller, Eric Dumazet, Paolo Abeni,
netdev, Robert Hancock, linux-kernel, Michal Simek,
linux-arm-kernel
On Thu, 12 Sep 2024 10:23:06 -0400 Sean Anderson wrote:
> __napi_schedule_irqoff selects between __napi_schedule and
> ____napi_schedule based on whether PREEMPT_RT is enabled. Is there some
> other way to force IRQ threading?
I think so, IIRC threadirqs= kernel boot option lets you do it.
I don't remember all the details now :( LMK if I'm wrong
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps
2024-09-12 15:43 ` Jakub Kicinski
@ 2024-09-12 16:07 ` Sean Anderson
0 siblings, 0 replies; 6+ messages in thread
From: Sean Anderson @ 2024-09-12 16:07 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Radhey Shyam Pandey, David S . Miller, Eric Dumazet, Paolo Abeni,
netdev, Robert Hancock, linux-kernel, Michal Simek,
linux-arm-kernel
On 9/12/24 11:43, Jakub Kicinski wrote:
> On Thu, 12 Sep 2024 10:23:06 -0400 Sean Anderson wrote:
>> __napi_schedule_irqoff selects between __napi_schedule and
>> ____napi_schedule based on whether PREEMPT_RT is enabled. Is there some
>> other way to force IRQ threading?
>
> I think so, IIRC threadirqs= kernel boot option lets you do it.
> I don't remember all the details now :( LMK if I'm wrong
Hm, maybe __napi_schedule_irqoff should be updated to take that into
account. I will resend without this change.
--Sean
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-12 16:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 23:19 [PATCH net] net: xilinx: axienet: Schedule NAPI in two steps Sean Anderson
2024-09-10 0:56 ` Nelson, Shannon
2024-09-11 1:58 ` Jakub Kicinski
2024-09-12 14:23 ` Sean Anderson
2024-09-12 15:43 ` Jakub Kicinski
2024-09-12 16:07 ` Sean Anderson
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).