2009-04-30 02:07:48

by Theodore Ts'o

[permalink] [raw]
Subject: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

I was taking a look at why I can't get NCQ working on the Ultrabay drive
on the X61s Thinkpad (which is a big deal if you're using the X25-M
SSD):

[ 4563.614247] ata4.00: 390721968 sectors, multi 16: LBA48 NCQ (depth 0/32)
^^^^^^^

which as near as I can tell is because ATA_FLAG_NCQ isn't set in struct
ata_port->flag. This looks like it should be set to ata_piix.c if the
controller supports NCQ --- but ata_piix.c doesn't set ATA_FLAG_NCQ at
all. However, this web page:

http://www.intel.com/support/chipsets/imst/sb/CS-012304.htm

Seems to imply the 82801HBM/HEM SATA controller from the ICH8M/ICHM8-E
supports AHCI and NCQ, and this is the controller which is in the X61s
laptop.

So I wonder if it's safe to simply add ATA_FLAG_NCQ to ata_piix.c or
not? Can someone who's more familiar with Intel's ICH8 SATA controller
comment on whether this would be a safe thing to do?

Thanks,

- Ted


2009-04-30 02:19:59

by Tejun Heo

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

Hello,

Theodore Ts'o wrote:
> [ 4563.614247] ata4.00: 390721968 sectors, multi 16: LBA48 NCQ (depth 0/32)
>
> which as near as I can tell is because ATA_FLAG_NCQ isn't set in struct
> ata_port->flag. This looks like it should be set to ata_piix.c if the
> controller supports NCQ --- but ata_piix.c doesn't set ATA_FLAG_NCQ at
> all. However, this web page:
>
> http://www.intel.com/support/chipsets/imst/sb/CS-012304.htm
>
> Seems to imply the 82801HBM/HEM SATA controller from the ICH8M/ICHM8-E
> supports AHCI and NCQ, and this is the controller which is in the X61s
> laptop.

The controller can be drive in two different modes - piix and ahci.
In piix mode, it behaves like good old IDE controller from 15 years
back and can't do NCQ. Looks like your controller is in piix mode.

> So I wonder if it's safe to simply add ATA_FLAG_NCQ to ata_piix.c or
> not? Can someone who's more familiar with Intel's ICH8 SATA controller
> comment on whether this would be a safe thing to do?

Oh... please don't that. It won't work. On ICHs, whether the
controller is put in piix or ahci mode is determined by the BIOS.
Most desktop BIOSen have option to put the controller in different
modes but most laptops don't seem to have such option.

Thanks.

--
tejun

2009-04-30 02:28:00

by Jeff Garzik

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

Theodore Ts'o wrote:

(you should cc linux-ide...)

> [ 4563.614247] ata4.00: 390721968 sectors, multi 16: LBA48 NCQ (depth 0/32)
> ^^^^^^^

That generally means your disk is capable of NCQ, but your controller is
not.

As Tejun noted, try switching to AHCI mode in BIOS.

Jeff


2009-04-30 07:34:39

by Alex Buell

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Wed, 29 Apr 2009 22:27:46 -0400, I waved a wand and this message
magically appears in front of Jeff Garzik:

> As Tejun noted, try switching to AHCI mode in BIOS.

But is there a way to switch modes without needing to go through the
BIOS? Some laptops won't let you do that through BIOS.
--
http://www.munted.org.uk

Fearsome grindings.

2009-04-30 07:46:48

by Tejun Heo

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

Alex Buell wrote:
> On Wed, 29 Apr 2009 22:27:46 -0400, I waved a wand and this message
> magically appears in front of Jeff Garzik:
>
>> As Tejun noted, try switching to AHCI mode in BIOS.
>
> But is there a way to switch modes without needing to go through the
> BIOS? Some laptops won't let you do that through BIOS.

There is and it isn't too difficult either in itself but the problem
is that for ahci mode to work the ABAR (PCI BAR 5) needs to be
allocated and enabled. On x86, the kernel takes the PCI resources
allocated by BIOS. Doing it directly isn't necessarily difficult but
is too dangerous as there can be areas which aren't described anywhere
but still are used by something.

Because ICHs don't enable ABAR in piix mode unless SCRAE is set and
most BIOSen don't set SCRAE, ABAR don't get allocated nor its space
get reserved in most cases if the controller is in piix mode.

