Index: sys/dev/ahci/ahci.c =================================================================== --- sys/dev/ahci/ahci.c +++ sys/dev/ahci/ahci.c @@ -483,6 +483,10 @@ /* AHCI declares level triggered IS. */ if (!(ctlr->quirks & AHCI_Q_EDGEIS)) ATA_OUTL(ctlr->r_mem, AHCI_IS, is); +#ifdef __arm__ + /* Readback ensures that AHCI_IS is already updated in HW */ + ATA_INL(ctlr->r_mem, AHCI_IS); +#endif } /* @@ -501,6 +505,10 @@ ctlr->interrupt[unit].function(arg); /* AHCI declares level triggered IS. */ ATA_OUTL(ctlr->r_mem, AHCI_IS, 1 << unit); +#ifdef __arm__ + /* Readback ensures that AHCI_IS is already updated in HW */ + ATA_INL(ctlr->r_mem, AHCI_IS); +#endif } static void @@ -516,6 +524,10 @@ ATA_OUTL(ctlr->r_mem, AHCI_IS, 1 << unit); if ((arg = ctlr->interrupt[unit].argument)) ctlr->interrupt[unit].function(arg); +#ifdef __arm__ + /* Readback ensures that AHCI_IS is already updated in HW */ + ATA_INL(ctlr->r_mem, AHCI_IS); +#endif } struct resource * @@ -1606,10 +1618,15 @@ if ((ch->quirks & AHCI_Q_NOBSYRES) == 0 && (ch->quirks & AHCI_Q_ATI_PMP_BUG) == 0 && softreset == 2 && et == AHCI_ERR_NONE) { - while ((val = fis[2]) & ATA_S_BUSY) { - DELAY(10); - if (count++ >= timeout) + for ( ; count < timeout; count++) { + bus_dmamap_sync(ch->dma.rfis_tag, + ch->dma.rfis_map, BUS_DMASYNC_POSTREAD); + val = fis[2]; + bus_dmamap_sync(ch->dma.rfis_tag, + ch->dma.rfis_map, BUS_DMASYNC_PREREAD); + if ((val & ATA_S_BUSY) == 0) break; + DELAY(10); } }