Patchwork IDE cable detection on Apple PowerBook

login
register
mail settings
Submitter TOMARI Hisanobu
Date March 18, 2009, 5:06 a.m.
Message ID <20090318140638.e6b61eaa.posco.grubb@gmail.com>
Download mbox | patch
Permalink /patch/24616/
State Superseded
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

TOMARI Hisanobu - March 18, 2009, 5:06 a.m.
Hello,

I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
The IDE drive fails to recognize 80-conductor cable that
connects the drive to motherboard to fall back to UDMA33.

This patch fixes this behavior by assuming that the cable is
short-40pin when the model string matches "PowerBook5" and 
the motherboard detects 80c cable.

This patch is against drivers/ide/pmac.c in linux 2.6.28.8.

(before applying the patch) hdparm -i /dev/hda
/dev/hda:
 Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
(dmesg 2.6.26)
ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
Probing IDE interface ide0...
hda: CORE_PATA, ATA DISK drive
hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
hda: UDMA/33 mode selected

(after applying the patch) hdparm -i /dev/hda
/dev/hda:
 Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
(dmesg 2.6.28.8)
ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
Probing IDE interface ide0...
hda: CORE_PATA, ATA DISK drive
hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
hda: UDMA/100 mode selected
ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
Benjamin Herrenschmidt - March 18, 2009, 7:58 a.m.
On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
> Hello,
> 
> I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
> The IDE drive fails to recognize 80-conductor cable that
> connects the drive to motherboard to fall back to UDMA33.
> 
> This patch fixes this behavior by assuming that the cable is
> short-40pin when the model string matches "PowerBook5" and 
> the motherboard detects 80c cable.
> 
> This patch is against drivers/ide/pmac.c in linux 2.6.28.8.

The patch is too much of an ad-hoc hack... _maybe_ an option is to make
the core fallback to 40 "short" when 80 pin detection fails on
powerbooks instead ?

Ben.

> (before applying the patch) hdparm -i /dev/hda
> /dev/hda:
>  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
> (dmesg 2.6.26)
> ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
> Probing IDE interface ide0...
> hda: CORE_PATA, ATA DISK drive
> hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
> hda: UDMA/33 mode selected
> 
> (after applying the patch) hdparm -i /dev/hda
> /dev/hda:
>  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
> (dmesg 2.6.28.8)
> ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
> Probing IDE interface ide0...
> hda: CORE_PATA, ATA DISK drive
> hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> hda: UDMA/100 mode selected
> ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
TOMARI Hisanobu - March 18, 2009, 1:47 p.m.
I thought the short-40pin assumption would cause no problem
considering all models beginning with "PowerBook5" are laptops.
Do you mean an option to toggle this hack on/off should be present 
in Kconfig?

Thanks,
TOMARI Hisanobu

On Wed, 18 Mar 2009 18:58:17 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
> > Hello,
> > 
> > I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
> > The IDE drive fails to recognize 80-conductor cable that
> > connects the drive to motherboard to fall back to UDMA33.
> > 
> > This patch fixes this behavior by assuming that the cable is
> > short-40pin when the model string matches "PowerBook5" and 
> > the motherboard detects 80c cable.
> > 
> > This patch is against drivers/ide/pmac.c in linux 2.6.28.8.
> 
> The patch is too much of an ad-hoc hack... _maybe_ an option is to make
> the core fallback to 40 "short" when 80 pin detection fails on
> powerbooks instead ?
> 
> Ben.
> 
> > (before applying the patch) hdparm -i /dev/hda
> > /dev/hda:
> >  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
> > (dmesg 2.6.26)
> > ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
> > Probing IDE interface ide0...
> > hda: CORE_PATA, ATA DISK drive
> > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
> > hda: UDMA/33 mode selected
> > 
> > (after applying the patch) hdparm -i /dev/hda
> > /dev/hda:
> >  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
> > (dmesg 2.6.28.8)
> > ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
> > Probing IDE interface ide0...
> > hda: CORE_PATA, ATA DISK drive
> > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > hda: UDMA/100 mode selected
> > ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
> > 
> > 
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@ozlabs.org
> > https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
Benjamin Herrenschmidt - March 19, 2009, 6:07 a.m.
On Wed, 2009-03-18 at 22:47 +0900, TOMARI Hisanobu wrote:
> I thought the short-40pin assumption would cause no problem
> considering all models beginning with "PowerBook5" are laptops.
> Do you mean an option to toggle this hack on/off should be present 
> in Kconfig?

Actually, it makes -some- amount of sense to do it by testing
specifically for the prefix "PowerBook" and "iBook" without a specific
number I suppose.

Ben.

