[ltp] Speeding up UltraBay PATA HDs tremendously

Henrique de Moraes Holschuh linux-thinkpad@linux-thinkpad.org
Tue, 15 Jan 2008 17:59:04 -0200


--Qxx1br4bt0+wmkIi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Well, to get to the point: Some (all?) IBM ThinkPads with a PATA UltraBay
can do UDMA/100 easily, but some (all?), like the T43, don't report this to
the kernel, so they were being limited to ATA/33 on the Ultrabay PATA port.

The attached patch fixes it for the T43 26xx.  I tested it, and a UltraBay
HDD went to ATA/100 happily, and after some 50GB of data reading and
writing, the kernel didn't complain of a single UDMA CRC error.

I was about to send it upstream, but decided it was best to check if someone
could test other thinkpads to cram as many as we can in a single patch.

BTW: Windows somehow knows this, and sets the drive to UDMA/100.

How to test (with T43 examples, other models will have different output):

0. Check if the kernel is limiting the interface to UDMA/33 or not in
   the first place :-)

   #grep "40-wire" /var/log/dmesg   (or dmesg | grep "40-wire", etc).
   ata2.00: limited to UDMA/33 due to 40-wire cable

   Oops, it is limiting the speed indeed... let's fix that :-)

   PS: 2.6.23 kernel, libata driver.  I suppose you could also use
   hdparm to check the level of UDMA that is active on the drive.

1. Use lspci to locate the IDE interface (note: could be a SATA chip
   that has PATA ports, like the ICH5, ICH6, ICH7...):

   #lspci
   [...]
   00:1f.2 IDE interface: Intel Corporation 82801FBM (ICH6M) SATA
   Controller (rev 03)
   [...]

   You could also look at the kernel initialization logs to figure
   out what is the PCI device:
   [    3.038758] ata_piix 0000:00:1f.2: version 2.12
   [    3.038763] ata_piix 0000:00:1f.2: MAP [ P0 P2 IDE IDE ]

   (the second line is quite clear if you know how to decipher it:
   there are two SATA and two PATA ports on that PCI device
   (0000:00:1f.2)).

   If AHCI is enabled (hacked T43 kernel, T60), the above will
   change a little.

2. Find out the PCI device id, subsystem vendor and id for the device
driving the IDE ports on the UltraBay:

   #lspci -nv
   [...]
   00:1f.2 0101: 8086:2653 (rev 03) (prog-if 80 [Master])
           Subsystem: 1014:056a
   [...]

   The device id is the number right before the revision (2653).
   The subsystem vendor is the first number after subsystem,
   and the id is the second one.

3. Edit the patch, and add the three numbers instead of the
   ones for the T43:

   { 0x2653, 0x1014, 0x056a },   /* T43 */

   The first is the pci device id. The second is the vendor id
   (normalyy 0x1014 for IBM, or something else for Lenovo).
   The third is the subsystem id.

4. compile the patched kernel, install, etc.

5. reboot with new kernel.

6. You should now have UDMA/100 (on ICH5, ICH6, ICH7, ICH8) or
   maybe a bit slower (but at least UDMA/66) on older ICHs, on
   all PATA ports.

   #dmesg | grep "configured for"
   ata1.00: configured for UDMA/100
   ata2.00: configured for UDMA/100   (Yeah!)

7. *TEST* *IT*.  "dd if=/dev/<ultrabay drive> of=/dev/null bs=1M" should do
   it.  Look for any CRC errors in the kernel log.

8. If it worked and didn't cause CRC errors, please drop me a note with the
   information (the IDs, and thinkpad model).  I will add it to the patch
   before I send it upstream.

A quick look on photos of thinkpad mainboards tell me all of the T4x are
extremely likely to work on UDMA/100.  I find it likely that the R5x would,
as well.

I will wait a bit for replies before sending the patch upstream.

-- 
  "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

--Qxx1br4bt0+wmkIi
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0001-ata_piix-add-IBM-ThinkPad-T43-to-short-cable-list.patch"

>From af039b458a3eaa52c01ab61035f1fe702890c2ba Mon Sep 17 00:00:00 2001
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Date: Tue, 15 Jan 2008 16:48:31 -0200
Subject: [PATCH] ata_piix: add IBM ThinkPad T43 to short cable list

IBM ThinkPad T4x series have the UltraBay (PATA) connectors so close to the
ICH that it is not even funny (due to thermal concerns).  As a result, the
UltraBay PATA port can work at 80-wire cable speeds without problems.

A T43 2687 test system worked wonderfully at ATA/100 (UDMA5), with
absolutely no CRC errors after a test run of 50GiB of reads and writes, so
add it to the whitelist.

Probably every other IBM ThinkPad T4x (and every thinkpad of that era...)
could also be whitelisted, but since I do not have them on hand to test,
nor the IDs for the whitelist, they will have to wait for another day.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
---
 drivers/ata/ata_piix.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index b406b39..e147306 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -700,6 +700,7 @@ static const struct ich_laptop ich_laptop[] = {
 	{ 0x27DF, 0x1043, 0x1267 },	/* ICH7 on Asus W5F */
 	{ 0x27DF, 0x103C, 0x30A1 },	/* ICH7 on HP Compaq nc2400 */
 	{ 0x24CA, 0x1025, 0x0061 },	/* ICH4 on ACER Aspire 2023WLMi */
+	{ 0x2653, 0x1014, 0x056a },	/* ICH6M on IBM ThinkPad T43 bay */
 	/* end marker */
 	{ 0, }
 };
-- 
1.5.3.7


--Qxx1br4bt0+wmkIi--