]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
octeontx2-pf: mcs: Fix mcs resources free on PF shutdown
authorGeetha sowjanya <gakula@marvell.com>
Tue, 16 Jun 2026 19:00:20 +0000 (00:30 +0530)
committerJakub Kicinski <kuba@kernel.org>
Sun, 21 Jun 2026 21:46:13 +0000 (14:46 -0700)
On PF shutdown, the current driver free mcs hardware
resources though mcs resources are not allocated to it.
This patch checks the mcs resources status and if resources
are allocated then only sends mailbox message to free them.

Fixes: c54ffc73601c ("octeontx2-pf: mcs: Introduce MACSEC hardware offloading")
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Link: https://patch.msgid.link/1781636420-19816-3-git-send-email-sbhatta@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c

index 702cf07490e792952a5836a83b9fea7220486f2e..9524d38f15822ba1b7860f7ac2f7e7ff82fc746b 100644 (file)
@@ -1777,11 +1777,16 @@ fail:
 
 void cn10k_mcs_free(struct otx2_nic *pfvf)
 {
+       struct cn10k_mcs_cfg *cfg = pfvf->macsec_cfg;
+
        if (!test_bit(CN10K_HW_MACSEC, &pfvf->hw.cap_flag))
                return;
 
-       cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SECY, 0, true);
-       cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SECY, 0, true);
+       if (!list_empty(&cfg->txsc_list)) {
+               cn10k_mcs_free_rsrc(pfvf, MCS_TX, MCS_RSRC_TYPE_SECY, 0, true);
+               cn10k_mcs_free_rsrc(pfvf, MCS_RX, MCS_RSRC_TYPE_SECY, 0, true);
+       }
+
        kfree(pfvf->macsec_cfg);
        pfvf->macsec_cfg = NULL;
 }