[RFC] patch to AHCI device detection code
Søren Schmidt
sos at FreeBSD.ORG
Wed Jun 11 07:54:57 UTC 2008
Hi
Well, as you can see I tried this when I added the PM code to AHCI,
however one of the reasons I left it out again (for now) is that it
doesn't work on more than about 50% of the AHCI chipsets out there..
Modern HW in a nutshell, you win some you loose some ;)
-Søren
On 11Jun, 2008, at 9:30 , Andrey V. Elsukov wrote:
> Hi, Soren.
>
> I'm found solution for AHCI that solve ATAPI device detection for me.
> I just added waiting loop on PxTFD after reset and now my SATA DVD
> detected well. Waiting time (in my case) may vary from 1ms to 900 ms.
>
> Also AHCI spec says:
>
> 10.4.2 Port Reset
> ...
> When PxSCTL.DET is set to 0h, upon receiving a COMINIT from
> the attached device, PxTFD.STS.BSY shall be set to ’1’ by the HBA.
>
> So we can wait until PxTFD.STS.BSY resets to zero and then
> read PxSIG.
>
> Any comments?
>
> --
> WBR, Andrey V. Elsukov
> Index: src/sys/dev/ata/ata-chipset.c
> ===================================================================
> RCS file: /ncvs/src/sys/dev/ata/ata-chipset.c,v
> retrieving revision 1.219
> diff -u -b -p -r1.219 ata-chipset.c
> --- src/sys/dev/ata/ata-chipset.c 21 Apr 2008 10:51:38 -0000 1.219
> +++ src/sys/dev/ata/ata-chipset.c 11 Jun 2008 07:17:53 -0000
> @@ -1059,10 +1059,10 @@ ata_ahci_softreset(device_t dev, int por
> struct ata_pci_controller *ctlr =
> device_get_softc(device_get_parent(dev));
> struct ata_channel *ch = device_get_softc(dev);
> int offset = ch->unit << 7;
> + int timeout = 0;
> #ifdef AHCI_PM
> struct ata_ahci_cmd_tab *ctp =
> (struct ata_ahci_cmd_tab *)(ch->dma.work + ATA_AHCI_CT_OFFSET);
> - int timeout = 0;
>
> /* kick controller into sane state if needed */
> ata_ahci_restart(dev);
> @@ -1091,6 +1091,7 @@ ata_ahci_softreset(device_t dev, int por
>
> ata_udelay(150000);
>
> +#endif
> timeout = 0;
> do {
> DELAY(1000);
> @@ -1101,7 +1102,6 @@ ata_ahci_softreset(device_t dev, int por
> } while (ATA_INL(ctlr->r_res2, ATA_AHCI_P_TFD + offset) &
> ATA_S_BUSY);
> if (bootverbose)
> device_printf(dev, "BUSY wait time=%dms\n", timeout);
> -#endif
> return ATA_INL(ctlr->r_res2, ATA_AHCI_P_SIG + offset);
> }
>
More information about the freebsd-hackers
mailing list