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: 4136091 Return-Path: X-Original-To: patchwork-linux-pm@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 123FA9F1E1 for ; Thu, 8 May 2014 12:52:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 409C22027D for ; Thu, 8 May 2014 12:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE2282026F for ; Thu, 8 May 2014 12:52:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbaEHMsp (ORCPT ); Thu, 8 May 2014 08:48:45 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:23404 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753694AbaEHMsQ (ORCPT ); Thu, 8 May 2014 08:48:16 -0400 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>; 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 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 - ARM Linux , Kukjin Kim , Kumar Gala , Mark Rutland , Pawel Moll , Rob Herring , Bartlomiej Zolnierkiewicz , Stephen Warren , Stephen Boyd , Lorenzo Pieralisi , Ulf Hansson , Marek Szyprowski , Kevin Hilman , Philipp Zabel , Tomasz Figa , Tomasz Figa 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= 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 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); } }