From patchwork Wed Apr 23 16:46:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 4042951 Return-Path: X-Original-To: patchwork-linux-pm@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 06577BFF02 for ; Wed, 23 Apr 2014 16:47:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C2D52022D for ; Wed, 23 Apr 2014 16:47:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FCBE20219 for ; Wed, 23 Apr 2014 16:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbaDWQrg (ORCPT ); Wed, 23 Apr 2014 12:47:36 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:9002 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754396AbaDWQr2 (ORCPT ); Wed, 23 Apr 2014 12:47:28 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N4H00I79TB2RI10@mailout3.w1.samsung.com>; Wed, 23 Apr 2014 17:47:27 +0100 (BST) X-AuditID: cbfec7f4-b7fb36d000006ff7-00-5357ee9ea94a Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FA.12.28663.E9EE7535; Wed, 23 Apr 2014 17:47:26 +0100 (BST) Received: from AMDC1227.digital.local ([106.116.147.199]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N4H00IDXTAW8080@eusync4.samsung.com>; Wed, 23 Apr 2014 17:47:26 +0100 (BST) From: Tomasz Figa To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Russell King , Kukjin Kim , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring , Bartlomiej Zolnierkiewicz , Stephen Warren , Mark Brown , Stephen Boyd , Lorenzo Pieralisi , Ulf Hansson , Marek Szyprowski , Tomasz Figa , Kevin Hilman , Philipp Zabel , Tomasz Figa Subject: [PATCH v3 2/3] drivercore: Bind/unbind power domain on probe/remove Date: Wed, 23 Apr 2014 18:46:57 +0200 Message-id: <1398271618-28932-3-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1398271618-28932-1-git-send-email-t.figa@samsung.com> References: <1398271618-28932-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeLIzCtJLcpLzFFi42I5/e/4Nd1578KDDd4uMrTYOGM9q8XUh0/Y LOYfOcdq0f9mIatF8+L1bBbnXq1ktOhdcJXN4uvhFYwWs6bsZbLY9Pgaq8XlXXPYLD73HmG0 mHF+H5PF7cu8Fm9+v2C3WHvkLrvF0usXmSzunjrKZjFh+loWi63zzjFanDl9idWide8Rdosf Z7pZLF4dbGOxWD/jNYvFql1/GC2Orw13kPZYM28No0dLcw+bx+W+XiaPnbPusnusXP6FzWPx npdMHptWdbJ53Lm2h81j/9w17B6bl9R7bLnazuLRt2UVo8eK1d/ZPT5vkvPYODc0gD+KyyYl NSezLLVI3y6BK+P8iR6WgufCFf23prI1MC4W6GLk5JAQMJFY+3AaG4QtJnHh3nogm4tDSGAp o8TCBe2sEE4fk8T9nztZQKrYBNQkPjc8AusQEZCRmHplP1gRs8AvdokHf98wgSSEBXwk1n9Y xQ5iswioSry8eBXM5hVwkjh/9BQzxDo5if8vV4DVcwo4S9zoPw9WIwRUM3/ycqYJjLwLGBlW MYqmliYXFCel5xrqFSfmFpfmpesl5+duYoRE35cdjIuPWR1iFOBgVOLhVbgVHizEmlhWXJl7 iFGCg1lJhHfJIqAQb0piZVVqUX58UWlOavEhRiYOTqkGRmu5u/u9Lxs528g93fHKI+/P5DIh 3s16s+1XhemfWHzk2u1AE+2uC+cn5jSX1URdFaipb/Lb/Xv6vvNvz3GWpRzLV76caLXxRi3H Tb3jnvs+1xak3b11LSd9xvzw9QKd6f+c/3bPTZ7wrOOaYKTeigJx51/nfz5JTovU+r7jgWTL 6R23Qw6uYVFiKc5INNRiLipOBACVlfSlnAIAAA== Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 8986b9f..7501c42 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -273,6 +274,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) @@ -303,6 +309,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); @@ -513,7 +520,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); } }