diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a6de57e020473293c2a043ebdcefc4ab01a6a5bd..5788a9dd0445ca3f414ac7c5bd6d029fd65a33c7 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3022,7 +3022,7 @@ int ata_wait_ready(struct ata_port *ap, unsigned long deadline)
 
 		if (!(status & ATA_BUSY))
 			return 0;
-		if (status == 0xff)
+		if (!ata_port_online(ap) && status == 0xff)
 			return -ENODEV;
 		if (time_after(now, deadline))
 			return -EBUSY;