Skip to contentSkip to conversation

netdev: enc28j60: use IRQF_TRIGGER_FALLING for IRQ by default

PATCH In review Mike Frysinger 5 participants 11 messages May 26, 2009 – May 27, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netdev: enc28j60: use IRQF_TRIGGER_FALLING for IRQ by default

From: Michael Hennerich <[email protected]>

Rather than have the default IRQ flags not be usable, use the logical settings which match the hardware. Since the part is /INT, it makes sense to have it default to a falling trigger. If a board truly needs something different, it still can tweak the defaults in its own board file.

---
 drivers/net/enc28j60.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/enc28j60.c +1 -1
index 36cb6e9..fbe2012 100644
@@ -1562,7 +1562,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
 	/* Board setup must set the relevant edge trigger type;
 	 * level triggers won't currently work.
 	 */
-	ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv);
+	ret = request_irq(spi->irq, enc28j60_irq, IRQF_TRIGGER_FALLING, DRV_NAME, priv);
 	if (ret < 0) {
 		if (netif_msg_probe(priv))
 			dev_err(&spi->dev, DRV_NAME ": request irq %d failed "
Signature · 1 line
1.6.3.1
#1 lore raw

Hi Michael,

Quoted 6 lines · Mike Frysinger

From: Michael Hennerich <[email protected]>

Rather than have the default IRQ flags not be usable, use the logical settings which match the hardware. Since the part is /INT, it makes sense to have it default to a falling trigger. If a board truly needs something different, it still can tweak the defaults in its own board file.

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Quoted 14 lines
---
 drivers/net/enc28j60.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/enc28j60.c +0 -0
index 36cb6e9..fbe2012 100644

drivers/net/enc28j60.c static int __devinit enc28j60_probe(struct spi_device *spi) · line 1568

Quoted 8 lines
drivers/net/enc28j60.c +1 -1
@@ -1562,7 +1562,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
 	/* Board setup must set the relevant edge trigger type;
 	 * level triggers won't currently work.
 	 */
-	ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv);
+	ret = request_irq(spi->irq, enc28j60_irq, IRQF_TRIGGER_FALLING, DRV_NAME, priv);
 	if (ret < 0) {
 		if (netif_msg_probe(priv))
 			dev_err(&spi->dev, DRV_NAME ": request irq %d failed "

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
#2 lore raw
Quoted 5 lines · Baruch Siach

Hi Michael,

Quoted 2 lines · Mike Frysinger

From: Michael Hennerich <[email protected]>

Quoted 7 lines
Quoted 4 lines

Rather than have the default IRQ flags not be usable, use the logical settings which match the hardware. Since the part is /INT, it makes sense to have it default to a falling trigger. If a board truly needs something different, it still can tweak the defaults in its own board file.

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

So I'd NAK this, on the grounds that it causes severe breakage.

Quoted 30 lines
Quoted 13 lines
---
 drivers/net/enc28j60.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/enc28j60.c +0 -0
index 36cb6e9..fbe2012 100644

drivers/net/enc28j60.c static int __devinit enc28j60_probe(struct spi_device *spi) · line 1568

Quoted 8 lines
drivers/net/enc28j60.c +1 -1
@@ -1562,7 +1562,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
 	/* Board setup must set the relevant edge trigger type;
 	 * level triggers won't currently work.
 	 */
-	ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv);
+	ret = request_irq(spi->irq, enc28j60_irq, IRQF_TRIGGER_FALLING, DRV_NAME, priv);
 	if (ret < 0) {
 		if (netif_msg_probe(priv))
 			dev_err(&spi->dev, DRV_NAME ": request irq %d failed "

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
#3 lore raw
Quoted 11 lines

From: David Brownell [mailto:[email protected]]
Sent: Tuesday, May 26, 2009 1:24 PM

Quoted 6 lines · Baruch Siach

Hi Michael,

Quoted 3 lines · Mike Frysinger

From: Michael Hennerich <[email protected]>

Rather than have the default IRQ flags not be usable, use the

logical

Quoted 1 line
Quoted 1 line
Quoted 1 line

settings which match the hardware. Since the part is /INT, it

makes sense

Quoted 1 line
Quoted 1 line
Quoted 1 line

to have it default to a falling trigger. If a board truly needs

something

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

different, it still can tweak the defaults in its own board file.

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Quoted 8 lines

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

So I'd NAK this, on the grounds that it causes severe breakage.

David,

The comment block above request_irq states:

Quoted 1 line
Quoted 1 line
Quoted 1 line

* level triggers won't currently work.

And I guess it's because IRQ handling is deferred to a work queue. I wonder how IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING will work in such a case.
Since the ENC28J60 /INT will de-assert during the work handler executes, thus causing a second spurious interrupt.

-Michael

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
---
 drivers/net/enc28j60.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 5 lines
Quoted 5 lines

drivers/net/enc28j60.c static int __devinit enc28j60_probe(struct

Quoted 5 lines
drivers/net/enc28j60.c +0 -0
index 36cb6e9..fbe2012 100644
@@ -1562,7 +1562,7 @@ static int __devinit enc28j60_probe(struct

spi_device *spi)

Quoted 5 lines
Quoted 5 lines

drivers/net/enc28j60.c static int __devinit enc28j60_probe(struct spi_device *spi)

Quoted 5 lines
drivers/net/enc28j60.c +1 -1
 	/* Board setup must set the relevant edge trigger type;
 	 * level triggers won't currently work.
 	 */
-	ret = request_irq(spi->irq, enc28j60_irq, 0, DRV_NAME, priv);
+	ret = request_irq(spi->irq, enc28j60_irq, IRQF_TRIGGER_FALLING,

DRV_NAME, priv);

Quoted 3 lines
Quoted 3 lines

drivers/net/enc28j60.c static int __devinit enc28j60_probe(struct spi_device *spi)

Quoted 3 lines
drivers/net/enc28j60.c +0 -0
 	if (ret < 0) {
 		if (netif_msg_probe(priv))
 			dev_err(&spi->dev, DRV_NAME ": request irq %d

failed "

Quoted 5 lines
Quoted 5 lines

baruch

--

                                                     ~. .~   Tk Open

Systems

Quoted 1 line
Quoted 1 line

=}------------------------------------------------ooO--U--Ooo----------- -{=

Quoted 1 line
Quoted 1 line

- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il

-

Quoted 4 lines
Quoted 2 lines
#4 lore raw
Quoted 5 lines · Michael

The comment block above request_irq states:

Quoted 1 line
Quoted 1 line
Quoted 1 line

    * level triggers won't currently work.

And I guess it's because IRQ handling is deferred to a work queue.

The IRQ needs to no longer be pending when the (hard) handler returns. For level triggers, that means disabling the IRQ ... then re-enabling it only when the (soft/threaded) handler returns.

Quoted 2 lines

I wonder how IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING will work in such a case.

It works just fine, since when the (hard) handler returns there is no longer "IRQ pending" status in the IRQ controller.

Quoted 2 lines

Since the ENC28J60 /INT will de-assert during the work handler executes, thus causing a second spurious interrupt.

No problem. The Ethernet adapter has no pending (unless another IRQ triggered meanwhile); its workqueue/threaded handler returns immediately.

#5 lore raw
In reply to David Brownell
Quoted 10 lines · On Tuesday 26 May 2009 07:24:17 David Brownell wrote:
Quoted 9 lines · Baruch Siach
Quoted 7 lines · Mike Frysinger

From: Michael Hennerich <[email protected]>

Rather than have the default IRQ flags not be usable, use the logical settings which match the hardware. Since the part is /INT, it makes sense to have it default to a falling trigger. If a board truly needs something different, it still can tweak the defaults in its own board file.

Quoted 8 lines
Quoted 2 lines

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

how can it provide breakage when people are forced to use set_irq_type() ?

Quoted 2 lines

So I'd NAK this, on the grounds that it causes severe breakage.

i see no consumers of this driver at all in mainline, so i dont think it causes any in tree breakage at all
-mike

#6 lore raw
Quoted 10 lines · Mike Frysinger
Quoted 8 lines
Quoted 2 lines

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

how can it provide breakage when people are forced to use set_irq_type() ?

It reverses the IRQ setup done by the board code ... the code which you said they'd have to use to work around the breakage your patch adds.

If you're really craving some change to the driver, you should make it take the relevant trigger type from the platform resource ... instead of hard-wiring it to a value which is *known* to break systems.

#7 lore raw
Quoted 7 lines · On Tuesday 26 May 2009 14:21:53 David Brownell wrote:
Quoted 6 lines · Mike Frysinger
Quoted 6 lines
Quoted 2 lines

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Moreover, it completely prevents working on systems which only support "both edges" triggering.

how can it provide breakage when people are forced to use set_irq_type() ?

It reverses the IRQ setup done by the board code ...

how so ? this code does the irq requesting which means the set_irq_type() needs to come after it anyways since the request_irq() will set any flags passed to it, right ?

Quoted 2 lines

the code which you said they'd have to use to work around the breakage your patch adds.

umm, i'm referring to code the driver and you says should be put in place -- a call to set_irq_type() somewhere in the board init code.

Quoted 4 lines

If you're really craving some change to the driver, you should make it take the relevant trigger type from the platform resource ... instead of hard-wiring it to a value which is *known* to break systems.

without any in-tree consumers, it's hard to see how things are supposed to be working and how they could possibly break
-mike

#8 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

how can it provide breakage when people are forced to use set_irq_type() ?

It reverses the IRQ setup done by the board code ...

how so ? this code does the irq requesting which means the set_irq_type() needs to come after it

No; set_irq_type() can happen at any time. It just does setup. One policy sets IRQ types beforehand.

Equivalently, the driver may run on hardware which only supports one policy ... *NOT* the policy you propose the driver be changed to require.

Quoted 2 lines

anyways since the request_irq() will set any flags passed to it, right ?

Wrong. A set_irq_type() call ensures the IRQ will trigger as specified by its parameters (unless it fails). The current request_irq() leaves that "default" setup alone.

Your patch changes that configuration, making it request a trigger mode that (a) the hardware may not support, so the request_irq() will fail; else if it succeeds, then
(b) will clobber whatever mode that was already set up. The first certainly breaks things; the second probably does so.

Quoted 5 lines
Quoted 2 lines

the code which you said they'd have to use to work around the breakage your patch adds.

umm, i'm referring to code the driver and you says should be put in place -- a call to set_irq_type() somewhere in the board init code.

Which is well before the driver request_irq(). As noted above, you're trying to make the driver request a specific IRQ type, which is *NOT* one that can necessarily be supported.

On the other hand, the current IRQ_NONE (type == 0) is by definition be supported *everywhere* ...

maintainer
#9 lore raw

From: David Brownell <[email protected]>
Date: Tue, 26 May 2009 18:17:06 -0700

Quoted 10 lines

Wrong. A set_irq_type() call ensures the IRQ will trigger as specified by its parameters (unless it fails). The current request_irq() leaves that "default" setup alone.

Your patch changes that configuration, making it request a trigger mode that (a) the hardware may not support, so the request_irq() will fail; else if it succeeds, then
(b) will clobber whatever mode that was already set up. The first certainly breaks things; the second probably does so.

I totally agree with David, this patch seems to be wrong on just about every possible level.

#10 lore raw
In reply to Mike Frysinger
Quoted 7 lines

From: Mike Frysinger [mailto:[email protected]]

Quoted 5 lines · On Tuesday 26 May 2009 07:24:17 David Brownell wrote:
Quoted 4 lines · Baruch Siach
Quoted 3 lines · Mike Frysinger

From: Michael Hennerich <[email protected]>

Rather than have the default IRQ flags not be usable, use the

logical

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

settings which match the hardware. Since the part is /INT, it

makes

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

sense to have it default to a falling trigger. If a board truly

needs

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

something different, it still can tweak the defaults in its own

board

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

file.

You revert David Brownell's commit here (c7b7b042068cd12b8b155722d24686f70b88ced1). Added to CC.

Quoted 7 lines
Quoted 5 lines

Right ... the appended patch will *undo* the setting established in the board init code via set_irq_type().

Moreover, it completely prevents working on systems which only support "both edges" triggering.

how can it provide breakage when people are forced to use

set_irq_type() ?

set_irq_type() is typically called before request_irq(). In case be give the IRQF_TRIGGER flag with request_irq() it will overwrite the settings done by set_irq_type().

-Michael

Quoted 5 lines
Quoted 3 lines

So I'd NAK this, on the grounds that it causes severe breakage.

i see no consumers of this driver at all in mainline, so i dont think

it

Quoted 2 lines

causes any in tree breakage at all
-mike