From: Lin Ming Date: Mon, 5 Dec 2011 01:20:26 +0000 (+0800) Subject: [SCSI] sd: check runtime PM status in sd_shutdown X-Git-Tag: v3.3-rc1~128^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54f57588463db1105f4a93b2902a6f95cb8f796a;p=platform%2Fkernel%2Flinux-exynos.git [SCSI] sd: check runtime PM status in sd_shutdown sd_shutdown is called during reboot/poweroff. It may fail if parent device, for example, ata port, was runtime suspended. Fix it by checking runtime PM status of sd. Exit immediately if sd was runtime suspended already. Acked-by: Alan Stern Signed-off-by: Lin Ming Signed-off-by: Jeff Garzik --- diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index fa3a591..7b3f807 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -2741,6 +2742,9 @@ static void sd_shutdown(struct device *dev) if (!sdkp) return; /* this can happen */ + if (pm_runtime_suspended(dev)) + goto exit; + if (sdkp->WCE) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); sd_sync_cache(sdkp); @@ -2751,6 +2755,7 @@ static void sd_shutdown(struct device *dev) sd_start_stop_device(sdkp, 0); } +exit: scsi_disk_put(sdkp); }