linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [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; 31+ 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] 31+ messages in thread
* [PATCH] pata_platform struct resource signness fix
@ 2008-09-25  8:36 Wang Jian
  2008-09-25  8:54 ` Wang Jian
  0 siblings, 1 reply; 31+ 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] 31+ messages in thread
* Possible bug in IRQ handling in pata_of_platform  / pata_platform
@ 2008-08-11 14:48 Steven A. Falco
  2008-08-11 15:19 ` [PATCH] pata_of_platform: fix no irq handling Anton Vorontsov
  0 siblings, 1 reply; 31+ messages in thread
From: Steven A. Falco @ 2008-08-11 14:48 UTC (permalink / raw)
  To: linuxppc-dev

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.

    Steve

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

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

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- strict thread matches above, loose matches on Subject: below --
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-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).