From patchwork Thu May 8 12:45:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 4136021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D6AD79F1E1 for ; Thu, 8 May 2014 12:51:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 106762024F for ; Thu, 8 May 2014 12:51:32 +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 33A3E201F9 for ; Thu, 8 May 2014 12:51:31 +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 1WiNkk-0008BD-CI; Thu, 08 May 2014 12:48:46 +0000 Received: from mailout4.w1.samsung.com ([210.118.77.14]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiNkc-00087l-W2 for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 12:48:39 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N59007E3A8ABJ00@mailout4.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 13:48:10 +0100 (BST) X-AuditID: cbfec7f5-b7fae6d000004d6d-fb-536b7d0e65d7 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id BA.1A.19821.E0D7B635; Thu, 08 May 2014 13:48:14 +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 <0N5900EP6A88X460@eusync4.samsung.com>; Thu, 08 May 2014 13:48:14 +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:45:08 +0200 Message-id: <1399553109-6487-3-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1399553109-6487-1-git-send-email-t.figa@samsung.com> References: <1399553109-6487-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAyWRW0hTYQDH/c7OzjkOJ6ep9SkiMbCH8pIj4qNCtB76HrpIQwILcupwonOy 4yyDaDIzL20KOR2mbrYWOi+HzUrTqWUzocyU2XxII1ZgpgUhalRkzb394H97+DMCybYgjikq LVdqSxUlUkpEvv477U+OvFEsP/xrJwK5LLwQWb2zQtS43iVEBjtPIaPtHYU2X3QD1NY8RiD3 J78Q+UbaKbRh9AJkeTtOoPc+MVr//YVG/d5lGjkW5wm0/GqKQk2t/SR63DkLUGOXkUC3xrw0 +jnTQKKvz2tIxFvWSOQc+QPQdP/FjFjc19kHcLXhDoV9JiOBn7Yt09juWSWw21lH4SW/h8IT HX00HnxwE5seOQEO2KsB7u7dpvGGOwG7OrKzInNEJwqUJUUVSm1qeq5I9dDkAGUrUddq2gcI PbCz9SCcgewRONTbS4V4L5z7wP9nESNhHQCutY8LgoKENRFwbkAcZIo9ADf0gd1ANBsPzQsT wmBAwPI0DMxYQD1gmCj2DPTZpUEPySbCWlfrbo+YzYTuxR5haCwB7qx2E0F7OHsSOseSQ1OZ 0NrwjW4CYhsIc4IYpS6/jMsrVMtSOIWa05UWpuRr1G4QOmtzGDheHpsELAOkEWJbvEouESoq uEr1JICMQBotXqgslkvEBYrK60qt5opWV6LkJgHBhMfpAZVBW3taErM5Xtd8gRlPN+uP3q9N a3kS1jy1NTp46NR+meZSHh2z4jEM+6cHbZpnsg5fXWsNxMrzWVuxXQOq3NEq49Uft3VL5nXr WY8vUqb5nkavzZk/30018Kff3NtzHFfxl7PLY4cM8qhzSQZxYcCVlKOt2zfv130ksZTkVIq0 gwItp/gHTgc0rooCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140508_054839_185621_B917E063 X-CRM114-Status: GOOD ( 15.70 ) X-Spam-Score: -5.7 (-----) Cc: Mark Rutland , Ulf Hansson , Pavel Machek , Len Brown , Tomasz Figa , Tomasz Figa , Philipp Zabel , Kukjin Kim , Marek Szyprowski , linux-samsung-soc@vger.kernel.org, Russell King - ARM Linux , Stephen Warren , Lorenzo Pieralisi , devicetree@vger.kernel.org, Kevin Hilman , Pawel Moll , Bartlomiej Zolnierkiewicz , "Rafael J. Wysocki" , 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); } }