Skip to contentSkip to conversation

Patch to fix cdrom being confused on using kdump

RFC In review Rachita Kothiyal 3 participants 8 messages Apr 7, 2006 – Apr 19, 2006

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Patch to fix cdrom being confused on using kdump

Hi Jens

As we had discussed earlier, I had seen the cdrom drive appearing confused on using kdump on certain x86_64 systems. During the booting up of the second kernel, the following message would keep flooding the console, and the booting would not proceed any further.

hda: cdrom_pc_intr: The drive appears confused (ireason = 0x01)

In this patch, whenever we are hitting a confused state in the interrupt handler with the DRQ set, we clear the DSC bit of the status register and return 'ide_stopped' from the interrupt handler.

Please provide your comments and feedback.

Thanks
Rachita

---

 drivers/ide/ide-cd.c |    5 +++++
 1 files changed, 5 insertions(+)
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +5 -0
diff -puN drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt drivers/ide/ide-cd.c
@@ -1450,6 +1450,11 @@ static ide_startstop_t cdrom_pc_intr (id
 			rq->sense_len += thislen;
 	} else {
 confused:
+		if (( stat & DRQ_STAT) == DRQ_STAT) {
+			/* DRQ is set. Interrupt not welcome now. Ignore */
+			HWIF(drive)->OUTB((stat & 0xEF), IDE_STATUS_REG);
+			return ide_stopped;
+		}
 		printk (KERN_ERR "%s: cdrom_pc_intr: The drive "
 			"appears confused (ireason = 0x%02x)\n",
 			drive->name, ireason);

_

#1 lore raw

drivers/ide/ide-cd.c static ide_startstop_t cdrom_pc_intr (id · line 1455

Quoted 4 lines · Rachita Kothiyal

confused:

drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +3 -0
+               if (( stat & DRQ_STAT) == DRQ_STAT) {
+                       /* DRQ is set. Interrupt not welcome now. Ignore */
+                       HWIF(drive)->OUTB((stat & 0xEF), IDE_STATUS_REG); 

Minor nit: kill the space before stat:

	if ((stat & DRQ_STAT) == DRQ_STAT) {

-- Dave

#2 lore raw
In reply to Rachita Kothiyal
Quoted 29 lines · Rachita Kothiyal

Hi Jens

As we had discussed earlier, I had seen the cdrom drive appearing confused on using kdump on certain x86_64 systems. During the booting up of the second kernel, the following message would keep flooding the console, and the booting would not proceed any further.

hda: cdrom_pc_intr: The drive appears confused (ireason = 0x01)

In this patch, whenever we are hitting a confused state in the interrupt handler with the DRQ set, we clear the DSC bit of the status register and return 'ide_stopped' from the interrupt handler.

Please provide your comments and feedback.

Thanks
Rachita

---

 drivers/ide/ide-cd.c |    5 +++++
 1 files changed, 5 insertions(+)

diff -puN drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt drivers/ide/ide-cd.c

drivers/ide/ide-cd.c static ide_startstop_t cdrom_pc_intr (id · line 1453

Quoted 4 lines
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +1 -0
@@ -1450,6 +1450,11 @@ static ide_startstop_t cdrom_pc_intr (id
 			rq->sense_len += thislen;
 	} else {
 confused:
+		if (( stat & DRQ_STAT) == DRQ_STAT) {

if (stat & DRQ_STAT)

checking for DRQ_STAT again doesn't make sense, how can it ever be anything but DRQ_STAT if DRQ_STAT is set?

drivers/ide/ide-cd.c static ide_startstop_t cdrom_pc_intr (id · line 1456

Quoted 3 lines
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +3 -0
+			/* DRQ is set. Interrupt not welcome now. Ignore */
+			HWIF(drive)->OUTB((stat & 0xEF), IDE_STATUS_REG);
+			return ide_stopped;

And this looks very wrong, you can't write to the status register. Well you can, but then it's the command register! Writing stat & 0xef to the command register is an odd thing to do. I think you just want to clear the DRQ bit, which should be fine after it was read initially. How about

if (stat & DRQ_STAT)
return ide_stopped;

Can you test that?

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 6 lines · Jens Axboe

On Fri, Apr 07 2006, Rachita Kothiyal wrote:

if (stat & DRQ_STAT)

checking for DRQ_STAT again doesn't make sense, how can it ever be anything but DRQ_STAT if DRQ_STAT is set?

Hi Jens,

Yes, you are right. The condition itself is redundant there as DRQ will always be set there. I will remove it.

Quoted 11 lines

drivers/ide/ide-cd.c static ide_startstop_t cdrom_pc_intr (id · line 1456

Quoted 4 lines
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +3 -0
+			/* DRQ is set. Interrupt not welcome now. Ignore */
+			HWIF(drive)->OUTB((stat & 0xEF), IDE_STATUS_REG);
+			return ide_stopped;

And this looks very wrong, you can't write to the status register. Well you can, but then it's the command register! Writing stat & 0xef to the command register is an odd thing to do. I think you just want to clear the DRQ bit, which should be fine after it was read initially. How about

Quoted 4 lines

if (stat & DRQ_STAT)
return ide_stopped;

Can you test that?

I tested this, but I see it fail a couple of times...sometimes it hung while booting up the second kernel and sometimes the kernel paniced while shutting it down.(attached partial log for panic)

I see your point that writing to the status register is not a good idea. I think what we want to do is just ignore this particular interrupt and let it continue.
Am not sure if clearing DRQ bit will achieve this. Please correct me if I am wrong, but to clear the DRQ bit also we will have to write to the status register.

Thanks
Rachita

Shutting down powersaved                                              done
Saving random seed                                                    done
Umount SMB/ CIFS File Systems                                         done
Shutting down ldap-server                                             done
Shutting down SSH daemon                                              done
Remove Net File System (NFS)                                          unused
Shutting down RPC portmap daemon                                      done
Shutting down syslog services                                         done

Shutting down network interfaces:
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
cdrom: entering cdrom_release
cdrom: Use count for "/dev/hda" now zero
cdrom: hda: No DVD+RW
cdrom: Unlocking door!
ide0: start_request: current=0xffff810003bfbca8
cdrom: entering cdrom_open
cdrom: Use count for "/dev/hda" now 1
ide0: start_request: current=0xffff810003bfbaa8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba18
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfba08
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfb9f8
ide0: start_request: current=0xffff810004c222d8
cdrom: entering CDROM_DRIVE_STATUS
ide0: start_request: current=0xffff810003bfbbb8
ide0: start_request: current=0xffff810004c222d8
ide0: start_request: current=0xffff810003bfbb58
Rachita: DRQ set.Interrupt ignored

BUG: spinlock recursion on CPU#0, hald-addon-stor/2018
 lock: ffffffff812c1128, .magic: dead4ead, .owner: hald-addon-stor/2018, .owner_cpu: 0

Call Trace: <IRQ> <ffffffff810cf6e9>{_raw_spin_lock+61}
       <ffffffff81042b08>{__do_IRQ+55} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <ffffffff880052cf>{:ide_core:ide_do_request+820}
       <ffffffff880052ca>{:ide_core:ide_do_request+815} <ffffffff8118e7d1>{_spin_lock_irqsave+9}
       <ffffffff88161c58>{:ide_cd:cdrom_decode_status+42} <ffffffff881626ca>{:ide_cd:cdrom_pc_intr+510}
       <ffffffff88005abd>{:ide_core:ide_intr+442} <ffffffff810431a8>{note_interrupt+219}
       <ffffffff81042b7e>{__do_IRQ+173} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <EOI> <ffffffff8102743a>{vprintk+652}
       <ffffffff88006233>{:ide_core:ide_outsw+0} <ffffffff88006238>{:ide_core:ide_outsw+5}
       <ffffffff88006681>{:ide_core:atapi_output_bytes+38}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88162b5b>{:ide_cd:cdrom_transfer_packet_command+182}
       <ffffffff88162bda>{:ide_cd:cdrom_do_pc_continuation+0}
       <ffffffff8815f91a>{:ide_cd:cdrom_start_packet_command+359}
       <ffffffff880055d2>{:ide_core:ide_do_request+1591} <ffffffff8118d1e4>{thread_return+0}
       <ffffffff8118d23a>{thread_return+86} <ffffffff8800574d>{:ide_core:ide_do_request+1970}
       <ffffffff810bd928>{elv_insert+120} <ffffffff880058a5>{:ide_core:ide_do_drive_cmd+245}
       <ffffffff881603a7>{:ide_cd:cdrom_queue_packet_command+70}
       <ffffffff810bf79a>{blk_end_sync_rq+0} <ffffffff880045f8>{:ide_core:ide_init_drive_cmd+16}
       <ffffffff881604de>{:ide_cd:ide_cdrom_packet+155} <ffffffff810bf79a>{blk_end_sync_rq+0}
       <ffffffff8814b7ea>{:cdrom:cdrom_get_media_event+77}
       <ffffffff88160b22>{:ide_cd:ide_cdrom_drive_status+65}
       <ffffffff8814b266>{:cdrom:cdrom_ioctl+1640} <ffffffff810ca406>{kobject_get+18}
       <ffffffff810c2747>{get_disk+47} <ffffffff810c21a3>{blkdev_ioctl+1558}
       <ffffffff81068f83>{do_open+221} <ffffffff81068e9e>{bdget+284}
       <ffffffff81068896>{bd_claim+131} <ffffffff810693ea>{blkdev_open+0}
       <ffffffff81069422>{blkdev_open+56} <ffffffff810608af>{__dentry_open+238}
       <ffffffff81068967>{block_ioctl+27} <ffffffff81072713>{do_ioctl+27}
       <ffffffff81072957>{vfs_ioctl+527} <ffffffff810729a5>{sys_ioctl+60}
       <ffffffff8100a47e>{system_call+126}
NMI Watchdog detected LOCKUP on CPU 0
CPU 0
Modules linked in: edd ipv6 loop dm_mod usbhid tg3 generic ide_cd shpchp cdrom pci_hotplug uhci_hcd ehci_hcd e752x_edac floppy usbcore edac_mc ext3 jbd processor sg aic79xx scsi_transport_spi piix sd_mod scsi_mod ide_disk ide_core
Pid: 2018, comm: hald-addon-stor Tainted: G     U 2.6.16-rc2-git5-rachita-3-kdump
#6
RIP: 0010:[<ffffffff810ce62b>] <ffffffff810ce62b>{__delay+2}
RSP: 0018:ffffffff8124b8a8  EFLAGS: 00000006
RAX: 00000000b395caba RBX: ffffffff812c1128 RCX: 00000000b395c9c7
RDX: 0000000000000205 RSI: ffffffff811b4fad RDI: 0000000000000001
RBP: 000000001bb47288 R08: 0000000000000007 R09: ffffffff8124b4f0
R10: ffffffff88164154 R11: 0000000000000000 R12: 0000000000000001
R13: ffffffff812c1128 R14: ffff810004af4488 R15: ffffffff8124b908
FS:  00002b44cadc36d0(0000) GS:ffffffff812c1000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00002b752a9f8280 CR3: 0000000002d42000 CR4: 00000000000006e0
Process hald-addon-stor (pid: 2018, threadinfo ffff810003bfa000, task ffff81000446e040)
Stack: ffffffff810cf72d 0000000000000000 ffffffff812c1100 0000000000000000
       ffffffff81042b08 ffff810004b71c10 ffffffff8124b908 0000000000000000
       ffff810004af4488 ffffffff8801d220
Call Trace: <IRQ> <ffffffff810cf72d>{_raw_spin_lock+129}
       <ffffffff81042b08>{__do_IRQ+55} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <ffffffff880052cf>{:ide_core:ide_do_request+820}
       <ffffffff880052ca>{:ide_core:ide_do_request+815} <ffffffff8118e7d1>{_spin_lock_irqsave+9}
       <ffffffff88161c58>{:ide_cd:cdrom_decode_status+42} <ffffffff881626ca>{:ide_cd:cdrom_pc_intr+510}
       <ffffffff88005abd>{:ide_core:ide_intr+442} <ffffffff810431a8>{note_interrupt+219}
       <ffffffff81042b7e>{__do_IRQ+173} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <EOI> <ffffffff8102743a>{vprintk+652}
       <ffffffff88006233>{:ide_core:ide_outsw+0} <ffffffff88006238>{:ide_core:ide_outsw+5}
       <ffffffff88006681>{:ide_core:atapi_output_bytes+38}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88162b5b>{:ide_cd:cdrom_transfer_packet_command+182}
       <ffffffff88162bda>{:ide_cd:cdrom_do_pc_continuation+0}
       <ffffffff8815f91a>{:ide_cd:cdrom_start_packet_command+359}
       <ffffffff880055d2>{:ide_core:ide_do_request+1591} <ffffffff8118d1e4>{thread_return+0}
       <ffffffff8118d23a>{thread_return+86} <ffffffff8800574d>{:ide_core:ide_do_request+1970}
       <ffffffff810bd928>{elv_insert+120} <ffffffff880058a5>{:ide_core:ide_do_drive_cmd+245}
       <ffffffff881603a7>{:ide_cd:cdrom_queue_packet_command+70}
       <ffffffff810bf79a>{blk_end_sync_rq+0} <ffffffff880045f8>{:ide_core:ide_init_drive_cmd+16}
       <ffffffff881604de>{:ide_cd:ide_cdrom_packet+155} <ffffffff810bf79a>{blk_end_sync_rq+0}
       <ffffffff8814b7ea>{:cdrom:cdrom_get_media_event+77}
       <ffffffff88160b22>{:ide_cd:ide_cdrom_drive_status+65}
       <ffffffff8814b266>{:cdrom:cdrom_ioctl+1640} <ffffffff810ca406>{kobject_get+18}
       <ffffffff810c2747>{get_disk+47} <ffffffff810c21a3>{blkdev_ioctl+1558}
       <ffffffff81068f83>{do_open+221} <ffffffff81068e9e>{bdget+284}
       <ffffffff81068896>{bd_claim+131} <ffffffff810693ea>{blkdev_open+0}
       <ffffffff81069422>{blkdev_open+56} <ffffffff810608af>{__dentry_open+238}
       <ffffffff81068967>{block_ioctl+27} <ffffffff81072713>{do_ioctl+27}
       <ffffffff81072957>{vfs_ioctl+527} <ffffffff810729a5>{sys_ioctl+60}
       <ffffffff8100a47e>{system_call+126}

Code: 89 c1 f3 90 0f 31 29 c8 48 39 f8 72 f5 c3 48 69 05 cc a4 1f

console shuts up ...
<3>Debug: sleeping function called from invalid context at include/linux/rwsem.h:43
in_atomic():1, irqs_disabled():1

Call Trace: <NMI> <ffffffff81027e14>{profile_task_exit+21}
       <ffffffff810299e0>{do_exit+32} <ffffffff8118ede7>{__die+0}
       <ffffffff8118f4d5>{nmi_watchdog_tick+161} <ffffffff8118f2d1>{default_do_nmi+115}
       <ffffffff8118f58b>{do_nmi+61} <ffffffff8118eb87>{nmi+127}
       <ffffffff810ce62b>{__delay+2} <EOE> <IRQ> <ffffffff810cf72d>{_raw_spin_lock+129}
       <ffffffff81042b08>{__do_IRQ+55} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <ffffffff880052cf>{:ide_core:ide_do_request+820}
       <ffffffff880052ca>{:ide_core:ide_do_request+815} <ffffffff8118e7d1>{_spin_lock_irqsave+9}
       <ffffffff88161c58>{:ide_cd:cdrom_decode_status+42} <ffffffff881626ca>{:ide_cd:cdrom_pc_intr+510}
       <ffffffff88005abd>{:ide_core:ide_intr+442} <ffffffff810431a8>{note_interrupt+219}
       <ffffffff81042b7e>{__do_IRQ+173} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <EOI> <ffffffff8102743a>{vprintk+652}
       <ffffffff88006233>{:ide_core:ide_outsw+0} <ffffffff88006238>{:ide_core:ide_outsw+5}
       <ffffffff88006681>{:ide_core:atapi_output_bytes+38}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88162b5b>{:ide_cd:cdrom_transfer_packet_command+182}
       <ffffffff88162bda>{:ide_cd:cdrom_do_pc_continuation+0}
       <ffffffff8815f91a>{:ide_cd:cdrom_start_packet_command+359}
       <ffffffff880055d2>{:ide_core:ide_do_request+1591} <ffffffff8118d1e4>{thread_return+0}
       <ffffffff8118d23a>{thread_return+86} <ffffffff8800574d>{:ide_core:ide_do_request+1970}
       <ffffffff810bd928>{elv_insert+120} <ffffffff880058a5>{:ide_core:ide_do_drive_cmd+245}
       <ffffffff881603a7>{:ide_cd:cdrom_queue_packet_command+70}
       <ffffffff810bf79a>{blk_end_sync_rq+0} <ffffffff880045f8>{:ide_core:ide_init_drive_cmd+16}
       <ffffffff881604de>{:ide_cd:ide_cdrom_packet+155} <ffffffff810bf79a>{blk_end_sync_rq+0}
       <ffffffff8814b7ea>{:cdrom:cdrom_get_media_event+77}
       <ffffffff88160b22>{:ide_cd:ide_cdrom_drive_status+65}
       <ffffffff8814b266>{:cdrom:cdrom_ioctl+1640} <ffffffff810ca406>{kobject_get+18}
       <ffffffff810c2747>{get_disk+47} <ffffffff810c21a3>{blkdev_ioctl+1558}
       <ffffffff81068f83>{do_open+221} <ffffffff81068e9e>{bdget+284}
       <ffffffff81068896>{bd_claim+131} <ffffffff810693ea>{blkdev_open+0}
       <ffffffff81069422>{blkdev_open+56} <ffffffff810608af>{__dentry_open+238}
       <ffffffff81068967>{block_ioctl+27} <ffffffff81072713>{do_ioctl+27}
       <ffffffff81072957>{vfs_ioctl+527} <ffffffff810729a5>{sys_ioctl+60}
       <ffffffff8100a47e>{system_call+126}
Kernel panic - not syncing: Aiee, killing interrupt handler!
#4 lore raw
Quoted 5 lines · Rachita Kothiyal
Quoted 4 lines · Jens Axboe

On Fri, Apr 07 2006, Rachita Kothiyal wrote:

if (stat & DRQ_STAT)

Quoted 7 lines
Quoted 2 lines

checking for DRQ_STAT again doesn't make sense, how can it ever be anything but DRQ_STAT if DRQ_STAT is set?

Hi Jens,

Yes, you are right. The condition itself is redundant there as DRQ will always be set there. I will remove it.

Good so far.

Quoted 20 lines
Quoted 11 lines

drivers/ide/ide-cd.c static ide_startstop_t cdrom_pc_intr (id · line 1456

Quoted 4 lines
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~cdrom-confused-clrinterrupt +3 -0
+			/* DRQ is set. Interrupt not welcome now. Ignore */
+			HWIF(drive)->OUTB((stat & 0xEF), IDE_STATUS_REG);
+			return ide_stopped;

And this looks very wrong, you can't write to the status register. Well you can, but then it's the command register! Writing stat & 0xef to the command register is an odd thing to do. I think you just want to clear the DRQ bit, which should be fine after it was read initially. How about

Quoted 4 lines

if (stat & DRQ_STAT)
return ide_stopped;

Can you test that?

I tested this, but I see it fail a couple of times...sometimes it hung while booting up the second kernel and sometimes the kernel paniced while shutting it down.(attached partial log for panic)

Quoted 6 lines

I see your point that writing to the status register is not a good idea. I think what we want to do is just ignore this particular interrupt and let it continue.
Am not sure if clearing DRQ bit will achieve this. Please correct me if I am wrong, but to clear the DRQ bit also we will have to write to the status register.

No, there is not writable status register - that is called the command register. Just reading the status register is enough to clear the irq, so if you just want to ignore the interrupt that'll work.

What happens if you rearm the interrupt handler instead of returning ide_stopped?

Signature · 1 line
Jens Axboe
#5 lore raw
Quoted 11 lines · Jens Axboe
Quoted 7 lines

I see your point that writing to the status register is not a good idea. I think what we want to do is just ignore this particular interrupt and let it continue.
Am not sure if clearing DRQ bit will achieve this. Please correct me if I am wrong, but to clear the DRQ bit also we will have to write to the status register.

No, there is not writable status register - that is called the command register. Just reading the status register is enough to clear the irq, so if you just want to ignore the interrupt that'll work.

Hi Jens,

I actually tried just reading the status register and then returning ide_stopped. It seemed to be working fine, just that there appears a 'status error' message while booting:

<snippet>
ide0: start_request: current=0xffff8100035cba68
hda: status error: status=0x58 { DriveReady SeekComplete DataRequest }
ide: failed opcode was: unknown
hda: drive not ready for command
</snippet>

The second kernel boots up fine though and I am able to mount the cdrom ok and access its files too.

Quoted 2 lines

What happens if you rearm the interrupt handler instead of returning ide_stopped?

In this case the kernel just panics during booting(attaching the partial panic log).

Thanks
Rachita

usb usb2: SerialNumber: 0000:00:1d.1
usb usb2: configuration #1 chosen from 1 choice
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 2 ports detected
ide0: start_request: current=0xffff810003a2ba88
Rachita: DRQ set.Interrupt ignored
hda: cdrom_pc_intr: The drive appears confused (ireason = 0x01)
hda: ide_set_handler: handler not null; old=ffffffff881624cc, new=ffffffff881624cc ----------- [cut here ] --------- [please bite here ] ---------

Kernel BUG at include/linux/timer.h:83
invalid opcode: 0000 [1] 
last sysfs file: /devices/platform/floppy.0/cmos
CPU 0 
Modules linked in: ide_cd cdrom ehci_hcd uhci_hcd usbcore shpchp e752x_edac pci_hotplug edac_mc floppy ext3 jbd processor sg aic79xx scsi_transport_spi piix sd_mod scsi_mod ide_disk ide_core
Pid: 940, comm: modprobe Tainted: G     U 2.6.16-rc2-git5-rachita-3-kdump #6
RIP: 0010:[<ffffffff88006ad1>] <ffffffff88006ad1>{:ide_core:__ide_set_handler+96}
RSP: 0018:ffffffff8124b9b8  EFLAGS: 00010082
RAX: 00000000ffff44ce RBX: ffff810004e2a548 RCX: 00000000000002f8
RDX: 0000000000003a98 RSI: 0000000000000046 RDI: ffff810004e2a588
RBP: ffffffff881624cc R08: 0000000000000007 R09: ffffffff8124b718
R10: 0000000000000010 R11: 0000000000000000 R12: ffffffff8815f1cf
R13: 0000000000003a98 R14: ffffffff881624cc R15: ffffffff8801d438
FS:  00002aba4494e6d0(0000) GS:ffffffff812c1000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 000000000053873d CR3: 00000000037f4000 CR4: 00000000000006e0
Process modprobe (pid: 940, threadinfo ffff810003a2a000, task ffff8100031760c0)
Stack: 0000000000000002 ffffffff8815f1cf 0000000000000018 0000000000003a98 
       0000000000000002 ffffffff88006cf5 ffff810003a2ba88 0000000000000018 
       ffffffff8801d438 0000000000000001 
Call Trace: <IRQ> <ffffffff8815f1cf>{:ide_cd:cdrom_timer_expiry+0}
       <ffffffff88006cf5>{:ide_core:ide_set_handler+53} <ffffffff88162713>{:ide_cd:cdrom_pc_intr+583}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88005a98>{:ide_core:ide_intr+386}
       <ffffffff810431a8>{note_interrupt+219} <ffffffff81042b7e>{__do_IRQ+173}
       <ffffffff8100c3cb>{do_IRQ+59} <ffffffff8100aa24>{ret_from_intr+0} <EOI>
       <ffffffff81046584>{mempool_alloc+66} <ffffffff8105e21b>{poison_obj+38}
       <ffffffff88006273>{:ide_core:ide_outsw+0} <ffffffff88006278>{:ide_core:ide_outsw+5}
       <ffffffff880066c1>{:ide_core:atapi_output_bytes+38}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88162b68>{:ide_cd:cdrom_transfer_packet_command+182}
       <ffffffff88162be7>{:ide_cd:cdrom_do_pc_continuation+0}
       <ffffffff8815f91a>{:ide_cd:cdrom_start_packet_command+359}
       <ffffffff880055dc>{:ide_core:ide_do_request+1601} <ffffffff810bd928>{elv_insert+120}
       <ffffffff880058b8>{:ide_core:ide_do_drive_cmd+245} <ffffffff881603a7>{:ide_cd:cdrom_queue_packet_command+70}
       <ffffffff81050afd>{__handle_mm_fault+2388} <ffffffff880045f8>{:ide_core:ide_init_drive_cmd+16}
       <ffffffff881604de>{:ide_cd:ide_cdrom_packet+155} <ffffffff810bf79a>{blk_end_sync_rq+0}
       <ffffffff8815f6c1>{:ide_cd:ide_cdrom_get_capabilities+114}
       <ffffffff88161491>{:ide_cd:ide_cd_probe+1335} <ffffffff8118e791>{_spin_unlock_irq+12}
       <ffffffff8118d23a>{thread_return+86} <ffffffff8111da4d>{driver_probe_device+82}
       <ffffffff8111dba4>{__driver_attach+140} <ffffffff8111db18>{__driver_attach+0}
       <ffffffff8111d452>{bus_for_each_dev+67} <ffffffff8111d0c2>{bus_add_driver+126}
       <ffffffff8103eca3>{sys_init_module+5269} <ffffffff81038aa5>{autoremove_wake_function+0}
       <ffffffff810625b2>{vfs_write+283} <ffffffff8100a47e>{system_call+126}

Code: 0f 0b 68 b7 ec 00 88 c2 53 00 48 8b 77 10 41 58 5b 5d 41 5c 

RIP <ffffffff88006ad1>{:ide_core:__ide_set_handler+96} RSP <ffffffff8124b9b8>
<3>Debug: sleeping function called from invalid context at include/linux/rwsem.h:43
in_atomic():1, irqs_disabled():1

Call Trace: <IRQ> <ffffffff81027e14>{profile_task_exit+21}
       <ffffffff810299e0>{do_exit+32} <ffffffff8100b85e>{kernel_math_error+0}
       <ffffffff8815f1cf>{:ide_cd:cdrom_timer_expiry+0} <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0}
       <ffffffff8100bdc5>{do_invalid_op+163} <ffffffff88006ad1>{:ide_core:__ide_set_handler+96}
       <ffffffff8102743a>{vprintk+652} <ffffffff81026de9>{release_console_sem+423}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff8815f1cf>{:ide_cd:cdrom_timer_expiry+0}
       <ffffffff8100adad>{error_exit+0} <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0}
       <ffffffff8815f1cf>{:ide_cd:cdrom_timer_expiry+0} <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0}
       <ffffffff88006ad1>{:ide_core:__ide_set_handler+96} <ffffffff88006aab>{:ide_core:__ide_set_handler+58}
       <ffffffff8815f1cf>{:ide_cd:cdrom_timer_expiry+0} <ffffffff88006cf5>{:ide_core:ide_set_handler+53}
       <ffffffff88162713>{:ide_cd:cdrom_pc_intr+583} <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0}
       <ffffffff88005a98>{:ide_core:ide_intr+386} <ffffffff810431a8>{note_interrupt+219}
       <ffffffff81042b7e>{__do_IRQ+173} <ffffffff8100c3cb>{do_IRQ+59}
       <ffffffff8100aa24>{ret_from_intr+0} <EOI> <ffffffff81046584>{mempool_alloc+66}
       <ffffffff8105e21b>{poison_obj+38} <ffffffff88006273>{:ide_core:ide_outsw+0}
       <ffffffff88006278>{:ide_core:ide_outsw+5} <ffffffff880066c1>{:ide_core:atapi_output_bytes+38}
       <ffffffff881624cc>{:ide_cd:cdrom_pc_intr+0} <ffffffff88162b68>{:ide_cd:cdrom_transfer_packet_command+182}
       <ffffffff8815f91a>{:ide_cd:cdrom_start_packet_command+359}
       <ffffffff880055dc>{:ide_core:ide_do_request+1601} <ffffffff810bd928>{elv_insert+120}
       <ffffffff880058b8>{:ide_core:ide_do_drive_cmd+245} <ffffffff881603a7>{:ide_cd:cdrom_queue_packet_command+70}
       <ffffffff81050afd>{__handle_mm_fault+2388} <ffffffff880045f8>{:ide_core:ide_init_drive_cmd+16}
       <ffffffff881604de>{:ide_cd:ide_cdrom_packet+155} <ffffffff810bf79a>{blk_end_sync_rq+0}
       <ffffffff8815f6c1>{:ide_cd:ide_cdrom_get_capabilities+114}
       <ffffffff88161491>{:ide_cd:ide_cd_probe+1335} <ffffffff8118e791>{_spin_unlock_irq+12}
       <ffffffff8118d23a>{thread_return+86} <ffffffff8111da4d>{driver_probe_device+82}
       <ffffffff8111dba4>{__driver_attach+140} <ffffffff8111db18>{__driver_attach+0}
       <ffffffff8111d452>{bus_for_each_dev+67} <ffffffff8111d0c2>{bus_add_driver+126}
       <ffffffff8103eca3>{sys_init_module+5269} <ffffffff81038aa5>{autoremove_wake_function+0}
       <ffffffff810625b2>{vfs_write+283} <ffffffff8100a47e>{system_call+126}
Kernel panic - not syncing: Aiee, killing interrupt handler!
#6 lore raw
Quoted 11 lines · Rachita Kothiyal

I actually tried just reading the status register and then returning ide_stopped. It seemed to be working fine, just that there appears a 'status error' message while booting:

<snippet>
ide0: start_request: current=0xffff8100035cba68
hda: status error: status=0x58 { DriveReady SeekComplete DataRequest }
ide: failed opcode was: unknown
hda: drive not ready for command
</snippet>

Hi Jens,

Instead of reading the status register and returning ide_stopped from the handler, which was resulting in the 'status error', I tried ending the request and returning ide_stopped when the drive is in a confused state. Using this I dont see the status error.

Following is the patch, kindly review.

Thanks
Rachita

---

 drivers/ide/ide-cd.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)
drivers/ide/ide-cd.c renamed from drivers/ide/ide-cd.c~fix-confused-cdrom-with-kdump-end-req-ret +4 -1
diff -puN drivers/ide/ide-cd.c~fix-confused-cdrom-with-kdump-end-req-ret drivers/ide/ide-cd.c
@@ -1451,9 +1451,12 @@ static ide_startstop_t cdrom_pc_intr (id
 	} else {
 confused:
 		printk (KERN_ERR "%s: cdrom_pc_intr: The drive "
-			"appears confused (ireason = 0x%02x)\n",
+			"appears confused (ireason = 0x%02x). "
+			"Trying to recover by ending request.\n",
 			drive->name, ireason);
 		rq->flags |= REQ_FAILED;
+		cdrom_end_request(drive, 0);
+		return ide_stopped;
 	}
 
 	/* Now we wait for another interrupt. */

_

#7 lore raw
Quoted 13 lines · Rachita Kothiyal
Quoted 11 lines · Rachita Kothiyal

I actually tried just reading the status register and then returning ide_stopped. It seemed to be working fine, just that there appears a 'status error' message while booting:

<snippet>
ide0: start_request: current=0xffff8100035cba68
hda: status error: status=0x58 { DriveReady SeekComplete DataRequest }
ide: failed opcode was: unknown
hda: drive not ready for command
</snippet>

Quoted 8 lines

Hi Jens,

Instead of reading the status register and returning ide_stopped from the handler, which was resulting in the 'status error', I tried ending the request and returning ide_stopped when the drive is in a confused state. Using this I dont see the status error.

Following is the patch, kindly review.

This looks a lot more appropriate! Thanks for following through on this.

Signature · 1 line
Jens Axboe