AHCI mode not restored during sleep-wakeup cycle

Bug #817017 reported by Bernhard Froemel
120
This bug affects 32 people
Affects Status Importance Assigned to Milestone
Mactel Support
In Progress
Undecided
Bernhard Froemel

Bug Description

The SATA controller operates by default in IDE mode and there is no known EFI setting to override this behavior. Fortunately, it can be put into AHCI mode before the Linux kernel is booted (e.g. by Grub2 *) ).
SSD disks perform much better in AHCI mode. On my laptop, both Intel SSD 320 and a Cruzial RealSSD C300 performed great in the beginning, but system responsiveness degraded soon to a point where system load was around 6 to 7 during updates (apt-get dist-upgrade) and second long freezes during normal work (e.g. browsing, responding to emails, heck - even when using vim in a terminal! ...).

Unfortunately there is a drawback when putting the SATA controller into AHCI mode: AHCI is not restored during sleep-wakeup cycles and thus the system crashes badly after wakeup, because it suddently finds only an IDE controller.
We need to patch (e.g. the SATA driver?) and check which mode the controller had been in, before the laptop was sent to sleep and restore the previous mode.

*) How to put the SATA controller into AHCI mode [1]:
MBP 6,2 (or any other 5 series/3400 series chipset based MBP)
put this line before 'set root=...':
setpci -d 8086:3b28 90.b=60
(that command sets bit 5 and 6 on register 0x90 -- lookup Intel document number 322169 for details)

[1] http://en.gentoo-wiki.com/wiki/Apple_Macbook_Pro

Tags: ahci ide mbp62 ssd
Revision history for this message
Greg White (gwhite-kupulau) wrote :

I have kernel patches which handle this - I added a quirk to put it into AHCI mode, then requirk on resume.

This required a somewhat scary patch to pci_driver.c, to make sure that quirks were fired *before* device initialization to work right.

Revision history for this message
Bernhard Froemel (froemel) wrote :

Great!
Could you please post your patch or link to it?

Revision history for this message
Greg White (gwhite-kupulau) wrote :
Download full text (3.4 KiB)

This is in drivers/pci/quirks.c. Note that to activate it, you use mbp_force_ahci=1 on the kernel command line. Also note that, IIRC, earlier MBP's required a 0x40 instead of a 0x60 written to config word 0x90.

static bool mbp_force_ahci;
module_param(mbp_force_ahci, bool, 0444);
MODULE_PARM_DESC(mbp_force_ahci, "AHCI mode for MacBook Pro");

static bool quirk_mbp_sata_dev(struct pci_dev *pdev)
{
 printk(KERN_INFO "Quirking ahci device %04x:%04x\n", pdev->vendor, pdev->device);
 pci_write_config_word(pdev, 0x90, 0x60); /* AHCI - 6 ports enabled */
 pdev->class = PCI_CLASS_STORAGE_SATA_AHCI;
 // pci_write_config_dword(pdev, 0x9c, 0);
 pci_write_config_byte(pdev, PCI_CLASS_PROG, 0x01);
 pci_write_config_byte(pdev, PCI_CLASS_DEVICE, 0x06);
   /* The PCI device ID will have been changed */
 pci_read_config_word(pdev, PCI_DEVICE_ID, &pdev->device);
 printk(KERN_DEBUG "ICH AHCI quirk: SATA AHCI controller has device ID %04x:%04x\n", pdev->vendor, pdev->device);
 return false;
}

static void quirk_mbp_sata(struct pci_dev *pdev)
{
 int ret = 0;

 if (!mbp_force_ahci)
  return;

 if (quirk_mbp_sata_dev(pdev))
  return; /* nothing to do */

 /* Try to allocate the resource on BAR 5.
  * If we have a bad alignment, don't even try,
  * thus neatly avoiding a scary warning.
  */
 if (pci_resource_alignment(pdev, &pdev->resource[5]))
  ret = pci_assign_resource(pdev, 5);
 if (!ret) {
  printk (KERN_INFO "Quirked ICH SATA controller to AHCI mode\n");
  return;
 }
 mbp_force_ahci = 0;
 printk (KERN_ERR "MBP ICH AHCI quirk: pci_assign_resource returned %d\n", ret);
}

