Skip to contentSkip to conversation

de2104x: interrupts before interrupt handler is registered

DISCUSSION Robert Hancock 5 participants 14 messages Mar 7, 2006 – Mar 9, 2006 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · linux-os (Dick Johnson)

This started to happen in a lot of PCI drivers once it became necessary to call pci_enable_device() in order to make the returned IRQ values valid. This has been reported numerious times and has not been fixed. Basically, in order to get the correct value, one needs to disable the board in some unspecified way so it is not possible for it to generate an interrupt before enabling the board. With some devices this may not be possible!

What kind of board behaves that way? pci_enable_device just enables the device BARs and wakes it up if it was suspended, I should think that any device that starts generating interrupts from that must be quite broken..

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/
#3 lore raw
Quoted 10 lines · Robert Hancock
Quoted 8 lines · linux-os (Dick Johnson)

This started to happen in a lot of PCI drivers once it became necessary to call pci_enable_device() in order to make the returned IRQ values valid. This has been reported numerious times and has not been fixed. Basically, in order to get the correct value, one needs to disable the board in some unspecified way so it is not possible for it to generate an interrupt before enabling the board. With some devices this may not be possible!

Quoted 8 lines

What kind of board behaves that way? pci_enable_device just enables the device BARs and wakes it up if it was suspended, I should think that any device that starts generating interrupts from that must be quite broken..

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected] Home Page: http://www.roberthancock.com/

No. It would be good if that was true. Unfortunately, the IRQ returned before the pci_enable_device() is not correct. It gets re-written by pci_enable_device().

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.50 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#4 lore raw
Quoted 3 lines · linux-os (Dick Johnson)

No. It would be good if that was true. Unfortunately, the IRQ returned before the pci_enable_device() is not correct. It gets re-written by pci_enable_device().

That wasn't what I meant, yes, that is true in the current kernel. However, any device which would start generating interrupts just because
its BARs got enabled by pci_enable_device seems broken.

The driver needs to request the interrupt after the device is enabled, and only after that can it enable the device to generate interrupts.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/
#5 lore raw
Quoted 8 lines · Robert Hancock
Quoted 3 lines · linux-os (Dick Johnson)

No. It would be good if that was true. Unfortunately, the IRQ returned before the pci_enable_device() is not correct. It gets re-written by pci_enable_device().

That wasn't what I meant, yes, that is true in the current kernel. However, any device which would start generating interrupts just because
its BARs got enabled by pci_enable_device seems broken.

Thinking that a device powers ON in a stable state is naive. Many complex devices will have FPGA devices with floating pins that don't become stable until their contents are loaded serially. Others will have IRQ requests based upon power-on states that need to be cleared with a software reset. One can't issue a software reset until the device is enabled and enabling the device may generate interrupts with no handler in place so you have a "can't get there from here" problem. Linux-2.4.x had IRQs that were stable. One could put a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs. Now, you need to make work-arounds that were never before necessary. My request to fix this fell upon deaf ears.

Quoted 9 lines

The driver needs to request the interrupt after the device is enabled, and only after that can it enable the device to generate interrupts.

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected] Home Page: http://www.roberthancock.com/

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.50 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#6 lore raw
Quoted 8 lines · linux-os (Dick Johnson)

Thinking that a device powers ON in a stable state is naive. Many complex devices will have FPGA devices with floating pins that don't become stable until their contents are loaded serially. Others will have IRQ requests based upon power-on states that need to be cleared with a software reset. One can't issue a software reset until the device is enabled and enabling the device may generate interrupts with no handler in place so you have a "can't get there from here" problem.

Maybe you could handle this with a PCI quirk that runs before pci_enable_device(). IIRC, we considered exposing a separate interface for PCI IRQ allocation and routing, but decided it wasn't worth the complexity since so few devices would need it.

Quoted 4 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs.

There are good reasons to wait to allocate the IRQ until you have a driver that cares about the device. I'm sorry that this broke your specific case.

Bjorn

#7 lore raw
Quoted 10 lines · Bjorn Helgaas
Quoted 8 lines · linux-os (Dick Johnson)

Thinking that a device powers ON in a stable state is naive. Many complex devices will have FPGA devices with floating pins that don't become stable until their contents are loaded serially. Others will have IRQ requests based upon power-on states that need to be cleared with a software reset. One can't issue a software reset until the device is enabled and enabling the device may generate interrupts with no handler in place so you have a "can't get there from here" problem.

