All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] thermal: rcar_thermal: Use platform_get_irq_optional() to get the interrupt
@ 2021-12-24 19:46 Lad Prabhakar
       [not found] ` <CAHp75Vd+84qyTzPc=Tkhz2cxkVv9Y+ME64XO6btXq=RmtWUxZw@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Lad Prabhakar @ 2021-12-24 19:46 UTC (permalink / raw)
  To: Geert Uytterhoeven, Niklas Söderlund, Rafael J. Wysocki,
	Daniel Lezcano, Amit Kucheria, Zhang Rui
  Cc: Rob Herring, linux-kernel, Prabhakar, Lad Prabhakar,
	linux-renesas-soc, linux-pm

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_optional().

This patch break's the for loop if there are no more interrupts instead
of continuing as done in previous code.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v1->v2
* Simplified checking error code
* Break loop earlier if no interrupts are seen
---
 drivers/thermal/rcar_thermal.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index b49f04daaf47..ff9c55999ddf 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -445,7 +445,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 	struct rcar_thermal_common *common;
 	struct rcar_thermal_priv *priv;
 	struct device *dev = &pdev->dev;
-	struct resource *res, *irq;
+	struct resource *res;
 	const struct rcar_thermal_chip *chip = of_device_get_match_data(dev);
 	int mres = 0;
 	int i;
@@ -467,9 +467,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 	pm_runtime_get_sync(dev);
 
 	for (i = 0; i < chip->nirqs; i++) {
-		irq = platform_get_resource(pdev, IORESOURCE_IRQ, i);
-		if (!irq)
-			continue;
+		int irq;
+
+		irq = platform_get_irq_optional(pdev, i);
+		if (irq == -ENXIO)
+			break;
+		if (irq < 0) {
+			ret = irq;
+			goto error_unregister;
+		}
+
 		if (!common->base) {
 			/*
 			 * platform has IRQ support.
@@ -487,7 +494,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 			idle = 0; /* polling delay is not needed */
 		}
 
-		ret = devm_request_irq(dev, irq->start, rcar_thermal_irq,
+		ret = devm_request_irq(dev, irq, rcar_thermal_irq,
 				       IRQF_SHARED, dev_name(dev), common);
 		if (ret) {
 			dev_err(dev, "irq request failed\n ");
-- 
2.17.1


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

* Re: [PATCH v2] thermal: rcar_thermal: Use platform_get_irq_optional() to get the interrupt
       [not found] ` <CAHp75Vd+84qyTzPc=Tkhz2cxkVv9Y+ME64XO6btXq=RmtWUxZw@mail.gmail.com>
