linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-omap@vger.kernel.org
Cc: Dave Gerlach <d-gerlach@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Nishanth Menon <nm@ti.com>, Suman Anna <s-anna@ti.com>,
	Tero Kristo <t-kristo@ti.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 11/16] bus: ti-sysc: Improve suspend and resume handling
Date: Mon, 23 Apr 2018 10:45:44 -0700	[thread overview]
Message-ID: <20180423174549.57412-12-tony@atomide.com> (raw)
In-Reply-To: <20180423174549.57412-1-tony@atomide.com>

Based on testing with more devices I noticed that some devices
don't suspend or resume properly. We need to PM runtime suspend
and resume devices if we have ddata->needs_resume set.

Let's also improve the error handling and add few debug statements
to make it easier to notice suspend and resume related issues if
DEBUG is set.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/bus/ti-sysc.c | 54 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 48 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -662,6 +662,7 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 static int sysc_suspend(struct device *dev)
 {
 	struct sysc *ddata;
+	int error;
 
 	ddata = dev_get_drvdata(dev);
 
@@ -672,14 +673,27 @@ static int sysc_suspend(struct device *dev)
 	if (!ddata->enabled)
 		return 0;
 
+	dev_dbg(ddata->dev, "%s %s\n", __func__,
+		ddata->name ? ddata->name : "");
+
+	error = pm_runtime_put_sync_suspend(dev);
+	if (error < 0) {
+		dev_warn(ddata->dev, "%s not idle %i %s\n",
+			 __func__, error,
+			 ddata->name ? ddata->name : "");
+
+		return 0;
+	}
+
 	ddata->needs_resume = true;
 
-	return sysc_runtime_suspend(dev);
+	return 0;
 }
 
 static int sysc_resume(struct device *dev)
 {
 	struct sysc *ddata;
+	int error;
 
 	ddata = dev_get_drvdata(dev);
 
@@ -691,9 +705,16 @@ static int sysc_resume(struct device *dev)
 		dev_dbg(ddata->dev, "%s %s\n", __func__,
 			ddata->name ? ddata->name : "");
 
-		ddata->needs_resume = false;
+		error = pm_runtime_get_sync(dev);
+		if (error < 0) {
+			dev_err(ddata->dev, "%s  error %i %s\n",
+				__func__, error,
+				 ddata->name ? ddata->name : "");
 
-		return sysc_runtime_resume(dev);
+			return error;
+		}
+
+		ddata->needs_resume = false;
 	}
 
 	return 0;
@@ -735,6 +756,9 @@ static int sysc_noirq_resume(struct device *dev)
 		return 0;
 
 	if (ddata->needs_resume) {
+		dev_dbg(ddata->dev, "%s %s\n", __func__,
+			ddata->name ? ddata->name : "");
+
 		ddata->needs_resume = false;
 
 		return sysc_runtime_resume(dev);
@@ -1069,18 +1093,33 @@ static int sysc_child_suspend_noirq(struct device *dev)
 
 	ddata = sysc_child_to_parent(dev);
 
+	dev_dbg(ddata->dev, "%s %s\n", __func__,
+		ddata->name ? ddata->name : "");
+
 	error = pm_generic_suspend_noirq(dev);
-	if (error)
+	if (error) {
+		dev_err(dev, "%s error at %i: %i\n",
+			__func__, __LINE__, error);
+
 		return error;
+	}
 
 	if (!pm_runtime_status_suspended(dev)) {
 		error = pm_generic_runtime_suspend(dev);
-		if (error)
+		if (error) {
+			dev_err(dev, "%s error at %i: %i\n",
+				__func__, __LINE__, error);
+
 			return error;
+		}
 
 		error = sysc_runtime_suspend(ddata->dev);
-		if (error)
+		if (error) {
+			dev_err(dev, "%s error at %i: %i\n",
+				__func__, __LINE__, error);
+
 			return error;
+		}
 
 		ddata->child_needs_resume = true;
 	}
@@ -1095,6 +1134,9 @@ static int sysc_child_resume_noirq(struct device *dev)
 
 	ddata = sysc_child_to_parent(dev);
 
+	dev_dbg(ddata->dev, "%s %s\n", __func__,
+		ddata->name ? ddata->name : "");
+
 	if (ddata->child_needs_resume) {
 		ddata->child_needs_resume = false;
 
-- 
2.17.0

  parent reply	other threads:[~2018-04-23 17:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 17:45 [PATCH 00/16] ti-sysc driver changes to support more devices Tony Lindgren
2018-04-23 17:45 ` [PATCH 01/16] ARM: OMAP2+: Drop unused pm-noop Tony Lindgren
2018-04-30 18:57   ` Mauro Carvalho Chehab
2018-04-23 17:45 ` [PATCH 02/16] ARM: OMAP2+: Allow using ti-sysc for system timers Tony Lindgren
2018-04-23 17:45 ` [PATCH 03/16] ARM: OMAP2+: Use signed value for sysc register offsets Tony Lindgren
2018-04-23 17:45 ` [PATCH 04/16] ARM: OMAP2+: Only probe SDMA via ti-sysc if configured in dts Tony Lindgren
2018-04-23 17:45 ` [PATCH 05/16] ARM: OMAP2+: Initialize SoC PM later Tony Lindgren
2018-04-23 17:45 ` [PATCH 06/16] ARM: OMAP2+: Make display related init into device_initcall Tony Lindgren
2018-04-23 17:45 ` [PATCH 07/16] bus: ti-sysc: Handle simple-bus for nested children Tony Lindgren
2018-04-23 17:45 ` [PATCH 08/16] bus: ti-sysc: Make child clock alias handling more generic Tony Lindgren
2018-04-23 17:45 ` [PATCH 09/16] bus: ti-sysc: Add handling for clkctrl opt clocks Tony Lindgren
2018-05-01 13:39   ` Rob Herring
2018-04-23 17:45 ` [PATCH 10/16] bus: ti-sysc: Tag some modules resource providers for noirq suspend Tony Lindgren
2018-04-23 17:45 ` Tony Lindgren [this message]
2018-04-23 17:45 ` [PATCH 12/16] bus: ti-sysc: Add initial support for external resets Tony Lindgren
2018-04-23 17:45 ` [PATCH 13/16] bus: ti-sysc: Detect omap4 type timers for quirk Tony Lindgren
2018-04-23 17:45 ` [PATCH 14/16] bus: ti-sysc: Detect UARTs for SYSC_QUIRK_LEGACY_IDLE quirk on omap4 Tony Lindgren
2018-04-23 17:45 ` [PATCH 15/16] bus: ti-sysc: Tag sdio and wdt with legacy mode for suspend Tony Lindgren
2018-04-23 17:45 ` [PATCH 16/16] bus: ti-sysc: Show module information for suspend if DEBUG is enabled Tony Lindgren

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=20180423174549.57412-12-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=d-gerlach@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=s-anna@ti.com \
    --cc=t-kristo@ti.com \
    /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).