All of lore.kernel.org
 help / color / mirror / Atom feed
From: jean.pihet@newoldbits.com
To: linux-omap@vger.kernel.org, paul@pwsan.com, b-cousson@ti.com,
	khilman@ti.com, linux-arm-kernel@lists.infradead.org
Cc: Jean Pihet <j-pihet@ti.com>
Subject: [PATCH 1/6] ARM: OMAP2+: PM: protect the power domain state change by a mutex
Date: Wed, 18 Apr 2012 14:39:37 +0200	[thread overview]
Message-ID: <1334752782-28804-2-git-send-email-j-pihet@ti.com> (raw)
In-Reply-To: <1334752782-28804-1-git-send-email-j-pihet@ti.com>

From: Jean Pihet <j-pihet@ti.com>

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm.c          |    8 ++++++--
 arch/arm/mach-omap2/powerdomain.c |    1 +
 arch/arm/mach-omap2/powerdomain.h |    3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index d0c1c96..6918a13 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -100,15 +100,17 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
 	if (!pwrdm || IS_ERR(pwrdm))
 		return -EINVAL;
 
+	mutex_lock(&pwrdm->lock);
+
 	while (!(pwrdm->pwrsts & (1 << pwrst))) {
 		if (pwrst == PWRDM_POWER_OFF)
-			return ret;
+			goto out;
 		pwrst--;
 	}
 
 	next_pwrst = pwrdm_read_next_pwrst(pwrdm);
 	if (next_pwrst == pwrst)
-		return ret;
+		goto out;
 
 	curr_pwrst = pwrdm_read_pwrst(pwrdm);
 	if (curr_pwrst < PWRDM_POWER_ON) {
@@ -141,6 +143,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
 		break;
 	}
 
+out:
+	mutex_unlock(&pwrdm->lock);
 	return ret;
 }
 
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 96ad3dbe..319b277 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -102,6 +102,7 @@ static int _pwrdm_register(struct powerdomain *pwrdm)
 	INIT_LIST_HEAD(&pwrdm->voltdm_node);
 	voltdm_add_pwrdm(voltdm, pwrdm);
 
+	mutex_init(&pwrdm->lock);
 	list_add(&pwrdm->node, &pwrdm_list);
 
 	/* Initialize the powerdomain's state counter */
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 0d72a8a..6c6567d 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -19,7 +19,7 @@
 
 #include <linux/types.h>
 #include <linux/list.h>
-
+#include <linux/mutex.h>
 #include <linux/atomic.h>
 
 #include <plat/cpu.h>
@@ -116,6 +116,7 @@ struct powerdomain {
 	struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
 	struct list_head node;
 	struct list_head voltdm_node;
+	struct mutex lock;
 	int state;
 	unsigned state_counter[PWRDM_MAX_PWRSTS];
 	unsigned ret_logic_off_counter;
-- 
1.7.7.6


WARNING: multiple messages have this Message-ID (diff)
From: jean.pihet@newoldbits.com (jean.pihet at newoldbits.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] ARM: OMAP2+: PM: protect the power domain state change by a mutex
Date: Wed, 18 Apr 2012 14:39:37 +0200	[thread overview]
Message-ID: <1334752782-28804-2-git-send-email-j-pihet@ti.com> (raw)
In-Reply-To: <1334752782-28804-1-git-send-email-j-pihet@ti.com>

From: Jean Pihet <j-pihet@ti.com>

Signed-off-by: Jean Pihet <j-pihet@ti.com>
---
 arch/arm/mach-omap2/pm.c          |    8 ++++++--
 arch/arm/mach-omap2/powerdomain.c |    1 +
 arch/arm/mach-omap2/powerdomain.h |    3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index d0c1c96..6918a13 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -100,15 +100,17 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
 	if (!pwrdm || IS_ERR(pwrdm))
 		return -EINVAL;
 
+	mutex_lock(&pwrdm->lock);
+
 	while (!(pwrdm->pwrsts & (1 << pwrst))) {
 		if (pwrst == PWRDM_POWER_OFF)
-			return ret;
+			goto out;
 		pwrst--;
 	}
 
 	next_pwrst = pwrdm_read_next_pwrst(pwrdm);
 	if (next_pwrst == pwrst)
-		return ret;
+		goto out;
 
 	curr_pwrst = pwrdm_read_pwrst(pwrdm);
 	if (curr_pwrst < PWRDM_POWER_ON) {
@@ -141,6 +143,8 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
 		break;
 	}
 
+out:
+	mutex_unlock(&pwrdm->lock);
 	return ret;
 }
 
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c
index 96ad3dbe..319b277 100644
--- a/arch/arm/mach-omap2/powerdomain.c
+++ b/arch/arm/mach-omap2/powerdomain.c
@@ -102,6 +102,7 @@ static int _pwrdm_register(struct powerdomain *pwrdm)
 	INIT_LIST_HEAD(&pwrdm->voltdm_node);
 	voltdm_add_pwrdm(voltdm, pwrdm);
 