/* On resume, the device will have been reset to IDE mode, so we need to re-quirk */
static void quirk_mbp_sata_resume(struct pci_dev *pdev)
{
 if (mbp_force_ahci && !quirk_mbp_sata_dev(pdev)) {
  pci_update_resource(pdev, 5);
  printk (KERN_INFO "Re-quirked ICH SATA controller to AHCI mode\n");
 }
}

DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3b28, quirk_mbp_sata); /* MacBook Pro (6,1) force AHCI */
DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 0x3b29, quirk_mbp_sata_resume); /* MacBook Pro (6,1) force AHCI on resume. Note that the original quirk will have changed the device ID */

DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3b20, quirk_mbp_sata); /* iMac 11,1 force AHCI */
DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 0x3b22, quirk_mbp_sata_resume); /* iMac 11,1 force AHCI on resume. Note that the original quirk will have changed the device ID */

DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1c01, quirk_mbp_sata); /* iMac 8,1 force AHCI */
DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 0x1c03, quirk_mbp_sata_resume); /* iMac 8,1 force AHCI on resume. Note that the original quirk will have changed the device ID */

--------------------------------------------------------------------------------------------------------------------------------- CUT HERE ---------...

Read more...

Revision history for this message
Bernhard Froemel (froemel) wrote :

Thanks!
> And this is in drivers/pci/pci-driver.c. Note that I have swapped the fixup and resume.
> [...]
I see your reservation concerning the changes here... we are not going to get that upstream: there could be side-effects with other quirks.

I have a different suggestion which is hooked in a little bit earlier, but does not require changes in pci-driver.c: instead of starting to handle the "wrong" device and change it into the "correct" one, this patch will put the SATA controller into the desired mode *before* the PCI subsystem sees it.
My patch uses a kernel command parameter too, but also registers the mode of the SATA device controller during startup (e.g. if someone has set it into AHCI via grub2). Resume should be handled correctly in any case (see the comments for details).

I put this yesterday in place and tested it a few times: seems to work fine for me. It should be easy to handle the other devices for iMac 8,1 and 11,1 too - for now I tested only my MBP 6,2.
Note that the patch is nearly upstream-ready, but I want to test it a few weeks/months before actual submission.

> IIRC, earlier MBP's required a 0x40 instead of a 0x60 written to config word 0x90.
That's chipset specific. I guess 0x60 will not harm where previously 0x40 "was required" (of course it's best to look it up in the datasheets). Bit 6 is the important part (AHCI mode) - bit 5 (6 SATA ports instead of 2 on controller 1) is a suggestion from the Intel 5 series datasheet and may be reserved/unused in previous chipsets.

Changed in mactel-support:
assignee: nobody → Bernhard Froemel (froemel)
status: New → In Progress
Revision history for this message
Daniel Graziotin (dgraziotin) wrote :

I am about to install Ubuntu 11.10 beta 1 on my Macbook Pro 6,2 with a Crucial C300 ssd.

I am confortable on applying patches on vanilla kernels to be used in distributions such as Slackware, but not on Ubuntu kernels (and generate the corresponding .deb files).

Can anybody please mail me with detailed instructions on how to apply this two patches (the attached one and the posted one) against the kernel sources and successfully generate and boot the kernel in Ubuntu?

