From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: Hack to fix not working spindown over Firewire
Date: Wed, 30 Apr 2008 15:31:41 +0200 [thread overview]
Message-ID: <481874BD.5010807@s5r6.in-berlin.de> (raw)
In-Reply-To: <20080429232606.GA14261@dose.home.local>
Tino Keitel wrote:
> I like the manage_start_stop feature of the SD driver to spin down the
> hard disks (SATA and USB) during suspend. However, it didn't work with
> my Firewire hard disk.
>
> After some research I found out that I can spin down the disk with
> sg_start --pc=2, and spin it up with sg_start --pc=1. I adopted this
> into sd_start_stop_device() with the vendor name of the device
> hardcoded (see the attached patch) and now my Firewire hard disk spins
> down on suspend and spins up on resume.
>
> Is there any chance to get this behaviour without such ugly changes to
> the kernel? I had to make it conditional by checking the device as
> otherwise the SATA disk reports an error.
[...]
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -1788,8 +1788,16 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
> struct scsi_device *sdp = sdkp->device;
> int res;
>
> - if (start)
> + if (start) {
> cmd[4] |= 1; /* START */
> + if(!strncmp(sdp->vendor, "WDC WD32", 8)) {
> + cmd[4] |= (1 << 4); /* power condition */
> + }
> + } else {
> + if(!strncmp(sdp->vendor, "WDC WD32", 8)) {
> + cmd[4] |= (2 << 4); /* power condition */
> + }
> + }
>
> if (!scsi_device_online(sdp))
> return -ENODEV;
For LKML: There was previous discussion on linux1394-user and LSML.
http://marc.info/?t=120720546800001
The enclosure is a Raidsonic ICY Box.
Responsible for the spindown behavior is the IDE-to-FireWire bridge
controller which is a Prolific PL-3507, and its firmware which is
different from the USB firmware. Also, there are different firmwares in
the wild for PL-3507.
The sdp->vendor string is assembled by the firmware from data gathered
from the IDE device. It is therefore not suitable to detect affected
devices.
The traditional way to handle things like this is:
- Implement this as a workaround in sd.
- Make this workaround conditional on a quirks flag in
struct scsi_device.
- Switch this flag on in a place where it can be reliably
detected that this device needs it. There is an interface
to do this in userspace. But in this particular case, the
best place is the sbp2 driver (ond firewire-sbp2 driver),
because it can detect PL-3507 firmwares by means of firmware
identifiers.
Tino, to find the firmware marker you can for example:
# echo 0x1000 > /sys/module/sbp2/parameters/workarounds
Then plug in the disk and
# dmesg | grep sbp2
On the other hand, perhaps we can enable the workaround unconditional
for all firewire disks (switch in the flag in sbp2 and firewire-sbp2
without looking at the device) or for all RBC disks (switch on the flag
in sd.c if sdev->type == TYPE_RBC).
RBC clause 5.4.1 states that support of the following POWER CONDITION
values in the START STOP UNIT cdb is mandatory:
0 = No change in power condition
1 = Place device in Active condition
2 = Place device in Idle condition
3 = Place device in Standby condition
5 = Place device in Sleep condition
There is also optional support for 7 = Device Control, which is
uninteresting for our purposes. According to the description of Active,
Idle, Standby, Sleep in RBC, we do most certainly want code 1 on resume,
and rather 3 than 2 on suspend. 5 instead of 3 or 2 might even be better
from the POV of energy consumption but a "device reset may be required
before access to the device is allowed" which I'd rather not deal with.
Tino, does the scsi stack log the device as "Direct-Access-RBC" after it
was plugged in?
Note to self: Test sg_start --pc={1,3} with all the various SBP-2
bridges I have access to...
--
Stefan Richter
-=====-==--- -=-- ====-
http://arcgraph.de/sr/
next prev parent reply other threads:[~2008-04-30 13:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-29 23:26 Hack to fix not working spindown over Firewire Tino Keitel
2008-04-30 13:31 ` Stefan Richter [this message]
2008-04-30 13:36 ` Stefan Richter
2008-05-09 20:16 ` Clean patch " Tino Keitel
2008-05-09 21:13 ` Stefan Richter
2008-05-09 22:02 ` Stefan Richter
2008-05-07 18:00 ` Hack " Tino Keitel
2008-05-09 18:32 ` Stefan Richter
2008-05-10 15:31 ` Stefan Richter
2008-05-10 22:32 ` [PATCH 0/5] SCSI and FireWire: fix/add START STOP UNIT for SBP-2 disks Stefan Richter
2008-05-10 22:34 ` [PATCH 1/5] scsi: sd: optionally set power condition in START STOP UNIT Stefan Richter
2008-05-10 22:35 ` [PATCH 2/5] firewire: fw-sbp2: fix spindown for PL-3507 and TSB42AA9 firmwares Stefan Richter
2008-05-10 22:35 ` [PATCH 3/5] ieee1394: sbp2: " Stefan Richter
2008-05-10 22:36 ` [PATCH 4/5] firewire: fw-sbp2: spin disks down on suspend and shutdown Stefan Richter
2008-05-10 22:37 ` [PATCH 5/5] ieee1394: sbp2: " Stefan Richter
2008-05-16 6:23 ` [PATCH 0/5] SCSI and FireWire: fix/add START STOP UNIT for SBP-2 disks Tino Keitel
2008-05-16 17:43 ` Stefan Richter
2008-05-18 17:35 ` Tino Keitel
2008-05-18 20:32 ` Stefan Richter
2008-05-19 17:18 ` Stefan Richter
2008-05-10 22:53 ` Hack to fix not working spindown over Firewire Stefan Richter
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=481874BD.5010807@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--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