Not in fact any relation to the famous large Greek meal of the same name.

Wednesday, 6 October 2010

Quirking a Mac Pro into AHCI mode

The Apple Mac Pro (2006 model) has an Intel ESB2 south-bridge, which includes the SATA controller. Under MacOS, this SATA controller is driven in AHCI mode, which is a great improvement on the “traditional IDE” mode — for one thing, it enables “NCQ” SCSI-like command queueing. But the pseudo-BIOS that boots non-MacOS operating systems on Intel Macs, forces the chip into traditional-IDE mode. This is certainly a good idea for wide compatibility, but for an OS which has AHCI drivers — such as Linux — it’d be good to force it back again.

Instructions do exist for forcing it back again using a hacked Grub bootloader, but for one thing that’s a hack, and for another I don’t use Grub, I use Lilo. The “right” way (well, other than convincing Apple to put an AHCI mode into their pseudo-BIOS) is to use Linux’s “PCI quirk” infrastructure. This patch (against 2.6.35.6, but similar should apply almost anywhere) gives me toasty AHCI goodness under Linux:

--- drivers/pci/quirks.c~ 2010-09-27 01:19:16.000000000 +0100
+++ drivers/pci/quirks.c 2010-10-06 20:29:04.000000000 +0100
@@ -1044,6 +1044,15 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDO
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
 
+static void __devinit quirk_intel_esb2_ahci(struct pci_dev *pdev)
+{
+    pci_write_config_byte(pdev, 0x90, 0x40);
+    pdev->class = PCI_CLASS_STORAGE_SATA_AHCI;
+    dev_info(&pdev->dev, "Intel ESB2 AHCI enabled\n");
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2680, quirk_intel_esb2_ahci);
+
 /*
  * Serverworks CSB5 IDE does not fully support native mode
  */
And here it is in my dmesg:
pci 0000:00:1f.2: Intel ESB2 AHCI enabled
ahci 0000:00:1f.2: flags: 64bit ncq pm led slum part 
ata1.00: 488397168 sectors, multi 16: LBA48 NCQ (depth 31/32)

All six SATA ports (four for the drive carriers, two by the optical drives) are seen by the ahci driver (which I have built-in to the kernel); loading the ata_piix driver as a module also enables the PATA port by the optical drives. (It's probably not a good idea to compile both ahci and ata_piix into the kernel, in case they fight over the ESB2 controller.)

Job’s a good ’un.

No comments:

Post a Comment

About Me

Cambridge, United Kingdom
Waits for audience applause ... not a sossinge.
CC0 To the extent possible under law, the author of this work has waived all copyright and related or neighboring rights to this work.