I may try it either on the stable 11.04 release or the 11.10 beta 1 (which I've already downloaded). Any suggestions on which one to pick?

I may obviously report bugs and perform some tests for you!

Best Regards

Revision history for this message
Daniel Graziotin (dgraziotin) wrote :

I think I managed to got it working:

dmesg|grep -i ahci
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-2.6.38.8-dg root=UUID=a62afe8f-9e3c-445c-bfdb-4e1c1bc82232 ro crashkernel=384M-2G:64M,2G-:128M i5s_3400s_force_ahci=1 quiet splash vt.handoff=7
[ 0.671966] [i5s_3400s ** FIXUP] SATA controller mode: NON AHCI (0x3c00)
[ 0.671967] [i5s_3400s ** FIXUP] Putting SATA controller into AHCI (0x3c60)
[ 1.294111] ahci 0000:00:1f.2: version 3.0
[ 1.294138] ahci 0000:00:1f.2: PCI INT B -> GSI 19 (level, low) -> IRQ 19
[ 1.294198] ahci 0000:00:1f.2: irq 41 for MSI/MSI-X
[ 1.294271] ahci 0000:00:1f.2: AHCI 0001.0300 32 slots 4 ports 3 Gbps 0x3 impl SATA mode
[ 1.294275] ahci 0000:00:1f.2: flags: 64bit ncq sntf pm led clo pio slum part ems apst
[ 1.294280] ahci 0000:00:1f.2: setting latency timer to 64
[ 1.300513] scsi0 : ahci
[ 1.300650] scsi1 : ahci
[ 1.300730] scsi2 : ahci
[ 1.300801] scsi3 : ahci

Can you confirm is using AHCI? Suspend works.

Revision history for this message
Bernhard Froemel (froemel) wrote :

> Can anybody please mail me with detailed instructions on how to
> apply this two patches (the attached one and the posted one)
Please only apply one of the patches (either Greg's or mine).
Concerning compiling & packaging:
https://help.ubuntu.com/community/Kernel/Compile

> [ 0.671966] [i5s_3400s ** FIXUP] SATA controller mode: NON AHCI (0x3c00)
> [ 0.671967] [i5s_3400s ** FIXUP] Putting SATA controller into AHCI (0x3c60)
Yes looking good. Note that there was an issue with my patch:
http://ns.spinics.net/lists/linux-ide/msg41438.html (see the whole thread).

The issue should not be a problem as long as you use AHCI (but will probably result in a crash if you use IDE and do a standby/resume cycle).

I'll update the patch here. Unfortunately, people on the linux-ide list don't seem too happy about the patch, although there are no other requests to revise it.

> Can you confirm is using AHCI? Suspend works.
Yes, the controller is in AHCI mode now. You can easily confirm by:
# lspci | grep AHCI

Revision history for this message
Bernhard Froemel (froemel) wrote :

Revised patch.

Revision history for this message
Daniel Graziotin (dgraziotin) wrote :

Thank you very much for your answer. I also confirm that the new patch works like a charm on 11.10 beta 1, kernel 3.0.4

Revision history for this message
Anders Rønningen (andersronningen) wrote :

Patch still working like a charm for you guys? I'm also keen to try this out. Do anyone care to post the instructions on how to patch and apply this to the kernel on 11.10? Something like this?

apt-get install linux-source
<patch>
<compile>
put in /boot alongside the other kernels (or overwrite?)
repeat every time the kernel is updated.

Revision history for this message
Daniel Graziotin (dgraziotin) wrote :

Here is a very well-written step-by-step guide on re-compling Ubuntu Kernel: http://task3.cc/322/easy-tutorial-for-re-compiling-and-installing-the-ubuntu-kernel/

Revision history for this message
Bernhard Froemel (froemel) wrote :

First: maybe it would be good if other people generate some heat on this thread:
http://ns.spinics.net/lists/linux-ide/threads.html#41438
and ask what's missing to get that into the kernel. As soon as it's 'in' (and I am not implying that it must be my particular patch, but any patch that enables the missing functionality), we don't need to manually patch anymore ;)

> Do anyone care to post the instructions on how to patch and apply this to the kernel on 11.10?
Usually this is just a (but proceed with care - just wrote this out of my head):
sudo -s # obtain root, beware!
apt-get install linux-source kernel-package
cd /usr/src/<linux-src>/
cp /boot/config-<your current kernel config> ./.config
make oldconfig
cat /tmp/i5s_3400s_ahci_handling_for_incapable_efi.patch | patch -p1
make-kpkg --initrd --append-to-version c1 kernel_image

(that append-to-version stuff is just useful to easier distinguish the kernel from other (default distribution) kernels).

After make-kpkg finishes, the linux-image-*.deb is ready in the parent directory and can be installed by dpkg -i <deb file>.

More deatils: https://help.ubuntu.com/community/Kernel/Compile

Revision history for this message
Tomodachi (tomodachi) wrote :

why just not boot your computers into efi mode?
then the controller is in AHCI mode by default

mamo@xerxes:/etc/apt$ dmesg |grep AHCI
[ 1.324986] ahci 0000:00:0b.0: AHCI 0001.0200 32 slots 6 ports 3 Gbps 0x3 impl SATA mode

Revision history for this message
Bernhard Froemel (froemel) wrote :

@Tomodachi: What model do you have? I use a MBP 6,2 and there pure EFI has problems on Linux: At least one year ago, there was no drivers from Nvidia that supported the graphics adapter on systems in EFI mode.. although it *seems* to be only a small problem: http://www.nvnews.net/vbulletin/showthread.php?t=162330

Revision history for this message
Alex Murray (alexmurray) wrote :

@Bernhard - actually the problem is that on the MBP5x, 6,x and 7,x the backlight is controlled via the gmux so a new driver is needed - I've updated the existing apple-bl driver to support this and it is available in my ppa https://launchpad.net/~alexmurray/+archive/ppa if you wish to try it - simply add my ppa and install the apple-bl-dkms package and let me know if it works for you - if so I will try and get this work upstreamed into the linux kernel itself so it is available in future kernel versions by default.

Revision history for this message
Anders Rønningen (andersronningen) wrote :

Does all of this put together mean that if we run in efi mode and have the latest apple-bl driver from alexmurray things should work well (including suspend/wakeup)?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

@Anders: I don't think so, I have a MBP 8,1 and booting in EFI (with grub2-efi) does not help me to get AHCI mode on, I can force it using the 'setpci' on grub (actually I have a script that puts it on every linux entry everytime I do a update-grub). Unfortunately, after suspend, it still goes back to ata mode (actually, I'm not sure what happens, the rootfilesystem simply becomes unaccessible, but I guess that's what's happening). I've disabled AHCI for now (or rather, haven't enabled it), but I do hope the patch gets merged into mainline kernel.

