Skip to contentSkip to conversation

ahci, SActive flag, and the HD activity LED

PATCH Applied Martin Wilck 8 participants 13 messages Aug 2, 2005 – Aug 26, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello Jeff, hello Jens, hello everybody,

I am referring to the debate about whether or not setting the SActive bit for non-NCQ ATA commands (e.g. http://lkml.org/lkml/2005/5/26/142).

In our machines, this behavior of the Linux AHCI driver causes the HD activity LED to stay on all the time. If I apply the attached trivial patch (this is for the RedHat EL4.0-U1 kernel), the LED behaves nicely.

Jeff has stated in the above thread that "SActive is intentionally used for non-NCQ devices". However I find clear indication in the specs that the SActive flag should be set if and only if tagged queuing is being used, and only for a specified subset of commands that support queuing (http://www.t13.org/docs2005/D1699r1e-ATA8-ACS.pdf, secs. 4.19 and 4.20). The current mainline driver doesn't use queuing.

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit. Could you please comment? Jeff, in particular, could you please give more detail why you say this flag is "intentionally used"?

Regards
Martin

Signature · 4 lines
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1        mailto:[email protected]
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy
ahci.c renamed from ahci.c.orig +0 -3
@@ -691,9 +703,6 @@
 	struct ata_port *ap = qc->ap;
 	void *port_mmio = (void *) ap->ioaddr.cmd_addr;
 
-	writel(1, port_mmio + PORT_SCR_ACT);
-	readl(port_mmio + PORT_SCR_ACT);	/* flush */
-
 	writel(1, port_mmio + PORT_CMD_ISSUE);
 	readl(port_mmio + PORT_CMD_ISSUE);	/* flush */
 
#1 lore raw
Quoted 16 lines · Martin Wilck

Hello Jeff, hello Jens, hello everybody,

I am referring to the debate about whether or not setting the SActive bit for non-NCQ ATA commands (e.g. http://lkml.org/lkml/2005/5/26/142).

In our machines, this behavior of the Linux AHCI driver causes the HD activity LED to stay on all the time. If I apply the attached trivial patch (this is for the RedHat EL4.0-U1 kernel), the LED behaves nicely.

Jeff has stated in the above thread that "SActive is intentionally used for non-NCQ devices". However I find clear indication in the specs that the SActive flag should be set if and only if tagged queuing is being used, and only for a specified subset of commands that support queuing
(http://www.t13.org/docs2005/D1699r1e-ATA8-ACS.pdf, secs. 4.19 and 4.20). The current mainline driver doesn't use queuing.

Quoted 4 lines

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit. Could you please comment? Jeff, in particular, could you please give more detail why you say this flag is "intentionally used"?

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 4 lines · Jens Axboe
Quoted 1 line

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

Regards
Martin

Signature · 4 lines
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1        mailto:[email protected]
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy
#3 lore raw
Quoted 10 lines · Martin Wilck
Quoted 5 lines · Jens Axboe
Quoted 2 lines

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

No, but I have observed that SActive never gets cleared by the device for non-NCQ commands (which is probably which gets you the stuck LED on some systems?), which to me is another indication that we should not be setting the tag bits for those commands.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 8 lines · Jens Axboe
Quoted 2 lines · Martin Wilck

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

No, but I have observed that SActive never gets cleared by the device for non-NCQ commands (which is probably which gets you the stuck LED on some systems?), which to me is another indication that we should not be setting the tag bits for those commands.

The drives won't send a SetBits FIS when not using NCQ, as it can really confuse some host adapters that don't understand NCQ. I'd imagine you're correct that the driver shouldn't be setting the bit in the first place.

--eric

#5 lore raw
In reply to Martin Wilck
Quoted 11 lines · Martin Wilck
Quoted 5 lines · Jens Axboe
Quoted 2 lines

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

I have a box with ICH6R and AHCI in use with Linux 2.6.11, using seagate NCQ sata drives. the HD activity LED is on all the time..

- Pasi Kärkkäinen

                                   ^
                                .     .
                                 Linux
                              /    -    \
                             Choice.of.the
                           .Next.Generation.
#6 lore raw
In reply to Martin Wilck
Quoted 10 lines · Martin Wilck
Quoted 5 lines · Jens Axboe
Quoted 1 line

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

I have, Asus P5LD2 i945P, ICH7R AHCI controller, Hitachi Deskstar T7K250 250GB "SATA2" drives. Kernel 2.6.12.x

#7 lore raw
In reply to Martin Wilck
Quoted 10 lines · Martin Wilck
Quoted 5 lines · Jens Axboe
Quoted 2 lines

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

Yes, Dell Precision 380, ICH7R AHCI controller, SATA non-NCQ Western Digital drive.

Adam

#8 lore raw

PATCH 1/1 Fix HD activity LED with ahci

All right,

this looks like a pretty broad agreement on this issue. Jeff, would you please apply this patch?

Regards,
Martin

Patch: fix wrong HD activity control by ahci driver

Signed-off-by [email protected]

The ahci driver 1.0 sets the SActive bit on every transaction, causing the LED to light up. The SActive bit is used only for native command queuing (NCQ) which the current driver version doesn't implement. Resetting the SActive bit is the device's responsibility (by sending a "Set Device Bits FIS" to the host adapter) but this is not required in response to non-NCQ commands, and (most) devices don't. Thus the LED stays always on. This patch fixes the LED behavior.

Spec references:
http://www.intel.com/technology/serialata/pdf/rev1_1.pdf, sec. 3.3.13, 5.5.1
http://www.serialata.org/docs/serialata10a.pdf
http://www.intel.com/design/storage/papers/25266401.pdf

drivers/scsi/ahci.c renamed from drivers/scsi/ahci.c.orig +0 -3
@@ -696,9 +696,6 @@ static int ahci_qc_issue(struct ata_queu
 	struct ata_port *ap = qc->ap;
 	void *port_mmio = (void *) ap->ioaddr.cmd_addr;
 
-	writel(1, port_mmio + PORT_SCR_ACT);
-	readl(port_mmio + PORT_SCR_ACT);	/* flush */
-
 	writel(1, port_mmio + PORT_CMD_ISSUE);
 	readl(port_mmio + PORT_CMD_ISSUE);	/* flush */
 
#9 lore raw

Re: [PATCH] Fix HD activity LED with ahci

Quoted 28 lines · Martin Wilck

All right,

this looks like a pretty broad agreement on this issue. Jeff, would you please apply this patch?

Regards,
Martin

------------------------------------------------------------------------

Patch: fix wrong HD activity control by ahci driver

Signed-off-by [email protected]

The ahci driver 1.0 sets the SActive bit on every transaction,
causing the LED to light up. The SActive bit is used only for
native command queuing (NCQ) which the current driver version doesn't implement. Resetting the SActive bit is the device's responsibility (by sending a "Set Device Bits FIS" to the host adapter) but this is not required in response to non-NCQ commands, and (most) devices don't. Thus the LED stays always on. This patch fixes the LED behavior.

Spec references:
http://www.intel.com/technology/serialata/pdf/rev1_1.pdf, sec. 3.3.13, 5.5.1
http://www.serialata.org/docs/serialata10a.pdf
http://www.intel.com/design/storage/papers/25266401.pdf

drivers/scsi/ahci.c static int ahci_qc_issue(struct ata_queu · line 700

Quoted 8 lines
drivers/scsi/ahci.c renamed from drivers/scsi/ahci.c.orig +0 -3
@@ -696,9 +696,6 @@ static int ahci_qc_issue(struct ata_queu
 	struct ata_port *ap = qc->ap;
 	void *port_mmio = (void *) ap->ioaddr.cmd_addr;
 
-	writel(1, port_mmio + PORT_SCR_ACT);
-	readl(port_mmio + PORT_SCR_ACT);	/* flush */
-
 	writel(1, port_mmio + PORT_CMD_ISSUE);
 	readl(port_mmio + PORT_CMD_ISSUE);	/* flush */

To answer the question everybody was asking, this line was in the code because it was in the patch that got AHCI working.

I'm inclined to apply the above patch, but I'll wait until 2.6.13, so that we can get some decent testing.

Jeff

#10 lore raw

Re: [PATCH] Fix HD activity LED with ahci

Quoted 3 lines · Jeff Garzik

To answer the question everybody was asking, this line was in the code because it was in the patch that got AHCI working.

I'm inclined to apply the above patch, but I'll wait until 2.6.13, so that we can get some decent testing.

Great. As far as the testing is concerned, we have had no problems with the patch here.

Thanks, Martin

Signature · 4 lines
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1        mailto:[email protected]
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy
#12 lore raw
In reply to Martin Wilck
Quoted 9 lines · Martin Wilck
Quoted 5 lines · Jens Axboe
Quoted 1 line

If I am reading the specs correctly, that'd mean the ahci driver is wrong in setting the SActive bit.

I completely agree, that was my reading of the spec as well and hence my original posts about this in the NCQ thread.

Have you (or has anybody else) also seen the wrong behavior of the activity LED?

925X-Chipset
Lspci says: 8086:2652
Intel Corp. 82801FR/FRW (ICH6R/ICH6RW) SATA Controller (rev 03) HDD:
Western Digital WD2000JD-00H, i believe this HDD is non-NCQ.

Kernels: 2.6.10 - 2.6.12
The Activity-LED has burned like a light-bulb every since i have that computer. (Excluding the few seconds before booting Linux. :-) )

Bis denn

Signature · 4 lines
Real Programmers consider "what you see is what you get" to be just as
bad a concept in Text Editors as it is in women. No, the Real Programmer
wants a "you asked for it, you got it" text editor -- complicated,
cryptic, powerful, unforgiving, dangerous.