From patchwork Thu May 8 12:49:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 4136071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F5BEBFF02 for ; Thu, 8 May 2014 12:52:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F6B62024F for ; Thu, 8 May 2014 12:52:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85F26200D9 for ; Thu, 8 May 2014 12:52:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiNm2-0000c3-CB; Thu, 08 May 2014 12:50:06 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiNlh-0008MB-Qm for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 12:49:46 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N5900HBEAA0JK00@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 13:49:12 +0100 (BST) X-AuditID: cbfec7f5-b7fae6d000004d6d-ef-536b7d536fc7 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 3C.4A.19821.35D7B635; Thu, 08 May 2014 13:49:23 +0100 (BST) Received: from AMDC1227.digital.local ([106.116.147.199]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N59004UQAA61SA0@eusync1.samsung.com>; Thu, 08 May 2014 13:49:23 +0100 (BST) From: Tomasz Figa To: linux-pm@vger.kernel.org Subject: [PATCH v4 2/3] drivercore: Bind/unbind power domain on probe/remove Date: Thu, 08 May 2014 14:49:14 +0200 Message-id: <1399553355-6615-3-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1399553355-6615-1-git-send-email-t.figa@samsung.com> References: <1399553355-6615-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsVy+t/xy7rBtdnBBl2bWC02zljPajH/yDlW i/43C1ktmhevZ7PoXXCVzeLr4RWMFrOm7GWy2PT4GqvF5V1z2Cw+9x5htJhxfh+Txe3LvBZv fr9gt1h75C67xdLrF5ks7p46ymYxYfpaFout884xWjxe8ZbdonXvEXaLH2e6WSxeHWxjsVg/ 4zWLxapdfxgtjq8Nd5D0WDNvDaNHS3MPm8flvl4mj52z7rJ7LN7zkslj06pONo871/aweeyf u4bdY/OSeo++LasYPVas/s7u8XmTnMfGuaEBvFFcNimpOZllqUX6dglcGcv6ljIWPBeuaJuz jqmBcbFAFyMnh4SAicTnSR/YIWwxiQv31rN1MXJxCAksZZS42rwOyuljklh9/icjSBWbgJrE 54ZHbCC2iICMxNQr+1lBipgF9rFLfPt8Dcjh4BAW8JG4vFgJpIZFQFVi69KJLCA2r4CjxL23 u1khtslJ/H+5ggnE5hRwklj/6QAziC0EVLNo0SWWCYy8CxgZVjGKppYmFxQnpeca6RUn5haX 5qXrJefnbmKExNTXHYxLj1kdYhTgYFTi4V0gkxEsxJpYVlyZe4hRgoNZSYT3SmV2sBBvSmJl VWpRfnxRaU5q8SFGJg5OqQbGmyx78p385zu8eLZhhv6n6g1Mtn4r/LJrPgq/vBS03KjnmJqk 4B3WAKMFfDPsZAIm5nZctbJmO3zJbsFrYTavY9r9DKVPHBL1bj55t8VN9FWadaxbw3HfI8rM S6b6ns5ULt0m1fjc/Xf2WqtpG+t732sk3l/UHpTBdyn8V+OsGQmLZ1lozTuoxFKckWioxVxU nAgAPwkLlIcCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140508_054946_026646_2BEA595E X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: -5.7 (-----) Cc: Mark Rutland , Ulf Hansson , Pavel Machek , Stephen Warren , Len Brown , Tomasz Figa , Tomasz Figa , Philipp Zabel , Kukjin Kim , Marek Szyprowski , linux-samsung-soc@vger.kernel.org, Russell King - ARM Linux , "Rafael J. Wysocki" , Lorenzo Pieralisi , devicetree@vger.kernel.org, Kevin Hilman , Pawel Moll , Bartlomiej Zolnierkiewicz , Rob Herring , linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , Stephen Boyd , linux-kernel@vger.kernel.org, Kumar Gala X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a number of platforms, devices are part of controllable power domains, which need to be enabled before such devices can be accessed and may be powered down when the device is idle to save some power. This means that on systems that support power domain control using generic power domains subsystem, it is necessary to add device to its power domain before binding a driver to it and remove it from its power domain after its driver is unbound to make sure that an unused device does not affect power domain state. Since this is not limited to particular busses and specific archs/platforms, it is more convenient to do the above directly in driver core, just as done with pinctrl default configuration. This patch adds necessary code to really_probe() and __device_release_driver() to achieve this and maintain consistent stack-like ordering of operations happening when binding and unbinding a driver. Signed-off-by: Tomasz Figa Reviewed-by: Stephen Boyd Reviewed-by: Philipp Zabel [on i.MX6 GK802] Tested-by: Philipp Zabel Reviewed-by: Mark Brown Reviewed-by: Ulf Hansson --- drivers/base/dd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 62ec61e..9489b3a 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -287,6 +288,11 @@ static int really_probe(struct device *dev, struct device_driver *drv) dev->driver = drv; + /* If using genpd, bind power domain now before probing */ + ret = genpd_bind_domain(dev); + if (ret) + goto probe_failed; + /* If using pinctrl, bind pins now before probing */ ret = pinctrl_bind_pins(dev); if (ret) @@ -317,6 +323,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) probe_failed: devres_release_all(dev); driver_sysfs_remove(dev); + genpd_unbind_domain(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL); @@ -530,7 +537,7 @@ static void __device_release_driver(struct device *dev) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_UNBOUND_DRIVER, dev); - + genpd_unbind_domain(dev); } }