All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: platform: parse IRQ flags from resources
@ 2015-02-18 16:12 Linus Walleij
  2015-02-20 15:40 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2015-02-18 16:12 UTC (permalink / raw)
  To: linux-kernel, Greg Kroah-Hartman, Grant Likely
  Cc: Thomas Gleixner, Robert Jarzmik, David S. Miller, Linus Walleij

This fixes a regression from the net subsystem:
After commit d52fdbb735c36a209f36a628d40ca9185b349ba7
"smc91x: retrieve IRQ and trigger flags in a modern way"
a regression would appear on some legacy platforms such
as the ARM PXA Zylonite that specify IRQ resources like
this:

static struct resource r = {
       .start  = X,
       .end    = X,
       .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
};

The previous code would retrieve the resource and parse
the high edge setting in the SMC91x driver, a use pattern
that means every driver specifying an IRQ flag from a
static resource need to parse resource flags and apply
them at runtime.

As we switched the code to use IRQ descriptors to retrieve
the the trigger type like this:

  irqd_get_trigger_type(irq_get_irq_data(...));

the code would work for new platforms using e.g. device
tree as the backing irq descriptor would have its flags
properly set, whereas this kind of oldstyle static
resources at no point assign the trigger flags to the
corresponding IRQ descriptor.

To make the behaviour identical on modern device tree
and legacy static platform data platforms, modify
platform_get_irq() to assign the trigger flags to the
irq descriptor when a client looks up an IRQ from static
resources.

Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way")
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Greg/Grant: I'm a bit uncertain here. It's kind of
unintuitive that the platform_get_irq() function go around
setting trigger flags on IRQ descriptors, but it is *also*
unintuitive that the descriptor has all the right flags
from a device tree but not from an identical static
resource. And it is bloated to have resource parsing in
each and every driver. The alternative is to revert
the offending patch and live with some resource parsing
all over the place. (Such a patch is posted.)
---
 drivers/base/platform.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9421fed40905..e68ab79df28b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
 	}
 
 	r = platform_get_resource(dev, IORESOURCE_IRQ, num);
+	/*
+	 * The resources may pass trigger flags to the irqs that need
+	 * to be set up. It so happens that the trigger flags for
+	 * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
+	 * settings.
+	 */
+	if (r && r->flags & IORESOURCE_BITS)
+		irqd_set_trigger_type(irq_get_irq_data(r->start),
+				      r->flags & IORESOURCE_BITS);
 
 	return r ? r->start : -ENXIO;
 #endif
-- 
1.9.3


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

* Re: [PATCH] drivers: platform: parse IRQ flags from resources
  2015-02-18 16:12 [PATCH] drivers: platform: parse IRQ flags from resources Linus Walleij
@ 2015-02-20 15:40 ` Greg Kroah-Hartman
  2015-03-05 13:07   ` Robert Jarzmik
  2015-03-09  7:59   ` Linus Walleij
  0 siblings, 2 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2015-02-20 15:40 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, Grant Likely, Thomas Gleixner, Robert Jarzmik,
	David S. Miller

On Wed, Feb 18, 2015 at 05:12:18PM +0100, Linus Walleij wrote:
> This fixes a regression from the net subsystem:
> After commit d52fdbb735c36a209f36a628d40ca9185b349ba7
> "smc91x: retrieve IRQ and trigger flags in a modern way"
> a regression would appear on some legacy platforms such
> as the ARM PXA Zylonite that specify IRQ resources like
> this:
> 
> static struct resource r = {
>        .start  = X,
>        .end    = X,
>        .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
> };
> 
> The previous code would retrieve the resource and parse
> the high edge setting in the SMC91x driver, a use pattern
> that means every driver specifying an IRQ flag from a
> static resource need to parse resource flags and apply
> them at runtime.
> 
> As we switched the code to use IRQ descriptors to retrieve
> the the trigger type like this:
> 
>   irqd_get_trigger_type(irq_get_irq_data(...));
> 
> the code would work for new platforms using e.g. device
> tree as the backing irq descriptor would have its flags
> properly set, whereas this kind of oldstyle static
> resources at no point assign the trigger flags to the
> corresponding IRQ descriptor.
> 
> To make the behaviour identical on modern device tree
> and legacy static platform data platforms, modify
> platform_get_irq() to assign the trigger flags to the
> irq descriptor when a client looks up an IRQ from static
> resources.
> 
> Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way")
> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Greg/Grant: I'm a bit uncertain here. It's kind of
> unintuitive that the platform_get_irq() function go around
> setting trigger flags on IRQ descriptors, but it is *also*
> unintuitive that the descriptor has all the right flags
> from a device tree but not from an identical static
> resource. And it is bloated to have resource parsing in
> each and every driver. The alternative is to revert
> the offending patch and live with some resource parsing
> all over the place. (Such a patch is posted.)
> ---
>  drivers/base/platform.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 9421fed40905..e68ab79df28b 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
>  	}
>  
>  	r = platform_get_resource(dev, IORESOURCE_IRQ, num);
> +	/*
> +	 * The resources may pass trigger flags to the irqs that need
> +	 * to be set up. It so happens that the trigger flags for
> +	 * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
> +	 * settings.
> +	 */
> +	if (r && r->flags & IORESOURCE_BITS)
> +		irqd_set_trigger_type(irq_get_irq_data(r->start),
> +				      r->flags & IORESOURCE_BITS);

Ah, found this now.

I'll defer to Grant as to what to do here, as I have no idea...

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

* Re: [PATCH] drivers: platform: parse IRQ flags from resources
  2015-02-20 15:40 ` Greg Kroah-Hartman
