This patch series is to fix bug for API devm_pci_epc_destroy() and simplify API pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@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@quicin...
--- Zijun Hu (2): PCI: endpoint: Fix that API devm_pci_epc_destroy() fails to destroy the EPC device PCI: endpoint: Simplify API pci_epc_get() implementation
drivers/pci/endpoint/pci-epc-core.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) --- base-commit: 11066801dd4b7c4d75fce65c812723a80c1481ae change-id: 20241020-pci-epc-core_fix-a92512fa9d19
Best regards,
From: Zijun Hu quic_zijuhu@quicinc.com
For devm_pci_epc_destroy(), its comment says it needs to destroy the EPC device, but it will not actually do that since devres_destroy() does not call devm_pci_epc_release(), and it also can not fully undo what the API devm_pci_epc_create() does, so it is faulty.
Fortunately, the faulty API has not been used by current kernel tree. Fixed by using devres_release() instead of devres_destroy() within the API.
Fixes: 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu quic_zijuhu@quicinc.com
--- Below linux-next commit fixes a similar issue. https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?...
Why to fix the API here instead of directly deleting it?
1) it is simpler, just one line change. 2) it may be used in future. 3) ensure this restored API right if need to restore it in future after deleting.
Anyone may remove such APIs separately later if he/she cares. --- drivers/pci/endpoint/pci-epc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 17f007109255..71b6d100056e 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -857,7 +857,7 @@ void devm_pci_epc_destroy(struct device *dev, struct pci_epc *epc) { int r;
- r = devres_destroy(dev, devm_pci_epc_release, devm_pci_epc_match, + r = devres_release(dev, devm_pci_epc_release, devm_pci_epc_match, epc); dev_WARN_ONCE(dev, r, "couldn't find PCI EPC resource\n"); }
On 2024/11/2 20:20, Zijun Hu wrote:
This patch series is to fix bug for API devm_pci_epc_destroy() and simplify API pci_epc_get().
Signed-off-by: Zijun Hu quic_zijuhu@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@quicin...
Zijun Hu (2): PCI: endpoint: Fix that API devm_pci_epc_destroy() fails to destroy the EPC device PCI: endpoint: Simplify API pci_epc_get() implementation
Hi Krzysztof,
could you code review for this patch series ?
drivers/pci/endpoint/pci-epc-core.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
base-commit: 11066801dd4b7c4d75fce65c812723a80c1481ae change-id: 20241020-pci-epc-core_fix-a92512fa9d19
Best regards,
linux-stable-mirror@lists.linaro.org