+	mutex_init(&pwrdm->lock);
 	list_add(&pwrdm->node, &pwrdm_list);
 
 	/* Initialize the powerdomain's state counter */
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 0d72a8a..6c6567d 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -19,7 +19,7 @@
 
 #include <linux/types.h>
 #include <linux/list.h>
-
+#include <linux/mutex.h>
 #include <linux/atomic.h>
 
 #include <plat/cpu.h>
@@ -116,6 +116,7 @@ struct powerdomain {
 	struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
 	struct list_head node;
 	struct list_head voltdm_node;
+	struct mutex lock;
 	int state;
 	unsigned state_counter[PWRDM_MAX_PWRSTS];
 	unsigned ret_logic_off_counter;
-- 
1.7.7.6

  reply	other threads:[~2012-04-18 12:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18 12:39 [PATCH v3 0/6] ARM: OMAP2+: PM: introduce the power domains functional states jean.pihet
2012-04-18 12:39 ` jean.pihet at newoldbits.com
2012-04-18 12:39 ` jean.pihet [this message]
2012-04-18 12:39   ` [PATCH 1/6] ARM: OMAP2+: PM: protect the power domain state change by a mutex jean.pihet at newoldbits.com
2012-05-07  6:41   ` Paul Walmsley
2012-05-07  6:41     ` Paul Walmsley
2012-05-08  8:28     ` Jean Pihet
2012-05-08  8:28       ` Jean Pihet
2012-04-18 12:39 ` [PATCH 2/6] ARM: OMAP2+: PM: introduce power domains functional states jean.pihet
2012-04-18 12:39   ` jean.pihet at newoldbits.com
2012-05-07  9:28   ` Paul Walmsley
2012-05-07  9:28     ` Paul Walmsley
2012-05-08  8:40     ` Jean Pihet
2012-05-08  8:40       ` Jean Pihet
2012-05-17 10:04       ` Santosh Shilimkar
2012-05-17 10:04         ` Santosh Shilimkar
2012-05-21 13:53         ` Jean Pihet
2012-05-21 13:53           ` Jean Pihet
2012-05-21 14:25           ` Shilimkar, Santosh
2012-05-21 14:25             ` Shilimkar, Santosh
2012-05-23  6:39             ` Santosh Shilimkar
2012-05-23  6:39               ` Santosh Shilimkar
2012-04-18 12:39 ` [PATCH 3/6] ARM: OMAP2+: PM: use the functional power states API jean.pihet
2012-04-18 12:39   ` jean.pihet at newoldbits.com
2012-04-18 12:39 ` [PATCH 4/6] ARM: OMAP2+: PM: introduce power domains logic and memory functional states jean.pihet
2012-04-18 12:39   ` jean.pihet at newoldbits.com
2012-04-18 12:39 ` [PATCH 5/6] ARM: OMAP2+: PM: use the functional power states API for logic and memory jean.pihet
2012-04-18 12:39   ` jean.pihet at newoldbits.com
2012-04-18 12:39 ` [PATCH 6/6] ARM: OMAP2+: PM: use power domain functional state in stats counters jean.pihet
2012-04-18 12:39   ` jean.pihet at newoldbits.com
  -- strict thread matches above, loose matches on Subject: below --
2012-04-11 20:46 [RFC/PATCH v2 0/6] ARM: OMAP2+: PM: introduce the power domains functional states jean.pihet
2012-04-11 20:46 ` [PATCH 1/6] ARM: OMAP2+: PM: protect the power domain state change by a mutex jean.pihet

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=1334752782-28804-2-git-send-email-j-pihet@ti.com \
    --to=jean.pihet@newoldbits.com \
    --cc=b-cousson@ti.com \
    --cc=j-pihet@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.