[PATCH net-next V2 5/7] octeontx2-af: Register devlink after SR-IOV init

From: Mark Bloch

Date: Wed Jun 03 2026 - 15:41:42 EST


A later patch makes devlink registration the point where devlink core may
call eswitch_mode_set() to apply a boot-time default eswitch mode.

Move octeontx2 AF devlink registration after SR-IOV is enabled and the
representor switch lock is initialized, so the AF eswitch mode set path
sees the state it depends on.

If devlink registration fails after SR-IOV setup, unregister interrupts
before disabling SR-IOV. This keeps the AF-VF mailbox IRQ handlers
synchronized before the AF-VF mailbox workqueue is destroyed.

Signed-off-by: Mark Bloch <mbloch@xxxxxxxxxx>
---
.../net/ethernet/marvell/octeontx2/af/rvu.c | 24 ++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index 3cf131508ecf..c2b52eb4ffab 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -3545,6 +3545,7 @@ static void rvu_update_module_params(struct rvu *rvu)
static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
+ bool sriov_done = false;
struct rvu *rvu;
int err;

@@ -3634,26 +3635,27 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_flr;
}

- err = rvu_register_dl(rvu);
- if (err) {
- dev_err(dev, "%s: Failed to register devlink\n", __func__);
- goto err_irq;
- }
-
rvu_setup_rvum_blk_revid(rvu);

/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err) {
dev_err(dev, "%s: Failed to enable sriov\n", __func__);
- goto err_dl;
+ goto err_irq;
+ }
+ sriov_done = true;
+
+ mutex_init(&rvu->rswitch.switch_lock);
+
+ err = rvu_register_dl(rvu);
+ if (err) {
+ dev_err(dev, "%s: Failed to register devlink\n", __func__);
+ goto err_irq;
}

/* Initialize debugfs */
rvu_dbg_init(rvu);

- mutex_init(&rvu->rswitch.switch_lock);
-
if (rvu->fwdata)
ptp_start(rvu, rvu->fwdata->sclk, rvu->fwdata->ptp_ext_clk_rate,
rvu->fwdata->ptp_ext_tstamp);
@@ -3662,10 +3664,10 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)
rvu_alloc_cint_qint_mem(rvu, &rvu->pf[RVU_AFPF], BLKADDR_NIX0,
(rvu->hw->block[BLKADDR_NIX0].lf.max));
return 0;
-err_dl:
- rvu_unregister_dl(rvu);
err_irq:
rvu_unregister_interrupts(rvu);
+ if (sriov_done)
+ rvu_disable_sriov(rvu);
err_flr:
rvu_flr_wq_destroy(rvu);
err_mbox:
--
2.34.1