aic7xxx deadlock in 2.6.0-test10
Subsystems (2)
One of my less-used boxes if taking an NMI watchdog hit on boot in test10:
(gdb) bt
#0 0xc02dc427 in .text.lock.scsi () at drivers/scsi/scsi.c:1049 #1 0xf70e5df8 in ?? () #2 0xc02df24a in scsi_report_bus_reset (shost=0xf70f6e48, channel=-150053384) at drivers/scsi/scsi_error.c:1625 #3 0xc02fbc96 in ahc_send_async (ahc=0xf70e5df8, channel=65 'A', target=4294967295, lun=4144983544, code=-134635520, arg=0x0) at drivers/scsi/aic7xxx/aic7xxx_osm.c:4075 #4 0xc02ee031 in ahc_reset_channel (ahc=0xf70f7df8, channel=65 'A', initiate_reset=1) at drivers/scsi/aic7xxx/aic7xxx_core.c:6077 #5 0xc02f7040 in ahc_linux_initialize_scsi_bus (ahc=0xf70f7df8) at drivers/scsi/aic7xxx/aic7xxx_osm.c:1846 #6 0xc02f6dc3 in ahc_linux_register_host (ahc=0xf70f7df8, template=0xf70f6df8) at drivers/scsi/aic7xxx/aic7xxx_osm.c:1737 #7 0xc02f5cc8 in ahc_linux_detect (template=0xc04a4ea0) at drivers/scsi/aic7xxx/aic7xxx_osm.c:908 #8 0xc05c47d5 in ahc_linux_init () at drivers/scsi/aic7xxx/aic7xxx_osm.c:5054 #9 0xc05ac865 in do_initcalls () at init/main.c:497
#10 0xc05ac8dc in do_basic_setup () at init/main.c:537 #11 0xc010512d in init (unused=0x0) at init/main.c:579
ahc_linux_register_host() is calling ahc_linux_initialize_scsi_bus() under ahc_lock(ahc, &s). But scsi_report_bus_reset() is taking host->host_lock inside shost_for_each_device(), and that is the same (already held) lock.
This patch gets things going again of course. Could someone please take a look at fixing this for real?
I'm not sure why this has suddenly started happening actually.
drivers/scsi/aic7xxx/aic7xxx_osm.c renamed from drivers/scsi/aic7xxx/aic7xxx_osm.c~aic7xxx-deadlock-fix +1 -1
@@ -1734,8 +1734,8 @@ ahc_linux_register_host(struct ahc_softc LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)scsi_set_pci_device (host, ahc->dev_softc);#endif -ahc_linux_initialize_scsi_bus (ahc);ahc_unlock (ahc, &s); +ahc_linux_initialize_scsi_bus (ahc); ahc->platform_data->dv_pid =kernel_thread (ahc_linux_dv_thread, ahc,0 );ahc_lock (ahc, &s);if (ahc->platform_data->dv_pid <0 ) {
_
Quoted 9 lines · Andrew Morton
ahc_linux_register_host()is callingahc_linux_initialize_scsi_bus()underahc_lock(ahc, &s). Butscsi_report_bus_reset()is takinghost->host_lockinsideshost_for_each_device(), and that is the same (already held) lock.This patch gets things going again of course. Could someone please take a look at fixing this for real?
I'm not sure why this has suddenly started happening actually.
jejb just posted another fix for it on linux-scsi, but in fact your fix looks better to me, ahc_initialize doesn't need the host_lock because ahc can't be reached from an other thread yet.
Quoted 3 lines · Christoph Hellwig
jejb just posted another fix for it on linux-scsi, but in fact your fix looks better to me,
ahc_initializedoesn't need thehost_lockbecause ahc can't be reached from an other thread yet.
I don't think so. This only fixes the boot case for aic7xxx (the boot problem is also present in aic79xx). This routine was designed to be called also when a driver detects a reset it didn't initiate (aic7xxx_old is probably the only driver that actually seems to do this). In that case, the detection is called from the ISR, so you don't want to drop the lock
The fix, I think, is to require the lock be held for the bus/device reset reporting callbacks and use the unlocked iterator.
James