BUG in 2.6.26-rc8 interrupt handling

From: Becker Stefan (Nokia-D/Salo)
Date: Sat Jun 28 2008 - 15:43:05 EST


Hi,

[I'm not subscribed to this list, so please CC: me]

[Subject has been changed, please read the rest of the thread for all the details]

On my AthlonXP single CPU laptop I experience random lockups when I access the external USB harddrive with kernels >2.6.23. The problem doesn't appear with 2.6.23.

Debugging revealed that a routine was called twice that takes a spinlock. But this actually shouldn't happen, because the function should only be invoked with interrupts disabled. A little more debugging revealed that apparently sometimes interrupts are enabled when the USB HCD interrupt handlers are called, although they are registered with IRQF_DISABLED.

With the attached patch ontop of 2.6.26-rc8 I get these messages:

kernel: USB_HCD_IRQ interrupts disabled 14206 enabled 6289
kernel: USB_HCD_IRQ interrupts disabled 14761 enabled 6290
kernel: USB_HCD_IRQ interrupts disabled 14761 enabled 6291

I also attached the contents from /proc/interrupts from the machine.

Any ideas what could be wrong or any suggestions in which direction I should continue debugging?

Regards,

Stefan

---
Stefan Becker Nokia-TP/Salo Senior Specialist, EE SW
E-Mail: Stefan.Becker@xxxxxxxxx SMS: 4871554@???.??
Office: +358-7180-71554 FAX: +358-7180-44751
GSM : +358-50-4871554
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 09a53e7..5814c5a 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1686,6 +1686,18 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
struct usb_hcd *hcd = __hcd;
int start = hcd->state;

+#ifdef DEBUG
+ static unsigned int _enabled = 0;
+ static unsigned int _disabled = 0;
+ if (raw_irqs_disabled()) {
+ _disabled++;
+ } else {
+ _enabled++;
+ printk(KERN_CRIT "USB_HCD_IRQ interrupts disabled %d enabled %d\n",
+ _disabled, _enabled);
+ }
+#endif
+
if (unlikely(start == HC_STATE_HALT ||
!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
return IRQ_NONE;
CPU0
0: 31904 XT-PIC-XT timer
1: 112 XT-PIC-XT i8042
2: 0 XT-PIC-XT cascade
5: 1 XT-PIC-XT firewire_ohci, VIA8233, VIA82XX-MODEM
6: 1 XT-PIC-XT
7: 0 XT-PIC-XT parport0
9: 52 XT-PIC-XT acpi
10: 21 XT-PIC-XT uhci_hcd:usb2
11: 36 XT-PIC-XT yenta, ehci_hcd:usb1, uhci_hcd:usb3
12: 120 XT-PIC-XT i8042
14: 1959 XT-PIC-XT pata_via
15: 39 XT-PIC-XT pata_via
NMI: 0 Non-maskable interrupts
LOC: 0 Local timer interrupts
RES: 0 Rescheduling interrupts
CAL: 0 function call interrupts
TLB: 0 TLB shootdowns
TRM: 0 Thermal event interrupts
SPU: 0 Spurious interrupts
ERR: 0
MIS: 0