This patch series is to fix bug for APIs - devm_pci_epc_destroy(). - pci_epf_remove_vepf().
and simplify APIs below: - pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com --- Changes in v3: - Remove stable tag of patch 1/3 - Add one more patch 3/3 - Link to v2: https://lore.kernel.org/all/20241102-pci-epc-core_fix-v2-0-0785f8435be5@quic...
Changes in v2: - Correct tile and commit message for patch 1/2. - Add one more patch 2/2 to simplify API pci_epc_get(). - Link to v1: https://lore.kernel.org/r/20241020-pci-epc-core_fix-v1-1-3899705e3537@quicin...
--- Zijun Hu (3): PCI: endpoint: Fix that API devm_pci_epc_destroy() fails to destroy the EPC device PCI: endpoint: Simplify API pci_epc_get() implementation PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error
drivers/pci/endpoint/pci-epc-core.c | 23 +++++++---------------- drivers/pci/endpoint/pci-epf-core.c | 1 + 2 files changed, 8 insertions(+), 16 deletions(-) --- base-commit: 11066801dd4b7c4d75fce65c812723a80c1481ae change-id: 20241020-pci-epc-core_fix-a92512fa9d19
Best regards,
From: Zijun Hu quic_zijuhu@quicinc.com
pci_epf_add_vepf() will suffer -EBUSY error by steps below:
pci_epf_add_vepf(@epf_pf, @epf_vf) // add pci_epf_remove_vepf(@epf_pf, @epf_vf) // remove pci_epf_add_vepf(@epf_pf, @epf_vf) // add again, -EBUSY error.
Fix by clearing @epf_vf->epf_pf in pci_epf_remove_vepf().
Fixes: 1cf362e907f3 ("PCI: endpoint: Add support to add virtual function in endpoint core") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com --- drivers/pci/endpoint/pci-epf-core.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 8fa2797d4169a9f21136bbf73daa818da6c4ac49..50bc2892a36c54aa82c819ac5a9c99e9155d92c1 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -202,6 +202,7 @@ void pci_epf_remove_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf)
mutex_lock(&epf_pf->lock); clear_bit(epf_vf->vfunc_no, &epf_pf->vfunction_num_map); + epf_vf->epf_pf = NULL; list_del(&epf_vf->list); mutex_unlock(&epf_pf->lock); }
On Tue, Dec 10, 2024 at 10:00:20PM +0800, Zijun Hu wrote:
From: Zijun Hu quic_zijuhu@quicinc.com
pci_epf_add_vepf() will suffer -EBUSY error by steps below:
pci_epf_add_vepf(@epf_pf, @epf_vf) // add pci_epf_remove_vepf(@epf_pf, @epf_vf) // remove pci_epf_add_vepf(@epf_pf, @epf_vf) // add again, -EBUSY error.
nit: can you align comments to the same column?
Reviewed-by: Frank Li Frank.Li@nxp.com
Fix by clearing @epf_vf->epf_pf in pci_epf_remove_vepf().
Fixes: 1cf362e907f3 ("PCI: endpoint: Add support to add virtual function in endpoint core") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com
drivers/pci/endpoint/pci-epf-core.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 8fa2797d4169a9f21136bbf73daa818da6c4ac49..50bc2892a36c54aa82c819ac5a9c99e9155d92c1 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -202,6 +202,7 @@ void pci_epf_remove_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf)
mutex_lock(&epf_pf->lock); clear_bit(epf_vf->vfunc_no, &epf_pf->vfunction_num_map);
- epf_vf->epf_pf = NULL; list_del(&epf_vf->list); mutex_unlock(&epf_pf->lock);
}
-- 2.34.1
On Tue, Dec 10, 2024 at 10:00:17PM +0800, Zijun Hu wrote:
This patch series is to fix bug for APIs
- devm_pci_epc_destroy().
- pci_epf_remove_vepf().
and simplify APIs below:
- pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com
This is very good. This is Config FS. Is there a kself test for configfs or did you create your own test?
regards, dan carpenter
On 2024/12/12 17:35, Dan Carpenter wrote:
On Tue, Dec 10, 2024 at 10:00:17PM +0800, Zijun Hu wrote:
This patch series is to fix bug for APIs
- devm_pci_epc_destroy().
- pci_epf_remove_vepf().
and simplify APIs below:
- pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com
This is very good. This is Config FS. Is there a kself test for configfs or did you create your own test?
no.
In order to investigate devres_release() usage for patch 1/3, i read 2 PCI source files and then find a few obvious bugs. (^^)
regards, dan carpenter
On Tue, Dec 10, 2024 at 10:00:17PM +0800, Zijun Hu wrote:
This patch series is to fix bug for APIs
- devm_pci_epc_destroy().
- pci_epf_remove_vepf().
and simplify APIs below:
- pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com
Applied to pci/endpoint for v6.14, thanks!
Changes in v3:
- Remove stable tag of patch 1/3
- Add one more patch 3/3
- Link to v2: https://lore.kernel.org/all/20241102-pci-epc-core_fix-v2-0-0785f8435be5@quic...
Changes in v2:
- Correct tile and commit message for patch 1/2.
- Add one more patch 2/2 to simplify API pci_epc_get().
- Link to v1: https://lore.kernel.org/r/20241020-pci-epc-core_fix-v1-1-3899705e3537@quicin...
Zijun Hu (3): PCI: endpoint: Fix that API devm_pci_epc_destroy() fails to destroy the EPC device PCI: endpoint: Simplify API pci_epc_get() implementation PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error
drivers/pci/endpoint/pci-epc-core.c | 23 +++++++---------------- drivers/pci/endpoint/pci-epf-core.c | 1 + 2 files changed, 8 insertions(+), 16 deletions(-)
base-commit: 11066801dd4b7c4d75fce65c812723a80c1481ae change-id: 20241020-pci-epc-core_fix-a92512fa9d19
Best regards,
Zijun Hu quic_zijuhu@quicinc.com
linux-stable-mirror@lists.linaro.org