>From 75de5ee7afc17322c61a1188b21e59b13b4a2bdb Mon Sep 17 00:00:00 2001 From: Oliver Neukum <oliver@xxxxxxxxxx> Date: Wed, 6 Oct 2010 15:33:37 +0200 Subject: [PATCH] SCSI: No sleep stop for devices in disconnection If the system is going to sleep while a device is being disconnected, the commands send during preparation for sleep are likely to fail. However if that happens it can be ignored as the devices are going away anyway. This can happen with eSATA because it takes long to process a disconnection. Signed-off-by: Oliver Neukum <oneukum@xxxxxxx> --- drivers/scsi/scsi_pm.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index d70e91a..9285726 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -17,16 +17,27 @@ static int scsi_dev_type_suspend(struct device *dev, pm_message_t msg) { struct device_driver *drv; - int err; + struct scsi_device *sdev; + int err, state; - err = scsi_device_quiesce(to_scsi_device(dev)); + sdev = to_scsi_device(dev); + err = scsi_device_quiesce(sdev); if (err == 0) { drv = dev->driver; if (drv && drv->suspend) err = drv->suspend(dev, msg); } dev_dbg(dev, "scsi suspend: %d\n", err); - return err; + + state = sdev->sdev_state; + switch (state) { + case SDEV_CANCEL: + case SDEV_DEL: + /* lost a race against a disconnection handler */ + return 0; + default: + return err; + } } static int scsi_dev_type_resume(struct device *dev) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html