linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
@ 2022-09-06  2:15 Dmitry Torokhov
  2022-09-06  7:09 ` Marc Zyngier
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2022-09-06  2:15 UTC (permalink / raw)
  To: Alyssa Rosenzweig, Marc Zyngier
  Cc: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
	Bjorn Helgaas, Hector Martin, Sven Peter, linux-pci,
	linux-kernel

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")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

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

diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index a2c3c207a04b..66f37e403a09 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -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);
 
-- 
2.37.2.789.g6183377224-goog


-- 
Dmitry

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

* Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
  2022-09-06  2:15 [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Dmitry Torokhov
@ 2022-09-06  7:09 ` Marc Zyngier
  2022-09-06  7:13 ` Hector Martin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-09-06  7:09 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Alyssa Rosenzweig, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, Hector Martin,
	Sven Peter, linux-pci, linux-kernel

On Tue, 06 Sep 2022 03:15:23 +0100,
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
> 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")
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

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

* Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
  2022-09-06  2:15 [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Dmitry Torokhov
  2022-09-06  7:09 ` Marc Zyngier
@ 2022-09-06  7:13 ` Hector Martin
  2022-09-09  9:16 ` Lorenzo Pieralisi
  2022-09-14 15:47 ` Lorenzo Pieralisi
  3 siblings, 0 replies; 6+ messages in thread
From: Hector Martin @ 2022-09-06  7:13 UTC (permalink / raw)
  To: Dmitry Torokhov, Alyssa Rosenzweig, Marc Zyngier
  Cc: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
	Bjorn Helgaas, Sven Peter, linux-pci, linux-kernel

On 06/09/2022 11.15, Dmitry Torokhov wrote:
> 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")
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index a2c3c207a04b..66f37e403a09 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -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);
>  

Reviewed-by: Hector Martin <marcan@marcan.st>

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

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

* Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
  2022-09-06  2:15 [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Dmitry Torokhov
  2022-09-06  7:09 ` Marc Zyngier
  2022-09-06  7:13 ` Hector Martin
@ 2022-09-09  9:16 ` Lorenzo Pieralisi
  2022-09-09 12:48   ` Marc Zyngier
  2022-09-14 15:47 ` Lorenzo Pieralisi
  3 siblings, 1 reply; 6+ messages in thread
From: Lorenzo Pieralisi @ 2022-09-09  9:16 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Alyssa Rosenzweig, Marc Zyngier, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, Hector Martin,
	Sven Peter, linux-pci, linux-kernel

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"

On Mon, Sep 05, 2022 at 07:15:23PM -0700, Dmitry Torokhov wrote:
> 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

> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 
> 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(-)
> 
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index a2c3c207a04b..66f37e403a09 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -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);
>  
> -- 
> 2.37.2.789.g6183377224-goog
> 
> 
> -- 
> Dmitry

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

* Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
  2022-09-09  9:16 ` Lorenzo Pieralisi
@ 2022-09-09 12:48   ` Marc Zyngier
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-09-09 12:48 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Dmitry Torokhov, Alyssa Rosenzweig, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, Hector Martin,
	Sven Peter, linux-pci, linux-kernel

On 2022-09-09 10:16, Lorenzo Pieralisi wrote:
> 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"
> 
> On Mon, Sep 05, 2022 at 07:15:23PM -0700, Dmitry Torokhov wrote:
>> 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.

I think 6.1 is perfectly fine.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error
  2022-09-06  2:15 [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2022-09-09  9:16 ` Lorenzo Pieralisi
@ 2022-09-14 15:47 ` Lorenzo Pieralisi
  3 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Pieralisi @ 2022-09-14 15:47 UTC (permalink / raw)
  To: Dmitry Torokhov, Marc Zyngier, Alyssa Rosenzweig
  Cc: Lorenzo Pieralisi, Hector Martin, Rob Herring,
	Krzysztof Wilczyński, Bjorn Helgaas, linux-pci, Sven Peter,
	linux-kernel

On Mon, 5 Sep 2022 19:15:23 -0700, Dmitry Torokhov wrote:
> 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

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

end of thread, other threads:[~2022-09-14 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06  2:15 [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Dmitry Torokhov
2022-09-06  7:09 ` Marc Zyngier
2022-09-06  7:13 ` Hector Martin
2022-09-09  9:16 ` Lorenzo Pieralisi
2022-09-09 12:48   ` Marc Zyngier
2022-09-14 15:47 ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).