PS.: I'm running precise x64

Revision history for this message
Bernhard Froemel (froemel) wrote :

Sorry for getting back to this so late.

@Alex: works great. I am using EFI mode and mainly the Intel graphics adapter on my MBP6,2 for about 3 months now.

@Anders: at least for 6,x MBPs.

@Pedro: thats bad -- seems like earlier firmware/models default to AHCI when booted in pure EFI and newer don't. To confirm this, could you please verify that you're really in pure EFI mode?
e.g.: load efivars (modprobe efivars) and look for /sys/firmware/efi/vars/
or look for EFI range messages in your kernel log (dmesg):
> NX (Execute Disable) protection: active
> EFI v1.10 by Apple
> ACPI=0x8b70e000 ACPI 2.0=0x8b70e014 SMBIOS=0x8b674000
> Kernel-defined memdesc doesn't match the one from EFI!
> EFI: mem00: type=7, attr=0xf, range=[0x0000000000000000-0x000000000008e000) (0MB)
> EFI: mem01: type=0, attr=0xf, range=[0x000000000008e000-0x000000000008f000) (0MB)
> EFI: mem02: type=10, attr=0xf, range=[0x000000000008f000-0x0000000000090000) (0MB)
> ...

> but I do hope the patch gets merged into mainline kernel.
My hopes aren't too high. I haven't heard anything from the maintainer and that usually means: no, sorry.

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

