From 4e2247b2bd289f079349d6c69755f8cff4e31f2b Mon Sep 17 00:00:00 2001 From: Lan Tianyu Date: Thu, 15 Mar 2012 11:11:31 +0800 Subject: [SCSI] sd: Add runtime pm in the sd_check_events() The sd_check_event() will be called periodly even when the device is in the suspended status to check media event. The scsi_test_unit_ready() in the sd_check_event() will issue scsi cmd request. Issuing scsi request when the device is in the suspeneded status will cause problem. For example, when a usb flash disk in the suspended status, scsi_test_unit_ready() issues a scsi request. The request will be returned as failed because the usb device is not active. The patch adds scsi_autopm_get_device() and scsi_autopm_put_device() around scsi_test_unit_ready() in the sd_check_event() to resolve such problem. Signed-off-by: Lan Tianyu Acked-by: Alan Stern Signed-off-by: James Bottomley --- drivers/scsi/sd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/scsi/sd.c') diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index bd17cf8af01..36763504588 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1212,9 +1212,14 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) retval = -ENODEV; if (scsi_block_when_processing_errors(sdp)) { + retval = scsi_autopm_get_device(sdp); + if (retval) + goto out; + sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL); retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES, sshdr); + scsi_autopm_put_device(sdp); } /* failed to execute TUR, assume media not present */ -- cgit v1.2.3-70-g09d2 From 2db93ce8cc1801ccb32a2f19062d110e5a9d4282 Mon Sep 17 00:00:00 2001 From: Petr Uzel Date: Fri, 24 Feb 2012 16:56:54 +0100 Subject: [SCSI] sd: make comment and printk string match code Adapt comment and printk string after renaming sd_init_command to sd_prep_fn Adapt comment and printk string after renaming sd_attach to sd_probe Signed-off-by: Petr Uzel Acked-by: Hannes Reinecke Signed-off-by: James Bottomley --- drivers/scsi/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/scsi/sd.c') diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 36763504588..92ab87a188b 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -664,7 +664,7 @@ static void sd_unprep_fn(struct request_queue *q, struct request *rq) } /** - * sd_init_command - build a scsi (read or write) command from + * sd_prep_fn - build a scsi (read or write) command from * information in the request structure. * @SCpnt: pointer to mid-level's per scsi command structure that * contains request and into which the scsi command is written @@ -711,7 +711,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) ret = BLKPREP_KILL; SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt, - "sd_init_command: block=%llu, " + "sd_prep_fn: block=%llu, " "count=%d\n", (unsigned long long)block, this_count)); @@ -2649,8 +2649,8 @@ static void sd_probe_async(void *data, async_cookie_t cookie) * (e.g. /dev/sda). More precisely it is the block device major * and minor number that is chosen here. * - * Assume sd_attach is not re-entrant (for time being) - * Also think about sd_attach() and sd_remove() running coincidentally. + * Assume sd_probe is not re-entrant (for time being) + * Also think about sd_probe() and sd_remove() running coincidentally. **/ static int sd_probe(struct device *dev) { @@ -2665,7 +2665,7 @@ static int sd_probe(struct device *dev) goto out; SCSI_LOG_HLQUEUE(3, sdev_printk(KERN_INFO, sdp, - "sd_attach\n")); + "sd_probe\n")); error = -ENOMEM; sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL); -- cgit v1.2.3-70-g09d2