Chapter 4. Locks

Each Scsi_Host instance has a spin_lock called Scsi_Host::default_lock which is initialized in scsi_register() [found in hosts.c]. Within the same function the Scsi_Host::host_lock pointer is initialized to point at default_lock with the scsi_assign_lock() function. Thereafter lock and unlock operations performed by the mid level use the Scsi_Host::host_lock pointer.

Lower level drivers can override the use of Scsi_Host::default_lock by using scsi_assign_lock(). The earliest opportunity to do this would be in the detect() function after it has invoked scsi_register(). It could be replaced by a coarser grain lock (e.g. per driver) or a lock of equal granularity (i.e. per host). Using finer grain locks (e.g. per scsi device) may be possible by juggling locks in queuecommand().