2022-09-12 14:41:37

by Prathamesh Shete

[permalink] [raw]
Subject: [PATCH] gpio: tegra186: Check PMC driver status before any request

This patch fixes the issue where even if pmc driver
status is disabled still we are invoking pmc driver
to process some request

Signed-off-by: Manish Bhardwaj <[email protected]>
Signed-off-by: Prathamesh Shete <[email protected]>
---
drivers/gpio/gpio-tegra186.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 54d9fa7da9c1..efd508ba07a6 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -895,7 +895,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
tegra186_gpio_init_route_mapping(gpio);

np = of_find_matching_node(NULL, tegra186_pmc_of_match);
- if (np) {
+ if (of_device_is_available(np)) {
irq->parent_domain = irq_find_host(np);
of_node_put(np);

--
2.17.1


2022-10-24 17:32:02

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH] gpio: tegra186: Check PMC driver status before any request

On Mon, Sep 12, 2022 at 07:03:09PM +0530, Prathamesh Shete wrote:
> This patch fixes the issue where even if pmc driver
> status is disabled still we are invoking pmc driver
> to process some request

s/pmc/PMC/ twice above. Also, this is slightly misleading. We're not
"invoking" the PMC driver, but rather we're trying to look up the IRQ
domain that the PMC driver would've registered if it had been enabled.
So perhaps reword this to more accurately reflect that.

>
> Signed-off-by: Manish Bhardwaj <[email protected]>
> Signed-off-by: Prathamesh Shete <[email protected]>
> ---
> drivers/gpio/gpio-tegra186.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 54d9fa7da9c1..efd508ba07a6 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -895,7 +895,7 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
> tegra186_gpio_init_route_mapping(gpio);
>
> np = of_find_matching_node(NULL, tegra186_pmc_of_match);
> - if (np) {
> + if (of_device_is_available(np)) {
> irq->parent_domain = irq_find_host(np);
> of_node_put(np);

This now leaks a reference to np if np is found but not available. So
this should be something like:

if (np) {
if (of_device_is_available(np)) {
irq->parent_domain = irq_find_host(np);
of_node_put(np);

if (!irq->parent_domain)
return -EPROBE_DEFER;
} else {
of_node_put(np);
}
}

or:

if (np) {
if (of_device_is_available(np))
irq->parent_domain = irq_find_host(np);

of_node_put(np);

if (of_device_is_available(np) && !irq->parent_domain)
return -EPROBE_DEFER;
}

The former is a little nicer because it doesn't check availability
twice.

Thierry


Attachments:
(No filename) (1.79 kB)
signature.asc (849.00 B)
Download all attachments

2022-10-26 07:30:30

by Prathamesh Shete

[permalink] [raw]
Subject: [PATCH v2] gpio: tegra186: Check PMC driver status before any request

This patch fixes the issue where even if PMC driver status is
disabled still we are trying to look up for the IRQ domain
that PMC driver would've registered if it had been enabled.

Signed-off-by: Manish Bhardwaj <[email protected]>
Signed-off-by: Prathamesh Shete <[email protected]>
---
drivers/gpio/gpio-tegra186.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
index 54d9fa7da9c1..b99756037ed4 100644
--- a/drivers/gpio/gpio-tegra186.c
+++ b/drivers/gpio/gpio-tegra186.c
@@ -896,11 +896,15 @@ static int tegra186_gpio_probe(struct platform_device *pdev)

np = of_find_matching_node(NULL, tegra186_pmc_of_match);
if (np) {
- irq->parent_domain = irq_find_host(np);
- of_node_put(np);
-
- if (!irq->parent_domain)
- return -EPROBE_DEFER;
+ if (of_device_is_available(np)) {
+ irq->parent_domain = irq_find_host(np);
+ of_node_put(np);
+
+ if (!irq->parent_domain)
+ return -EPROBE_DEFER;
+ } else {
+ of_node_put(np);
+ }
}

irq->map = devm_kcalloc(&pdev->dev, gpio->gpio.ngpio,
--
2.17.1


2022-11-08 10:51:24

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: tegra186: Check PMC driver status before any request

On Wed, Oct 26, 2022 at 9:06 AM Prathamesh Shete <[email protected]> wrote:

> This patch fixes the issue where even if PMC driver status is
> disabled still we are trying to look up for the IRQ domain
> that PMC driver would've registered if it had been enabled.
>
> Signed-off-by: Manish Bhardwaj <[email protected]>
> Signed-off-by: Prathamesh Shete <[email protected]>

Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij

2022-11-08 14:25:54

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: tegra186: Check PMC driver status before any request

On Wed, Oct 26, 2022 at 12:36:14PM +0530, Prathamesh Shete wrote:
> This patch fixes the issue where even if PMC driver status is
> disabled still we are trying to look up for the IRQ domain
> that PMC driver would've registered if it had been enabled.
>
> Signed-off-by: Manish Bhardwaj <[email protected]>
> Signed-off-by: Prathamesh Shete <[email protected]>
> ---
> drivers/gpio/gpio-tegra186.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)

Acked-by: Thierry Reding <[email protected]>


Attachments:
(No filename) (534.00 B)
signature.asc (849.00 B)
Download all attachments