> Thanks,
> TOMARI Hisanobu
> 
> On Wed, 18 Mar 2009 18:58:17 +1100
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> 
> > On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
> > > Hello,
> > > 
> > > I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
> > > The IDE drive fails to recognize 80-conductor cable that
> > > connects the drive to motherboard to fall back to UDMA33.
> > > 
> > > This patch fixes this behavior by assuming that the cable is
> > > short-40pin when the model string matches "PowerBook5" and 
> > > the motherboard detects 80c cable.
> > > 
> > > This patch is against drivers/ide/pmac.c in linux 2.6.28.8.
> > 
> > The patch is too much of an ad-hoc hack... _maybe_ an option is to make
> > the core fallback to 40 "short" when 80 pin detection fails on
> > powerbooks instead ?
> > 
> > Ben.
> > 
> > > (before applying the patch) hdparm -i /dev/hda
> > > /dev/hda:
> > >  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
> > > (dmesg 2.6.26)
> > > ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
> > > Probing IDE interface ide0...
> > > hda: CORE_PATA, ATA DISK drive
> > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
> > > hda: UDMA/33 mode selected
> > > 
> > > (after applying the patch) hdparm -i /dev/hda
> > > /dev/hda:
> > >  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
> > > (dmesg 2.6.28.8)
> > > ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
> > > Probing IDE interface ide0...
> > > hda: CORE_PATA, ATA DISK drive
> > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > hda: UDMA/100 mode selected
> > > ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
> > > 
> > > 
> > > _______________________________________________
> > > Linuxppc-dev mailing list
> > > Linuxppc-dev@ozlabs.org
> > > https://ozlabs.org/mailman/listinfo/linuxppc-dev
> >
Benjamin Herrenschmidt - March 19, 2009, 6:08 a.m.
On Thu, 2009-03-19 at 17:07 +1100, Benjamin Herrenschmidt wrote:
> On Wed, 2009-03-18 at 22:47 +0900, TOMARI Hisanobu wrote:
> > I thought the short-40pin assumption would cause no problem
> > considering all models beginning with "PowerBook5" are laptops.
> > Do you mean an option to toggle this hack on/off should be present 
> > in Kconfig?
> 
> Actually, it makes -some- amount of sense to do it by testing
> specifically for the prefix "PowerBook" and "iBook" without a specific
> number I suppose.

Actually "PowerBook" is enough, there's no iBook prefix in the
device-tree, I was confusing with old busted iMac firmwares that used
iMac instead of PowerMac in there.

Cheers,
Ben.

> Ben.
> 
> > Thanks,
> > TOMARI Hisanobu
> > 
> > On Wed, 18 Mar 2009 18:58:17 +1100
> > Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> > 
> > > On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
> > > > Hello,
> > > > 
> > > > I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
> > > > The IDE drive fails to recognize 80-conductor cable that
> > > > connects the drive to motherboard to fall back to UDMA33.
> > > > 
> > > > This patch fixes this behavior by assuming that the cable is
> > > > short-40pin when the model string matches "PowerBook5" and 
> > > > the motherboard detects 80c cable.
> > > > 
> > > > This patch is against drivers/ide/pmac.c in linux 2.6.28.8.
> > > 
> > > The patch is too much of an ad-hoc hack... _maybe_ an option is to make
> > > the core fallback to 40 "short" when 80 pin detection fails on
> > > powerbooks instead ?
> > > 
> > > Ben.
> > > 
> > > > (before applying the patch) hdparm -i /dev/hda
> > > > /dev/hda:
> > > >  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
> > > > (dmesg 2.6.26)
> > > > ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
> > > > Probing IDE interface ide0...
> > > > hda: CORE_PATA, ATA DISK drive
> > > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > > hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
> > > > hda: UDMA/33 mode selected
> > > > 
> > > > (after applying the patch) hdparm -i /dev/hda
> > > > /dev/hda:
> > > >  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
> > > > (dmesg 2.6.28.8)
> > > > ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
> > > > Probing IDE interface ide0...
> > > > hda: CORE_PATA, ATA DISK drive
> > > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > > hda: UDMA/100 mode selected
> > > > ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
> > > > 
> > > > 
> > > > _______________________________________________
> > > > Linuxppc-dev mailing list
> > > > Linuxppc-dev@ozlabs.org
> > > > https://ozlabs.org/mailman/listinfo/linuxppc-dev
> > >

Patch

*** linux-2.6.28.8/drivers/ide/pmac.c.orig	2009-03-18 13:59:39.645805773 +0900
--- linux-2.6.28.8/drivers/ide/pmac.c	2009-03-18 13:57:38.935818468 +0900
***************
*** 916,926 ****
  	pmac_ide_hwif_t *pmif =
  		(pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  	struct device_node *np = pmif->node;
  	const char *cable = of_get_property(np, "cable-type", NULL);
  
  	/* Get cable type from device-tree. */
  	if (cable && !strncmp(cable, "80-", 3))
! 		return ATA_CBL_PATA80;
  
  	/*
  	 * G5's seem to have incorrect cable type in device-tree.
--- 916,934 ----
  	pmac_ide_hwif_t *pmif =
  		(pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
  	struct device_node *np = pmif->node;
+ 	struct device_node *root = of_find_node_by_path("/");
  	const char *cable = of_get_property(np, "cable-type", NULL);
+ 	const char *model = of_get_property(root, "model", NULL);
  
  	/* Get cable type from device-tree. */
  	if (cable && !strncmp(cable, "80-", 3))
! 	  {
! 	    if(strncmp(model,"PowerBook5",10)==0)
! 	      /* Some drives fail to detect 80c cable in PowerBook */
! 	      return ATA_CBL_PATA40_SHORT;
! 	    else
! 	      return ATA_CBL_PATA80;
! 	  }
  
  	/*
  	 * G5's seem to have incorrect cable type in device-tree.