Skip to contentSkip to conversation

PCI: apple: do not leak reset GPIO on unbind/unload/error

PATCH Applied Dmitry Torokhov 4 participants 6 messages Sep 6, 2022 – Sep 14, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: apple: do not leak reset GPIO on unbind/unload/error

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")

---

This patch has been pulled out of the series
https://lore.kernel.org/all/20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com/
with updated justification (leak fix vs pure API deprecation).

 drivers/pci/controller/pcie-apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-apple.c +2 -2
index a2c3c207a04b..66f37e403a09 100644
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	u32 stat, idx;
 	int ret, i;
 
-	reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-				       GPIOD_OUT_LOW, "PERST#");
+	reset = devm_fwnode_gpiod_get(pcie->dev, of_fwnode_handle(np), "reset",
+				      GPIOD_OUT_LOW, "PERST#");
 	if (IS_ERR(reset))
 		return PTR_ERR(reset);
 
Signature · 5 lines
2.37.2.789.g6183377224-goog


-- 
Dmitry
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dmitry Torokhov

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Torokhov
Quoted 24 lines · Dmitry Torokhov

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")

---

This patch has been pulled out of the series
https://lore.kernel.org/all/20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com/
with updated justification (leak fix vs pure API deprecation).

 drivers/pci/controller/pcie-apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-apple.c +0 -0
index a2c3c207a04b..66f37e403a09 100644

drivers/pci/controller/pcie-apple.c static int apple_pcie_setup_port(struct apple_pcie *pcie, · line 523

Quoted 10 lines
drivers/pci/controller/pcie-apple.c +2 -2
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	u32 stat, idx;
 	int ret, i;
 
-	reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-				       GPIOD_OUT_LOW, "PERST#");
+	reset = devm_fwnode_gpiod_get(pcie->dev, of_fwnode_handle(np), "reset",
+				      GPIOD_OUT_LOW, "PERST#");
 	if (IS_ERR(reset))
 		return PTR_ERR(reset);
 

I actually caught this one a while back, just didn't get around to submitting it yet since it's part of my WIP PCIe power management branch (that I'm getting back to next week or so!) :)

https://github.com/AsahiLinux/linux/commit/04f5628fc73ea0369f66c83ba473cb6f8187d2b3

- Hector

#3 lore raw
In reply to Dmitry Torokhov

Nit: please capitalize beginning of the sentence in the subject - that's what we do for PCI controllers commits.

"PCI: apple: Do not leak reset GPIO on unbind/unload/error"

Quoted 9 lines · Dmitry Torokhov

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")

Should I take it via the PCI tree ? Usually we send fixes through -rcX only if the fix applies to code merged last merge window, which is not the case here, so I would queue if for v6.1.

Lorenzo

Quoted 31 lines

---

This patch has been pulled out of the series
https://lore.kernel.org/all/20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com/
with updated justification (leak fix vs pure API deprecation).

 drivers/pci/controller/pcie-apple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-apple.c +2 -2
index a2c3c207a04b..66f37e403a09 100644
@@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	u32 stat, idx;
 	int ret, i;
 
-	reset = gpiod_get_from_of_node(np, "reset-gpios", 0,
-				       GPIOD_OUT_LOW, "PERST#");
+	reset = devm_fwnode_gpiod_get(pcie->dev, of_fwnode_handle(np), "reset",
+				      GPIOD_OUT_LOW, "PERST#");
 	if (IS_ERR(reset))
 		return PTR_ERR(reset);
 
Signature · 5 lines
2.37.2.789.g6183377224-goog


-- 
Dmitry
maintainer
#4 lore raw
Quoted 14 lines · Lorenzo Pieralisi

Nit: please capitalize beginning of the sentence in the subject - that's what we do for PCI controllers commits.

"PCI: apple: Do not leak reset GPIO on unbind/unload/error"

Quoted 8 lines · Dmitry Torokhov

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

Quoted 5 lines
Quoted 1 line
Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")

Should I take it via the PCI tree ? Usually we send fixes through -rcX only if the fix applies to code merged last merge window, which is not the case here, so I would queue if for v6.1.

I think 6.1 is perfectly fine.

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer Applied
#5 lore raw
In reply to Dmitry Torokhov
Quoted 9 lines · Dmitry Torokhov

The driver allocates reset GPIO in apple_pcie_setup_port() but neither releases the resource, nor uses devm API to have it released automatically.

Let's fix this by switching to devm API. While at it let's use generic devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node()
- this will allow us top stop exporting the latter down the road.

[...]

Applied to pci/apple, thanks!

[1/1] PCI: apple: do not leak reset GPIO on unbind/unload/error
https://git.kernel.org/lpieralisi/pci/c/a6b9ede1f3df

Thanks,
Lorenzo