Quoted 5 lines

Maybe you could handle this with a PCI quirk that runs before pci_enable_device(). IIRC, we considered exposing a separate interface for PCI IRQ allocation and routing, but decided it wasn't worth the complexity since so few devices would need it.

The problem is that I can't write device internal registers to put the device into a stable state without enabling the device. So, the "fix" (read hack) was to mask off all possible interrupts in the ioapic, call pci_enable_device(), initialize the device, clear any pending hardware interrupts on the device, then reenable the ioapic interrupts. I couldn't just use a spin-lock because somebody complains and the machine panics.

Quoted 10 lines
Quoted 4 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs.

There are good reasons to wait to allocate the IRQ until you have a driver that cares about the device. I'm sorry that this broke your specific case.

Bjorn

There are now other "standard" boards that seem to be experiencing the same problem. Maybe it is time to make a procedure that turns off interrupts for a specific device (not an unknown IRQ). Then a subsequent call turns them on after the handler is in place. This wouldn't affect current drivers. They would still turn on hot by default.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.50 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#8 lore raw
Quoted 6 lines · linux-os (Dick Johnson)

There are now other "standard" boards that seem to be experiencing the same problem. Maybe it is time to make a procedure that turns off interrupts for a specific device (not an unknown IRQ). Then a subsequent call turns them on after the handler is in place. This wouldn't affect current drivers. They would still turn on hot by default.

How do you propose to do this? There's no way to mask interrupts from just one device which is sharing an IRQ line, you have to mask interrupts from all of those devices. That would be quite ugly IMHO if one device could disable the interrupt used by another device for however long it felt like.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/
#9 lore raw
In reply to Bjorn Helgaas
Quoted 6 lines · Bjorn Helgaas

On Tuesday 07 March 2006 07:21, linux-os (Dick Johnson) wrote:
Maybe you could handle this with a PCI quirk that runs before pci_enable_device(). IIRC, we considered exposing a separate interface for PCI IRQ allocation and routing, but decided it wasn't worth the complexity since so few devices would need it.

Quoted 8 lines
Quoted 4 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs.

There are good reasons to wait to allocate the IRQ until you have a driver that cares about the device. I'm sorry that this broke your specific case.

FWIW, I'd be interested in following up on something like this in another thread because e100 appears to have (at least in one reporter's dual e100 machine) a similar "hardware problem" where a shared interrupt line gets asserted too early and the kernel prints a Nobody Cared message.

So we have a new way of doing things that exposes more broken hardware, shouldn't we provide a way for that hardware to continue working?

http://bugzilla.kernel.org/show_bug.cgi?id=5918

Jesse

#10 lore raw
Quoted 22 lines · Jesse Brandeburg
Quoted 6 lines · Bjorn Helgaas

On Tuesday 07 March 2006 07:21, linux-os (Dick Johnson) wrote:
Maybe you could handle this with a PCI quirk that runs before pci_enable_device(). IIRC, we considered exposing a separate interface for PCI IRQ allocation and routing, but decided it wasn't worth the complexity since so few devices would need it.

Quoted 8 lines
Quoted 4 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs.

There are good reasons to wait to allocate the IRQ until you have a driver that cares about the device. I'm sorry that this broke your specific case.

FWIW, I'd be interested in following up on something like this in another thread because e100 appears to have (at least in one reporter's dual e100 machine) a similar "hardware problem" where a shared interrupt line gets asserted too early and the kernel prints a Nobody Cared message.

Quoted 3 lines

So we have a new way of doing things that exposes more broken hardware, shouldn't we provide a way for that hardware to continue working?

Booting with "pci=routeirq" gives the previous behavior.

It would be interesting to know whether that makes a difference in the e100 issue you mention.

#11 lore raw
Quoted 4 lines · Bjorn Helgaas

Booting with "pci=routeirq" gives the previous behavior.

It would be interesting to know whether that makes a difference in the e100 issue you mention.

FWIW, I'm pretty sure I tried this with de2104x and it didn't help. I'm not positive though, but I could test again if people are interested in the result.

Signature · 2 lines
Martin Michlmayr
[email protected]
#12 lore raw
In reply to linux-os (Dick Johnson)
Quoted 1 line · linux-os (Dick Johnson)

Thinking that a device powers ON in a stable state is naive.

