]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
octeontx2-pf: clear stale mailbox IRQ state before request_irq()
authorRunyu Xiao <runyu.xiao@seu.edu.cn>
Thu, 11 Jun 2026 16:00:13 +0000 (00:00 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 15 Jun 2026 19:47:19 +0000 (12:47 -0700)
otx2_register_mbox_intr() currently installs the PF mailbox IRQ handler
before clearing stale mailbox interrupt state. The function itself then
comments that the local interrupt bits must be cleared first to avoid
spurious interrupts, but that clear happens only after request_irq() has
already exposed the handler to irq delivery.

A running system can reach this during PF mailbox interrupt registration
while stale or latched RVU_PF_INT state is still present. If delivery
happens in the request_irq()-to-clear window,
otx2_pfaf_mbox_intr_handler() can run before local quiesce and touch
the same pf->mbox and pf->mbox_wq carrier that probe and teardown later
reuse or destroy.

Move the stale mailbox interrupt clear ahead of request_irq(), but keep
interrupt enabling after the handler is installed. This closes the
pre-clear early-IRQ window without creating a new enable-before-handler
window.

Fixes: 5a6d7c9daef3 ("octeontx2-pf: Mailbox communication with AF")
Cc: stable@vger.kernel.org
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260611160014.3202224-2-runyu.xiao@seu.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

index f9fbf0c176482536a43bb1d865360255dc48ab5f..0311357dd05b53fad88c6a5b3aa58205c6918c2a 100644 (file)
@@ -1119,9 +1119,16 @@ int otx2_register_mbox_intr(struct otx2_nic *pf, bool probe_af)
 {
        struct otx2_hw *hw = &pf->hw;
        struct msg_req *req;
+       u64 mbox_int_mask;
        char *irq_name;
        int err;
 
+       mbox_int_mask = !is_cn20k(pf->pdev) ? BIT_ULL(0) :
+                               BIT_ULL(0) | BIT_ULL(1);
+
+       /* Clear stale mailbox interrupt state before installing the handler. */
+       otx2_write64(pf, RVU_PF_INT, mbox_int_mask);
+
        /* Register mailbox interrupt handler */
        if (!is_cn20k(pf->pdev)) {
                irq_name = &hw->irq_name[RVU_PF_INT_VEC_AFPF_MBOX * NAME_SIZE];
@@ -1147,17 +1154,8 @@ int otx2_register_mbox_intr(struct otx2_nic *pf, bool probe_af)
                return err;
        }
 
-       /* Enable mailbox interrupt for msgs coming from AF.
-        * First clear to avoid spurious interrupts, if any.
-        */
-       if (!is_cn20k(pf->pdev)) {
-               otx2_write64(pf, RVU_PF_INT, BIT_ULL(0));
-               otx2_write64(pf, RVU_PF_INT_ENA_W1S, BIT_ULL(0));
-       } else {
-               otx2_write64(pf, RVU_PF_INT, BIT_ULL(0) | BIT_ULL(1));
-               otx2_write64(pf, RVU_PF_INT_ENA_W1S, BIT_ULL(0) |
-                            BIT_ULL(1));
-       }
+       /* Enable mailbox interrupt for msgs coming from AF. */
+       otx2_write64(pf, RVU_PF_INT_ENA_W1S, mbox_int_mask);
 
        if (!probe_af)
                return 0;