[PATCH 3/3] can: ifi_canfd: enable NAPI before starting the controller

From: Patrick Zhang

Date: Wed Oct 21 2026 - 17:05:52 EST


ifi_canfd_open() calls ifi_canfd_start(), which unmasks the interrupts
in IFI_CANFD_IRQMASK and then enables the controller through
IFI_CANFD_STCMD, and only then calls napi_enable(). A frame that
arrives in that window raises RXFIFO_NEMPTY. ifi_canfd_isr() masks all
interrupts with ifi_canfd_irq_enable(ndev, 0) and calls
napi_schedule(). NAPI is still disabled, so napi_schedule_prep() finds
NAPI_STATE_SCHED set and the schedule is dropped. Only ifi_canfd_poll()
unmasks the interrupts again, and it never runs. From then on the
interface receives nothing. ifi_canfd_start_xmit() stops the queue
after every frame and relies on the TX FIFO interrupt to wake it, and
that interrupt is masked too, so transmit stops after the next frame.
The stall lasts until the next close. Every re-open runs the same race
again.

Enable NAPI before the controller starts, so that an early RX interrupt
can schedule the poll. NAPI can be enabled while the controller is in
reset, because nothing schedules it until an interrupt arrives.
ifi_canfd_start() cannot fail, so no error path changes.

This is the same race as in ctucanfd and xilinx_can, fixed by the
previous patches. I do not have IFI CAN FD hardware, so this change is
compile tested only and the failure sequence is taken from the code.

Fixes: 0c4d9c94a130 ("can: ifi: Add IFI CANFD IP support")
Assisted-by: LLM
Signed-off-by: Patrick Zhang <patrzhan@xxxxxxxxxx>
---
drivers/net/can/ifi_canfd/ifi_canfd.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c
index 0f83335e4..feb738eb0 100644
--- a/drivers/net/can/ifi_canfd/ifi_canfd.c
+++ b/drivers/net/can/ifi_canfd/ifi_canfd.c
@@ -846,9 +846,12 @@ static int ifi_canfd_open(struct net_device *ndev)
goto err_irq;
}

+ /* Keep before ifi_canfd_start(): the ISR masks the interrupts and only
+ * the poll unmasks them.
+ */
+ napi_enable(&priv->napi);
ifi_canfd_start(ndev);

- napi_enable(&priv->napi);
netif_start_queue(ndev);

return 0;
--
2.50.1