The cam_sim structure was being deallocated unconditionally by device
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 15 Mar 2004 01:10:45 +0000 (01:10 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 15 Mar 2004 01:10:45 +0000 (01:10 +0000)
commit3aed135530c28652bc765e16ab0058fb65e21933
treebf991a1c487a23e6d521ca5eb958dc14fb3df545
parentc3619d4227ba0b3d23d510ccdc64af5e20190582
The cam_sim structure was being deallocated unconditionally by device
driver detach routines.  The problem with this is that part of the CAM
bus structure may still be active (for example, with pending timeout()'s),
and even though the bus, target, and device is freed, since the sim IS
freed any accesses through the sim will hit 0xdeadc0de.  This case most often
occurs with USB UMASS devices.

The CAM_XPT and CAM_SIM layer has been revamped.  CAM_DEV_UNCONFIGURED is now
accounted for in the device->refcount, and the cam_sim structure is now
ref-counted as well.  Additionally, the cam_simq* code which handles the
device queues has been revamped to refcount as well, so shared device queues
(raid and multi-channel devices) are not free()'d before all references have
gone away.

scsi_low free'd its cam_sim twice.  Fixed.

USB was improperly using M_NOWAIT.  All M_NOWAIT instances have been renamed
to M_INTWAIT.
45 files changed:
sys/bus/cam/cam_queue.c
sys/bus/cam/cam_queue.h
sys/bus/cam/cam_sim.c
sys/bus/cam/cam_sim.h
sys/bus/cam/cam_xpt.c
sys/bus/cam/scsi/scsi_low.c
sys/dev/disk/advansys/advansys.c
sys/dev/disk/advansys/adwcam.c
sys/dev/disk/aha/aha.c
sys/dev/disk/ahb/ahb.c
sys/dev/disk/aic/aic.c
sys/dev/disk/aic7xxx/ahc_eisa.c
sys/dev/disk/aic7xxx/ahc_pci.c
sys/dev/disk/aic7xxx/ahd_pci.c
sys/dev/disk/aic7xxx/aic79xx.c
sys/dev/disk/aic7xxx/aic79xx_osm.c
sys/dev/disk/aic7xxx/aic7xxx.c
sys/dev/disk/aic7xxx/aic7xxx_osm.c
sys/dev/disk/amd/amd.c
sys/dev/disk/ata/ata-all.c
sys/dev/disk/ata/ata-disk.c
sys/dev/disk/ata/atapi-all.c
sys/dev/disk/ata/atapi-cam.c
sys/dev/disk/buslogic/bt.c
sys/dev/disk/ccd/ccd.c
sys/dev/disk/fd/fd.c
sys/dev/disk/i386/bs/bsfunc.c
sys/dev/disk/i386/bs/bsif.c
sys/dev/disk/isp/isp_freebsd.c
sys/dev/disk/isp/isp_pci.c
sys/dev/disk/ispfw/ispfw.c
sys/dev/disk/mpt/mpt_freebsd.c
sys/dev/disk/ncr/ncr.c
sys/dev/disk/sbp/sbp.c
sys/dev/disk/simos/simos.c
sys/dev/disk/sym/sym_hipd.c
sys/dev/disk/trm/trm.c
sys/dev/disk/vpo/immio.c
sys/dev/disk/vpo/vpo.c
sys/dev/disk/vpo/vpoio.c
sys/dev/usbmisc/uhid/uhid.c
sys/dev/usbmisc/ukbd/ukbd.c
sys/dev/usbmisc/umass/umass.c
sys/dev/usbmisc/umct/umct.c
sys/dev/usbmisc/ums/ums.c