All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	thierry.reding@gmail.com, bcousson@baylibre.com,
	tony@atomide.com, linux@arm.linux.org.uk,
	mchehab@osg.samsung.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pwm@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, sre@kernel.org,
	pali.rohar@gmail.com,
	Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Subject: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
Date: Sat,  7 May 2016 18:21:46 +0300	[thread overview]
Message-ID: <1462634508-24961-6-git-send-email-ivo.g.dimitrov.75@gmail.com> (raw)
In-Reply-To: <1462634508-24961-1-git-send-email-ivo.g.dimitrov.75@gmail.com>

once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
functions called in omap_dm_timer_enable/disable lead to long and unneeded
delays.

Fix that by implementing an "enabled" counter, so the PM runtime functions
get called only when really needed.

Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/plat-omap/dmtimer.c              | 9 ++++++++-
 arch/arm/plat-omap/include/plat/dmtimer.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 7a327bd..f35a78c 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -365,6 +365,9 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer)
 {
 	int c;
 
+	if (timer->enabled++)
+		return;
+
 	pm_runtime_get_sync(&timer->pdev->dev);
 
 	if (!(timer->capability & OMAP_TIMER_ALWON)) {
@@ -383,7 +386,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
 
 void omap_dm_timer_disable(struct omap_dm_timer *timer)
 {
-	pm_runtime_put_sync(&timer->pdev->dev);
+	if (timer->enabled == 1)
+		pm_runtime_put_sync(&timer->pdev->dev);
+
+	if (timer->enabled)
+		timer->enabled--;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
 
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index dd79f30..fc984e1 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -114,6 +114,7 @@ struct omap_dm_timer {
 	unsigned long rate;
 	unsigned reserved:1;
 	unsigned posted:1;
+	u32 enabled;
 	struct timer_regs context;
 	int (*get_context_loss_count)(struct device *);
 	int ctx_loss_count;
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	thierry.reding@gmail.com, bcousson@baylibre.com,
	tony@atomide.com, linux@arm.linux.org.uk,
	mchehab@osg.samsung.com
Cc: devicetree@vger.kernel.org,
	Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	sre@kernel.org, pali.rohar@gmail.com, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
Date: Sat,  7 May 2016 18:21:46 +0300	[thread overview]
Message-ID: <1462634508-24961-6-git-send-email-ivo.g.dimitrov.75@gmail.com> (raw)
In-Reply-To: <1462634508-24961-1-git-send-email-ivo.g.dimitrov.75@gmail.com>

once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
functions called in omap_dm_timer_enable/disable lead to long and unneeded
delays.

Fix that by implementing an "enabled" counter, so the PM runtime functions
get called only when really needed.

Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/plat-omap/dmtimer.c              | 9 ++++++++-
 arch/arm/plat-omap/include/plat/dmtimer.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 7a327bd..f35a78c 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -365,6 +365,9 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer)
 {
 	int c;
 
+	if (timer->enabled++)
+		return;
+
 	pm_runtime_get_sync(&timer->pdev->dev);
 
 	if (!(timer->capability & OMAP_TIMER_ALWON)) {
@@ -383,7 +386,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
 
 void omap_dm_timer_disable(struct omap_dm_timer *timer)
 {
-	pm_runtime_put_sync(&timer->pdev->dev);
+	if (timer->enabled == 1)
+		pm_runtime_put_sync(&timer->pdev->dev);
+
+	if (timer->enabled)
+		timer->enabled--;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
 
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index dd79f30..fc984e1 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -114,6 +114,7 @@ struct omap_dm_timer {
 	unsigned long rate;
 	unsigned reserved:1;
 	unsigned posted:1;
+	u32 enabled;
 	struct timer_regs context;
 	int (*get_context_loss_count)(struct device *);
 	int ctx_loss_count;
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: ivo.g.dimitrov.75@gmail.com (Ivaylo Dimitrov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed.
Date: Sat,  7 May 2016 18:21:46 +0300	[thread overview]
Message-ID: <1462634508-24961-6-git-send-email-ivo.g.dimitrov.75@gmail.com> (raw)
In-Reply-To: <1462634508-24961-1-git-send-email-ivo.g.dimitrov.75@gmail.com>

once omap_dm_timer_start() is called, which calls omap_dm_timer_enable()
and thus pm_runtime_get_sync(), it doesn't make sense to call PM runtime
functions again before omap_dm_timer_stop is called(). Otherwise PM runtime
functions called in omap_dm_timer_enable/disable lead to long and unneeded
delays.

Fix that by implementing an "enabled" counter, so the PM runtime functions
get called only when really needed.

Without that patch Nokia N900 IR TX driver (ir-rx51) does not function.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
---
 arch/arm/plat-omap/dmtimer.c              | 9 ++++++++-
 arch/arm/plat-omap/include/plat/dmtimer.h | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 7a327bd..f35a78c 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -365,6 +365,9 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer)
 {
 	int c;
 
+	if (timer->enabled++)
+		return;
+
 	pm_runtime_get_sync(&timer->pdev->dev);
 
 	if (!(timer->capability & OMAP_TIMER_ALWON)) {
@@ -383,7 +386,11 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_enable);
 
 void omap_dm_timer_disable(struct omap_dm_timer *timer)
 {
-	pm_runtime_put_sync(&timer->pdev->dev);
+	if (timer->enabled == 1)
+		pm_runtime_put_sync(&timer->pdev->dev);
+
+	if (timer->enabled)
+		timer->enabled--;
 }
 EXPORT_SYMBOL_GPL(omap_dm_timer_disable);
 
diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index dd79f30..fc984e1 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -114,6 +114,7 @@ struct omap_dm_timer {
 	unsigned long rate;
 	unsigned reserved:1;
 	unsigned posted:1;
+	u32 enabled;
 	struct timer_regs context;
 	int (*get_context_loss_count)(struct device *);
 	int ctx_loss_count;
-- 
1.9.1

  parent reply	other threads:[~2016-05-07 15:23 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07 15:21 [PATCH 0/7] ir-rx51 driver fixes Ivaylo Dimitrov
2016-05-07 15:21 ` Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 1/7] ir-rx51: Fix build after multiarch changes broke it Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 2/7] pwm: omap-dmtimer: Allow for setting dmtimer clock source Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-09 20:01   ` Rob Herring
2016-05-09 20:01     ` Rob Herring
2016-05-07 15:21 ` [PATCH 3/7] [media] ir-rx51: use PWM framework instead of OMAP dmtimer Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 4/7] [media] ir-rx51: add DT support to driver Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-09 20:06   ` Rob Herring
2016-05-09 20:06     ` Rob Herring
2016-05-09 20:53     ` Ivaylo Dimitrov
2016-05-09 20:53       ` Ivaylo Dimitrov
2016-05-09 20:53       ` Ivaylo Dimitrov
2016-05-09 21:07       ` Rob Herring
2016-05-09 21:07         ` Rob Herring
2016-05-09 21:07         ` Rob Herring
2016-05-09 22:06         ` Ivaylo Dimitrov
2016-05-09 22:06           ` Ivaylo Dimitrov
2016-05-10  2:18         ` Sebastian Reichel
2016-05-10  2:18           ` Sebastian Reichel
2016-05-11 14:14           ` Rob Herring
2016-05-11 14:14             ` Rob Herring
2016-05-13  6:15             ` Ivaylo Dimitrov
2016-05-13  6:15               ` Ivaylo Dimitrov
2016-05-13 14:01               ` Sebastian Reichel
2016-05-13 14:01                 ` Sebastian Reichel
2016-05-07 15:21 ` Ivaylo Dimitrov [this message]
2016-05-07 15:21   ` [PATCH 5/7] ARM: OMAP: dmtimer: Do not call PM runtime functions when not needed Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-09 19:36   ` Tony Lindgren
2016-05-09 19:36     ` Tony Lindgren
2016-05-09 19:36     ` Tony Lindgren
2016-05-09 20:51     ` Ivaylo Dimitrov
2016-05-09 20:51       ` Ivaylo Dimitrov
2016-06-10 10:22       ` Tony Lindgren
2016-06-10 10:22         ` Tony Lindgren
2016-06-10 21:21         ` Ivaylo Dimitrov
2016-06-10 21:21           ` Ivaylo Dimitrov
2016-06-13  7:10           ` Tony Lindgren
2016-06-13  7:10             ` Tony Lindgren
2016-06-13  7:39             ` Tony Lindgren
2016-06-13  7:39               ` Tony Lindgren
2016-06-13 18:58             ` Ivaylo Dimitrov
2016-06-13 18:58               ` Ivaylo Dimitrov
2016-06-14  7:53               ` Tony Lindgren
2016-06-14  7:53                 ` Tony Lindgren
2016-06-14  7:53                 ` Tony Lindgren
2016-05-07 15:21 ` [PATCH 6/7] [media] ir-rx51: use hrtimer instead of dmtimer Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-05-07 15:21 ` [PATCH 7/7] ARM: dts: n900: enable lirc-rx51 driver Ivaylo Dimitrov
2016-05-07 15:21   ` Ivaylo Dimitrov
2016-06-10 10:20   ` Tony Lindgren
2016-06-10 10:20     ` Tony Lindgren
2016-06-13 18:17 ` [PATCH 0/7] ir-rx51 driver fixes Pali Rohár
2016-06-13 18:17   ` Pali Rohár
2016-06-13 18:48   ` Ivaylo Dimitrov
2016-06-13 18:48     ` Ivaylo Dimitrov

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=1462634508-24961-6-git-send-email-ivo.g.dimitrov.75@gmail.com \
    --to=ivo.g.dimitrov.75@gmail.com \
    --cc=bcousson@baylibre.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@osg.samsung.com \
    --cc=pali.rohar@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=tony@atomide.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.