@ 2015-03-05 13:07   ` Robert Jarzmik
  2015-03-09  7:59   ` Linus Walleij
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Jarzmik @ 2015-03-05 13:07 UTC (permalink / raw)
  To: Grant Likely
  Cc: Linus Walleij, linux-kernel, Thomas Gleixner, David S. Miller,
	Greg Kroah-Hartman

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

> On Wed, Feb 18, 2015 at 05:12:18PM +0100, Linus Walleij wrote:
>> This fixes a regression from the net subsystem:
>> After commit d52fdbb735c36a209f36a628d40ca9185b349ba7
>> "smc91x: retrieve IRQ and trigger flags in a modern way"
>> a regression would appear on some legacy platforms such
>> as the ARM PXA Zylonite that specify IRQ resources like
>> this:
>> 
>> static struct resource r = {
>>        .start  = X,
>>        .end    = X,
>>        .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
>> };
>> 
>> The previous code would retrieve the resource and parse
>> the high edge setting in the SMC91x driver, a use pattern
>> that means every driver specifying an IRQ flag from a
>> static resource need to parse resource flags and apply
>> them at runtime.
>> 
>> As we switched the code to use IRQ descriptors to retrieve
>> the the trigger type like this:
>> 
>>   irqd_get_trigger_type(irq_get_irq_data(...));
>> 
>> the code would work for new platforms using e.g. device
>> tree as the backing irq descriptor would have its flags
>> properly set, whereas this kind of oldstyle static
>> resources at no point assign the trigger flags to the
>> corresponding IRQ descriptor.
>> 
>> To make the behaviour identical on modern device tree
>> and legacy static platform data platforms, modify
>> platform_get_irq() to assign the trigger flags to the
>> irq descriptor when a client looks up an IRQ from static
>> resources.
>> 
>> Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way")
>> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>> Greg/Grant: I'm a bit uncertain here. It's kind of
>> unintuitive that the platform_get_irq() function go around
>> setting trigger flags on IRQ descriptors, but it is *also*
>> unintuitive that the descriptor has all the right flags
>> from a device tree but not from an identical static
>> resource. And it is bloated to have resource parsing in
>> each and every driver. The alternative is to revert
>> the offending patch and live with some resource parsing
>> all over the place. (Such a patch is posted.)
>> ---
>>  drivers/base/platform.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>> 
>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>> index 9421fed40905..e68ab79df28b 100644
>> --- a/drivers/base/platform.c
>> +++ b/drivers/base/platform.c
>> @@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
>>  	}
>>  
>>  	r = platform_get_resource(dev, IORESOURCE_IRQ, num);
>> +	/*
>> +	 * The resources may pass trigger flags to the irqs that need
>> +	 * to be set up. It so happens that the trigger flags for
>> +	 * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
>> +	 * settings.
>> +	 */
>> +	if (r && r->flags & IORESOURCE_BITS)
>> +		irqd_set_trigger_type(irq_get_irq_data(r->start),
>> +				      r->flags & IORESOURCE_BITS);
>
> Ah, found this now.
>
> I'll defer to Grant as to what to do here, as I have no idea...

Hi Grant,

Any comment on the patch ?

Cheers.

-- 
Robert

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

* Re: [PATCH] drivers: platform: parse IRQ flags from resources
  2015-02-20 15:40 ` Greg Kroah-Hartman
  2015-03-05 13:07   ` Robert Jarzmik
