* [PATCH] ahci: Turn off DMA engines when there's no device attached
@ 2010-03-10 20:32 Matthew Garrett
2010-03-24 14:19 ` Matthew Garrett
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Matthew Garrett @ 2010-03-10 20:32 UTC (permalink / raw)
To: linux-ide; +Cc: jgarzik, Matthew Garrett, Kristen Carlson Accardi
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>
---
drivers/ata/ahci.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 6bd930b..ff08317 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1016,11 +1016,30 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
return -EINVAL;
}
+static int ahci_is_device_present(struct ata_port *ap)
+{
+ void __iomem *port_mmio = ahci_port_base(ap);
+ 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;
+}
+
static void ahci_start_engine(struct ata_port *ap)
{
void __iomem *port_mmio = ahci_port_base(ap);
u32 tmp;
+ if (!ahci_is_device_present(ap))
+ return;
+
/* start DMA */
tmp = readl(port_mmio + PORT_CMD);
tmp |= PORT_CMD_START;
--
1.6.6.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ahci: Turn off DMA engines when there's no device attached
2010-03-10 20:32 [PATCH] ahci: Turn off DMA engines when there's no device attached Matthew Garrett
@ 2010-03-24 14:19 ` Matthew Garrett
2010-03-24 14:43 ` Jeff Garzik
2010-03-28 4:39 ` Jeff Garzik
2010-03-29 21:30 ` Jeff Garzik
2 siblings, 1 reply; 5+ messages in thread
From: Matthew Garrett @ 2010-03-24 14:19 UTC (permalink / raw)
To: linux-ide; +Cc: jgarzik, Kristen Carlson Accardi
Any feedback on this?
On Wed, Mar 10, 2010 at 03:32:30PM -0500, Matthew Garrett wrote:
> 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>
> ---
> drivers/ata/ahci.c | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index 6bd930b..ff08317 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -1016,11 +1016,30 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
> return -EINVAL;
> }
>
> +static int ahci_is_device_present(struct ata_port *ap)
> +{
> + void __iomem *port_mmio = ahci_port_base(ap);
> + 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;
> +}
> +
> static void ahci_start_engine(struct ata_port *ap)
> {
> void __iomem *port_mmio = ahci_port_base(ap);
> u32 tmp;
>
> + if (!ahci_is_device_present(ap))
> + return;
> +
> /* start DMA */
> tmp = readl(port_mmio + PORT_CMD);
> tmp |= PORT_CMD_START;
> --
> 1.6.6.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ahci: Turn off DMA engines when there's no device attached
2010-03-24 14:19 ` Matthew Garrett
@ 2010-03-24 14:43 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2010-03-24 14:43 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-ide, Kristen Carlson Accardi
On 03/24/2010 10:19 AM, Matthew Garrett wrote:
> On Wed, Mar 10, 2010 at 03:32:30PM -0500, Matthew Garrett wrote:
>> 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>
>> ---
>> drivers/ata/ahci.c | 19 +++++++++++++++++++
>> 1 files changed, 19 insertions(+), 0 deletions(-)
(please don't top-post, it makes replying more difficult)
> Any feedback on this?
It should be fine, but I have to rebase it onto the latest upstream ahci
(libata-dev.git#upstream), so it's been waiting on that...
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ahci: Turn off DMA engines when there's no device attached
2010-03-10 20:32 [PATCH] ahci: Turn off DMA engines when there's no device attached Matthew Garrett
2010-03-24 14:19 ` Matthew Garrett
@ 2010-03-28 4:39 ` Jeff Garzik
2010-03-29 21:30 ` Jeff Garzik
2 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2010-03-28 4:39 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-ide, Kristen Carlson Accardi
On 03/10/2010 03:32 PM, Matthew Garrett wrote:
> 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>
> ---
> drivers/ata/ahci.c | 19 +++++++++++++++++++
> 1 files changed, 19 insertions(+), 0 deletions(-)
applied manually to libata-dev.git#upstream, due to large code movements
in creation of new libahci kernel module
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ahci: Turn off DMA engines when there's no device attached
2010-03-10 20:32 [PATCH] ahci: Turn off DMA engines when there's no device attached Matthew Garrett
2010-03-24 14:19 ` Matthew Garrett
2010-03-28 4:39 ` Jeff Garzik
@ 2010-03-29 21:30 ` Jeff Garzik
2 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2010-03-29 21:30 UTC (permalink / raw)
To: Matthew Garrett; +Cc: linux-ide, Kristen Carlson Accardi
On 03/10/2010 03:32 PM, Matthew Garrett wrote:
> +static int ahci_is_device_present(struct ata_port *ap)
> +{
> + void __iomem *port_mmio = ahci_port_base(ap);
> + 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;
Note that this last test, reading SATA Control Register (SCR) Status,
does not account for in-transition status, ie. devices that were just
plugged in.
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-03-29 21:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-10 20:32 [PATCH] ahci: Turn off DMA engines when there's no device attached Matthew Garrett
2010-03-24 14:19 ` Matthew Garrett
2010-03-24 14:43 ` Jeff Garzik
2010-03-28 4:39 ` Jeff Garzik
2010-03-29 21:30 ` Jeff Garzik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.