* [PATCH] libata: Handle drives that require a spin-up command before first access
@ 2007-04-17 22:26 Mark Lord
2007-04-28 18:41 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: Mark Lord @ 2007-04-17 22:26 UTC (permalink / raw)
To: Jeff Garzik, IDE/ATA development list; +Cc: Tejun Heo, Alan Cox
(S)ATA drives can be configured for "power-up in standby",
a mode whereby a specific "spin up now!" command is required
before the first media access.
Currently, a drive with this feature enabled can not be used at all
with libata, and once in this mode, the drive becomes a doorstop.
The older drivers/ide subsystem at least enumerates the drive,
so that it can be woken up after the fact from a userspace HDIO_*
command, but not libata.
This patch adds support to libata for the "power-up in standby"
mode where a "spin up now!" command (SET_FEATURES) is needed.
With this, libata will recognize such drives, spin them up,
and then re-IDENTIFY them if necessary to get a full/complete
set of drive features data.
Drives in this state are determined by looking for
special values in id[2], as documented in the current ATA specs.
Signed-off-by: Mark Lord <mlord@pobox.com>
---
diff -u --recursive --new-file --exclude-from=linux-2.6.20//Documentation/dontdiff linux-2.6.20/drivers/ata/libata-core.c linux/drivers/ata/libata-core.c
--- linux-2.6.20/drivers/ata/libata-core.c 2007-02-04 13:44:54.000000000 -0500
+++ linux/drivers/ata/libata-core.c 2007-02-22 15:19:41.000000000 -0500
@@ -1453,6 +1453,7 @@
struct ata_taskfile tf;
unsigned int err_mask = 0;
const char *reason;
+ int tried_spinup = 0;
int rc;
if (ata_msg_ctl(ap))
@@ -1460,7 +1461,6 @@
__FUNCTION__, ap->id, dev->devno);
ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
-
retry:
ata_tf_init(dev, &tf);
@@ -1508,6 +1508,32 @@
goto err_out;
}
+ if (!tried_spinup && (id[2] == 0x37c8 || id[2] == 0x738c)) {
+ tried_spinup = 1;
+ /*
+ * Drive powered-up in standby mode, and requires a specific
+ * SET_FEATURES spin-up subcommand before it will accept
+ * anything other than the original IDENTIFY command.
+ */
+ ata_tf_init(dev, &tf);
+ tf.command = ATA_CMD_SET_FEATURES;
+ tf.feature = SETFEATURES_SPINUP;
+ tf.protocol = ATA_PROT_NODATA;
+ tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+ err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
+ if (err_mask) {
+ rc = -EIO;
+ reason = "SPINUP failed";
+ goto err_out;
+ }
+ /*
+ * If the drive initially returned incomplete IDENTIFY info,
+ * we now must reissue the IDENTIFY command.
+ */
+ if (id[2] == 0x37c8)
+ goto retry;
+ }
+
if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
/*
* The exact sequence expected by certain pre-ATA4 drives is:
diff -u --recursive --new-file --exclude-from=linux-2.6.20//Documentation/dontdiff linux-2.6.20/include/linux/ata.h linux/include/linux/ata.h
--- linux-2.6.20/include/linux/ata.h 2007-02-04 13:44:54.000000000 -0500
+++ linux/include/linux/ata.h 2007-02-22 13:52:45.000000000 -0500
@@ -190,6 +190,8 @@
SETFEATURES_WC_ON = 0x02, /* Enable write cache */
SETFEATURES_WC_OFF = 0x82, /* Disable write cache */
+ SETFEATURES_SPINUP = 0x07, /* Spin-up drive */
+
/* ATAPI stuff */
ATAPI_PKT_DMA = (1 << 0),
ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] libata: Handle drives that require a spin-up command before first access
@ 2007-04-19 13:40 Mark Lord
2007-04-20 4:46 ` Tejun Heo
0 siblings, 1 reply; 5+ messages in thread
From: Mark Lord @ 2007-04-19 13:40 UTC (permalink / raw)
To: IDE/ATA development list, Jeff Garzik; +Cc: Tejun Heo, Alan Cox
I'm resending this now that reverse-DNS has been fixed on
our out-going mail server.
Jeff, this would be a very good thing to queue up for 2.6.22,
as otherwise drives become permanent paperweights when
the "power-up-in-standby" feature is turned on.
Cheers
-------- Original Message --------
Subject: [PATCH] libata: Handle drives that require a spin-up command before first access
Date: Tue, 17 Apr 2007 18:26:07 -0400
From: Mark Lord <liml@rtr.ca>
To: Jeff Garzik <jgarzik@pobox.com>, IDE/ATA development list <linux-ide@vger.kernel.org>
CC: Tejun Heo <htejun@gmail.com>, Alan Cox <alan@redhat.com>
(S)ATA drives can be configured for "power-up in standby",
a mode whereby a specific "spin up now!" command is required
before the first media access.
Currently, a drive with this feature enabled can not be used at all
with libata, and once in this mode, the drive becomes a doorstop.
The older drivers/ide subsystem at least enumerates the drive,
so that it can be woken up after the fact from a userspace HDIO_*
command, but not libata.
This patch adds support to libata for the "power-up in standby"
mode where a "spin up now!" command (SET_FEATURES) is needed.
With this, libata will recognize such drives, spin them up,
and then re-IDENTIFY them if necessary to get a full/complete
set of drive features data.
Drives in this state are determined by looking for
special values in id[2], as documented in the current ATA specs.
Signed-off-by: Mark Lord <mlord@pobox.com>
---
diff -u --recursive --new-file --exclude-from=linux-2.6.20//Documentation/dontdiff linux-2.6.20/drivers/ata/libata-core.c linux/drivers/ata/libata-core.c
--- linux-2.6.20/drivers/ata/libata-core.c 2007-02-04 13:44:54.000000000 -0500
+++ linux/drivers/ata/libata-core.c 2007-02-22 15:19:41.000000000 -0500
@@ -1453,6 +1453,7 @@
struct ata_taskfile tf;
unsigned int err_mask = 0;
const char *reason;
+ int tried_spinup = 0;
int rc;
if (ata_msg_ctl(ap))
@@ -1460,7 +1461,6 @@
__FUNCTION__, ap->id, dev->devno);
ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
-
retry:
ata_tf_init(dev, &tf);
@@ -1508,6 +1508,32 @@
goto err_out;
}
+ if (!tried_spinup && (id[2] == 0x37c8 || id[2] == 0x738c)) {
+ tried_spinup = 1;
+ /*
+ * Drive powered-up in standby mode, and requires a specific
+ * SET_FEATURES spin-up subcommand before it will accept
+ * anything other than the original IDENTIFY command.
+ */
+ ata_tf_init(dev, &tf);
+ tf.command = ATA_CMD_SET_FEATURES;
+ tf.feature = SETFEATURES_SPINUP;
+ tf.protocol = ATA_PROT_NODATA;
+ tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+ err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
+ if (err_mask) {
+ rc = -EIO;
+ reason = "SPINUP failed";
+ goto err_out;
+ }
+ /*
+ * If the drive initially returned incomplete IDENTIFY info,
+ * we now must reissue the IDENTIFY command.
+ */
+ if (id[2] == 0x37c8)
+ goto retry;
+ }
+
if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
/*
* The exact sequence expected by certain pre-ATA4 drives is:
diff -u --recursive --new-file --exclude-from=linux-2.6.20//Documentation/dontdiff linux-2.6.20/include/linux/ata.h linux/include/linux/ata.h
--- linux-2.6.20/include/linux/ata.h 2007-02-04 13:44:54.000000000 -0500
+++ linux/include/linux/ata.h 2007-02-22 13:52:45.000000000 -0500
@@ -190,6 +190,8 @@
SETFEATURES_WC_ON = 0x02, /* Enable write cache */
SETFEATURES_WC_OFF = 0x82, /* Disable write cache */
+ SETFEATURES_SPINUP = 0x07, /* Spin-up drive */
+
/* ATAPI stuff */
ATAPI_PKT_DMA = (1 << 0),
ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata: Handle drives that require a spin-up command before first access
2007-04-19 13:40 Mark Lord
@ 2007-04-20 4:46 ` Tejun Heo
0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2007-04-20 4:46 UTC (permalink / raw)
To: Mark Lord; +Cc: IDE/ATA development list, Jeff Garzik, Alan Cox
Mark Lord wrote:
> I'm resending this now that reverse-DNS has been fixed on
> our out-going mail server.
>
> Jeff, this would be a very good thing to queue up for 2.6.22,
> as otherwise drives become permanent paperweights when
> the "power-up-in-standby" feature is turned on.
>
> Cheers
>
>
> -------- Original Message --------
> Subject: [PATCH] libata: Handle drives that require a spin-up command
> before first access
> Date: Tue, 17 Apr 2007 18:26:07 -0400
> From: Mark Lord <liml@rtr.ca>
> To: Jeff Garzik <jgarzik@pobox.com>, IDE/ATA development list
> <linux-ide@vger.kernel.org>
> CC: Tejun Heo <htejun@gmail.com>, Alan Cox <alan@redhat.com>
>
>
> (S)ATA drives can be configured for "power-up in standby",
> a mode whereby a specific "spin up now!" command is required
> before the first media access.
>
> Currently, a drive with this feature enabled can not be used at all
> with libata, and once in this mode, the drive becomes a doorstop.
>
> The older drivers/ide subsystem at least enumerates the drive,
> so that it can be woken up after the fact from a userspace HDIO_*
> command, but not libata.
>
> This patch adds support to libata for the "power-up in standby"
> mode where a "spin up now!" command (SET_FEATURES) is needed.
> With this, libata will recognize such drives, spin them up,
> and then re-IDENTIFY them if necessary to get a full/complete
> set of drive features data.
>
> Drives in this state are determined by looking for
> special values in id[2], as documented in the current ATA specs.
>
> Signed-off-by: Mark Lord <mlord@pobox.com>
Acked-by: Tejun Heo <htejun@gmail.com>
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata: Handle drives that require a spin-up command before first access
2007-04-17 22:26 [PATCH] libata: Handle drives that require a spin-up command before first access Mark Lord
@ 2007-04-28 18:41 ` Jeff Garzik
2007-04-28 20:05 ` Mark Lord
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2007-04-28 18:41 UTC (permalink / raw)
To: Mark Lord; +Cc: IDE/ATA development list, Tejun Heo, Alan Cox
Mark Lord wrote:
>
> (S)ATA drives can be configured for "power-up in standby",
> a mode whereby a specific "spin up now!" command is required
> before the first media access.
>
> Currently, a drive with this feature enabled can not be used at all
> with libata, and once in this mode, the drive becomes a doorstop.
>
> The older drivers/ide subsystem at least enumerates the drive,
> so that it can be woken up after the fact from a userspace HDIO_*
> command, but not libata.
>
> This patch adds support to libata for the "power-up in standby"
> mode where a "spin up now!" command (SET_FEATURES) is needed.
> With this, libata will recognize such drives, spin them up,
> and then re-IDENTIFY them if necessary to get a full/complete
> set of drive features data.
>
> Drives in this state are determined by looking for
> special values in id[2], as documented in the current ATA specs.
>
> Signed-off-by: Mark Lord <mlord@pobox.com>
applied
though I'm curious where the verify step went, that was in the previous
rev of the patch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata: Handle drives that require a spin-up command before first access
2007-04-28 18:41 ` Jeff Garzik
@ 2007-04-28 20:05 ` Mark Lord
0 siblings, 0 replies; 5+ messages in thread
From: Mark Lord @ 2007-04-28 20:05 UTC (permalink / raw)
To: Jeff Garzik; +Cc: IDE/ATA development list, Tejun Heo, Alan Cox
Jeff Garzik wrote:
> Mark Lord wrote:
>
>> This patch adds support to libata for the "power-up in standby"
>> mode where a "spin up now!" command (SET_FEATURES) is needed.
>> With this, libata will recognize such drives, spin them up,
>> and then re-IDENTIFY them if necessary to get a full/complete
>> set of drive features data.
>>
>> Drives in this state are determined by looking for
>> special values in id[2], as documented in the current ATA specs.
>>
>> Signed-off-by: Mark Lord <mlord@pobox.com>
>
> applied
>
> though I'm curious where the verify step went, that was in the previous
> rev of the patch
Hi Jeff,
The difference between this patch and the first RFC version,
is that I've dropped the code that attempted to deal with
the *other* kind of power-up-in-standby that some drives use.
That form is enabled with a Jumper setting on the drive
(eg. WD 37GB Raptor drives) rather than through software,
and I was unable to figure out exactly what they wanted
while I still had them here to experiment on.
Those drives are no longer in my possession, so.. no support.
The majority of drives use the software enable/disable form,
which is (still) fully addressed by the patch you applied.
Thanks!
-ml
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-04-28 20:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-17 22:26 [PATCH] libata: Handle drives that require a spin-up command before first access Mark Lord
2007-04-28 18:41 ` Jeff Garzik
2007-04-28 20:05 ` Mark Lord
-- strict thread matches above, loose matches on Subject: below --
2007-04-19 13:40 Mark Lord
2007-04-20 4:46 ` Tejun Heo
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).