@ 2015-03-09  7:59   ` Linus Walleij
  2015-03-14 21:35     ` Robert Jarzmik
  1 sibling, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2015-03-09  7:59 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Grant Likely
  Cc: linux-kernel, Thomas Gleixner, Robert Jarzmik, David S. Miller,
	Arnd Bergmann

On Fri, Feb 20, 2015 at 4:40 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Wed, Feb 18, 2015 at 05:12:18PM +0100, Linus Walleij wrote:
>> This fixes a regression from the net subsystem:
>> After commit d52fdbb735c36a209f36a628d40ca9185b349ba7
>> "smc91x: retrieve IRQ and trigger flags in a modern way"
>> a regression would appear on some legacy platforms such
>> as the ARM PXA Zylonite that specify IRQ resources like
>> this:
>>
>> static struct resource r = {
>>        .start  = X,
>>        .end    = X,
>>        .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
>> };
>>
>> The previous code would retrieve the resource and parse
>> the high edge setting in the SMC91x driver, a use pattern
>> that means every driver specifying an IRQ flag from a
>> static resource need to parse resource flags and apply
>> them at runtime.
>>
>> As we switched the code to use IRQ descriptors to retrieve
>> the the trigger type like this:
>>
>>   irqd_get_trigger_type(irq_get_irq_data(...));
>>
>> the code would work for new platforms using e.g. device
>> tree as the backing irq descriptor would have its flags
>> properly set, whereas this kind of oldstyle static
>> resources at no point assign the trigger flags to the
>> corresponding IRQ descriptor.
>>
>> To make the behaviour identical on modern device tree
>> and legacy static platform data platforms, modify
>> platform_get_irq() to assign the trigger flags to the
>> irq descriptor when a client looks up an IRQ from static
>> resources.
>>
>> Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way")
>> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>> Greg/Grant: I'm a bit uncertain here. It's kind of
>> unintuitive that the platform_get_irq() function go around
>> setting trigger flags on IRQ descriptors, but it is *also*
>> unintuitive that the descriptor has all the right flags
>> from a device tree but not from an identical static
>> resource. And it is bloated to have resource parsing in
>> each and every driver. The alternative is to revert
>> the offending patch and live with some resource parsing
>> all over the place. (Such a patch is posted.)
>> ---
>>  drivers/base/platform.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>> index 9421fed40905..e68ab79df28b 100644
>> --- a/drivers/base/platform.c
>> +++ b/drivers/base/platform.c
>> @@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
>>       }
>>
>>       r = platform_get_resource(dev, IORESOURCE_IRQ, num);
>> +     /*
>> +      * The resources may pass trigger flags to the irqs that need
>> +      * to be set up. It so happens that the trigger flags for
>> +      * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
>> +      * settings.
>> +      */
>> +     if (r && r->flags & IORESOURCE_BITS)
>> +             irqd_set_trigger_type(irq_get_irq_data(r->start),
>> +                                   r->flags & IORESOURCE_BITS);
>
> Ah, found this now.
>
> I'll defer to Grant as to what to do here, as I have no idea...

OK no answer, Greg can you just merge this patch then, because
I say it's my best bet for a solution.

Yours,
Linus Walleij

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

