linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lan Tianyu <tianyu.lan@intel.com>
To: James.Bottomley@suse.de
Cc: Lan Tianyu <tianyu.lan@intel.com>,
	stern@rowland.harvard.edu, linux-scsi@vger.kernel.org
Subject: [PATCH 1/1] SCSI: Add rumtime pm in the sd_check_events()
Date: Mon, 20 Feb 2012 16:49:20 +0800	[thread overview]
Message-ID: <1329727760-6467-1-git-send-email-tianyu.lan@intel.com> (raw)

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 <tianyu.lan@intel.com>
---
 drivers/scsi/sd.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c691fb5..7913bd1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1183,8 +1183,14 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
 
 	if (scsi_block_when_processing_errors(sdp)) {
 		sshdr  = kzalloc(sizeof(*sshdr), GFP_KERNEL);
+
+		retval = scsi_autopm_get_device(sdp);
+		if (retval)
+			goto out;
+
 		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 */
-- 
1.7.6.rc2.8.g28eb


             reply	other threads:[~2012-02-20  8:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20  8:49 Lan Tianyu [this message]
2012-02-20 20:41 ` [PATCH 1/1] SCSI: Add rumtime pm in the sd_check_events() Alan Stern
2012-02-21  1:09   ` Lan Tianyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329727760-6467-1-git-send-email-tianyu.lan@intel.com \
    --to=tianyu.lan@intel.com \
    --cc=James.Bottomley@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).