So, at the point of driver load, there just isn't much we can do about
the missing ABAR. It's sad. Dunno why some laptop manufacturers
still program the thing into piix mode. :-(

Thanks.

--
tejun

2009-04-30 11:35:32

by Theodore Ts'o

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, Apr 30, 2009 at 08:33:09AM +0100, Alex Buell wrote:
> On Wed, 29 Apr 2009 22:27:46 -0400, I waved a wand and this message
> magically appears in front of Jeff Garzik:
>
> > As Tejun noted, try switching to AHCI mode in BIOS.
>
> But is there a way to switch modes without needing to go through the
> BIOS? Some laptops won't let you do that through BIOS.

The BIOS setting already is in AHCI mode, and not in "compatibility
mode". This is with BIOS version 2.19 on the X61s. I can check to
see if there is a newer BIOS revision... hmm, there is a 2.20, but it
claims the only thing it fixes is:

- Fixed an issue where the AMT menu of BIOS Setup Utility might not be
displayed.

I can try upgrading to it and see if it's any better. Or maybe
someone on the Linux-thinkpad mailing list with contacts inside Lenovo
can bug them. Sounds like there's no way to work around this except
for a BIOS-level fix then? :-(

- Ted

2009-04-30 11:38:38

by Theodore Ts'o

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, Apr 30, 2009 at 07:34:45AM -0400, Theodore Tso wrote:
> On Thu, Apr 30, 2009 at 08:33:09AM +0100, Alex Buell wrote:
> > On Wed, 29 Apr 2009 22:27:46 -0400, I waved a wand and this message
> > magically appears in front of Jeff Garzik:
> >
> > > As Tejun noted, try switching to AHCI mode in BIOS.
> >
> > But is there a way to switch modes without needing to go through the
> > BIOS? Some laptops won't let you do that through BIOS.
>
> The BIOS setting already is in AHCI mode, and not in "compatibility
> mode".

Thinking about this a bit more, I'll bet the problem is the BIOS
setting is only affecting the primary SATA ports (which are being
grabed by ahci) and not the SATA port in the Ultrabay slot (which is
being picked up by either the ata_piix or piix driver). Sigh...

- Ted

2009-04-30 13:48:30

by Alan

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

> So, at the point of driver load, there just isn't much we can do about
> the missing ABAR. It's sad. Dunno why some laptop manufacturers
> still program the thing into piix mode. :-(

Forcing out of PIIX mode would need to go into the PCI quirks and be a
boot option not a module one - at that point its doable as a header quirk.

2009-04-30 15:35:47

by Matthew Wilcox

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, Apr 30, 2009 at 02:47:02PM +0100, Alan Cox wrote:
> > So, at the point of driver load, there just isn't much we can do about
> > the missing ABAR. It's sad. Dunno why some laptop manufacturers
> > still program the thing into piix mode. :-(
>
> Forcing out of PIIX mode would need to go into the PCI quirks and be a
> boot option not a module one - at that point its doable as a header quirk.

I think Matthew Garrett already has code to do this.

Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, 30 Apr 2009, Theodore Tso wrote:
> I can try upgrading to it and see if it's any better. Or maybe
> someone on the Linux-thinkpad mailing list with contacts inside Lenovo
> can bug them. Sounds like there's no way to work around this except
> for a BIOS-level fix then? :-(

Either me or Thomas Renninger can get in touch with Lenovo, yes. As usual,
I need a self-contained, precise report of what is wrong, why it is wrong,
and what should be done to fix it, so that I can forward it.

--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh

2009-04-30 15:56:29

by Matthew Garrett

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, Apr 30, 2009 at 08:35:08AM -0700, Matthew Wilcox wrote:
> On Thu, Apr 30, 2009 at 02:47:02PM +0100, Alan Cox wrote:
> > > So, at the point of driver load, there just isn't much we can do about
> > > the missing ABAR. It's sad. Dunno why some laptop manufacturers
> > > still program the thing into piix mode. :-(
> >
> > Forcing out of PIIX mode would need to go into the PCI quirks and be a
> > boot option not a module one - at that point its doable as a header quirk.
>
> I think Matthew Garrett already has code to do this.

Yeah, but some testers reported that it broke after using it for a
while. The most recent version I have is this:

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index a807797..9e7b460 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -893,6 +893,52 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);

+static void __devinit quirk_ahci_sata(struct pci_dev *pdev)
+{
+ u32 sir, newval;
+ u16 mode;
+
+ /* Make sure we're in AHCI mode */
+ pci_read_config_word(pdev, 0x90, &mode);
+ pci_write_config_word(pdev, 0x90, 0x40);
+
+ /* Need to set the SCRAE bit */
+ pci_read_config_dword(pdev, 0x94, &sir);
+ newval = (sir | 0x200);
+ pci_write_config_dword(pdev, 0x94, newval);
+
+ /* Set PCI_CLASS_STORAGE_SATA */
+ if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
+ pci_write_config_byte(pdev, PCI_CLASS_PROG, 0x01);
+ pci_write_config_byte(pdev, PCI_CLASS_DEVICE, 0x06);
+ pdev->class = PCI_CLASS_STORAGE_SATA_AHCI;
+ }
+
+ pci_read_config_word(pdev, PCI_DEVICE_ID, &pdev->device);
+ pci_assign_resource(pdev, 5);
+
+ printk (KERN_INFO "Quirked PIIX device to AHCI mode\n");
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2652, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2653, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2680, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x27c4, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2828, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2928, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x292d, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x292e, quirk_ahci_sata);
+
+#if 0
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2651, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x27c0, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2820, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2825, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2920, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2921, quirk_ahci_sata);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2926, quirk_ahci_sata);
+#endif
+
/*
* Serverworks CSB5 IDE does not fully support native mode
*/

--
Matthew Garrett | [email protected]

2009-05-01 01:49:33

by Robert Hancock

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

Matthew Garrett wrote:
> On Thu, Apr 30, 2009 at 08:35:08AM -0700, Matthew Wilcox wrote:
>> On Thu, Apr 30, 2009 at 02:47:02PM +0100, Alan Cox wrote:
>>>> So, at the point of driver load, there just isn't much we can do about
>>>> the missing ABAR. It's sad. Dunno why some laptop manufacturers
>>>> still program the thing into piix mode. :-(
>>> Forcing out of PIIX mode would need to go into the PCI quirks and be a
>>> boot option not a module one - at that point its doable as a header quirk.
>> I think Matthew Garrett already has code to do this.
>
> Yeah, but some testers reported that it broke after using it for a
> while. The most recent version I have is this:

We should likely have something like this in the kernel, but it should
default to off. For one thing, some machines seem to have BIOS code that
tries to poke the controller for some reason during suspend/shutdown
events, etc. which would likely go nuts if the controller was
unexpectedly in AHCI mode..

>
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index a807797..9e7b460 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -893,6 +893,52 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk
> DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
> DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
>
> +static void __devinit quirk_ahci_sata(struct pci_dev *pdev)
> +{
> + u32 sir, newval;
> + u16 mode;
> +
> + /* Make sure we're in AHCI mode */
> + pci_read_config_word(pdev, 0x90, &mode);
> + pci_write_config_word(pdev, 0x90, 0x40);
> +
> + /* Need to set the SCRAE bit */
> + pci_read_config_dword(pdev, 0x94, &sir);
> + newval = (sir | 0x200);
> + pci_write_config_dword(pdev, 0x94, newval);
> +
> + /* Set PCI_CLASS_STORAGE_SATA */
> + if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE) {
> + pci_write_config_byte(pdev, PCI_CLASS_PROG, 0x01);
> + pci_write_config_byte(pdev, PCI_CLASS_DEVICE, 0x06);
> + pdev->class = PCI_CLASS_STORAGE_SATA_AHCI;
> + }
> +
> + pci_read_config_word(pdev, PCI_DEVICE_ID, &pdev->device);
> + pci_assign_resource(pdev, 5);
> +
> + printk (KERN_INFO "Quirked PIIX device to AHCI mode\n");
> +}
> +
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2652, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2653, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2680, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x27c4, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2828, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2928, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x292d, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x292e, quirk_ahci_sata);
> +
> +#if 0
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2651, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x27c0, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2820, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2825, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2920, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2921, quirk_ahci_sata);
> +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2926, quirk_ahci_sata);
> +#endif
> +
> /*
> * Serverworks CSB5 IDE does not fully support native mode
> */
>

