mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
PCI: endpoint: Clear secondary (not primary) EPC in pci_epc_remove_epf()
[ Upstream commit 688d2eb4c6fcfdcdaed0592f9df9196573ff5ce2 ]
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/20241107-epc_rfc-v2-2-da5b6a99a66f@quicinc.com
Fixes: 63840ff532 ("PCI: endpoint: Add support to associate secondary EPC with EPF")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
[mani: reworded subject and description]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9102582762
commit
3c2a6d4d02
@@ -664,18 +664,18 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
|
|||||||
if (!epc || IS_ERR(epc) || !epf)
|
if (!epc || IS_ERR(epc) || !epf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mutex_lock(&epc->list_lock);
|
||||||
if (type == PRIMARY_INTERFACE) {
|
if (type == PRIMARY_INTERFACE) {
|
||||||
func_no = epf->func_no;
|
func_no = epf->func_no;
|
||||||
list = &epf->list;
|
list = &epf->list;
|
||||||
|
epf->epc = NULL;
|
||||||
} else {
|
} else {
|
||||||
func_no = epf->sec_epc_func_no;
|
func_no = epf->sec_epc_func_no;
|
||||||
list = &epf->sec_epc_list;
|
list = &epf->sec_epc_list;
|
||||||
|
epf->sec_epc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&epc->list_lock);
|
|
||||||
clear_bit(func_no, &epc->function_num_map);
|
clear_bit(func_no, &epc->function_num_map);
|
||||||
list_del(list);
|
list_del(list);
|
||||||
epf->epc = NULL;
|
|
||||||
mutex_unlock(&epc->list_lock);
|
mutex_unlock(&epc->list_lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(pci_epc_remove_epf);
|
EXPORT_SYMBOL_GPL(pci_epc_remove_epf);
|
||||||
|
|||||||
Reference in New Issue
Block a user