]> Git Repo - linux.git/commitdiff
PCI: endpoint: Clear secondary (not primary) EPC in pci_epc_remove_epf()
authorZijun Hu <[email protected]>
Thu, 7 Nov 2024 00:53:09 +0000 (08:53 +0800)
committerKrzysztof Wilczyński <[email protected]>
Mon, 18 Nov 2024 17:18:19 +0000 (17:18 +0000)
In addition to a primary endpoint controller, an endpoint function may be
associated with a secondary endpoint controller, epf->sec_epc, to provide
NTB (non-transparent bridge) functionality.

Previously, pci_epc_remove_epf() incorrectly cleared epf->epc instead of
epf->sec_epc when removing from the secondary endpoint controller.

Extend the epc->list_lock coverage and clear either epf->epc or
epf->sec_epc as indicated.

Link: https://lore.kernel.org/r/[email protected]
Fixes: 63840ff53223 ("PCI: endpoint: Add support to associate secondary EPC with EPF")
Signed-off-by: Zijun Hu <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
[mani: reworded subject and description]
Signed-off-by: Manivannan Sadhasivam <[email protected]>
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas <[email protected]>
Signed-off-by: Krzysztof Wilczyński <[email protected]>
Cc: [email protected]
drivers/pci/endpoint/pci-epc-core.c

index 21af2dbacc333b24a2947cc714fe4c201a46ec77..bed7c7d1fe3c372125c7661082f87c9c89383703 100644 (file)
@@ -746,18 +746,18 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
        if (IS_ERR_OR_NULL(epc) || !epf)
                return;
 
+       mutex_lock(&epc->list_lock);
        if (type == PRIMARY_INTERFACE) {
                func_no = epf->func_no;
                list = &epf->list;
+               epf->epc = NULL;
        } else {
                func_no = epf->sec_epc_func_no;
                list = &epf->sec_epc_list;
+               epf->sec_epc = NULL;
        }
-
-       mutex_lock(&epc->list_lock);
        clear_bit(func_no, &epc->function_num_map);
        list_del(list);
-       epf->epc = NULL;
        mutex_unlock(&epc->list_lock);
 }
 EXPORT_SYMBOL_GPL(pci_epc_remove_epf);
This page took 0.05443 seconds and 4 git commands to generate.