@Bernard: After I load the efivars module (which gives no erros), then I do a "$lsmod | grep efivars", but get nothing. Also I can't find the /sys/firmware/efi folder. "dmesg | tail" gives me nothing special either. Weird, I just assumed since I was using grub-efi, I would be in EFI mode. Any idea what I might be doing wrong? (I'm using refit and grub-efi-amd64)

About the patch, seems pretty straight-forwards. Just adds a booting parameter. Even though it's a "dirty fix", seems reasonable to me to add it.

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

@Bernard: You were right, I was not in EFI mode. I've followed http://www.rodsbooks.com/ubuntu-efi/index.html and http://mennucc1.debian.net/macbook_linux_efi.html . Now I can suspend and get AHCI mode back after suspend. Do you know how I could make it so that update-grub updates /efi/EFI/grub/grub.efi instead of /boot/grub/grub.cfg?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

I've checked what does update-grub do, and it's just a bash script that calls grub-mkconfig. So I guess I'll just modify update-grub to change the folder.

Revision history for this message
analogue (analogue-yahoo) wrote :

Have any of the patches that fix this made it upstream yet?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

Hey Analogue,
The easiest way to solve this is to install grub-efi instead of grub-pc. There is a bunch of stuff about efi that I don't understand very well, but my advice is:
-Use Disk Utility to partition your drive (apparently OSX doesn't like other OSes touching the partition tables)
-Install Ubuntu using grub-efi option. If you are doing this on top of a existing Ubuntu installation, mount the EFI partition to /boot/efi and install grub-efi.
-When booted through EFI, the system will automatically use AHCI.

If you don't want to use EFI, I think there's no solution for it.

Revision history for this message
analogue (analogue-yahoo) wrote :

Pedro,

I'm using refit (http://refit.sourceforge.net/). Any idea if this works with grub-efi?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote : Re: [Bug 817017] Re: AHCI mode not restored during sleep-wakeup cycle

Yes,

I originally used refit as well. It has one problem. It will not detect
grub-efi as Linux, it will only show a diamond shaped symbol indicating it
as a EFI bootloader.
I currently use refind (http://www.rodsbooks.com/refind/), it is great! :D
You should check it out.
(Sometimes Grub might set itself to be run before refind/refit. In this
case, you can boot in OSX and "bless" it (just as if you were installing
refit again).

Pedro Nariyoshi

On Wed, Jan 30, 2013 at 1:08 PM, analogue <email address hidden> wrote:

> Pedro,
>
> I'm using refit (http://refit.sourceforge.net/). Any idea if this works
> with grub-efi?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/817017
>
> Title:
> AHCI mode not restored during sleep-wakeup cycle
>
> Status in Mactel Support:
> In Progress
>
> Bug description:
> The SATA controller operates by default in IDE mode and there is no
> known EFI setting to override this behavior. Fortunately, it can be put
> into AHCI mode before the Linux kernel is booted (e.g. by Grub2 *) ).
> SSD disks perform much better in AHCI mode. On my laptop, both Intel SSD
> 320 and a Cruzial RealSSD C300 performed great in the beginning, but system
> responsiveness degraded soon to a point where system load was around 6 to 7
> during updates (apt-get dist-upgrade) and second long freezes during normal
> work (e.g. browsing, responding to emails, heck - even when using vim in a
> terminal! ...).
>
> Unfortunately there is a drawback when putting the SATA controller into
> AHCI mode: AHCI is not restored during sleep-wakeup cycles and thus the
> system crashes badly after wakeup, because it suddently finds only an IDE
> controller.
> We need to patch (e.g. the SATA driver?) and check which mode the
> controller had been in, before the laptop was sent to sleep and restore the
> previous mode.
>
> *) How to put the SATA controller into AHCI mode [1]:
> MBP 6,2 (or any other 5 series/3400 series chipset based MBP)
> put this line before 'set root=...':
> setpci -d 8086:3b28 90.b=60
> (that command sets bit 5 and 6 on register 0x90 -- lookup Intel document
> number 322169 for details)
>
> [1] http://en.gentoo-wiki.com/wiki/Apple_Macbook_Pro
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mactel-support/+bug/817017/+subscriptions
>

Revision history for this message
Adam Dingle (adam-yorba) wrote :

Pedro, you wrote

> Install Ubuntu using grub-efi option. If you are doing this on top of a existing Ubuntu installation, mount the EFI partition to /boot/efi and install grub-efi.

Could you explain in a little more detail how to do this, or point to a Web page that explains how?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

Sure, I can't point out to a single website since I found out about this more or less by trial and error. The ArchWiki is a good source however.

First, I mounted my efi partition at /boot/efi. This can be achieved my using a line like this on /etc/fstab:
UUID=70D6-1701 /boot/efi vfat defaults 0 0
(substitute 70D6-1701 with the UUID of your efi partition, you can check it with "sudo blkid | grep EFI" )
(If you want to just mount it once, you can run "sudo mount /dev/sdXX /boot/efi", where /dev/sdXX is your efi partition)

Then I installed grub-efi:
sudo apt-get install grub-efi
(it will install the necessary efi components such as efibootmgr)

I think this will already install grub-efi to your drive, but if you want to make sure do a:
sudo grub-install /dev/sda

(warning, this will set grub as the primary boot option, if you have refit or refind installed, they will not run as default, to run them you'll have to hold the right-hand "alt-option" key during boot)

Revision history for this message
Adam Dingle (adam-yorba) wrote :

Pedro, thanks a lot for the additional info. I do have rEFInd installed and I like it. Is it not possible to use grub-efi and also have rEFInd run as default?

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

Yes, it is. But you will have to "rebless" it. (Set it as default, otherwise, it will still be installed, but grub will load automatically instead)

To do this, boot on OSX and set refind as default again. I usually run the install.sh script after that, but you can try something like:
sudo bless --setBoot --folder /efi/refind --file /efi/refind/refind_x64.efi
(More info here: http://www.rodsbooks.com/refind/installing.html)

Revision history for this message
Adam Dingle (adam-yorba) wrote :

Pedro, thanks again for this helpful information.

The good news: I was able to get my machine (a MacBookPro9,1) to boot using EFI. Rather than modifying an existing install, I simply reinstalled Ubuntu using the 64-bit non-Mac live image, which is able to set up an EFI install. (rEFInd can boot this image.)

The bad news: Resuming is still not working. When I attempt to resume from suspend after an EFI boot I do see my desktop background, so I believe that AHCI mode is active, but the system is unresponsive. I filed a separate bug for this at bug #1186818.

Revision history for this message
Phil Colbourn (philcolbourn) wrote :

Is this already fixed in 3.8.0-25 (and possibly earlier versions)?

I have a macbookpro2,1 and macbookpro4,1 and once AHCI mode is enabled I can sleep/resume fine - so far.

I enable AHCI mode using setpci -s 0:1f.2 90.b=40 in grub or via a patched MBR called patchedcode.bin (some say to use 60 but I now think that 40 is correct value based on Intel ICH7/8 datasheets).

http://www.intel.com.au/content/dam/doc/datasheet/intel-io-controller-hub-8-datasheet.pdf page 486.

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

What does "dmesg | grep ahci" show?

I don't know about using BIOS and then using setpci anymore, but it might
be fixed. I guess the only ones who can really tell are the guys who
published this patch over here.

Pedro Nariyoshi

On Sat, Jun 15, 2013 at 9:19 AM, Phil Colbourn <email address hidden>wrote:

> Is this already fixed in 3.8.0-25 (and possibly earlier versions)?
>
> I have a macbookpro2,1 and macbookpro4,1 and once AHCI mode is enabled I
> can sleep/resume fine - so far.
>
> I enable AHCI mode using setpci -s 0:1f.2 90.b=40 in grub or via a
> patched MBR called patchedcode.bin (some say to use 60 but I now think
> that 40 is correct value based on Intel ICH7/8 datasheets).
>
> http://www.intel.com.au/content/dam/doc/datasheet/intel-io-controller-
> hub-8-datasheet.pdf page 486.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/817017
>
> Title:
> AHCI mode not restored during sleep-wakeup cycle
>
> Status in Mactel Support:
> In Progress
>
> Bug description:
> The SATA controller operates by default in IDE mode and there is no
> known EFI setting to override this behavior. Fortunately, it can be put
> into AHCI mode before the Linux kernel is booted (e.g. by Grub2 *) ).
> SSD disks perform much better in AHCI mode. On my laptop, both Intel SSD
> 320 and a Cruzial RealSSD C300 performed great in the beginning, but system
> responsiveness degraded soon to a point where system load was around 6 to 7
> during updates (apt-get dist-upgrade) and second long freezes during normal
> work (e.g. browsing, responding to emails, heck - even when using vim in a
> terminal! ...).
>
> Unfortunately there is a drawback when putting the SATA controller into
> AHCI mode: AHCI is not restored during sleep-wakeup cycles and thus the
> system crashes badly after wakeup, because it suddently finds only an IDE
> controller.
> We need to patch (e.g. the SATA driver?) and check which mode the
> controller had been in, before the laptop was sent to sleep and restore the
> previous mode.
>
> *) How to put the SATA controller into AHCI mode [1]:
> MBP 6,2 (or any other 5 series/3400 series chipset based MBP)
> put this line before 'set root=...':
> setpci -d 8086:3b28 90.b=60
> (that command sets bit 5 and 6 on register 0x90 -- lookup Intel document
> number 322169 for details)
>
> [1] http://en.gentoo-wiki.com/wiki/Apple_Macbook_Pro
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/mactel-support/+bug/817017/+subscriptions
>

Revision history for this message
Phil Colbourn (philcolbourn) wrote :

$ dmesg | grep -i ahci
[ 3.446820] ahci 0000:00:1f.2: version 3.0
[ 3.446834] ahci 0000:00:1f.2: enabling device (0005 -> 0007)
[ 3.446910] ahci 0000:00:1f.2: irq 45 for MSI/MSI-X
[ 3.446973] ahci: SSS flag set, parallel bus scan disabled
[ 3.447007] ahci 0000:00:1f.2: AHCI 0001.0100 32 slots 4 ports 1.5 Gbps 0x4 impl SATA mode
[ 3.447012] ahci 0000:00:1f.2: flags: 64bit ncq ilck stag pm led clo pio slum part
[ 3.447018] ahci 0000:00:1f.2: setting latency timer to 64
[ 3.451086] scsi2 : ahci
[ 3.454794] scsi3 : ahci
[ 3.479022] scsi4 : ahci
[ 3.481944] scsi5 : ahci
[ 124.425204] ahci 0000:00:1f.2: setting latency timer to 64

Revision history for this message
Pedro Nariyoshi (pedro-nariyoshi) wrote :

Interesting. Although I'm pretty happy with grub-efi :P
Feels safer and more elegant than setting pci parameters directly :9

Should we mark it as fixed?

Revision history for this message
Dominik (dominalien) wrote :

This is definitely not fixed. I wish I could run the MBP 6,2 with EFI, but then the proprietary driver for the nvidia card doesn't work, so that's not an option (I play games).

I just tested again (seeing what Phil wrote in #31 above), booting with the setpci option and after resuming the computer spat out a ton of ATA errors and froze. Ubuntu 14.04, 3.13 kernel.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.