Skip to contentSkip to conversation

AHCI PCI ID for MacBook Pro

PATCH In review Root Kit 5 participants 18 messages Feb 8, 2007 – Feb 11, 2007 libata

lore
Share & tools
lore

Root Kit

author
#0 lore raw

PATCH 1/1 AHCI PCI ID for MacBook Pro

hi,
i have a MacBook pro and i noticed that linux (2.6.20)
binds the ata_piix driver
to the SATA controller.
being my SATA controller an AHCI (ICH7M) i added the PCI ID to ahci.c
then tested the system.
i inline the patch here:

--- linux-2.6.20/drivers/ata/ahci.c 2007-02-06
19:11:08.000000000 +0100
+++ linux-2.6.20/drivers/ata/ahci.c 2007-02-06
19:13:31.000000000 +0100
@@ -366,6 +366,7 @@
{ PCI_VDEVICE(INTEL, 0x27c1), board_ahci }, /* ICH7
*/
{ PCI_VDEVICE(INTEL, 0x27c5), board_ahci }, /* ICH7M
*/
{ PCI_VDEVICE(INTEL, 0x27c3), board_ahci }, /* ICH7R
*/
+ { PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M
*/
{ PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr },
/* ULi M5288 */
{ PCI_VDEVICE(INTEL, 0x2681), board_ahci }, /* ESB2
*/
{ PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2
*/

and i also done some benchmarks just to test if it is worth it:
http://teknoraver.campuslife.it/bench/ata_piix_vs_ahci.pdf

Best Regards,
Matteo Croce

___________________________________
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail:
http://it.docs.yahoo.com/nowyoucan.html

#1 lore raw
Quoted 9 lines · Root Kit

hi,
i have a MacBook pro and i noticed that linux (2.6.20)
binds the ata_piix driver
to the SATA controller.
being my SATA controller an AHCI (ICH7M) i added the PCI ID to ahci.c
then tested the system.
i inline the patch here:

Great. Care to post a proper patch with leading description and SOB? Please take a look at the following patch. You can omit diffstat result.

http://article.gmane.org/gmane.linux.ide/15855

Signature · 1 line
tejun
#2 lore raw

---

drivers/ata/ahci.c +1 -0
@@ -366,6 +366,7 @@
 	{ PCI_VDEVICE(INTEL, 0x27c1), board_ahci }, /* ICH7 */
 	{ PCI_VDEVICE(INTEL, 0x27c5), board_ahci }, /* ICH7M */
 	{ PCI_VDEVICE(INTEL, 0x27c3), board_ahci }, /* ICH7R */
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */
 	{ PCI_VDEVICE(AL, 0x5288), board_ahci_ign_iferr }, /* ULi M5288 */
 	{ PCI_VDEVICE(INTEL, 0x2681), board_ahci }, /* ESB2 */
 	{ PCI_VDEVICE(INTEL, 0x2682), board_ahci }, /* ESB2 */
#3 lore raw

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

- DML

#4 lore raw
Quoted 7 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

- DML

rejected? why?

#5 lore raw
Quoted 10 lines · Matteo Croce
Quoted 7 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

- DML

rejected? why?

Because 0x27C4 is not an AHCI controller.... at least, the one in my Dell laptop isn't.

- DML

#6 lore raw
Quoted 8 lines · On Friday 09 February 2007 19:15:40 you wrote:
Quoted 7 lines · Matteo Croce
Quoted 6 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

- DML

rejected? why?

Because 0x27C4 is not an AHCI controller.... at least, the one in my Dell laptop isn't.

- DML

if so, how could it works with my laptop?
i also have NCQ enabled...

#7 lore raw
In reply to David M. Lloyd
Quoted 8 lines · David M. Lloyd
Quoted 7 lines · Matteo Croce
Quoted 6 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

- DML

rejected? why?

Because 0x27C4 is not an AHCI controller.... at least, the one in my Dell laptop isn't.

David, could you please point us to the patch/thread where this has been discussed before ? Also as this is working nicely for me too, could you please try this again with 2.6.20, that is enable ahci *builtin* in your kernel config and apply Matteo's patch and post results ?

Thanks,
Soeren

Signature · 2 lines
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.
#8 lore raw
In reply to Matteo Croce
Quoted 7 lines · Matteo Croce
Quoted 4 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

rejected? why?

Ah... right.

All ICH7 R/M silicons can be put into either IDE or AHCI mode. Which mode is used is currently determined by BIOS. If BIOS puts the controller into ahci mode on boot, ahci is attached; otherwise, ata_piix. This sometimes reduces confusion level but more importantly in some cases it's not possible to use the other mode because PCI resource allocation is upto BIOS and it's not guaranteed to allocate all the needed resources for the mode not in use.

Till now, the policy to follow BIOS setting has worked well enough. Most desktop BIOSen give choice between the two modes anyway. There have been some cases where some desktops and many notebooks where the silicon itself is capable of ahci but BIOS doesn't allow it. It seems Mac is one of them.

Signature · 1 line
tejun
#9 lore raw
Quoted 7 lines · Tejun Heo
Quoted 6 lines · Matteo Croce
Quoted 4 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

Quoted 8 lines
Quoted 1 line

rejected? why?

Ah... right.

All ICH7 R/M silicons can be put into either IDE or AHCI mode. Which mode is used is currently determined by BIOS. If BIOS puts the controller into ahci mode on boot, ahci is attached; otherwise, ata_piix. This sometimes reduces confusion level but more importantly

So this means on macbook* one can use either mode ?!

Quoted 9 lines

in some cases it's not possible to use the other mode because PCI resource allocation is upto BIOS and it's not guaranteed to allocate all the needed resources for the mode not in use.

Till now, the policy to follow BIOS setting has worked well enough. Most desktop BIOSen give choice between the two modes anyway. There have been some cases where some desktops and many notebooks where the silicon itself is capable of ahci but BIOS doesn't allow it. It seems Mac is one of them.

I don't get it. Why is it rejected then ? If I'd like to use the ahci mode of the ich7 r/m driver I just compile it into the kernel, else the piix ?!

Soeren

Signature · 2 lines
For the one fact about the future of which we can be certain is that it
will be utterly fantastic. -- Arthur C. Clarke, 1962
#10 lore raw
Quoted 3 lines · Soeren Sonnenburg

I don't get it. Why is it rejected then ? If I'd like to use the ahci mode of the ich7 r/m driver I just compile it into the kernel, else the piix ?!

Well, it's probably okay if you know what you want but when ich's are present, most distributions choose to load both ahci and ata_piix while usually preferring ahci. That should generally work. If BIOS didn't set it up properly, ahci will fail to load then ata_piix is loaded instead. The thing is that BIOSen are weird and it's quite possible that switching to ahci mode might have other side effects. For one, ACPI methods could have been written assuming certain mode and suspend/resume might choke if the controller is put into different mode from what BIOS has configured.

Signature · 1 line
tejun
#11 lore raw
In reply to Tejun Heo
Quoted 7 lines · Tejun Heo
Quoted 6 lines · Matteo Croce
Quoted 4 lines · On Friday 09 February 2007 15:54:53 you wrote:

drivers/ata/ahci.c line 369

Quoted 1 line · Matteo Croce
drivers/ata/ahci.c +1 -0
+	{ PCI_VDEVICE(INTEL, 0x27c4), board_ahci }, /* ICH7M */

Wasn't this PCI ID proposed for addition a while ago, and subsequently rejected? Or am I missing something?

Quoted 5 lines
Quoted 1 line

rejected? why?

Ah... right.

All ICH7 R/M silicons can be put into either IDE or AHCI mode. <...>

I see... so probably my Dell laptop doesn't (and maybe can't) enable it, but Matteo's Macbook does. That makes sense...

- DML

#12 lore raw
In reply to Tejun Heo
Quoted 11 lines · Tejun Heo
Quoted 9 lines · Root Kit

hi,
i have a MacBook pro and i noticed that linux (2.6.20)
binds the ata_piix driver
to the SATA controller.
being my SATA controller an AHCI (ICH7M) i added the PCI ID to ahci.c
then tested the system.
i inline the patch here:

Quoted 2 lines

Great. Care to post a proper patch with leading description and SOB? Please take a look at the following patch. You can omit diffstat result.

Hmmhh I cannot really reproduce this benchmark. Matteo, with which benchmarking program did you produce this ?

Below is what I get when compiling shogun with make -j 4 (src from www.shogun-toolbox.org) and a bonnie++ run:

piix:

$ /usr/sbin/bonnie++ -d ./
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.03       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
no               4G 23865  57 24221   6 11588   2 26972  60 27942   2  88.5   0
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
no,4G,23865,57,24221,6,11588,2,26972,60,27942,2,88.5,0,16,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++
$ time make -j4
real    2m40.799s
user    4m9.374s
sys     0m8.719s

ahci:

$ /usr/sbin/bonnie++ -d ./
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.03       ------Sequential Output------ --Sequential Input- --Random-
                    -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
no               4G 20872  48 29348   7 11642   2 28080  60 27293   2 126.5   0
                    ------Sequential Create------ --------Random Create--------
                    -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++
no,4G,20872,48,29348,7,11642,2,28080,60,27293,2,126.5,0,16,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++
$ time make -j4
real    2m33.293s
user    4m1.954s
sys     0m8.533s
Signature · 2 lines
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.
#13 lore raw
Quoted 77 lines · On Friday 09 February 2007 16:45:49 you wrote:
Quoted 11 lines · Tejun Heo
Quoted 9 lines · Root Kit

hi,
i have a MacBook pro and i noticed that linux (2.6.20)
binds the ata_piix driver
to the SATA controller.
being my SATA controller an AHCI (ICH7M) i added the PCI ID to ahci.c
then tested the system.
i inline the patch here:

Quoted 2 lines

Great. Care to post a proper patch with leading description and SOB? Please take a look at the following patch. You can omit diffstat result.

Hmmhh I cannot really reproduce this benchmark. Matteo, with which benchmarking program did you produce this ?

Below is what I get when compiling shogun with make -j 4 (src from www.shogun-toolbox.org) and a bonnie++ run:

piix:

$ /usr/sbin/bonnie++ -d ./
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.03       ------Sequential Output------ --Sequential Input-
--Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec
%CP no               4G 23865  57 24221   6 11588   2 26972  60 27942   2 
88.5   0 ------Sequential Create------ --------Random Create--------
-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files  /sec %CP
 /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP 16 +++++ +++ +++++ +++
+++++ +++ +++++ +++ +++++ +++ +++++ +++
no,4G,23865,57,24221,6,11588,2,26972,60,27942,2,88.5,0,16,+++++,+++,+++++,+
++,+++++,+++,+++++,+++,+++++,+++,+++++,+++
$ time make -j4
real    2m40.799s
user    4m9.374s
sys     0m8.719s

ahci:

$ /usr/sbin/bonnie++ -d ./
Writing with putc()...done
Writing intelligently...done
Rewriting...done
Reading with getc()...done
Reading intelligently...done
start 'em...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version  1.03       ------Sequential Output------ --Sequential Input-
--Random- -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec
%CP no               4G 20872  48 29348   7 11642   2 28080  60 27293   2
126.5   0 ------Sequential Create------ --------Random Create--------
-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files  /sec %CP
 /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP 16 +++++ +++ +++++ +++
+++++ +++ +++++ +++ +++++ +++ +++++ +++
no,4G,20872,48,29348,7,11642,2,28080,60,27293,2,126.5,0,16,+++++,+++,+++++,
+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++
Quoted 4 lines
$ time make -j4
real    2m33.293s
user    4m1.954s
sys     0m8.533s

bonnie++ from ubuntu repos

#14 lore raw
Quoted 8 lines · Matteo Croce
Quoted 6 lines · On Friday 09 February 2007 16:45:49 you wrote:
Quoted 1 line · Tejun Heo

Root Kit wrote:

[...]
Hmmhh I cannot really reproduce this benchmark. Matteo, with which benchmarking program did you produce this ?
[...]

bonnie++ from ubuntu repos

OK, I reran bonnie++ -d /tmp/ on a unencrypted partition - results are here http://nn7.de/bench/ahci.html . Looks like it is slightly faster for sequential block write (2MB/s faster) and sequential read using putc() (1MB/s faster), though putc() is slowed down by 6MB/s.

However what may make it worth is that I don't see any errors on suspend/resume anymore...

Soeren

Signature · 2 lines
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.
#15 lore raw
Quoted 8 lines · Soeren Sonnenburg
Quoted 7 lines · Matteo Croce
Quoted 6 lines · On Friday 09 February 2007 16:45:49 you wrote:
Quoted 1 line · Tejun Heo

Root Kit wrote:

[...]
Hmmhh I cannot really reproduce this benchmark. Matteo, with which benchmarking program did you produce this ?
[...]

Quoted 6 lines
Quoted 1 line

bonnie++ from ubuntu repos

OK, I reran bonnie++ -d /tmp/ on a unencrypted partition - results are here http://nn7.de/bench/ahci.html . Looks like it is slightly faster for sequential block write (2MB/s faster) and sequential read using putc() (1MB/s faster), though putc() is slowed down by 6MB/s.

I suspect the difference is caused by either the io scheduler in use or disk drive itself.

Quoted 2 lines

However what may make it worth is that I don't see any errors on suspend/resume anymore...

Hmm... So, ata_piix fails to suspend/resume properly on your machine? It should work. Can you describe how it fails?

Signature · 1 line
tejun
#16 lore raw
Quoted 11 lines · Tejun Heo
Quoted 10 lines · Soeren Sonnenburg
Quoted 8 lines · Matteo Croce
Quoted 6 lines · On Friday 09 February 2007 16:45:49 you wrote:
Quoted 1 line · Tejun Heo

Root Kit wrote:

[...]
Hmmhh I cannot really reproduce this benchmark. Matteo, with which benchmarking program did you produce this ?
[...]

bonnie++ from ubuntu repos

Quoted 7 lines
Quoted 4 lines

OK, I reran bonnie++ -d /tmp/ on a unencrypted partition - results are here http://nn7.de/bench/ahci.html . Looks like it is slightly faster for sequential block write (2MB/s faster) and sequential read using putc() (1MB/s faster), though putc() is slowed down by 6MB/s.

I suspect the difference is caused by either the io scheduler in use or disk drive itself.

well I am doing both benchmarks on a macbookpro1,1 -> 32bit mode (matteo does it on a macbook pro2, sth so he has a c2d and does it in 64bit -> amd64 mode).

So the io scheduler is the same or do you mean inside of ahci/piix ?

Quoted 5 lines
Quoted 2 lines

However what may make it worth is that I don't see any errors on suspend/resume anymore...

Hmm... So, ata_piix fails to suspend/resume properly on your machine? It should work. Can you describe how it fails?

Well I keep seeing this:

ata3.01: revalidation failed (errno=-2)
ata3: failed to recover some devices, retrying in 5 secs
ATA: abnormal status 0x7F on port 0x40DF
ATA: abnormal status 0x7F on port 0x40DF ata3.01: configured for UDMA/133

but I am still on 2.6.20-rc6 ... so sorry if this is now fixed in .20.

Soeren.

Signature · 2 lines
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.
#17 lore raw
Quoted 5 lines · Soeren Sonnenburg

well I am doing both benchmarks on a macbookpro1,1 -> 32bit mode (matteo does it on a macbook pro2, sth so he has a c2d and does it in 64bit -> amd64 mode).

So the io scheduler is the same or do you mean inside of ahci/piix ?

I meant the iosched (cfq/as/deadline...).

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

However what may make it worth is that I don't see any errors on suspend/resume anymore...

Hmm... So, ata_piix fails to suspend/resume properly on your machine? It should work. Can you describe how it fails?

Well I keep seeing this:

Quoted 7 lines

ata3.01: revalidation failed (errno=-2)
ata3: failed to recover some devices, retrying in 5 secs
ATA: abnormal status 0x7F on port 0x40DF
ATA: abnormal status 0x7F on port 0x40DF ata3.01: configured for UDMA/133

but I am still on 2.6.20-rc6 ... so sorry if this is now fixed in .20.

Yeap, please give a shot at 2.6.20. Maybe the TF clearing for IDENTIFY fixed the problem.

Thanks.

Signature · 1 line
tejun