Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API
@ 2024-12-10 14:00 Zijun Hu
  2024-12-10 14:00 ` [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error Zijun Hu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Zijun Hu @ 2024-12-10 14:00 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun
  Cc: Zijun Hu, linux-pci, linux-kernel, Zijun Hu, stable

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@quicinc.com

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@quicinc.com

---
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>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error
  2024-12-10 14:00 [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Zijun Hu
@ 2024-12-10 14:00 ` Zijun Hu
  2024-12-12 18:03   ` Frank Li
  2024-12-12  9:35 ` [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Dan Carpenter
  2024-12-12 19:12 ` Bjorn Helgaas
  2 siblings, 1 reply; 6+ messages in thread
From: Zijun Hu @ 2024-12-10 14:00 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun
  Cc: Zijun Hu, linux-pci, linux-kernel, Zijun Hu, stable

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);
 }

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API
  2024-12-10 14:00 [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Zijun Hu
  2024-12-10 14:00 ` [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error Zijun Hu
@ 2024-12-12  9:35 ` Dan Carpenter
  2024-12-12 11:56   ` Zijun Hu
  2024-12-12 19:12 ` Bjorn Helgaas
  2 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2024-12-12  9:35 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun, linux-pci, linux-kernel, Zijun Hu,
	stable, linux-kselftest, Harshit Mogalapalli

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API
  2024-12-12  9:35 ` [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Dan Carpenter
@ 2024-12-12 11:56   ` Zijun Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Zijun Hu @ 2024-12-12 11:56 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun, linux-pci, linux-kernel, Zijun Hu,
	stable, linux-kselftest, Harshit Mogalapalli

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
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error
  2024-12-10 14:00 ` [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error Zijun Hu
@ 2024-12-12 18:03   ` Frank Li
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Li @ 2024-12-12 18:03 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun, linux-pci, linux-kernel, Zijun Hu,
	stable

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
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API
  2024-12-10 14:00 [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Zijun Hu
  2024-12-10 14:00 ` [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error Zijun Hu
  2024-12-12  9:35 ` [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Dan Carpenter
@ 2024-12-12 19:12 ` Bjorn Helgaas
  2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2024-12-12 19:12 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Manivannan Sadhasivam, Krzysztof Wilczyński,
	Kishon Vijay Abraham I, Bjorn Helgaas, Joao Pinto,
	Lorenzo Pieralisi, Wei Yongjun, linux-pci, linux-kernel, Zijun Hu,
	stable

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@quicinc.com
> 
> 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@quicinc.com
> 
> ---
> 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>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-12 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10 14:00 [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Zijun Hu
2024-12-10 14:00 ` [PATCH v3 3/3] PCI: endpoint: Fix API pci_epf_add_vepf() returning -EBUSY error Zijun Hu
2024-12-12 18:03   ` Frank Li
2024-12-12  9:35 ` [PATCH v3 0/3] PCI: endpoint: fix bug for 2 APIs and simplify 1 API Dan Carpenter
2024-12-12 11:56   ` Zijun Hu
2024-12-12 19:12 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox