linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ulf.hansson@linaro.org (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/10] i2c: designware-platdrv: Unconditionally enable runtime PM
Date: Tue, 14 Jun 2016 17:07:21 +0200	[thread overview]
Message-ID: <1465916848-8207-4-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org>

In cases when the designware specific flag "pm_runtime_disable" is set,
->probe() calls pm_runtime_forbid() for the device, but without enabling
runtime PM. This increases the runtime PM usage count for the device, but
as runtime PM is disabled it's pointless.

Let's instead convert to unconditionally enable runtime PM, which has the
effect of making a parent device aware of its child.

To also maintain the old behaviour when the "pm_runtime_disable" flag is
set, which prevents userspace to enable runtime PM suspend via sysfs,
switch from calling pm_runtime_forbid() into pm_runtime_get_noresume()
during ->probe().

While changing this, let's also also correct the error path in ->probe()
and fix ->remove(), as to decrease the runtime PM usage count when it has
been in increased by pm_runtime_forbid() (after this change, by
pm_runtime_get_noresume()).

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 19174e7..94ff953 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -236,21 +236,21 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	adap->dev.of_node = pdev->dev.of_node;
 
 	pm_runtime_get_noresume(&pdev->dev);
-	if (dev->pm_runtime_disabled) {
-		pm_runtime_forbid(&pdev->dev);
-	} else {
-		pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
-		pm_runtime_use_autosuspend(&pdev->dev);
-		pm_runtime_set_active(&pdev->dev);
-		pm_runtime_enable(&pdev->dev);
-	}
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	if (dev->pm_runtime_disabled)
+		pm_runtime_get_noresume(&pdev->dev);
 
 	r = i2c_dw_probe(dev);
 	if (r) {
 		if (!IS_ERR(dev->clk))
 			clk_disable_unprepare(dev->clk);
-		if (!dev->pm_runtime_disabled)
-			pm_runtime_disable(&pdev->dev);
+		pm_runtime_disable(&pdev->dev);
+		if (dev->pm_runtime_disabled)
+			pm_runtime_put_noidle(&pdev->dev);
 	}
 	pm_runtime_put(&pdev->dev);
 
@@ -267,10 +267,11 @@ static int dw_i2c_plat_remove(struct platform_device *pdev)
 
 	i2c_dw_disable(dev);
 
+	if (dev->pm_runtime_disabled)
+		pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_put_sync(&pdev->dev);
-	if (!dev->pm_runtime_disabled)
-		pm_runtime_disable(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 
 	return 0;
 }
-- 
1.9.1

  parent reply	other threads:[~2016-06-14 15:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 15:07 [PATCH 00/10] i2c: designware-platdrv: Some improvments related to PM Ulf Hansson
2016-06-14 15:07 ` [PATCH 01/10] i2c: designware-platdrv: Return error in ->probe() when clk ungate fails Ulf Hansson
2016-06-15  7:04   ` Jarkko Nikula
2016-06-14 15:07 ` [PATCH 02/10] i2c: designware-platdrv: Gate clk in error path in ->probe() Ulf Hansson
2016-06-14 15:22   ` Andy Shevchenko
2016-06-15  7:16     ` Ulf Hansson
2016-06-15 12:07       ` Jarkko Nikula
2016-06-20  4:41         ` Ulf Hansson
2016-06-14 15:07 ` Ulf Hansson [this message]
2016-06-15 12:47   ` [PATCH 03/10] i2c: designware-platdrv: Unconditionally enable runtime PM Jarkko Nikula
2016-06-20  5:15     ` Ulf Hansson
2016-06-14 15:07 ` [PATCH 04/10] i2c: designware-platdrv: Disable autosuspend in error path in ->probe() Ulf Hansson
2016-06-14 15:07 ` [PATCH 05/10] i2c: designware-platdrv: Fix clk gating in ->remove() Ulf Hansson
2016-06-14 15:07 ` [PATCH 06/10] i2c: designware-platdrv: Update runtime PM last busy mark in ->probe() Ulf Hansson
2016-06-15 13:22   ` Jarkko Nikula
2016-06-14 15:07 ` [PATCH 07/10] i2c: designware-platdrv: Re-init the HW when resuming Ulf Hansson
2016-06-14 15:07 ` [PATCH 08/10] i2c: designware-platdrv: Check return value from clk_prepare_enable() Ulf Hansson
2016-06-14 15:07 ` [PATCH 09/10] i2c: designware-platdrv: Simplify code by using dev_get_drvdata() Ulf Hansson
2016-06-15 11:24   ` Jarkko Nikula
2016-06-14 15:07 ` [PATCH 10/10] i2c: designware-platdrv: Rework system PM support Ulf Hansson
2016-06-14 15:35   ` Andy Shevchenko
2016-06-15  7:52     ` Ulf Hansson
2016-06-14 15:39 ` [PATCH 00/10] i2c: designware-platdrv: Some improvments related to PM Andy Shevchenko
2016-06-15  8:16   ` Ulf Hansson

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=1465916848-8207-4-git-send-email-ulf.hansson@linaro.org \
    --to=ulf.hansson@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).