ionic_qcq_disable() cancels a queue's DIM work before it masks the interrupt and disables NAPI, so a poll that runs in between can queue the work again. The queue is freed when the interface goes down or a reset tears it down, and a PCI reset also unmaps BAR0, so the requeued work then writes the interrupt control register through the freed queue and can write the unmapped BAR. Cancel the work once NAPI is disabled, when no poll can queue it again. A work item the cancel drops is what would have returned DIM to measuring, so reset its state there too; otherwise DIM stays stuck when the queues restart on the same qcq after a link flap or reconfiguration. Found by an AI code review of the previous version of this series and confirmed by reading the code. Not reproduced, as nothing can hold a NAPI poll between the cancel and napi_disable(). Tested on an AMD Pensando NIC, on a kernel with KASAN and lockdep, with the PCI reset tests. Fixes: 04a834592bf5 ("ionic: dynamic interrupt moderation") Reported-by: Sashiko AI review Closes: https://lore.kernel.org/netdev/179625854521.3146.11030796304497825514@kernel.org/ Signed-off-by: Nikhil P. Rao --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 339a3c4c5b43..909781f06496 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -358,13 +358,14 @@ static int ionic_qcq_disable(struct ionic_lif *lif, struct ionic_qcq *qcq, int f if (lif->doorbell_wa) cancel_work_sync(&qcq->doorbell_napi_work); - cancel_work_sync(&qcq->dim.work); ionic_intr_mask(idev->intr_ctrl, qcq->intr.index, IONIC_INTR_MASK_SET); synchronize_irq(qcq->intr.vector); irq_set_affinity_notifier(qcq->intr.vector, NULL); irq_set_affinity_hint(qcq->intr.vector, NULL); napi_disable(&qcq->napi); + cancel_work_sync(&qcq->dim.work); + qcq->dim.state = DIM_START_MEASURE; } /* If there was a previous fw communcation error, don't bother with -- 2.43.0