2009-05-01 01:51:45

by Robert Hancock

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

Theodore Tso wrote:
> On Thu, Apr 30, 2009 at 07:34:45AM -0400, Theodore Tso wrote:
>> On Thu, Apr 30, 2009 at 08:33:09AM +0100, Alex Buell wrote:
>>> On Wed, 29 Apr 2009 22:27:46 -0400, I waved a wand and this message
>>> magically appears in front of Jeff Garzik:
>>>
>>>> As Tejun noted, try switching to AHCI mode in BIOS.
>>> But is there a way to switch modes without needing to go through the
>>> BIOS? Some laptops won't let you do that through BIOS.
>> The BIOS setting already is in AHCI mode, and not in "compatibility
>> mode".
>
> Thinking about this a bit more, I'll bet the problem is the BIOS
> setting is only affecting the primary SATA ports (which are being
> grabed by ahci) and not the SATA port in the Ultrabay slot (which is
> being picked up by either the ata_piix or piix driver). Sigh...

dmesg and lspci -vv output might be useful..

2009-05-01 02:52:10

by Theodore Ts'o

[permalink] [raw]
Subject: Re: No NCQ support on X61s Ultrabay? (Intel ICH8 SATA controller question)

On Thu, Apr 30, 2009 at 07:51:28PM -0600, Robert Hancock wrote:
>> Thinking about this a bit more, I'll bet the problem is the BIOS
>> setting is only affecting the primary SATA ports (which are being
>> grabed by ahci) and not the SATA port in the Ultrabay slot (which is
>> being picked up by either the ata_piix or piix driver). Sigh...
>
> dmesg and lspci -vv output might be useful..

Here you go...



Attachments:
(No filename) (408.00 B)
dmesg (46.13 kB)
lspci (12.27 kB)
Download all attachments