I don't think so.. if you build a device that connects to the PCI bus it had better come up in a stable state if it wants to be compliant with the spec. That's what the reset line and power-up reset interval is for.

Quoted 8 lines

Many
complex devices will have FPGA devices with floating pins that don't become stable until their contents are loaded serially. Others will have IRQ requests based upon power-on states that need to be cleared with a software reset. One can't issue a software reset until the device is enabled and enabling the device may generate interrupts with no handler in place so you have a "can't get there from here" problem.

You still aren't seeing my point. Why does enabling the device BARs cause the device to generate interrupts? And if there's something you need to do to prevent the device from generating interrupts, how can you do it without enabling the device?

Also, the device's ISR must clear the condition which is causing the interrupt, otherwise interrupt storms will result. If your device can enter a state where the interrupt cannot be reliably cleared, how can you possibly comply with this?

Quoted 6 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs. Now, you need to make work-arounds that were never before necessary. My request to fix this fell upon deaf ears.

I don't think any workarounds are needed except for devices that don't comply with the spec. Asserting interrupts that have not been specifically enabled by the driver would meet that definition in my view. If a device happens to do this then maybe a workaround would be needed, but that's what it would be, a workaround for a broken device.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/
#13 lore raw
Quoted 21 lines · Robert Hancock
Quoted 1 line · linux-os (Dick Johnson)

Thinking that a device powers ON in a stable state is naive.

I don't think so.. if you build a device that connects to the PCI bus it had better come up in a stable state if it wants to be compliant with the spec. That's what the reset line and power-up reset interval is for.

Quoted 8 lines

Many
complex devices will have FPGA devices with floating pins that don't become stable until their contents are loaded serially. Others will have IRQ requests based upon power-on states that need to be cleared with a software reset. One can't issue a software reset until the device is enabled and enabling the device may generate interrupts with no handler in place so you have a "can't get there from here" problem.

You still aren't seeing my point. Why does enabling the device BARs cause the device to generate interrupts? And if there's something you need to do to prevent the device from generating interrupts, how can you do it without enabling the device?

Quoted 4 lines

Also, the device's ISR must clear the condition which is causing the interrupt, otherwise interrupt storms will result. If your device can enter a state where the interrupt cannot be reliably cleared, how can you possibly comply with this?

You don't bother to read. The reported interrupt is WRONG, INVALID, INCORRECT, BROKEN, until __after__ the device is enabled. That means that one CANNOT put an interrupt handler in place before the device is enabled.

It's the Linux code that was broken when 2.6.x started. Previous Linux code never failed to report the correct IRQ.

Quoted 19 lines
Quoted 7 lines

Linux-2.4.x had IRQs that were stable. One could put
a handler in place that would handle the possible burst of interrupts upon startup. Then this was changed so the IRQ value is wrong until an unrelated and illogical event occurs. Now, you need to make work-arounds that were never before necessary. My request to fix this fell upon deaf ears.

I don't think any workarounds are needed except for devices that don't comply with the spec. Asserting interrupts that have not been specifically enabled by the driver would meet that definition in my view. If a device happens to do this then maybe a workaround would be needed, but that's what it would be, a workaround for a broken device.

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected] Home Page: http://www.roberthancock.com/

Quoted 6 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.50 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#14 lore raw
Quoted 4 lines · linux-os (Dick Johnson)

You don't bother to read. The reported interrupt is WRONG, INVALID, INCORRECT, BROKEN, until __after__ the device is enabled. That means that one CANNOT put an interrupt handler in place before the device is enabled.

And my point is, even if you COULD put an interrupt handler into place before enabling the device, if the device can be in an unstable state such that the interrupt can't be acknowledged reliably, how can you handle it without causing an interrupt storm?

Signature · 2 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
#15 lore raw
Quoted 11 lines · Robert Hancock
Quoted 4 lines · linux-os (Dick Johnson)

You don't bother to read. The reported interrupt is WRONG, INVALID, INCORRECT, BROKEN, until __after__ the device is enabled. That means that one CANNOT put an interrupt handler in place before the device is enabled.

And my point is, even if you COULD put an interrupt handler into place before enabling the device, if the device can be in an unstable state such that the interrupt can't be acknowledged reliably, how can you handle it without causing an interrupt storm?

Easy. Mask off the interrupts in the device. Software should certainly "know" if the device has been initialized to a stable state. Until it has been initialized, the ISR will simply clear and mask the device.

Quoted 4 lines

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.50 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.