linux/drivers/scsi/pm8001
Benjamin Rood 2a188cb42b pm80xx: remove the SCSI host before detaching from SAS transport
Previously, when this module was unloaded via 'rmmod' with at least one
drive attached, the SCSI error handler thread would become stuck in an
infinite recovery loop and lockup the system, necessitating a reboot.

Once the SAS layer is detached, the driver will fail any subsequent
commands since the target devices are removed.  However, removing the
SCSI host generates a SYNCHRONIZE CACHE (10) command, which was failed
and left the error handler no method of recovery.

This patch simply removes the SCSI host first so that no more commands
can come down, prior to cleaning up the SAS layer.  Note that the stack
is built up with the SCSI host first, and then the SAS layer.  Perhaps
it should be reversed for symmetry, so that commands cannot be sent to
the pm80xx driver prior to attaching the SAS layer?

What was really strange about this bug was that it was introduced at
commit cff549e486 ("[SCSI]: proper state checking and module refcount
handling in scsi_device_get").  This commit appears to tinker with how
the reference counting is performed for SCSI device objects.  My theory
is that prior to this commit, the refcount for a device object was
blindly incremented at some point during the teardown process which
coincidentially made the device stick around during the procedure, which
also coincidentially made any commands sent to the driver not fail
(since the device was technically still "there").  After this commit was
applied, my theory is the refcount for the device object is not being
incremented at a specific point anymore, which makes the device go away,
and thus made the pm80xx driver fail any subsequent commands.

You may also want to see the following for more details:

[1] http://www.spinics.net/lists/linux-scsi/msg37208.html
[2] http://marc.info/?l=linux-scsi&m=144416476406993&w=2

Signed-off-by: Benjamin Rood <brood@attotech.com>
Acked-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-09 19:41:31 -05:00
..
Makefile [SCSI] pm80xx: Added SPCv/ve specific hardware functionalities and relevant changes in common files 2013-05-10 07:47:47 -07:00
pm80xx_hwi.c pm80xx: do not examine registers for iButton feature if ATTO adapter 2015-11-02 23:39:35 -05:00
pm80xx_hwi.h pm80xx: Handling Invalid SSP Response frame 2015-08-26 17:18:31 -07:00
pm8001_chips.h [SCSI] pm8001: fix endian issue with code optimization. 2012-02-29 16:54:09 -06:00
pm8001_ctl.c pm8001: Update nvmd response data to request buffer 2014-09-16 09:09:48 -07:00
pm8001_ctl.h [SCSI] pm80xx: Firmware logging support. 2013-10-25 09:58:16 +01:00
pm8001_defs.h pm80xx: add support for PMC Sierra 8070 and PMC Sierra 8072 SAS controllers 2015-11-02 23:34:12 -05:00
pm8001_hwi.c pm80xx: Don't override ts->stat on IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY 2015-09-06 11:53:31 -07:00
pm8001_hwi.h [SCSI] pm80xx: Resetting the phy state. 2013-12-02 10:35:52 -08:00
pm8001_init.c pm80xx: remove the SCSI host before detaching from SAS transport 2015-11-09 19:41:31 -05:00
pm8001_sas.c pm80xx: Fix for Incorrect DMA Unmapping of SG List 2015-08-26 17:11:01 -07:00
pm8001_sas.h pm80xx: set PHY profiles for ATTO 12Gb SAS controllers 2015-11-02 23:39:02 -05:00