From: Lin Ming <ming.m.lin@intel.com>
To: Jeff Garzik <jgarzik@pobox.com>,
Alan Stern <stern@rowland.harvard.edu>, Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
linux-pm@vger.kernel.org, "Rafael J. Wysocki" <rjw@sisk.pl>
Subject: [RFC][PATCH 3/4] ata: runtime suspend port if no device attached
Date: Thu, 15 Dec 2011 21:12:48 +0800 [thread overview]
Message-ID: <1323954769-3918-4-git-send-email-ming.m.lin@intel.com> (raw)
In-Reply-To: <1323954769-3918-1-git-send-email-ming.m.lin@intel.com>
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 are 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 8996758..4bbbd55 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5934,6 +5934,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)
{
@@ -5954,7 +5969,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
next prev parent reply other threads:[~2011-12-15 13:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-15 13:12 [RFC][PATCH 0/4] ahci controller runtime PM support Lin Ming
2011-12-15 13:12 ` [RFC][PATCH 1/4] ahci: port legacy pm interface to struct dev_pm_ops Lin Ming
2011-12-15 19:53 ` Rafael J. Wysocki
2011-12-16 13:07 ` Lin Ming
2011-12-15 13:12 ` [RFC][PATCH 2/4] ahci: add runtime PM callbacks Lin Ming
2011-12-15 13:12 ` Lin Ming [this message]
2011-12-15 13:12 ` [RFC][PATCH 4/4] ahci: support hot plug when port/controller is runtime suspended Lin Ming
2011-12-15 19:21 ` Tejun Heo
2011-12-15 23:29 ` Kay Sievers
2012-01-02 15:57 ` Matthew Garrett
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323954769-3918-4-git-send-email-ming.m.lin@intel.com \
--to=ming.m.lin@intel.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).