diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 14de3c506..3aff3f3c2 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -385,14 +385,21 @@ static int ahci_init_port(struct ahci_port *ahci_port) ahci_port_info(ahci_port, "Spinning up device...\n"); ret = wait_on_timeout(WAIT_SPINUP, - (readl(port_mmio + PORT_TFDATA) & - (ATA_STATUS_BUSY | ATA_STATUS_DRQ)) == 0); + ((readl(port_mmio + PORT_TFDATA) & + (ATA_STATUS_BUSY | ATA_STATUS_DRQ)) == 0) + || !((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1)); if (ret) { ahci_port_info(ahci_port, "timeout.\n"); ret = -ENODEV; goto err_init; } + if ((readl(port_mmio + PORT_SCR_STAT) & 0xf) == 1) { + ahci_port_info(ahci_port, "down.\n"); + ret = -ENODEV; + goto err_init; + } + ahci_port_info(ahci_port, "ok.\n"); val = ahci_port_read(ahci_port, PORT_SCR_ERR);