diff options
author | Matthew Garrett <mjg@redhat.com> | 2010-03-28 06:37:21 +0200 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2010-05-14 23:08:01 +0200 |
commit | 96d60303fd3336893a93565d58c4f1805a327061 (patch) | |
tree | e6534dabeceb4a0a0b511c17dbffe47639fff0ac /drivers/ata/libahci.c | |
parent | ahci: Add platform driver (diff) | |
download | linux-96d60303fd3336893a93565d58c4f1805a327061.tar.xz linux-96d60303fd3336893a93565d58c4f1805a327061.zip |
ahci: Turn off DMA engines when there's no device attached
According to section 10.3.1 of the AHCI spec, PxCMD.ST must not be set
unless there's a device attached. Following this saves us a measurable
quantity of power and does not impair hotplug support. Based on a patch
by Kristen Carlson Accardi.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libahci.c')
-rw-r--r-- | drivers/ata/libahci.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 38e1b4e9ecf4..3f586ec84a3c 100644 --- a/drivers/ata/libahci.c +++ b/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; |