According to the AHCI spec, you should not set PxCMD.ST unless
a functional device is present, as determined by PxTFD.STS.BSY=0,
PxTFD.STS.DRQ=0, and PxSSTS.DET = 3.

Signed-off-by:  Kristen Carlson Accardi <[EMAIL PROTECTED]>

Index: linux-2.6.25-rc3/drivers/ata/ahci.c
===================================================================
--- linux-2.6.25-rc3.orig/drivers/ata/ahci.c
+++ linux-2.6.25-rc3/drivers/ata/ahci.c
@@ -783,11 +783,40 @@ static int ahci_scr_write(struct ata_por
        return -EINVAL;
 }
 
+static int ahci_is_device_present(struct ata_port *ap)
+{
+       void __iomem *port_mmio = ahci_port_base(ap);
+       u8 status;
+
+       /* Make sure PxTFD.STS.BSY and PxTFD.STS.DRQ are 0 */
+       status = ahci_check_status(ap);
+       if (status & (ATA_BUSY | ATA_DRQ))
+               return 0;
+
+       /* Make sure PxSSTS.DET is 3h */
+       status = readl(port_mmio + PORT_SCR_STAT);
+       status &= 0xf;
+       if ((status & 0xf) != 3)
+               return 0;
+       return 1;
+}
+
 static void ahci_start_engine(struct ata_port *ap)
 {
        void __iomem *port_mmio = ahci_port_base(ap);
        u32 tmp;
 
+       /*
+        * See AHCI specification 1.2 section 10.1.2
+        *
+        * Software shall not set PxCMD.ST to '1' until it is
+        * determined that a functional device is present on
+        * the port, as determined by PxTFD.STS.BSY = '0',
+        * PxTFD.STS.DRQ = '0', PxSSTS.DET = 3h
+        */
+       if (!ahci_is_device_present(ap))
+               return;
+
        /* start DMA */
        tmp = readl(port_mmio + PORT_CMD);
        tmp |= PORT_CMD_START;

-- 

_______________________________________________
Discuss mailing list
[email protected]
http://mail.lesswatts.org/mailman/listinfo/discuss

Reply via email to