* [RESEND PATCH v2 0/3] ahci controller runtime PM support
@ 2012-02-15 10:18 Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops Lin Ming
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lin Ming @ 2012-02-15 10:18 UTC (permalink / raw)
To: Jeff Garzik, Rafael J. Wysocki, Tejun Heo
Cc: linux-kernel, linux-ide, linux-pm
Hi Jeff,
(RESEND, now applied on top of libata/ALL branch)
Here is the v2 patches to add ahci controller runtime PM support.
Thanks for any comments.
v2:
- add ahci hibernate callbacks
v1:
https://lkml.org/lkml/2011/12/15/198
Lin Ming (3):
ahci: port legacy pm interface to struct dev_pm_ops
ahci: add runtime PM callbacks
ata: runtime suspend port if no device attached
drivers/ata/ahci.c | 71 +++++++++++++++++++++++++++++++++++++++-----
drivers/ata/libata-core.c | 21 ++++++++++++-
2 files changed, 83 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RESEND PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops
2012-02-15 10:18 [RESEND PATCH v2 0/3] ahci controller runtime PM support Lin Ming
@ 2012-02-15 10:18 ` Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 2/3] ahci: add runtime PM callbacks Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 3/3] ata: runtime suspend port if no device attached Lin Ming
2 siblings, 0 replies; 4+ messages in thread
From: Lin Ming @ 2012-02-15 10:18 UTC (permalink / raw)
To: Jeff Garzik, Rafael J. Wysocki, Tejun Heo
Cc: linux-kernel, linux-ide, linux-pm
Also add hibernate callbacks.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
drivers/ata/ahci.c | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index cf26222..183c8b2 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -84,8 +84,10 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
#ifdef CONFIG_PM
-static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
-static int ahci_pci_device_resume(struct pci_dev *pdev);
+static int ahci_pci_device_suspend(struct device *dev);
+static int ahci_pci_device_resume(struct device *dev);
+static int ahci_pci_device_freeze(struct device *dev);
+static int ahci_pci_device_poweroff(struct device *dev);
#endif
static struct scsi_host_template ahci_sht = {
@@ -400,6 +402,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
{ } /* terminate list */
};
+static const struct dev_pm_ops ahci_pci_pm_ops = {
+ .suspend = ahci_pci_device_suspend,
+ .resume = ahci_pci_device_resume,
+ .freeze = ahci_pci_device_freeze,
+ .thaw = ahci_pci_device_resume,
+ .poweroff = ahci_pci_device_poweroff,
+ .restore = ahci_pci_device_resume,
+};
static struct pci_driver ahci_pci_driver = {
.name = DRV_NAME,
@@ -407,8 +417,9 @@ static struct pci_driver ahci_pci_driver = {
.probe = ahci_init_one,
.remove = ata_pci_remove_one,
#ifdef CONFIG_PM
- .suspend = ahci_pci_device_suspend,
- .resume = ahci_pci_device_resume,
+ .driver = {
+ .pm = &ahci_pci_pm_ops
+ },
#endif
};
@@ -567,7 +578,8 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
}
#ifdef CONFIG_PM
-static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
+static int ahci_pci_device_suspend_common(struct pci_dev *pdev,
+ pm_message_t mesg)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct ahci_host_priv *hpriv = host->private_data;
@@ -595,9 +607,31 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
return ata_pci_device_suspend(pdev, mesg);
}
-static int ahci_pci_device_resume(struct pci_dev *pdev)
+static int ahci_pci_device_suspend(struct device *dev)
{
- struct ata_host *host = dev_get_drvdata(&pdev->dev);
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return ahci_pci_device_suspend_common(pdev, PMSG_SUSPEND);
+}
+
+static int ahci_pci_device_freeze(struct device *dev)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return ahci_pci_device_suspend_common(pdev, PMSG_FREEZE);
+}
+
+static int ahci_pci_device_poweroff(struct device *dev)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+
+ return ahci_pci_device_suspend_common(pdev, PMSG_HIBERNATE);
+}
+
+static int ahci_pci_device_resume(struct device *dev)
+{
+ struct ata_host *host = dev_get_drvdata(dev);
+ struct pci_dev *pdev = to_pci_dev(dev);
int rc;
rc = ata_pci_device_do_resume(pdev);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RESEND PATCH v2 2/3] ahci: add runtime PM callbacks
2012-02-15 10:18 [RESEND PATCH v2 0/3] ahci controller runtime PM support Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops Lin Ming
@ 2012-02-15 10:18 ` Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 3/3] ata: runtime suspend port if no device attached Lin Ming
2 siblings, 0 replies; 4+ messages in thread
From: Lin Ming @ 2012-02-15 10:18 UTC (permalink / raw)
To: Jeff Garzik, Rafael J. Wysocki, Tejun Heo
Cc: linux-kernel, linux-ide, linux-pm
Add ahci controller runtime PM callbacks.
Call pm_runtime_put_noidle() in its probe routine and
pm_runtime_get_noresume() in its remove routine.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
drivers/ata/ahci.c | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 183c8b2..f70f030 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -46,6 +46,7 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <linux/libata.h>
+#include <linux/pm_runtime.h>
#include "ahci.h"
#define DRV_NAME "ahci"
@@ -79,6 +80,7 @@ enum board_ids {
};
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
+static void ahci_remove_one(struct pci_dev *pdev);
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@ -88,6 +90,7 @@ static int ahci_pci_device_suspend(struct device *dev);
static int ahci_pci_device_resume(struct device *dev);
static int ahci_pci_device_freeze(struct device *dev);
static int ahci_pci_device_poweroff(struct device *dev);
+static int ahci_pci_device_runtime_idle(struct device *dev);
#endif
static struct scsi_host_template ahci_sht = {
@@ -409,13 +412,16 @@ static const struct dev_pm_ops ahci_pci_pm_ops = {
.thaw = ahci_pci_device_resume,
.poweroff = ahci_pci_device_poweroff,
.restore = ahci_pci_device_resume,
+ .runtime_suspend = ahci_pci_device_suspend,
+ .runtime_resume = ahci_pci_device_resume,
+ .runtime_idle = ahci_pci_device_runtime_idle
};
static struct pci_driver ahci_pci_driver = {
.name = DRV_NAME,
.id_table = ahci_pci_tbl,
.probe = ahci_init_one,
- .remove = ata_pci_remove_one,
+ .remove = ahci_remove_one,
#ifdef CONFIG_PM
.driver = {
.pm = &ahci_pci_pm_ops
@@ -650,6 +656,11 @@ static int ahci_pci_device_resume(struct device *dev)
return 0;
}
+
+static int ahci_pci_device_runtime_idle(struct device *dev)
+{
+ return pm_runtime_suspend(dev);
+}
#endif
static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
@@ -1239,10 +1250,20 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
ahci_pci_print_info(host);
pci_set_master(pdev);
+ pm_runtime_put_noidle(dev);
+ pm_runtime_allow(dev);
return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
&ahci_sht);
}
+static void ahci_remove_one(struct pci_dev *pdev)
+{
+ pm_runtime_forbid(&pdev->dev);
+ pm_runtime_get_noresume(&pdev->dev);
+
+ ata_pci_remove_one(pdev);
+}
+
static int __init ahci_init(void)
{
return pci_register_driver(&ahci_pci_driver);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RESEND PATCH v2 3/3] ata: runtime suspend port if no device attached
2012-02-15 10:18 [RESEND PATCH v2 0/3] ahci controller runtime PM support Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 2/3] ahci: add runtime PM callbacks Lin Ming
@ 2012-02-15 10:18 ` Lin Ming
2 siblings, 0 replies; 4+ messages in thread
From: Lin Ming @ 2012-02-15 10:18 UTC (permalink / raw)
To: Jeff Garzik, Rafael J. Wysocki, Tejun Heo
Cc: linux-kernel, linux-ide, linux-pm
Add a new function ata_device_probed(...) to check if device was probed.
Runtime suspend scsi_host--->ata port if no device was probed.
Controller will be runtime suspended if all port were suspended already.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
drivers/ata/libata-core.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c04ad68..1ff921b 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5906,6 +5906,21 @@ int ata_port_probe(struct ata_port *ap)
return rc;
}
+/**
+ * ata_device_probed - Check if device is probed
+ * @ap: port to check
+ */
+static bool ata_device_probed(struct ata_port *ap)
+{
+ struct ata_link *link;
+ struct ata_device *dev;
+
+ ata_for_each_link(link, ap, EDGE)
+ ata_for_each_dev(dev, link, ENABLED)
+ return true;
+
+ return false;
+}
static void async_port_probe(void *data, async_cookie_t cookie)
{
@@ -5926,7 +5941,11 @@ static void async_port_probe(void *data, async_cookie_t cookie)
/* in order to keep device order, we need to synchronize at this point */
async_synchronize_cookie(cookie);
- ata_scsi_scan_host(ap, 1);
+ if (ata_device_probed(ap))
+ ata_scsi_scan_host(ap, 1);
+ else
+ /* Runtime suspend it if no device is attached */
+ pm_runtime_idle(&ap->scsi_host->shost_gendev);
}
/**
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-15 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-15 10:18 [RESEND PATCH v2 0/3] ahci controller runtime PM support Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 2/3] ahci: add runtime PM callbacks Lin Ming
2012-02-15 10:18 ` [RESEND PATCH v2 3/3] ata: runtime suspend port if no device attached Lin Ming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).