linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pata_platform struct resource signness fix
@ 2008-09-25  8:36 Wang Jian
  2008-09-25  8:54 ` Wang Jian
  2008-09-25  9:12 ` Leo Li
  0 siblings, 2 replies; 40+ messages in thread
From: Wang Jian @ 2008-09-25  8:36 UTC (permalink / raw)
  To: linuxppc-dev

Hi,

This patch is to pata_platform.c but at this time, it's powerpc specific
because it can only be triggerred using openfirmware, so I post the patch
here. The patch is against 2.6.26-rc8.

The problem is triggerred when ata device is populated using 
pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).

pata_of_platform_probe() parse device tree and

        if (ret == NO_IRQ)
	                irq_res.start = irq_res.end = -1;

Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
requested.


---
(irq_res->start > 0) will be true even when it is (-1). When the device
has no irq, irq_res->start is assigned (-1).

Signed-off-by: Wang Jian <lark@linux.net.cn>
---
 drivers/ata/pata_platform.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 8f65ad6..b12cd0c 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device *dev,
 	/*
 	 * And the IRQ
 	 */
-	if (irq_res && irq_res->start > 0) {
+	if (irq_res && irq_res->start != -1) {
 		irq = irq_res->start;
 		irq_flags = irq_res->flags;
 	}
-- 
1.5.5.4

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25  8:36 [PATCH] pata_platform struct resource signness fix Wang Jian
@ 2008-09-25  8:54 ` Wang Jian
  2008-09-25 10:40   ` Li Yang
  2008-09-25  9:12 ` Leo Li
  1 sibling, 1 reply; 40+ messages in thread
From: Wang Jian @ 2008-09-25  8:54 UTC (permalink / raw)
  To: linuxppc-dev

The alternative fix can be.

diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 408da30..1f18ad9 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,

         ret = of_irq_to_resource(dn, 0, &irq_res);
         if (ret == NO_IRQ)
-               irq_res.start = irq_res.end = -1;
+               irq_res.start = irq_res.end = 0;
         else
                 irq_res.flags = 0;

I just didn't spend much time to see which is better.

Wang Jian wrote:
> Hi,
> 
> This patch is to pata_platform.c but at this time, it's powerpc specific
> because it can only be triggerred using openfirmware, so I post the patch
> here. The patch is against 2.6.26-rc8.
> 
> The problem is triggerred when ata device is populated using 
> pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).
> 
> pata_of_platform_probe() parse device tree and
> 
>         if (ret == NO_IRQ)
> 	                irq_res.start = irq_res.end = -1;
> 
> Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
> requested.
> 
> 
> ---
> (irq_res->start > 0) will be true even when it is (-1). When the device
> has no irq, irq_res->start is assigned (-1).
> 
> Signed-off-by: Wang Jian <lark@linux.net.cn>
> ---
>  drivers/ata/pata_platform.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
> index 8f65ad6..b12cd0c 100644
> --- a/drivers/ata/pata_platform.c
> +++ b/drivers/ata/pata_platform.c
> @@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device *dev,
>  	/*
>  	 * And the IRQ
>  	 */
> -	if (irq_res && irq_res->start > 0) {
> +	if (irq_res && irq_res->start != -1) {
>  		irq = irq_res->start;
>  		irq_flags = irq_res->flags;
>  	}

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25  8:36 [PATCH] pata_platform struct resource signness fix Wang Jian
  2008-09-25  8:54 ` Wang Jian
@ 2008-09-25  9:12 ` Leo Li
  2008-09-25  9:30   ` Wang Jian
  1 sibling, 1 reply; 40+ messages in thread
From: Leo Li @ 2008-09-25  9:12 UTC (permalink / raw)
  To: Wang Jian; +Cc: linuxppc-dev

On Thu, Sep 25, 2008 at 4:36 PM, Wang Jian <lark@linux.net.cn> wrote:
> Hi,
>
> This patch is to pata_platform.c but at this time, it's powerpc specific
> because it can only be triggerred using openfirmware, so I post the patch
> here. The patch is against 2.6.26-rc8.

Powerpc isn't the only arch to use openfirmware.  Anyway, you have to
cc linux-ide@vger.kernel.org if you want the patch to be merged.

- Leo

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25  9:12 ` Leo Li
@ 2008-09-25  9:30   ` Wang Jian
  0 siblings, 0 replies; 40+ messages in thread
From: Wang Jian @ 2008-09-25  9:30 UTC (permalink / raw)
  To: Leo Li; +Cc: linuxppc-dev

As I said, I didn't spend much time on the issue, so I don't know which patch
is better. (But I do think the patch to pata_of_platform.c is better ATM).

AFAIK, powerpc is the only consumer of pata_of_platform.c, so I think this list
is better for discussion.

I should cc: Anton Vorontsov <avorontsov@ru.mvista.com> but last time I cc:
him I got bounced.

Leo Li wrote:
> On Thu, Sep 25, 2008 at 4:36 PM, Wang Jian <lark@linux.net.cn> wrote:
>> Hi,
>>
>> This patch is to pata_platform.c but at this time, it's powerpc specific
>> because it can only be triggerred using openfirmware, so I post the patch
>> here. The patch is against 2.6.26-rc8.
> 
> Powerpc isn't the only arch to use openfirmware.  Anyway, you have to
> cc linux-ide@vger.kernel.org if you want the patch to be merged.
> 
> - Leo
> 
> 

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25  8:54 ` Wang Jian
@ 2008-09-25 10:40   ` Li Yang
  2008-09-25 10:48     ` Anton Vorontsov
  2008-09-25 15:33     ` [PATCH] pata_platform struct resource signness fix Wang Jian
  0 siblings, 2 replies; 40+ messages in thread
From: Li Yang @ 2008-09-25 10:40 UTC (permalink / raw)
  To: Wang Jian; +Cc: linuxppc-dev, linux-ide

On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
> The alternative fix can be.

This one is better as 0 is defined as 'invalid irq' for all
architectures.  Added linux-ide and Anton to cc.

- Leo

>
> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
> index 408da30..1f18ad9 100644
> --- a/drivers/ata/pata_of_platform.c
> +++ b/drivers/ata/pata_of_platform.c
> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct
> of_device *ofdev,
>
>        ret = of_irq_to_resource(dn, 0, &irq_res);
>        if (ret == NO_IRQ)
> -               irq_res.start = irq_res.end = -1;
> +               irq_res.start = irq_res.end = 0;
>        else
>                irq_res.flags = 0;
>
> I just didn't spend much time to see which is better.
>
> Wang Jian wrote:
>>
>> Hi,
>>
>> This patch is to pata_platform.c but at this time, it's powerpc specific
>> because it can only be triggerred using openfirmware, so I post the patch
>> here. The patch is against 2.6.26-rc8.
>>
>> The problem is triggerred when ata device is populated using
>> pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).
>>
>> pata_of_platform_probe() parse device tree and
>>
>>        if (ret == NO_IRQ)
>>                        irq_res.start = irq_res.end = -1;
>>
>> Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
>> requested.
>>
>>
>> ---
>> (irq_res->start > 0) will be true even when it is (-1). When the device
>> has no irq, irq_res->start is assigned (-1).
>>
>> Signed-off-by: Wang Jian <lark@linux.net.cn>
>> ---
>>  drivers/ata/pata_platform.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
>> index 8f65ad6..b12cd0c 100644
>> --- a/drivers/ata/pata_platform.c
>> +++ b/drivers/ata/pata_platform.c
>> @@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device
>> *dev,
>>        /*
>>         * And the IRQ
>>         */
>> -       if (irq_res && irq_res->start > 0) {
>> +       if (irq_res && irq_res->start != -1) {
>>                irq = irq_res->start;
>>                irq_flags = irq_res->flags;
>>        }
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25 10:40   ` Li Yang
@ 2008-09-25 10:48     ` Anton Vorontsov
  2008-09-29  4:19       ` Jeff Garzik
  2008-09-25 15:33     ` [PATCH] pata_platform struct resource signness fix Wang Jian
  1 sibling, 1 reply; 40+ messages in thread
From: Anton Vorontsov @ 2008-09-25 10:48 UTC (permalink / raw)
  To: Li Yang, Jeff Garzik; +Cc: linux-ide, linuxppc-dev, Wang Jian

On Thu, Sep 25, 2008 at 06:40:59PM +0800, Li Yang wrote:
> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
> > The alternative fix can be.
> 
> This one is better as 0 is defined as 'invalid irq' for all
> architectures.  Added linux-ide and Anton to cc.

Thanks for the correct Cc.

I've sent a patch to fix the issue more than a month ago.

http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg22851.html

Jeff, could you apply the patch?

Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25 10:40   ` Li Yang
  2008-09-25 10:48     ` Anton Vorontsov
@ 2008-09-25 15:33     ` Wang Jian
  2008-09-25 15:47       ` Anton Vorontsov
  1 sibling, 1 reply; 40+ messages in thread
From: Wang Jian @ 2008-09-25 15:33 UTC (permalink / raw)
  To: Li Yang; +Cc: linuxppc-dev, linux-ide

Li Yang wrote:
> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>> The alternative fix can be.
> 
> This one is better as 0 is defined as 'invalid irq' for all
> architectures.  Added linux-ide and Anton to cc.

However, this is not very true. Just git grep "#define NO_IRQ" and see. It
seems that the NO_IRQ is in transition from (-1) to (0).

I happened to code the same 2 patches as Anton Vorontsov <avorontsov@ru.mvista.com>
had done without knowing his earlier work. I think he was also confused by (-1)
and (0).

> 
> - Leo
> 
>> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
>> index 408da30..1f18ad9 100644
>> --- a/drivers/ata/pata_of_platform.c
>> +++ b/drivers/ata/pata_of_platform.c
>> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct
>> of_device *ofdev,
>>
>>        ret = of_irq_to_resource(dn, 0, &irq_res);
>>        if (ret == NO_IRQ)
>> -               irq_res.start = irq_res.end = -1;
>> +               irq_res.start = irq_res.end = 0;
>>        else
>>                irq_res.flags = 0;
>>
>> I just didn't spend much time to see which is better.
>>
>> Wang Jian wrote:
>>> Hi,
>>>
>>> This patch is to pata_platform.c but at this time, it's powerpc specific
>>> because it can only be triggerred using openfirmware, so I post the patch
>>> here. The patch is against 2.6.26-rc8.
>>>
>>> The problem is triggerred when ata device is populated using
>>> pata_of_platform.c, and no irq is assigned (poll mode, such as CF card).
>>>
>>> pata_of_platform_probe() parse device tree and
>>>
>>>        if (ret == NO_IRQ)
>>>                        irq_res.start = irq_res.end = -1;
>>>
>>> Then irq is 0xffffffff, not NULL. Probe will fail coz irq can't be
>>> requested.
>>>
>>>
>>> ---
>>> (irq_res->start > 0) will be true even when it is (-1). When the device
>>> has no irq, irq_res->start is assigned (-1).
>>>
>>> Signed-off-by: Wang Jian <lark@linux.net.cn>
>>> ---
>>>  drivers/ata/pata_platform.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
>>> index 8f65ad6..b12cd0c 100644
>>> --- a/drivers/ata/pata_platform.c
>>> +++ b/drivers/ata/pata_platform.c
>>> @@ -123,7 +123,7 @@ int __devinit __pata_platform_probe(struct device
>>> *dev,
>>>        /*
>>>         * And the IRQ
>>>         */
>>> -       if (irq_res && irq_res->start > 0) {
>>> +       if (irq_res && irq_res->start != -1) {
>>>                irq = irq_res->start;
>>>                irq_flags = irq_res->flags;
>>>        }
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>>
> 
> 

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25 15:33     ` [PATCH] pata_platform struct resource signness fix Wang Jian
@ 2008-09-25 15:47       ` Anton Vorontsov
  0 siblings, 0 replies; 40+ messages in thread
From: Anton Vorontsov @ 2008-09-25 15:47 UTC (permalink / raw)
  To: Wang Jian; +Cc: linuxppc-dev, Li Yang, linux-ide

On Thu, Sep 25, 2008 at 11:33:35PM +0800, Wang Jian wrote:
> Li Yang wrote:
>> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>>> The alternative fix can be.
>>
>> This one is better as 0 is defined as 'invalid irq' for all
>> architectures.  Added linux-ide and Anton to cc.
>
> However, this is not very true. Just git grep "#define NO_IRQ" and see. It
> seems that the NO_IRQ is in transition from (-1) to (0).

Yeah, there is a mess, but it gets better as time goes by.
The platforms/drivers should be fixed, since 0 is the only
invalid VIRQ.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_platform struct resource signness fix
  2008-09-25 10:48     ` Anton Vorontsov
@ 2008-09-29  4:19       ` Jeff Garzik
  2008-09-29 13:32         ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
  0 siblings, 1 reply; 40+ messages in thread
From: Jeff Garzik @ 2008-09-29  4:19 UTC (permalink / raw)
  To: avorontsov; +Cc: linux-ide, linuxppc-dev, Li Yang, Wang Jian

Anton Vorontsov wrote:
> On Thu, Sep 25, 2008 at 06:40:59PM +0800, Li Yang wrote:
>> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>>> The alternative fix can be.
>> This one is better as 0 is defined as 'invalid irq' for all
>> architectures.  Added linux-ide and Anton to cc.
> 
> Thanks for the correct Cc.
> 
> I've sent a patch to fix the issue more than a month ago.
> 
> http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg22851.html
> 
> Jeff, could you apply the patch?

Can you resend, I don't seem to have it...

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

* [PATCH] pata_of_platform: fix no irq handling
  2008-09-29  4:19       ` Jeff Garzik
@ 2008-09-29 13:32         ` Anton Vorontsov
  0 siblings, 0 replies; 40+ messages in thread
From: Anton Vorontsov @ 2008-09-29 13:32 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, linuxppc-dev, Li Yang, Wang Jian

When no irq specified the pata_of_platform fills the irq_res with -1,
which is wrong to do for two reasons:

1. By definition, 'no irq' should be IRQ 0, not some negative integer;
2. pata_platform checks for irq_res.start > 0, but since irq_res.start
   is unsigned type, the check will be true for `-1'.

Reported-by: Steven A. Falco <sfalco@harris.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

On Mon, Sep 29, 2008 at 12:19:14AM -0400, Jeff Garzik wrote:
> Anton Vorontsov wrote:
>> On Thu, Sep 25, 2008 at 06:40:59PM +0800, Li Yang wrote:
>>> On Thu, Sep 25, 2008 at 4:54 PM, Wang Jian <lark@linux.net.cn> wrote:
>>>> The alternative fix can be.
>>> This one is better as 0 is defined as 'invalid irq' for all
>>> architectures.  Added linux-ide and Anton to cc.
>>
>> Thanks for the correct Cc.
>>
>> I've sent a patch to fix the issue more than a month ago.
>>
>> http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg22851.html
>>
>> Jeff, could you apply the patch?
>
> Can you resend, I don't seem to have it...

Here it is.

Thanks,

 drivers/ata/pata_of_platform.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 408da30..1f18ad9 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
 
 	ret = of_irq_to_resource(dn, 0, &irq_res);
 	if (ret == NO_IRQ)
-		irq_res.start = irq_res.end = -1;
+		irq_res.start = irq_res.end = 0;
 	else
 		irq_res.flags = 0;
 
-- 
1.5.6.3

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-13  6:56 ` Tejun Heo
@ 2008-10-13 23:27   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 40+ messages in thread
From: Benjamin Herrenschmidt @ 2008-10-13 23:27 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linux-ide, linux-kernel, linuxppc-dev, Li Yang, Jeff Garzik, Wang Jian

On Mon, 2008-10-13 at 15:56 +0900, Tejun Heo wrote:
> Anton Vorontsov wrote:
> > When no irq specified the pata_of_platform fills the irq_res with -1,
> > which is wrong to do for two reasons:
> > 
> > 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> > 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
> >    is unsigned type, the check will be true for `-1'.
> > 
> > Reported-by: Steven A. Falco <sfalco@harris.com>
> > Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> 
> applied to #tj-upstream (will soon be sent upstream)

Hrm... I applied it to powerpc.git too :-) Hopefully the merge will sort
it out !

Cheers,
Ben.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-06 17:26 [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
  2008-10-06 20:41 ` Matt Sealey
@ 2008-10-13  6:56 ` Tejun Heo
  2008-10-13 23:27   ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 40+ messages in thread
From: Tejun Heo @ 2008-10-13  6:56 UTC (permalink / raw)
  To: avorontsov
  Cc: linuxppc-dev, linux-kernel, linux-ide, Li Yang, Jeff Garzik, Wang Jian

Anton Vorontsov wrote:
> When no irq specified the pata_of_platform fills the irq_res with -1,
> which is wrong to do for two reasons:
> 
> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>    is unsigned type, the check will be true for `-1'.
> 
> Reported-by: Steven A. Falco <sfalco@harris.com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>

applied to #tj-upstream (will soon be sent upstream)

-- 
tejun

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-08  9:59             ` Geert Uytterhoeven
  2008-10-08 10:27               ` Alan Cox
@ 2008-10-10 17:55               ` Paul Mundt
  1 sibling, 0 replies; 40+ messages in thread
From: Paul Mundt @ 2008-10-10 17:55 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linuxppc-dev, Jeff Garzik, linux-kernel, linux-ide, Tejun Heo,
	Li Yang, David Woodhouse, Alan Cox, Wang Jian

On Wed, Oct 08, 2008 at 11:59:59AM +0200, Geert Uytterhoeven wrote:
> On Wed, 8 Oct 2008, Alan Cox wrote:
> > On Wed, 08 Oct 2008 09:40:54 +0100
> > David Woodhouse <dwmw2@infradead.org> wrote:
> > 
> > > On Tue, 2008-10-07 at 10:37 +0100, Alan Cox wrote:
> > > > Zero means no IRQ. Any platform with bits of code left over exposing IRQ
> > > > 0 is already not supported by lots of driver code including libata.
> > > 
> > > ...and must implement some kind of interrupt remapping crap just to work
> > > around this bogus design decision.
> > 
> > I'll leave you to argue with Linus about that, but since that was the
> > decision back in 2005 (for good C reasons) we can safely rely on it.
> 
> `git grep NO_IRQ include arch/*/include' is still quite enlightening...
> 
In the case of PCI where IRQ is unsigned int, that's certainly bogus. The
problem originates on platforms where a 1:1 mapping between vector and
IRQ exists, where 0 is a valid value. This then needs to be remapped in
to an IRQ cookie that has a non-0 value in order to be assigned to
dev->irq. Despite whether this is bogus or not, there's not much to be
done about it. Those of us with vectored IRQ platforms generally have
enough sources that the use of IRQ-0 doesn't matter, and it's not worth
the headache of setting up the remapping crap.

As an example, on SH, IRQ-0 is mapped to vector 0x200. It is '0' for
symbolic reasons only. It's just as easy to pad out irq_desc and treat it
as an off-by-1 to work around all of code that assumes NO_IRQ == 0. There
is enough code in the kernel today that makes the non-zero IRQ cookie
assumption that platforms that do otherwise are simply broken.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-08  9:59             ` Geert Uytterhoeven
@ 2008-10-08 10:27               ` Alan Cox
  2008-10-10 17:55               ` Paul Mundt
  1 sibling, 0 replies; 40+ messages in thread
From: Alan Cox @ 2008-10-08 10:27 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linuxppc-dev, Jeff Garzik, linux-kernel, linux-ide, Tejun Heo,
	Li Yang, David Woodhouse, Wang Jian

> > I'll leave you to argue with Linus about that, but since that was the
> > decision back in 2005 (for good C reasons) we can safely rely on it.
> 
> `git grep NO_IRQ include arch/*/include' is still quite enlightening...

Good guide to platform code we should delete really

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-08  9:00           ` Alan Cox
@ 2008-10-08  9:59             ` Geert Uytterhoeven
  2008-10-08 10:27               ` Alan Cox
  2008-10-10 17:55               ` Paul Mundt
  0 siblings, 2 replies; 40+ messages in thread
From: Geert Uytterhoeven @ 2008-10-08  9:59 UTC (permalink / raw)
  To: Alan Cox
  Cc: linuxppc-dev, Jeff Garzik, linux-kernel, linux-ide, Tejun Heo,
	Li Yang, David Woodhouse, Wang Jian

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1093 bytes --]

On Wed, 8 Oct 2008, Alan Cox wrote:
> On Wed, 08 Oct 2008 09:40:54 +0100
> David Woodhouse <dwmw2@infradead.org> wrote:
> 
> > On Tue, 2008-10-07 at 10:37 +0100, Alan Cox wrote:
> > > Zero means no IRQ. Any platform with bits of code left over exposing IRQ
> > > 0 is already not supported by lots of driver code including libata.
> > 
> > ...and must implement some kind of interrupt remapping crap just to work
> > around this bogus design decision.
> 
> I'll leave you to argue with Linus about that, but since that was the
> decision back in 2005 (for good C reasons) we can safely rely on it.

`git grep NO_IRQ include arch/*/include' is still quite enlightening...

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-08  8:40         ` David Woodhouse
@ 2008-10-08  9:00           ` Alan Cox
  2008-10-08  9:59             ` Geert Uytterhoeven
  0 siblings, 1 reply; 40+ messages in thread
From: Alan Cox @ 2008-10-08  9:00 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Li Yang, linux-ide, linux-kernel, linuxppc-dev, Tejun Heo,
	Jeff Garzik, Wang Jian

On Wed, 08 Oct 2008 09:40:54 +0100
David Woodhouse <dwmw2@infradead.org> wrote:

> On Tue, 2008-10-07 at 10:37 +0100, Alan Cox wrote:
> > Zero means no IRQ. Any platform with bits of code left over exposing IRQ
> > 0 is already not supported by lots of driver code including libata.
> 
> ...and must implement some kind of interrupt remapping crap just to work
> around this bogus design decision.

I'll leave you to argue with Linus about that, but since that was the
decision back in 2005 (for good C reasons) we can safely rely on it.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-07  9:37       ` Alan Cox
@ 2008-10-08  8:40         ` David Woodhouse
  2008-10-08  9:00           ` Alan Cox
  0 siblings, 1 reply; 40+ messages in thread
From: David Woodhouse @ 2008-10-08  8:40 UTC (permalink / raw)
  To: Alan Cox
  Cc: Li Yang, linux-ide, linux-kernel, linuxppc-dev, Tejun Heo,
	Jeff Garzik, Wang Jian

On Tue, 2008-10-07 at 10:37 +0100, Alan Cox wrote:
> Zero means no IRQ. Any platform with bits of code left over exposing IRQ
> 0 is already not supported by lots of driver code including libata.

...and must implement some kind of interrupt remapping crap just to work
around this bogus design decision.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-07  9:26       ` Anton Vorontsov
@ 2008-10-07 10:04         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 40+ messages in thread
From: Benjamin Herrenschmidt @ 2008-10-07 10:04 UTC (permalink / raw)
  To: avorontsov
  Cc: linux-ide, linux-kernel, linuxppc-dev, Tejun Heo, Li Yang,
	Jeff Garzik, Wang Jian

On Tue, 2008-10-07 at 13:26 +0400, Anton Vorontsov wrote:
> On Tue, Oct 07, 2008 at 10:30:59AM +0900, Tejun Heo wrote:
> > Anton Vorontsov wrote:
> > > On Mon, Oct 06, 2008 at 03:41:19PM -0500, Matt Sealey wrote:
> > >> There is a simple problem with the patch which is that an "IRQ 0" can and does
> > >> actually exist on a bunch of platforms, at least to the best of my knowledge.
> > >>
> > >> Checking for -1 (which means for definite, no irq at all, because it is
> > >> totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.
> > > 
> > > This was discussed years ago.
> > > 
> > > http://lkml.org/lkml/2005/11/22/159
> > > http://lkml.org/lkml/2005/11/22/227
> > > 
> > 
> > Would this break any existing platforms?
> 
> Nope.
> 
> The driver is only available for PPC platforms.
> 
> As time goes by one can change `depend on PPC_OF' to just `depends on
> OF', so that the driver will be also available for SPARC. And still
> it will work, because SPARC also understands VIRQ0 as invalid VIRQ.
> 

Yup, I agree. I'll pick it up in my next batch.

Cheers,
Ben.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-07  1:30     ` Tejun Heo
  2008-10-07  9:18       ` Wang Jian
  2008-10-07  9:26       ` Anton Vorontsov
@ 2008-10-07  9:37       ` Alan Cox
  2008-10-08  8:40         ` David Woodhouse
  2 siblings, 1 reply; 40+ messages in thread
From: Alan Cox @ 2008-10-07  9:37 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Li Yang, linuxppc-dev, linux-kernel, linux-ide, Jeff Garzik, Wang Jian

> > This was discussed years ago.
> > 
> > http://lkml.org/lkml/2005/11/22/159
> > http://lkml.org/lkml/2005/11/22/227
> > 
> 
> Would this break any existing platforms?  If so, can those be fixed
> together or does it become a much bigger problem that way?

Zero means no IRQ. Any platform with bits of code left over exposing IRQ
0 is already not supported by lots of driver code including libata.

As IRQs are unsigned using -1 is asking for trouble

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-07  1:30     ` Tejun Heo
  2008-10-07  9:18       ` Wang Jian
@ 2008-10-07  9:26       ` Anton Vorontsov
  2008-10-07 10:04         ` Benjamin Herrenschmidt
  2008-10-07  9:37       ` Alan Cox
  2 siblings, 1 reply; 40+ messages in thread
From: Anton Vorontsov @ 2008-10-07  9:26 UTC (permalink / raw)
  To: Tejun Heo
  Cc: linuxppc-dev, linux-kernel, linux-ide, Li Yang, Jeff Garzik, Wang Jian

On Tue, Oct 07, 2008 at 10:30:59AM +0900, Tejun Heo wrote:
> Anton Vorontsov wrote:
> > On Mon, Oct 06, 2008 at 03:41:19PM -0500, Matt Sealey wrote:
> >> There is a simple problem with the patch which is that an "IRQ 0" can and does
> >> actually exist on a bunch of platforms, at least to the best of my knowledge.
> >>
> >> Checking for -1 (which means for definite, no irq at all, because it is
> >> totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.
> > 
> > This was discussed years ago.
> > 
> > http://lkml.org/lkml/2005/11/22/159
> > http://lkml.org/lkml/2005/11/22/227
> > 
> 
> Would this break any existing platforms?

Nope.

The driver is only available for PPC platforms.

As time goes by one can change `depend on PPC_OF' to just `depends on
OF', so that the driver will be also available for SPARC. And still
it will work, because SPARC also understands VIRQ0 as invalid VIRQ.


Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-07  1:30     ` Tejun Heo
@ 2008-10-07  9:18       ` Wang Jian
  2008-10-07  9:26       ` Anton Vorontsov
  2008-10-07  9:37       ` Alan Cox
  2 siblings, 0 replies; 40+ messages in thread
From: Wang Jian @ 2008-10-07  9:18 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Li Yang, linuxppc-dev, linux-kernel, linux-ide, Jeff Garzik

Tejun Heo wrote:
> Anton Vorontsov wrote:
>> On Mon, Oct 06, 2008 at 03:41:19PM -0500, Matt Sealey wrote:
>>> There is a simple problem with the patch which is that an "IRQ 0" can and does
>>> actually exist on a bunch of platforms, at least to the best of my knowledge.
>>>
>>> Checking for -1 (which means for definite, no irq at all, because it is
>>> totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.
>> This was discussed years ago.
>>
>> http://lkml.org/lkml/2005/11/22/159
>> http://lkml.org/lkml/2005/11/22/227
>>
> 
> Would this break any existing platforms?  If so, can those be fixed
> together or does it become a much bigger problem that way?
> 

Pata_of_platform stacks upon pata_platform. This patch fixes problem
concerning definition of "no irq" without touch any other place.  So
far I can't see any new problem.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-06 21:32   ` Anton Vorontsov
@ 2008-10-07  1:30     ` Tejun Heo
  2008-10-07  9:18       ` Wang Jian
                         ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Tejun Heo @ 2008-10-07  1:30 UTC (permalink / raw)
  To: avorontsov
  Cc: linuxppc-dev, linux-kernel, linux-ide, Li Yang, Jeff Garzik, Wang Jian

Anton Vorontsov wrote:
> On Mon, Oct 06, 2008 at 03:41:19PM -0500, Matt Sealey wrote:
>> There is a simple problem with the patch which is that an "IRQ 0" can and does
>> actually exist on a bunch of platforms, at least to the best of my knowledge.
>>
>> Checking for -1 (which means for definite, no irq at all, because it is
>> totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.
> 
> This was discussed years ago.
> 
> http://lkml.org/lkml/2005/11/22/159
> http://lkml.org/lkml/2005/11/22/227
> 

Would this break any existing platforms?  If so, can those be fixed
together or does it become a much bigger problem that way?

Thanks.

-- 
tejun

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-06 20:41 ` Matt Sealey
@ 2008-10-06 21:32   ` Anton Vorontsov
  2008-10-07  1:30     ` Tejun Heo
  0 siblings, 1 reply; 40+ messages in thread
From: Anton Vorontsov @ 2008-10-06 21:32 UTC (permalink / raw)
  To: Matt Sealey
  Cc: linux-ide, linux-kernel, linuxppc-dev, Li Yang, Jeff Garzik, Wang Jian

On Mon, Oct 06, 2008 at 03:41:19PM -0500, Matt Sealey wrote:
> There is a simple problem with the patch which is that an "IRQ 0" can and does
> actually exist on a bunch of platforms, at least to the best of my knowledge.
> 
> Checking for -1 (which means for definite, no irq at all, because it is
> totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.

This was discussed years ago.

http://lkml.org/lkml/2005/11/22/159
http://lkml.org/lkml/2005/11/22/227

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-10-06 17:26 [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
@ 2008-10-06 20:41 ` Matt Sealey
  2008-10-06 21:32   ` Anton Vorontsov
  2008-10-13  6:56 ` Tejun Heo
  1 sibling, 1 reply; 40+ messages in thread
From: Matt Sealey @ 2008-10-06 20:41 UTC (permalink / raw)
  To: avorontsov
  Cc: linux-ide, linux-kernel, linuxppc-dev, Li Yang, Jeff Garzik, Wang Jian

There is a simple problem with the patch which is that an "IRQ 0" can and does
actually exist on a bunch of platforms, at least to the best of my knowledge.

Checking for -1 (which means for definite, no irq at all, because it is
totally unambiguous, as a -1 IRQ numbering is "impossible") is more correct.

The problem is the check against an unsigned value for interrupts (is there
any reason why you would need 4 billion interrupts possible instead of just
2 billion?) although I must say, the patch will work, and probably 99.9999999%
of people will never see a problem with it :)

-- 
Matt Sealey <matt@genesi-usa.com>
Genesi, Manager, Developer Relations

Anton Vorontsov wrote:
> When no irq specified the pata_of_platform fills the irq_res with -1,
> which is wrong to do for two reasons:
> 
> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>    is unsigned type, the check will be true for `-1'.
> 
> Reported-by: Steven A. Falco <sfalco@harris.com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
> 
> Resending again...
> 
>  drivers/ata/pata_of_platform.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
> index 408da30..1f18ad9 100644
> --- a/drivers/ata/pata_of_platform.c
> +++ b/drivers/ata/pata_of_platform.c
> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
>  
>  	ret = of_irq_to_resource(dn, 0, &irq_res);
>  	if (ret == NO_IRQ)
> -		irq_res.start = irq_res.end = -1;
> +		irq_res.start = irq_res.end = 0;
>  	else
>  		irq_res.flags = 0;
>  

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

* [PATCH] pata_of_platform: fix no irq handling
@ 2008-10-06 17:26 Anton Vorontsov
  2008-10-06 20:41 ` Matt Sealey
  2008-10-13  6:56 ` Tejun Heo
  0 siblings, 2 replies; 40+ messages in thread
From: Anton Vorontsov @ 2008-10-06 17:26 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linuxppc-dev, linux-kernel, linux-ide, Li Yang, Wang Jian

When no irq specified the pata_of_platform fills the irq_res with -1,
which is wrong to do for two reasons:

1. By definition, 'no irq' should be IRQ 0, not some negative integer;
2. pata_platform checks for irq_res.start > 0, but since irq_res.start
   is unsigned type, the check will be true for `-1'.

Reported-by: Steven A. Falco <sfalco@harris.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

Resending again...

 drivers/ata/pata_of_platform.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 408da30..1f18ad9 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
 
 	ret = of_irq_to_resource(dn, 0, &irq_res);
 	if (ret == NO_IRQ)
-		irq_res.start = irq_res.end = -1;
+		irq_res.start = irq_res.end = 0;
 	else
 		irq_res.flags = 0;
 
-- 
1.5.6.3

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-12 14:31               ` Anton Vorontsov
@ 2008-08-13 21:25                 ` Steven A. Falco
  0 siblings, 0 replies; 40+ messages in thread
From: Steven A. Falco @ 2008-08-13 21:25 UTC (permalink / raw)
  To: avorontsov
  Cc: Sparks, Sam, linuxppc-dev, linux-ide, Stefan Roese, Jeff Garzik

[-- Attachment #1: Type: text/plain, Size: 1989 bytes --]

Anton Vorontsov wrote:
> On Tue, Aug 12, 2008 at 06:18:42PM +0400, Sergei Shtylyov wrote:
>   
>> Anton Vorontsov wrote:
>>
>>     
>>>>>> 1. IDE status read does not work. (But am I understand correctly
>>>>>>   that IDE works well if IRQ is unspecified? Then this is hardly
>>>>>>   an issue.)
>>>>>> 2. IDE interrupt comes when it should not. I'd recommend to use
>>>>>>   oscilloscope to find out what is happening there, that is, if
>>>>>>   the drive actually deasserts its irq line after status read.
>>>>>>   If so, than this could be a PIC problem.
>>>>>>             
>>>>>> What is the platform on which you're observing the issue, btw?
>>>>>>             
>>>>> Another possibility is that you got the wrong interrupt number
>>>>> in the device-tree...
>>>>>           
>>>>> Ben.
>>>>>           
>>>> The platform is the AMCC Sequoia board.  We've built a little adapter to
>>>> connect a compact flash card to the processor bus.  I believe the
>>>> interrupt selection in the device tree is correct, and I've checked over
>>>> the u-boot settings for the IRQ line (active high, level sensitive). 
>>>>         
>>> IDE IRQs are active-low.
>>>       
>>    Only on the PCI and only in the native mode. Natively, the IDE INTRQ  
>> signal is active-high, rising edge triggering, as on ISA. You seem to 
>> have an invertor somewhere, if it's not a PCI chip...
>>     
>
> Ugh. Right you are, as always. I've just looked into mpc8349emitx
> schematics, there is indeed an inverter on the irq line.
>
> CF in True IDE mode is active-high, sorry.
>   

Ok, just to close this issue, my CF device is now working perfectly. 
Two problems, both my fault.  1) I thought the alternate registers used
the same reg-shift and offset, so the alt_command and alt_status were at
the wrong address, and 2) I was missing a pull-down on the IRQ line -
the sequoia eval board has it in the schematic, but it is marked "not
populated".

    Thanks to all for your comments and help,
    Steve


[-- Attachment #2: Type: text/html, Size: 3345 bytes --]

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-12 14:18             ` Sergei Shtylyov
@ 2008-08-12 14:31               ` Anton Vorontsov
  2008-08-13 21:25                 ` Steven A. Falco
  0 siblings, 1 reply; 40+ messages in thread
From: Anton Vorontsov @ 2008-08-12 14:31 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Sparks, Sam, linuxppc-dev, linux-ide, Stefan Roese, Jeff Garzik

On Tue, Aug 12, 2008 at 06:18:42PM +0400, Sergei Shtylyov wrote:
> Anton Vorontsov wrote:
>
>>>>> 1. IDE status read does not work. (But am I understand correctly
>>>>>   that IDE works well if IRQ is unspecified? Then this is hardly
>>>>>   an issue.)
>>>>> 2. IDE interrupt comes when it should not. I'd recommend to use
>>>>>   oscilloscope to find out what is happening there, that is, if
>>>>>   the drive actually deasserts its irq line after status read.
>>>>>   If so, than this could be a PIC problem.
>
>>>>> What is the platform on which you're observing the issue, btw?
>
>>>> Another possibility is that you got the wrong interrupt number
>>>> in the device-tree...
>
>>>> Ben.
>
>>> The platform is the AMCC Sequoia board.  We've built a little adapter to
>>> connect a compact flash card to the processor bus.  I believe the
>>> interrupt selection in the device tree is correct, and I've checked over
>>> the u-boot settings for the IRQ line (active high, level sensitive). 
>
>> IDE IRQs are active-low.
>
>    Only on the PCI and only in the native mode. Natively, the IDE INTRQ  
> signal is active-high, rising edge triggering, as on ISA. You seem to 
> have an invertor somewhere, if it's not a PCI chip...

Ugh. Right you are, as always. I've just looked into mpc8349emitx
schematics, there is indeed an inverter on the irq line.

CF in True IDE mode is active-high, sorry.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-12 14:04           ` Anton Vorontsov
  2008-08-12 14:18             ` Stefan Roese
@ 2008-08-12 14:18             ` Sergei Shtylyov
  2008-08-12 14:31               ` Anton Vorontsov
  1 sibling, 1 reply; 40+ messages in thread
From: Sergei Shtylyov @ 2008-08-12 14:18 UTC (permalink / raw)
  To: avorontsov; +Cc: linux-ide, Jeff Garzik, Sparks, Sam, linuxppc-dev

Anton Vorontsov wrote:

>>>>1. IDE status read does not work. (But am I understand correctly
>>>>   that IDE works well if IRQ is unspecified? Then this is hardly
>>>>   an issue.)
>>>>2. IDE interrupt comes when it should not. I'd recommend to use
>>>>   oscilloscope to find out what is happening there, that is, if
>>>>   the drive actually deasserts its irq line after status read.
>>>>   If so, than this could be a PIC problem.

>>>>What is the platform on which you're observing the issue, btw?

>>>Another possibility is that you got the wrong interrupt number
>>>in the device-tree...

>>>Ben.

>>The platform is the AMCC Sequoia board.  We've built a little adapter to
>>connect a compact flash card to the processor bus.  I believe the
>>interrupt selection in the device tree is correct, and I've checked over
>>the u-boot settings for the IRQ line (active high, level sensitive). 

> IDE IRQs are active-low.

    Only on the PCI and only in the native mode. Natively, the IDE INTRQ 
signal is active-high, rising edge triggering, as on ISA. You seem to have an 
invertor somewhere, if it's not a PCI chip...

WBR, Sergei

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-12 14:04           ` Anton Vorontsov
@ 2008-08-12 14:18             ` Stefan Roese
  2008-08-12 14:18             ` Sergei Shtylyov
  1 sibling, 0 replies; 40+ messages in thread
From: Stefan Roese @ 2008-08-12 14:18 UTC (permalink / raw)
  To: linuxppc-dev, avorontsov; +Cc: linux-ide, Jeff Garzik, Sparks, Sam

On Tuesday 12 August 2008, Anton Vorontsov wrote:
> > > Another possibility is that you got the wrong interrupt number
> > > in the device-tree...
> > >
> > > Ben.
> >
> > The platform is the AMCC Sequoia board.  We've built a little adapter to
> > connect a compact flash card to the processor bus.  I believe the
> > interrupt selection in the device tree is correct, and I've checked over
> > the u-boot settings for the IRQ line (active high, level sensitive).
>
> IDE IRQs are active-low.

IIRC, the CompactFlash interrupt is active-high.

Best regards,
Stefan

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-12 14:00         ` Steven A. Falco
@ 2008-08-12 14:04           ` Anton Vorontsov
  2008-08-12 14:18             ` Stefan Roese
  2008-08-12 14:18             ` Sergei Shtylyov
  0 siblings, 2 replies; 40+ messages in thread
From: Anton Vorontsov @ 2008-08-12 14:04 UTC (permalink / raw)
  To: Steven A. Falco; +Cc: linux-ide, Jeff Garzik, Sparks, Sam, linuxppc-dev

On Tue, Aug 12, 2008 at 10:00:40AM -0400, Steven A. Falco wrote:
> Benjamin Herrenschmidt wrote:
> >   
> >> 1. IDE status read does not work. (But am I understand correctly
> >>    that IDE works well if IRQ is unspecified? Then this is hardly
> >>    an issue.)
> >> 2. IDE interrupt comes when it should not. I'd recommend to use
> >>    oscilloscope to find out what is happening there, that is, if
> >>    the drive actually deasserts its irq line after status read.
> >>    If so, than this could be a PIC problem.
> >>
> >> What is the platform on which you're observing the issue, btw?
> >>     
> >
> > Another possibility is that you got the wrong interrupt number
> > in the device-tree...
> >
> > Ben.
> >   
> 
> The platform is the AMCC Sequoia board.  We've built a little adapter to
> connect a compact flash card to the processor bus.  I believe the
> interrupt selection in the device tree is correct, and I've checked over
> the u-boot settings for the IRQ line (active high, level sensitive). 

IDE IRQs are active-low.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 22:00       ` Benjamin Herrenschmidt
@ 2008-08-12 14:00         ` Steven A. Falco
  2008-08-12 14:04           ` Anton Vorontsov
  0 siblings, 1 reply; 40+ messages in thread
From: Steven A. Falco @ 2008-08-12 14:00 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, Jeff Garzik, Sparks, Sam, linux-ide

[-- Attachment #1: Type: text/plain, Size: 2206 bytes --]

Benjamin Herrenschmidt wrote:
>   
>> 1. IDE status read does not work. (But am I understand correctly
>>    that IDE works well if IRQ is unspecified? Then this is hardly
>>    an issue.)
>> 2. IDE interrupt comes when it should not. I'd recommend to use
>>    oscilloscope to find out what is happening there, that is, if
>>    the drive actually deasserts its irq line after status read.
>>    If so, than this could be a PIC problem.
>>
>> What is the platform on which you're observing the issue, btw?
>>     
>
> Another possibility is that you got the wrong interrupt number
> in the device-tree...
>
> Ben.
>   

The platform is the AMCC Sequoia board.  We've built a little adapter to
connect a compact flash card to the processor bus.  I believe the
interrupt selection in the device tree is correct, and I've checked over
the u-boot settings for the IRQ line (active high, level sensitive). 
I've also tried edge-sensitive but it doesn't make a difference.

When u-boot queries the CF card, we see the IRQ pulse as expected, but
when the kernel runs, we see the IRQ go high and stay there, which the
kernel naturally treats as a stuck interrupt.  The other oddity is that
we see a single diagnostic failure on startup:

    ata1.00: Drive reports diagnostics failure. This may indicate a drive
    ata1.00: fault or invalid emulation. Contact drive vendor for
    information.


That is strange, because if we manually do the soft reset from u-boot,
we see the ATA "feature byte" return 0x01, which means success.  When
the kernel does the soft reset, we see a 0x00, which means failure.  You
would think it is timing related, but a logic analyzer trace shows
reasonable timing.  We need to wire up a better test rig, so I don't
want folks on this list to waste any time on it.  I'll report back if I
learn anything of general interest.

With the interrupt disabled in the device tree, and ignoring the
diagnostics failure, the drive actually works.  I'm able to mount a
filesystem, read files from it, etc.  So, the drive is fully functional,
just without using interrupts.  Therefore, I believe most everything is
correct - byte lanes, read/write signaling, timing, etc.  Curious.

    Steve


[-- Attachment #2: Type: text/html, Size: 2699 bytes --]

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 16:36   ` Ben Dooks
  2008-08-11 16:26     ` Alan Cox
  2008-08-11 16:42     ` Steven A. Falco
@ 2008-08-11 22:02     ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 40+ messages in thread
From: Benjamin Herrenschmidt @ 2008-08-11 22:02 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linuxppc-dev, Jeff Garzik, linux-ide

On Mon, 2008-08-11 at 17:36 +0100, Ben Dooks wrote:
> On Mon, Aug 11, 2008 at 07:19:13PM +0400, Anton Vorontsov wrote:
> > When no irq specified, pata_of_platform fills irq_res with -1,
> > which is wrong to do for two reasons:
> > 
> > 1. By definition, 'no irq' should be IRQ 0, not some negative integer;

> interesting, IRQ 0 is actually valid on some ARM systems.

It never is on powerpc (anymore). Linus several times said he believed
that was the right thing to do, so when I make the whole IRQ handling
using virtual IRQ numbers on ppc, I made 0 reserved (and 1..15 only ever
assigned to a 8259 if there's one).

ARM, with their collections of cascaded fancy PICs all over the place
should probably look into using a similar remapping scheme :-)
 
Ben.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 17:07     ` Anton Vorontsov
@ 2008-08-11 22:00       ` Benjamin Herrenschmidt
  2008-08-12 14:00         ` Steven A. Falco
  0 siblings, 1 reply; 40+ messages in thread
From: Benjamin Herrenschmidt @ 2008-08-11 22:00 UTC (permalink / raw)
  To: avorontsov; +Cc: linuxppc-dev, Jeff Garzik, Sparks, Sam, linux-ide


> 1. IDE status read does not work. (But am I understand correctly
>    that IDE works well if IRQ is unspecified? Then this is hardly
>    an issue.)
> 2. IDE interrupt comes when it should not. I'd recommend to use
>    oscilloscope to find out what is happening there, that is, if
>    the drive actually deasserts its irq line after status read.
>    If so, than this could be a PIC problem.
> 
> What is the platform on which you're observing the issue, btw?

Another possibility is that you got the wrong interrupt number
in the device-tree...

Ben.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 16:23   ` Steven A. Falco
@ 2008-08-11 17:07     ` Anton Vorontsov
  2008-08-11 22:00       ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 40+ messages in thread
From: Anton Vorontsov @ 2008-08-11 17:07 UTC (permalink / raw)
  To: Steven A. Falco; +Cc: linuxppc-dev, Jeff Garzik, Sparks, Sam, linux-ide

On Mon, Aug 11, 2008 at 12:23:10PM -0400, Steven A. Falco wrote:
> Anton Vorontsov wrote:
> > When no irq specified, pata_of_platform fills irq_res with -1,
> > which is wrong to do for two reasons:
> >
> > 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> > 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
> >    is unsigned type, the check will be true for `-1'.
> >
> > Reported-by: Steven A. Falco <sfalco@harris.com>
> > Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> > ---
> 
> Thanks!  Your fix is better - I didn't really like the -1 stuff.
> 
> I found this bug because I had to disable the ATA interrupt on my system
> in order to get a compact-flash card to work.  I am still trying to find
> out why the interrupt doesn't work for me.  Here is part of the console
> log with the interrupt enabled:
> 
>     Uniform Multi-Platform E-IDE driver
>     ide: Assuming 33MHz system bus speed for PIO modes; override with
>     idebus=xx
>     Driver 'sd' needs updating - please use bus_type methods
>     irq: irq_create_mapping(0xc0574900, 0x1b)
>     irq: -> using host @c0574900
>     irq: -> obtained virq 32
>     scsi0 : pata_platform
>     ata1: PATA max PIO4 mmio cmd 0x1c1000000 ctl 0x1c1000080 irq 32
>     irq 32: nobody cared (try booting with the "irqpoll" option)
>     Call Trace:
>     [cf83fcc0] [c0005a64] show_stack+0x44/0x1ac (unreliable)
>     [cf83fd00] [c00489e4] __report_bad_irq+0x34/0xb8
>     [cf83fd20] [c0048cf0] note_interrupt+0x288/0x2d0
>     [cf83fd50] [c0049a94] handle_level_irq+0xac/0x114
>     [cf83fd60] [c0003df0] do_IRQ+0xa4/0xc8
>     [cf83fd70] [c000d60c] ret_from_except+0x0/0x18
>     [cf83fe30] [00000020] 0x20
>     [cf83fe50] [c0003d48] do_softirq+0x54/0x58
>     [cf83fe60] [c00241c0] irq_exit+0x90/0x94
>     [cf83fe70] [c0003df4] do_IRQ+0xa8/0xc8
>     [cf83fe80] [c000d60c] ret_from_except+0x0/0x18
>     [cf83ff40] [c01b2cc0] ata_pio_task+0x48/0x104
>     [cf83ff60] [c00307a0] run_workqueue+0xb8/0x148
>     [cf83ff90] [c0030d54] worker_thread+0x70/0xd0
>     [cf83ffd0] [c0034788] kthread+0x48/0x84
>     [cf83fff0] [c000cd6c] kernel_thread+0x44/0x60
>     handlers:
>     [<c01b2d7c>] (ata_sff_interrupt+0x0/0x234)
>     Disabling IRQ #32
> 
> 
> So it looks like the ATA handler was attached - not sure yet why I got
> the "nobody cared" message. 

Nobody cared means that ata_sff_interrupt handler didn't notice
any IDE events, and returned zero value. This could mean that

1. IDE status read does not work. (But am I understand correctly
   that IDE works well if IRQ is unspecified? Then this is hardly
   an issue.)
2. IDE interrupt comes when it should not. I'd recommend to use
   oscilloscope to find out what is happening there, that is, if
   the drive actually deasserts its irq line after status read.
   If so, than this could be a PIC problem.

What is the platform on which you're observing the issue, btw?

Just asking because recently Sam Sparks reported that he is observing
similar issue on MPC8349E-mITX-based boards, which I can't not
reproduce on my board though:

http://www.nabble.com/Compact-Flash-on-8349mITX-td18754330.html
http://www.nabble.com/Compact-flash-on-mpc8349eITX-td18777724.html

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 16:36   ` Ben Dooks
  2008-08-11 16:26     ` Alan Cox
@ 2008-08-11 16:42     ` Steven A. Falco
  2008-08-11 22:02     ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 40+ messages in thread
From: Steven A. Falco @ 2008-08-11 16:42 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linuxppc-dev, Jeff Garzik, linux-ide

[-- Attachment #1: Type: text/plain, Size: 2710 bytes --]

Ben Dooks wrote:
> On Mon, Aug 11, 2008 at 07:19:13PM +0400, Anton Vorontsov wrote:
>   
>> When no irq specified, pata_of_platform fills irq_res with -1,
>> which is wrong to do for two reasons:
>>
>> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
>>     
>
> interesting, IRQ 0 is actually valid on some ARM systems.
>
>   

It is here too, but I believe most of the code uses a virtualized irq
number, so physical IRQ 0 would presumably get mapped to a non-zero
virtual one.

>> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>>    is unsigned type, the check will be true for `-1'.
>>
>> Reported-by: Steven A. Falco <sfalco@harris.com>
>> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>> ---
>>
>> On Mon, Aug 11, 2008 at 10:48:50AM -0400, Steven A. Falco wrote:
>>     
>>> I think there is a bug in the communications between pata_of_platform
>>> and pata_platform.  I will refer to the master branch of the DENX git
>>> tree, which is roughly v2.6.26.1 at this time.  I am using a Sequoia
>>> board with a PPC440EPx.
>>>
>>> In pata_of_platform, we have:
>>>
>>>     ret = of_irq_to_resource(dn, 0, &irq_res);
>>>     if (ret == NO_IRQ)
>>>         irq_res.start = irq_res.end = -1;
>>>
>>> so if there is no interrupt defined, then start and end are -1. 
>>> However, __pata_platform_probe has:
>>>
>>>     if (irq_res && irq_res->start > 0) {
>>>         irq = irq_res->start;
>>>         irq_flags = irq_res->flags;
>>>     }
>>>
>>> You might think that the (irq_res->start > 0) test will fail, as it
>>> should in this no-irq case.  But, start is a u64, so the -1 actually
>>> looks like a large positive number in the comparison.  So,
>>> __pata_platform_probe attempts to use an interrupt when there isn't one.
>>>
>>> I think the fix would be to change __pata_platform_probe to:
>>>
>>>     if (irq_res && irq_res->start != -1) {
>>>
>>> but that might have other unintended consequences, so I'll defer to
>>> whomever knows more about the intent of this code.
>>>       
>> Something like this patch should work. Thanks for noticing!
>>
>>  drivers/ata/pata_of_platform.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
>> index 408da30..1f18ad9 100644
>> --- a/drivers/ata/pata_of_platform.c
>> +++ b/drivers/ata/pata_of_platform.c
>> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
>>  
>>  	ret = of_irq_to_resource(dn, 0, &irq_res);
>>  	if (ret == NO_IRQ)
>> -		irq_res.start = irq_res.end = -1;
>> +		irq_res.start = irq_res.end = 0;
>>  	else
>>  		irq_res.flags = 0;
>>  
>>     
>
>   


[-- Attachment #2: Type: text/html, Size: 3435 bytes --]

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 15:19 ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
  2008-08-11 16:23   ` Steven A. Falco
  2008-08-11 16:29   ` Alan Cox
@ 2008-08-11 16:36   ` Ben Dooks
  2008-08-11 16:26     ` Alan Cox
                       ` (2 more replies)
  2 siblings, 3 replies; 40+ messages in thread
From: Ben Dooks @ 2008-08-11 16:36 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev, Jeff Garzik, linux-ide


On Mon, Aug 11, 2008 at 07:19:13PM +0400, Anton Vorontsov wrote:
> When no irq specified, pata_of_platform fills irq_res with -1,
> which is wrong to do for two reasons:
> 
> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;

interesting, IRQ 0 is actually valid on some ARM systems.

> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>    is unsigned type, the check will be true for `-1'.
> 
> Reported-by: Steven A. Falco <sfalco@harris.com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
> 
> On Mon, Aug 11, 2008 at 10:48:50AM -0400, Steven A. Falco wrote:
> > I think there is a bug in the communications between pata_of_platform
> > and pata_platform.  I will refer to the master branch of the DENX git
> > tree, which is roughly v2.6.26.1 at this time.  I am using a Sequoia
> > board with a PPC440EPx.
> > 
> > In pata_of_platform, we have:
> > 
> >     ret = of_irq_to_resource(dn, 0, &irq_res);
> >     if (ret == NO_IRQ)
> >         irq_res.start = irq_res.end = -1;
> > 
> > so if there is no interrupt defined, then start and end are -1. 
> > However, __pata_platform_probe has:
> > 
> >     if (irq_res && irq_res->start > 0) {
> >         irq = irq_res->start;
> >         irq_flags = irq_res->flags;
> >     }
> > 
> > You might think that the (irq_res->start > 0) test will fail, as it
> > should in this no-irq case.  But, start is a u64, so the -1 actually
> > looks like a large positive number in the comparison.  So,
> > __pata_platform_probe attempts to use an interrupt when there isn't one.
> > 
> > I think the fix would be to change __pata_platform_probe to:
> > 
> >     if (irq_res && irq_res->start != -1) {
> > 
> > but that might have other unintended consequences, so I'll defer to
> > whomever knows more about the intent of this code.
> 
> Something like this patch should work. Thanks for noticing!
> 
>  drivers/ata/pata_of_platform.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
> index 408da30..1f18ad9 100644
> --- a/drivers/ata/pata_of_platform.c
> +++ b/drivers/ata/pata_of_platform.c
> @@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
>  
>  	ret = of_irq_to_resource(dn, 0, &irq_res);
>  	if (ret == NO_IRQ)
> -		irq_res.start = irq_res.end = -1;
> +		irq_res.start = irq_res.end = 0;
>  	else
>  		irq_res.flags = 0;
>  

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 15:19 ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
  2008-08-11 16:23   ` Steven A. Falco
@ 2008-08-11 16:29   ` Alan Cox
  2008-08-11 16:36   ` Ben Dooks
  2 siblings, 0 replies; 40+ messages in thread
From: Alan Cox @ 2008-08-11 16:29 UTC (permalink / raw)
  To: avorontsov; +Cc: linuxppc-dev, Jeff Garzik, linux-ide

On Mon, 11 Aug 2008 19:19:13 +0400
Anton Vorontsov <avorontsov@ru.mvista.com> wrote:

> When no irq specified, pata_of_platform fills irq_res with -1,
> which is wrong to do for two reasons:
> 
> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>    is unsigned type, the check will be true for `-1'.
> 
> Reported-by: Steven A. Falco <sfalco@harris.com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Alan Cox <alan@redhat.com>

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 16:36   ` Ben Dooks
@ 2008-08-11 16:26     ` Alan Cox
  2008-08-11 16:42     ` Steven A. Falco
  2008-08-11 22:02     ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 40+ messages in thread
From: Alan Cox @ 2008-08-11 16:26 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linuxppc-dev, Jeff Garzik, linux-ide

On Mon, 11 Aug 2008 17:36:48 +0100
Ben Dooks <ben-linux@fluff.org> wrote:

> 
> On Mon, Aug 11, 2008 at 07:19:13PM +0400, Anton Vorontsov wrote:
> > When no irq specified, pata_of_platform fills irq_res with -1,
> > which is wrong to do for two reasons:
> > 
> > 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> 
> interesting, IRQ 0 is actually valid on some ARM systems.

Not as far as Linux is concerned. It's expected that any IRQ that happens
to be "physical IRQ 0" whatever that means is remapped by the arch code
unless not visible outside the arch.

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

* Re: [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 15:19 ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
@ 2008-08-11 16:23   ` Steven A. Falco
  2008-08-11 17:07     ` Anton Vorontsov
  2008-08-11 16:29   ` Alan Cox
  2008-08-11 16:36   ` Ben Dooks
  2 siblings, 1 reply; 40+ messages in thread
From: Steven A. Falco @ 2008-08-11 16:23 UTC (permalink / raw)
  To: avorontsov; +Cc: linuxppc-dev, Jeff Garzik, linux-ide

[-- Attachment #1: Type: text/plain, Size: 2272 bytes --]

Anton Vorontsov wrote:
> When no irq specified, pata_of_platform fills irq_res with -1,
> which is wrong to do for two reasons:
>
> 1. By definition, 'no irq' should be IRQ 0, not some negative integer;
> 2. pata_platform checks for irq_res.start > 0, but since irq_res.start
>    is unsigned type, the check will be true for `-1'.
>
> Reported-by: Steven A. Falco <sfalco@harris.com>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---

Thanks!  Your fix is better - I didn't really like the -1 stuff.

I found this bug because I had to disable the ATA interrupt on my system
in order to get a compact-flash card to work.  I am still trying to find
out why the interrupt doesn't work for me.  Here is part of the console
log with the interrupt enabled:

    Uniform Multi-Platform E-IDE driver
    ide: Assuming 33MHz system bus speed for PIO modes; override with
    idebus=xx
    Driver 'sd' needs updating - please use bus_type methods
    irq: irq_create_mapping(0xc0574900, 0x1b)
    irq: -> using host @c0574900
    irq: -> obtained virq 32
    scsi0 : pata_platform
    ata1: PATA max PIO4 mmio cmd 0x1c1000000 ctl 0x1c1000080 irq 32
    irq 32: nobody cared (try booting with the "irqpoll" option)
    Call Trace:
    [cf83fcc0] [c0005a64] show_stack+0x44/0x1ac (unreliable)
    [cf83fd00] [c00489e4] __report_bad_irq+0x34/0xb8
    [cf83fd20] [c0048cf0] note_interrupt+0x288/0x2d0
    [cf83fd50] [c0049a94] handle_level_irq+0xac/0x114
    [cf83fd60] [c0003df0] do_IRQ+0xa4/0xc8
    [cf83fd70] [c000d60c] ret_from_except+0x0/0x18
    [cf83fe30] [00000020] 0x20
    [cf83fe50] [c0003d48] do_softirq+0x54/0x58
    [cf83fe60] [c00241c0] irq_exit+0x90/0x94
    [cf83fe70] [c0003df4] do_IRQ+0xa8/0xc8
    [cf83fe80] [c000d60c] ret_from_except+0x0/0x18
    [cf83ff40] [c01b2cc0] ata_pio_task+0x48/0x104
    [cf83ff60] [c00307a0] run_workqueue+0xb8/0x148
    [cf83ff90] [c0030d54] worker_thread+0x70/0xd0
    [cf83ffd0] [c0034788] kthread+0x48/0x84
    [cf83fff0] [c000cd6c] kernel_thread+0x44/0x60
    handlers:
    [<c01b2d7c>] (ata_sff_interrupt+0x0/0x234)
    Disabling IRQ #32


So it looks like the ATA handler was attached - not sure yet why I got
the "nobody cared" message.  Also, the system hangs.  If I find
something, I'll post it.

    Steve



[-- Attachment #2: Type: text/html, Size: 3162 bytes --]

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

* [PATCH] pata_of_platform: fix no irq handling
  2008-08-11 14:48 Possible bug in IRQ handling in pata_of_platform / pata_platform Steven A. Falco
@ 2008-08-11 15:19 ` Anton Vorontsov
  2008-08-11 16:23   ` Steven A. Falco
                     ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: Anton Vorontsov @ 2008-08-11 15:19 UTC (permalink / raw)
  To: Jeff Garzik, Steven A. Falco; +Cc: linuxppc-dev, linux-ide

When no irq specified, pata_of_platform fills irq_res with -1,
which is wrong to do for two reasons:

1. By definition, 'no irq' should be IRQ 0, not some negative integer;
2. pata_platform checks for irq_res.start > 0, but since irq_res.start
   is unsigned type, the check will be true for `-1'.

Reported-by: Steven A. Falco <sfalco@harris.com>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

On Mon, Aug 11, 2008 at 10:48:50AM -0400, Steven A. Falco wrote:
> I think there is a bug in the communications between pata_of_platform
> and pata_platform.  I will refer to the master branch of the DENX git
> tree, which is roughly v2.6.26.1 at this time.  I am using a Sequoia
> board with a PPC440EPx.
> 
> In pata_of_platform, we have:
> 
>     ret = of_irq_to_resource(dn, 0, &irq_res);
>     if (ret == NO_IRQ)
>         irq_res.start = irq_res.end = -1;
> 
> so if there is no interrupt defined, then start and end are -1. 
> However, __pata_platform_probe has:
> 
>     if (irq_res && irq_res->start > 0) {
>         irq = irq_res->start;
>         irq_flags = irq_res->flags;
>     }
> 
> You might think that the (irq_res->start > 0) test will fail, as it
> should in this no-irq case.  But, start is a u64, so the -1 actually
> looks like a large positive number in the comparison.  So,
> __pata_platform_probe attempts to use an interrupt when there isn't one.
> 
> I think the fix would be to change __pata_platform_probe to:
> 
>     if (irq_res && irq_res->start != -1) {
> 
> but that might have other unintended consequences, so I'll defer to
> whomever knows more about the intent of this code.

Something like this patch should work. Thanks for noticing!

 drivers/ata/pata_of_platform.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c
index 408da30..1f18ad9 100644
--- a/drivers/ata/pata_of_platform.c
+++ b/drivers/ata/pata_of_platform.c
@@ -52,7 +52,7 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
 
 	ret = of_irq_to_resource(dn, 0, &irq_res);
 	if (ret == NO_IRQ)
-		irq_res.start = irq_res.end = -1;
+		irq_res.start = irq_res.end = 0;
 	else
 		irq_res.flags = 0;
 
-- 
1.5.6.3

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

end of thread, other threads:[~2008-10-13 23:27 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25  8:36 [PATCH] pata_platform struct resource signness fix Wang Jian
2008-09-25  8:54 ` Wang Jian
2008-09-25 10:40   ` Li Yang
2008-09-25 10:48     ` Anton Vorontsov
2008-09-29  4:19       ` Jeff Garzik
2008-09-29 13:32         ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
2008-09-25 15:33     ` [PATCH] pata_platform struct resource signness fix Wang Jian
2008-09-25 15:47       ` Anton Vorontsov
2008-09-25  9:12 ` Leo Li
2008-09-25  9:30   ` Wang Jian
  -- strict thread matches above, loose matches on Subject: below --
2008-10-06 17:26 [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
2008-10-06 20:41 ` Matt Sealey
2008-10-06 21:32   ` Anton Vorontsov
2008-10-07  1:30     ` Tejun Heo
2008-10-07  9:18       ` Wang Jian
2008-10-07  9:26       ` Anton Vorontsov
2008-10-07 10:04         ` Benjamin Herrenschmidt
2008-10-07  9:37       ` Alan Cox
2008-10-08  8:40         ` David Woodhouse
2008-10-08  9:00           ` Alan Cox
2008-10-08  9:59             ` Geert Uytterhoeven
2008-10-08 10:27               ` Alan Cox
2008-10-10 17:55               ` Paul Mundt
2008-10-13  6:56 ` Tejun Heo
2008-10-13 23:27   ` Benjamin Herrenschmidt
2008-08-11 14:48 Possible bug in IRQ handling in pata_of_platform / pata_platform Steven A. Falco
2008-08-11 15:19 ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
2008-08-11 16:23   ` Steven A. Falco
2008-08-11 17:07     ` Anton Vorontsov
2008-08-11 22:00       ` Benjamin Herrenschmidt
2008-08-12 14:00         ` Steven A. Falco
2008-08-12 14:04           ` Anton Vorontsov
2008-08-12 14:18             ` Stefan Roese
2008-08-12 14:18             ` Sergei Shtylyov
2008-08-12 14:31               ` Anton Vorontsov
2008-08-13 21:25                 ` Steven A. Falco
2008-08-11 16:29   ` Alan Cox
2008-08-11 16:36   ` Ben Dooks
2008-08-11 16:26     ` Alan Cox
2008-08-11 16:42     ` Steven A. Falco
2008-08-11 22:02     ` Benjamin Herrenschmidt

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