linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Bombe <aeb@debian.org>
To: "James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH] [SCSI] sd: When no media present ignore WCE in suspend/shutdown
Date: Wed, 26 Dec 2012 00:24:01 +0100	[thread overview]
Message-ID: <20121225232401.GA19299@amos.fritz.box> (raw)

When the WCE flag is set for a drive, sd_shutdown() and sd_suspend() try
to send a SYNCHRONIZE_CACHE command to that drive. This is not
meaningful when no media are present and causes errors with devices
where the media are the actual command processing devices, such as SATA
attached RDX docks where the removable cartridges contain hard disks.

In the RDX case, the WCE bit is set when a cartridge is inserted and not
reset when it is removed. Suspending the computer afterwards will not be
possible unless a cartridge is inserted since otherwise the
SYNCHRONIZE_CACHE command will fail causing sd_suspend() to return an
error.

Signed-off-by: Andreas Bombe <aeb@debian.org>
---

Ok, this patch makes the problem go away, but I'm not sure whether this
is right solution. I also don't know whether SATA RDX docks are sort of
a special case in this regard.

I can think of two other solutions:
1. Also skip the sd_start_stop_device() call. The device for the RDX
   dock isn't managed so I can't test.
2. Clear the WCE flag when media are removed and leave sd_shutdown() /
   sd_suspend() alone.

The final patch would then also be Cc: stable, I don't know how far back
this goes but at least 3.7 is affected.


 drivers/scsi/sd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 7992635..723512e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3048,7 +3048,7 @@ static void sd_shutdown(struct device *dev)
 	if (pm_runtime_suspended(dev))
 		goto exit;
 
-	if (sdkp->WCE) {
+	if (sdkp->WCE && sdkp->media_present) {
 		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
 		sd_sync_cache(sdkp);
 	}
@@ -3070,7 +3070,7 @@ static int sd_suspend(struct device *dev)
 	if (!sdkp)
 		return 0;	/* this can happen */
 
-	if (sdkp->WCE) {
+	if (sdkp->WCE && sdkp->media_present) {
 		sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
 		ret = sd_sync_cache(sdkp);
 		if (ret)
-- 
1.7.10.4

                 reply	other threads:[~2012-12-25 23:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20121225232401.GA19299@amos.fritz.box \
    --to=aeb@debian.org \
    --cc=JBottomley@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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).