Commit 54f57588 authored by Lin Ming's avatar Lin Ming Committed by Jeff Garzik

[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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 28640516
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <linux/string_helpers.h> #include <linux/string_helpers.h>
#include <linux/async.h> #include <linux/async.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
...@@ -2741,6 +2742,9 @@ static void sd_shutdown(struct device *dev) ...@@ -2741,6 +2742,9 @@ static void sd_shutdown(struct device *dev)
if (!sdkp) if (!sdkp)
return; /* this can happen */ return; /* this can happen */
if (pm_runtime_suspended(dev))
goto exit;
if (sdkp->WCE) { if (sdkp->WCE) {
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
sd_sync_cache(sdkp); sd_sync_cache(sdkp);
...@@ -2751,6 +2755,7 @@ static void sd_shutdown(struct device *dev) ...@@ -2751,6 +2755,7 @@ static void sd_shutdown(struct device *dev)
sd_start_stop_device(sdkp, 0); sd_start_stop_device(sdkp, 0);
} }
exit:
scsi_disk_put(sdkp); scsi_disk_put(sdkp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment