diff options
author | Lin Ming <ming.m.lin@intel.com> | 2011-12-04 20:20:26 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2012-01-08 19:14:57 -0500 |
commit | 54f57588463db1105f4a93b2902a6f95cb8f796a (patch) | |
tree | 5a8f50a836f49db68f994de214fdcaacda337151 /drivers/scsi | |
parent | 286405167e815adc4ae0132214246a350b0208bc (diff) |
[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 <stern@rowland.harvard.edu>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sd.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index fa3a5918009c..7b3f8075e2a5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include <linux/string_helpers.h> | 50 | #include <linux/string_helpers.h> |
51 | #include <linux/async.h> | 51 | #include <linux/async.h> |
52 | #include <linux/slab.h> | 52 | #include <linux/slab.h> |
53 | #include <linux/pm_runtime.h> | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/unaligned.h> | 55 | #include <asm/unaligned.h> |
55 | 56 | ||
@@ -2741,6 +2742,9 @@ static void sd_shutdown(struct device *dev) | |||
2741 | if (!sdkp) | 2742 | if (!sdkp) |
2742 | return; /* this can happen */ | 2743 | return; /* this can happen */ |
2743 | 2744 | ||
2745 | if (pm_runtime_suspended(dev)) | ||
2746 | goto exit; | ||
2747 | |||
2744 | if (sdkp->WCE) { | 2748 | if (sdkp->WCE) { |
2745 | sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); | 2749 | sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); |
2746 | sd_sync_cache(sdkp); | 2750 | sd_sync_cache(sdkp); |
@@ -2751,6 +2755,7 @@ static void sd_shutdown(struct device *dev) | |||
2751 | sd_start_stop_device(sdkp, 0); | 2755 | sd_start_stop_device(sdkp, 0); |
2752 | } | 2756 | } |
2753 | 2757 | ||
2758 | exit: | ||
2754 | scsi_disk_put(sdkp); | 2759 | scsi_disk_put(sdkp); |
2755 | } | 2760 | } |
2756 | 2761 | ||