* Re: [PATCH] drivers: platform: parse IRQ flags from resources
  2015-03-09  7:59   ` Linus Walleij
@ 2015-03-14 21:35     ` Robert Jarzmik
  2015-03-18 12:13       ` Linus Walleij
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Jarzmik @ 2015-03-14 21:35 UTC (permalink / raw)
  To: Linus Walleij, Greg Kroah-Hartman, Grant Likely
  Cc: linux-kernel, Thomas Gleixner, David S. Miller, Arnd Bergmann

Linus Walleij <linus.walleij@linaro.org> writes:

> On Fri, Feb 20, 2015 at 4:40 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>> On Wed, Feb 18, 2015 at 05:12:18PM +0100, Linus Walleij wrote:
>>> This fixes a regression from the net subsystem:
>>> After commit d52fdbb735c36a209f36a628d40ca9185b349ba7
>>> "smc91x: retrieve IRQ and trigger flags in a modern way"
>>> a regression would appear on some legacy platforms such
>>> as the ARM PXA Zylonite that specify IRQ resources like
>>> this:
>>>
>>> static struct resource r = {
>>>        .start  = X,
>>>        .end    = X,
>>>        .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
>>> };
>>>
>>> The previous code would retrieve the resource and parse
>>> the high edge setting in the SMC91x driver, a use pattern
>>> that means every driver specifying an IRQ flag from a
>>> static resource need to parse resource flags and apply
>>> them at runtime.
>>>
>>> As we switched the code to use IRQ descriptors to retrieve
>>> the the trigger type like this:
>>>
>>>   irqd_get_trigger_type(irq_get_irq_data(...));
>>>
>>> the code would work for new platforms using e.g. device
>>> tree as the backing irq descriptor would have its flags
>>> properly set, whereas this kind of oldstyle static
>>> resources at no point assign the trigger flags to the
>>> corresponding IRQ descriptor.
>>>
>>> To make the behaviour identical on modern device tree
>>> and legacy static platform data platforms, modify
>>> platform_get_irq() to assign the trigger flags to the
>>> irq descriptor when a client looks up an IRQ from static
>>> resources.
>>>
>>> Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way")
>>> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
>>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>>> ---
>>> Greg/Grant: I'm a bit uncertain here. It's kind of
>>> unintuitive that the platform_get_irq() function go around
>>> setting trigger flags on IRQ descriptors, but it is *also*
>>> unintuitive that the descriptor has all the right flags
>>> from a device tree but not from an identical static
>>> resource. And it is bloated to have resource parsing in
>>> each and every driver. The alternative is to revert
>>> the offending patch and live with some resource parsing
>>> all over the place. (Such a patch is posted.)
>>> ---
>>>  drivers/base/platform.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
>>> index 9421fed40905..e68ab79df28b 100644
>>> --- a/drivers/base/platform.c
>>> +++ b/drivers/base/platform.c
>>> @@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
>>>       }
>>>
>>>       r = platform_get_resource(dev, IORESOURCE_IRQ, num);
>>> +     /*
>>> +      * The resources may pass trigger flags to the irqs that need
>>> +      * to be set up. It so happens that the trigger flags for
>>> +      * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER*
>>> +      * settings.
>>> +      */
>>> +     if (r && r->flags & IORESOURCE_BITS)
>>> +             irqd_set_trigger_type(irq_get_irq_data(r->start),
>>> +                                   r->flags & IORESOURCE_BITS);
>>
>> Ah, found this now.
>>
>> I'll defer to Grant as to what to do here, as I have no idea...
>
> OK no answer, Greg can you just merge this patch then, because
> I say it's my best bet for a solution.

Hi Linus, Greg and Grant,

It's been 3 weeks this patch was posted by Linus. I'd like to know if this will
be merged in rc4/rc5, or not. If not, I have a revert to apply to the 4.0 tree.

Cheers.

-- 
Robert

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

* Re: [PATCH] drivers: platform: parse IRQ flags from resources
  2015-03-14 21:35     ` Robert Jarzmik
@ 2015-03-18 12:13       ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2015-03-18 12:13 UTC (permalink / raw)
  To: Robert Jarzmik, Benjamin Herrenschmidt, Grant Likely
  Cc: Greg Kroah-Hartman, linux-kernel, Thomas Gleixner,
	David S. Miller, Arnd Bergmann

On Sat, Mar 14, 2015 at 10:35 PM, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
> Linus Walleij <linus.walleij@linaro.org> writes:
>> On Fri, Feb 20, 2015 at 4:40 PM, Greg Kroah-Hartman
>> <gregkh@linuxfoundation.org> wrote:

>>> Ah, found this now.
>>>
>>> I'll defer to Grant as to what to do here, as I have no idea...
>>
>> OK no answer, Greg can you just merge this patch then, because
>> I say it's my best bet for a solution.
>
> Hi Linus, Greg and Grant,
>
> It's been 3 weeks this patch was posted by Linus. I'd like to know if this will
> be merged in rc4/rc5, or not. If not, I have a revert to apply to the 4.0 tree.

Putting Benjamin on the To: line as well.

If noone knows how to handle this, Greg defers to Grant and
Grant doesn't answer, maybe I should set myself as maintainer
for this file or something? :/

Yours,
Linus Walleij

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

end of thread, other threads:[~2015-03-18 12:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 16:12 [PATCH] drivers: platform: parse IRQ flags from resources Linus Walleij
2015-02-20 15:40 ` Greg Kroah-Hartman
2015-03-05 13:07   ` Robert Jarzmik
2015-03-09  7:59   ` Linus Walleij
2015-03-14 21:35     ` Robert Jarzmik
2015-03-18 12:13       ` Linus Walleij

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.