linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Ramirez Luna <omar.ramirez@ti.com>
To: l-o <linux-omap@vger.kernel.org>
Cc: Omar Ramirez Luna <omar.ramirez@ti.com>,
	Fernando Guzman Lugo <fernando.lugo@ti.com>,
	Armando Uribe <x0095078@ti.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 3/8] staging: tidspbridge: remove msleep for dsp transition wait
Date: Wed, 23 Mar 2011 12:49:48 -0600	[thread overview]
Message-ID: <1300906193-1732-4-git-send-email-omar.ramirez@ti.com> (raw)
In-Reply-To: <1300906193-1732-1-git-send-email-omar.ramirez@ti.com>

Remove msleep from the waiting loop used to the dsp
transition into a lower power state. Instead use jiffies
as the timeout count and do not sleep, otherwise when
protecting this functions through spin_lock_bh it will
cause a nasty BUG message to appear.

Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
---
 drivers/staging/tidspbridge/core/tiomap3430_pwr.c |   41 ++++++++++-----------
 1 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
index 69cc2c4..9595abc 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
@@ -81,7 +81,8 @@ int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context)
 {
 	int status = 0;
 #ifdef CONFIG_PM
-	u16 timeout = PWRSTST_TIMEOUT / 10;
+	u8 t;
+	unsigned long v;
 	u32 pwr_state;
 #ifdef CONFIG_TIDSPBRIDGE_DVFS
 	u32 opplevel;
@@ -90,18 +91,17 @@ int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context)
 	struct omap_dsp_platform_data *pdata =
 		omap_dspbridge_dev->dev.platform_data;
 
-	pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) &
-						OMAP_POWERSTATEST_MASK;
 	/* Wait for DSP to move into OFF state */
-	while ((pwr_state != PWRDM_POWER_OFF) && --timeout) {
-		if (msleep_interruptible(10)) {
-			pr_err("Waiting for DSP OFF mode interrupted\n");
-			return -EPERM;
-		}
+	v = msecs_to_jiffies(PWRSTST_TIMEOUT) + jiffies;
+	do {
+		t = time_is_after_jiffies(v);
 		pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
 					OMAP2_PM_PWSTST) & OMAP_POWERSTATEST_MASK;
-	}
-	if (timeout == 0) {
+		if (pwr_state == PWRDM_POWER_OFF)
+			break;
+	} while (t);
+
+	if (!t) {
 		pr_err("%s: Timed out waiting for DSP off mode\n", __func__);
 		status = -ETIMEDOUT;
 		return status;
@@ -154,7 +154,8 @@ int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd,
 #ifdef CONFIG_TIDSPBRIDGE_NTFY_PWRERR
 	struct deh_mgr *hdeh_mgr;
 #endif /* CONFIG_TIDSPBRIDGE_NTFY_PWRERR */
-	u16 timeout = PWRSTST_TIMEOUT / 10;
+	u8 t;
+	unsigned long v;
 	u32 pwr_state, target_pwr_state;
 	struct omap_dsp_platform_data *pdata =
 		omap_dspbridge_dev->dev.platform_data;
@@ -198,21 +199,17 @@ int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd,
 		return -EPERM;
 	}
 
-	/* Get the PRCM DSP power domain status */
-	pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) &
-						OMAP_POWERSTATEST_MASK;
-
 	/* Wait for DSP to move into target power state */
-	while ((pwr_state != target_pwr_state) && --timeout) {
-		if (msleep_interruptible(10)) {
-			pr_err("Waiting for DSP to Suspend interrupted\n");
-			return -EPERM;
-		}
+	v = msecs_to_jiffies(PWRSTST_TIMEOUT) + jiffies;
+	do {
+		t = time_is_after_jiffies(v);
 		pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
 					OMAP2_PM_PWSTST) & OMAP_POWERSTATEST_MASK;
-	}
+		if (pwr_state == target_pwr_state)
+			break;
+	} while (t);
 
-	if (!timeout) {
+	if (!t) {
 		pr_err("%s: Timed out waiting for DSP off mode, state %x\n",
 		       __func__, pwr_state);
 #ifdef CONFIG_TIDSPBRIDGE_NTFY_PWRERR
-- 
1.7.1


  parent reply	other threads:[~2011-03-23 19:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 18:49 [PATCH 0/8] staging: tidspbridge: PM routines cleanup Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 1/8] staging: tidspbridge: make wake_dsp to handle PM code Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 2/8] staging: tidspbridge: fix resume path from retention Omar Ramirez Luna
2011-03-23 18:49 ` Omar Ramirez Luna [this message]
2011-03-23 18:49 ` [PATCH 4/8] staging: tidspbridge: send mbox PM command directly Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 5/8] staging: tidspbridge: send wake message even if dsp is running Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 6/8] staging: tidspbridge: remove redundant code from PM routines Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 7/8] staging: tidspbridge: remove redundant indentation in " Omar Ramirez Luna
2011-03-23 18:49 ` [PATCH 8/8] staging: tidspbridge: protect critical sections on " Omar Ramirez Luna
2011-04-29 19:20 ` [PATCH 0/8] staging: tidspbridge: PM routines cleanup Ramirez Luna, Omar

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=1300906193-1732-4-git-send-email-omar.ramirez@ti.com \
    --to=omar.ramirez@ti.com \
    --cc=felipe.contreras@gmail.com \
    --cc=fernando.lugo@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=x0095078@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).