From bc18a46ad2a9c277ba25fcd662968af87bf3926d Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Sun, 28 Mar 2010 00:37:21 -0400 Subject: [PATCH] --- yaml --- r: 192592 b: refs/heads/master c: 96d60303fd3336893a93565d58c4f1805a327061 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/ata/libahci.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index a0c106b0bf08..0e5ada9307e8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1c2a49f61785ebbcbfb481a2aab659020f0457f7 +refs/heads/master: 96d60303fd3336893a93565d58c4f1805a327061 diff --git a/trunk/drivers/ata/libahci.c b/trunk/drivers/ata/libahci.c index 38e1b4e9ecf4..3f586ec84a3c 100644 --- a/trunk/drivers/ata/libahci.c +++ b/trunk/drivers/ata/libahci.c @@ -437,11 +437,29 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val) return -EINVAL; } +static int ahci_is_device_present(void __iomem *port_mmio) +{ + u8 status = readl(port_mmio + PORT_TFDATA) & 0xff; + + /* Make sure PxTFD.STS.BSY and PxTFD.STS.DRQ are 0 */ + if (status & (ATA_BUSY | ATA_DRQ)) + return 0; + + /* Make sure PxSSTS.DET is 3h */ + status = readl(port_mmio + PORT_SCR_STAT) & 0xf; + if (status != 3) + return 0; + return 1; +} + void ahci_start_engine(struct ata_port *ap) { void __iomem *port_mmio = ahci_port_base(ap); u32 tmp; + if (!ahci_is_device_present(port_mmio)) + return; + /* start DMA */ tmp = readl(port_mmio + PORT_CMD); tmp |= PORT_CMD_START;