@ 2021-12-25 12:17   ` Lad, Prabhakar
  2021-12-25 15:55   ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Lad, Prabhakar @ 2021-12-25 12:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lad Prabhakar, Geert Uytterhoeven, Niklas Söderlund,
	Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	Rob Herring, linux-kernel, linux-renesas-soc, linux-pm

Hi Andy,

Thank you for the review.

On Sat, Dec 25, 2021 at 11:41 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
>
>
> On Friday, December 24, 2021, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:
>>
>> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
>> allocation of IRQ resources in DT core code, this causes an issue
>> when using hierarchical interrupt domains using "interrupts" property
>> in the node as this bypasses the hierarchical setup and messes up the
>> irq chaining.
>>
>> In preparation for removal of static setup of IRQ resource from DT core
>> code use platform_get_irq_optional().
>>
>> This patch break's the for loop if there are no more interrupts instead
>> of continuing as done in previous code.
>>
>> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>> ---
>> v1->v2
>> * Simplified checking error code
>> * Break loop earlier if no interrupts are seen
>> ---
>>  drivers/thermal/rcar_thermal.c | 17 ++++++++++++-----
>>  1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
>> index b49f04daaf47..ff9c55999ddf 100644
>> --- a/drivers/thermal/rcar_thermal.c
>> +++ b/drivers/thermal/rcar_thermal.c
>> @@ -445,7 +445,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>>         struct rcar_thermal_common *common;
>>         struct rcar_thermal_priv *priv;
>>         struct device *dev = &pdev->dev;
>> -       struct resource *res, *irq;
>> +       struct resource *res;
>>         const struct rcar_thermal_chip *chip = of_device_get_match_data(dev);
>>         int mres = 0;
>>         int i;
>> @@ -467,9 +467,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>>         pm_runtime_get_sync(dev);
>>
>>         for (i = 0; i < chip->nirqs; i++) {
>> -               irq = platform_get_resource(pdev, IORESOURCE_IRQ, i);
>> -               if (!irq)
>> -                       continue;
>> +               int irq;
>> +
>> +               irq = platform_get_irq_optional(pdev, i);
>> +               if (irq == -ENXIO)
>> +                       break;
>> +               if (irq < 0) {
>> +                       ret = irq;
>> +                       goto error_unregister;
>> +               }
>
>
> In all your patches which introduce optional IRQ please change the logic to the opposite:
>
>   if (irq > 0)
>     ...we got one...
>   if (irq == -EPROBE_DEFER)
>     ...return it, if it is ever possible...
>
> With this you adding me a work.
>
The maintainer has requested me to do so [0].

[0] https://patchwork.kernel.org/project/linux-pm/patch/20211218144136.6663-1-prabhakar.mahadev-lad.rj@bp.renesas.com/#24669399

Cheers,
Prabhakar
>
>>
>> +
>>                 if (!common->base) {
>>                         /*
>>                          * platform has IRQ support.
>> @@ -487,7 +494,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
>>                         idle = 0; /* polling delay is not needed */
>>                 }
>>
>> -               ret = devm_request_irq(dev, irq->start, rcar_thermal_irq,
>> +               ret = devm_request_irq(dev, irq, rcar_thermal_irq,
>>                                        IRQF_SHARED, dev_name(dev), common);
>>                 if (ret) {
>>                         dev_err(dev, "irq request failed\n ");
>> --
>> 2.17.1
>>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

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

* Re: [PATCH v2] thermal: rcar_thermal: Use platform_get_irq_optional() to get the interrupt
       [not found] ` <CAHp75Vd+84qyTzPc=Tkhz2cxkVv9Y+ME64XO6btXq=RmtWUxZw@mail.gmail.com>
  2021-12-25 12:17   ` Lad, Prabhakar
@ 2021-12-25 15:55   ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-12-25 15:55 UTC (permalink / raw)
  To: Lad Prabhakar
  Cc: Geert Uytterhoeven, Niklas Söderlund, Rafael J. Wysocki,
	Daniel Lezcano, Amit Kucheria, Zhang Rui, Rob Herring,
	linux-kernel, Prabhakar, linux-renesas-soc, linux-pm

On Sat, Dec 25, 2021 at 1:41 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Friday, December 24, 2021, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> wrote:

...

>> +               int irq;
>> +
>> +               irq = platform_get_irq_optional(pdev, i);
>> +               if (irq == -ENXIO)
>> +                       break;
>> +               if (irq < 0) {
>> +                       ret = irq;
>> +                       goto error_unregister;
>> +               }
>
>
> In all your patches which introduce optional IRQ please change the logic to the opposite:
>
>   if (irq > 0)
>     ...we got one...
>   if (irq == -EPROBE_DEFER)
>     ...return it, if it is ever possible...
>
> With this you adding me a work.

I noticed that in some patches you actually do the right things, so,
please do it in the same way where you use _optiomal() variant, i.e.

if (ret < 0 && ret != -ENXIO)
  return ret;
if (ret > 0)
  ...we got it...

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2021-12-25 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 19:46 [PATCH v2] thermal: rcar_thermal: Use platform_get_irq_optional() to get the interrupt Lad Prabhakar
     [not found] ` <CAHp75Vd+84qyTzPc=Tkhz2cxkVv9Y+ME64XO6btXq=RmtWUxZw@mail.gmail.com>
2021-12-25 12:17   ` Lad, Prabhakar
2021-12-25 15:55   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.