From: "J, KEERTHY" <j-keerthy@ti.com> To: "AnilKumar, Chimata" <anilkumar@ti.com> Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "Hilman, Kevin" <khilman@ti.com>, "rjw@sisk.pl" <rjw@sisk.pl>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-pm@lists.linux-foundation.org" <linux-pm@lists.linux-foundation.org>, "Pihet-XID, Jean" <j-pihet@ti.com> Subject: Re: [PATCH V3 05/10] ARM: OMAP2+: SmartReflex: introduce a busy loop condition test macro Date: Mon, 7 May 2012 10:51:53 +0530 [thread overview] Message-ID: <CAJ6a13aA9nutZvRkcj8GHok9cEe8A=J2bwzSXt=Sd0Hu_WPaPw@mail.gmail.com> (raw) In-Reply-To: <331ABD5ECB02734CA317220B2BBEABC13E9B1B40@DBDE01.ent.ti.com> On Fri, May 4, 2012 at 2:42 PM, AnilKumar, Chimata <anilkumar@ti.com> wrote: > On Thu, Apr 26, 2012 at 23:10:36, J, KEERTHY wrote: >> From: Jean Pihet <j-pihet@ti.com> >> >> Now that omap_test_timeout is only accessible from mach-omap2/, >> introduce a similar function for SR. >> >> This change makes the SmartReflex implementation ready for the move >> to drivers/. >> >> Signed-off-by: Jean Pihet <j-pihet@ti.com> >> Signed-off-by: J Keerthy <j-keerthy@ti.com> >> --- >> arch/arm/mach-omap2/smartreflex.c | 12 ++++++------ >> include/linux/power/smartreflex.h | 23 ++++++++++++++++++++++- >> 2 files changed, 28 insertions(+), 7 deletions(-) >> >> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c >> index d859277..acef08d 100644 >> --- a/arch/arm/mach-omap2/smartreflex.c >> +++ b/arch/arm/mach-omap2/smartreflex.c >> @@ -289,9 +289,9 @@ static void sr_v1_disable(struct omap_sr *sr) >> * Wait for SR to be disabled. >> * wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us. >> */ >> - omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) & >> - ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, >> - timeout); >> + sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) & >> + ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, >> + timeout); >> >> if (timeout >= SR_DISABLE_TIMEOUT) >> dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", >> @@ -334,9 +334,9 @@ static void sr_v2_disable(struct omap_sr *sr) >> * Wait for SR to be disabled. >> * wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us. >> */ >> - omap_test_timeout((sr_read_reg(sr, IRQSTATUS) & >> - IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, >> - timeout); >> + sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) & >> + IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, >> + timeout); >> >> if (timeout >= SR_DISABLE_TIMEOUT) >> dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", >> diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h >> index 884eaee..78b795e 100644 >> --- a/include/linux/power/smartreflex.h >> +++ b/include/linux/power/smartreflex.h >> @@ -22,7 +22,7 @@ >> >> #include <linux/types.h> >> #include <linux/platform_device.h> >> - >> +#include <linux/delay.h> >> #include <plat/voltage.h> >> >> /* >> @@ -168,6 +168,27 @@ struct omap_sr { >> }; >> >> /** >> + * test_cond_timeout - busy-loop, testing a condition >> + * @cond: condition to test until it evaluates to true >> + * @timeout: maximum number of microseconds in the timeout >> + * @index: loop index (integer) >> + * >> + * Loop waiting for @cond to become true or until at least @timeout >> + * microseconds have passed. To use, define some integer @index in the >> + * calling code. After running, if @index == @timeout, then the loop has >> + * timed out. >> + * >> + * Copied from omap_test_timeout */ >> +#define sr_test_cond_timeout(cond, timeout, index) \ >> +({ \ >> + for (index = 0; index < timeout; index++) { \ >> + if (cond) \ >> + break; \ >> + udelay(1); \ >> + } \ >> +}) > > I think we can use time_after()/time_before() APIs for timeout and cpu_relax() for > tight loops instead of udelay(). cpu_relax() changes the priority everytime to low and will yield to another thread. Considering that we are checking the condition every microsecond does it make some saving using cpu_relax(). > > Regards > AnilKumar -- Regards and Thanks, Keerthy
WARNING: multiple messages have this Message-ID (diff)
From: j-keerthy@ti.com (J, KEERTHY) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH V3 05/10] ARM: OMAP2+: SmartReflex: introduce a busy loop condition test macro Date: Mon, 7 May 2012 10:51:53 +0530 [thread overview] Message-ID: <CAJ6a13aA9nutZvRkcj8GHok9cEe8A=J2bwzSXt=Sd0Hu_WPaPw@mail.gmail.com> (raw) In-Reply-To: <331ABD5ECB02734CA317220B2BBEABC13E9B1B40@DBDE01.ent.ti.com> On Fri, May 4, 2012 at 2:42 PM, AnilKumar, Chimata <anilkumar@ti.com> wrote: > On Thu, Apr 26, 2012 at 23:10:36, J, KEERTHY wrote: >> From: Jean Pihet <j-pihet@ti.com> >> >> Now that omap_test_timeout is only accessible from mach-omap2/, >> introduce a similar function for SR. >> >> This change makes the SmartReflex implementation ready for the move >> to drivers/. >> >> Signed-off-by: Jean Pihet <j-pihet@ti.com> >> Signed-off-by: J Keerthy <j-keerthy@ti.com> >> --- >> ?arch/arm/mach-omap2/smartreflex.c | ? 12 ++++++------ >> ?include/linux/power/smartreflex.h | ? 23 ++++++++++++++++++++++- >> ?2 files changed, 28 insertions(+), 7 deletions(-) >> >> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c >> index d859277..acef08d 100644 >> --- a/arch/arm/mach-omap2/smartreflex.c >> +++ b/arch/arm/mach-omap2/smartreflex.c >> @@ -289,9 +289,9 @@ static void sr_v1_disable(struct omap_sr *sr) >> ? ? ? ?* Wait for SR to be disabled. >> ? ? ? ?* wait until ERRCONFIG.MCUDISACKINTST = 1. Typical latency is 1us. >> ? ? ? ?*/ >> - ? ? omap_test_timeout((sr_read_reg(sr, ERRCONFIG_V1) & >> - ? ? ? ? ? ? ? ? ? ? ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, >> - ? ? ? ? ? ? ? ? ? ? timeout); >> + ? ? sr_test_cond_timeout((sr_read_reg(sr, ERRCONFIG_V1) & >> + ? ? ? ? ? ? ? ? ? ? ? ? ?ERRCONFIG_MCUDISACKINTST), SR_DISABLE_TIMEOUT, >> + ? ? ? ? ? ? ? ? ? ? ? ? ?timeout); >> >> ? ? ? if (timeout >= SR_DISABLE_TIMEOUT) >> ? ? ? ? ? ? ? dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", >> @@ -334,9 +334,9 @@ static void sr_v2_disable(struct omap_sr *sr) >> ? ? ? ?* Wait for SR to be disabled. >> ? ? ? ?* wait until IRQSTATUS.MCUDISACKINTST = 1. Typical latency is 1us. >> ? ? ? ?*/ >> - ? ? omap_test_timeout((sr_read_reg(sr, IRQSTATUS) & >> - ? ? ? ? ? ? ? ? ? ? IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, >> - ? ? ? ? ? ? ? ? ? ? timeout); >> + ? ? sr_test_cond_timeout((sr_read_reg(sr, IRQSTATUS) & >> + ? ? ? ? ? ? ? ? ? ? ? ? ?IRQSTATUS_MCUDISABLEACKINT), SR_DISABLE_TIMEOUT, >> + ? ? ? ? ? ? ? ? ? ? ? ? ?timeout); >> >> ? ? ? if (timeout >= SR_DISABLE_TIMEOUT) >> ? ? ? ? ? ? ? dev_warn(&sr->pdev->dev, "%s: Smartreflex disable timedout\n", >> diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h >> index 884eaee..78b795e 100644 >> --- a/include/linux/power/smartreflex.h >> +++ b/include/linux/power/smartreflex.h >> @@ -22,7 +22,7 @@ >> >> ?#include <linux/types.h> >> ?#include <linux/platform_device.h> >> - >> +#include <linux/delay.h> >> ?#include <plat/voltage.h> >> >> ?/* >> @@ -168,6 +168,27 @@ struct omap_sr { >> ?}; >> >> ?/** >> + * test_cond_timeout - busy-loop, testing a condition >> + * @cond: condition to test until it evaluates to true >> + * @timeout: maximum number of microseconds in the timeout >> + * @index: loop index (integer) >> + * >> + * Loop waiting for @cond to become true or until at least @timeout >> + * microseconds have passed. ?To use, define some integer @index in the >> + * calling code. ?After running, if @index == @timeout, then the loop has >> + * timed out. >> + * >> + * Copied from omap_test_timeout */ >> +#define sr_test_cond_timeout(cond, timeout, index) ? ? ? ? ? \ >> +({ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ >> + ? ? for (index = 0; index < timeout; index++) { ? ? ? ? ? ? \ >> + ? ? ? ? ? ? if (cond) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ >> + ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ >> + ? ? ? ? ? ? udelay(1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\ >> + ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ >> +}) > > I think we can use time_after()/time_before() APIs for timeout and cpu_relax() for > tight loops instead of udelay(). cpu_relax() changes the priority everytime to low and will yield to another thread. Considering that we are checking the condition every microsecond does it make some saving using cpu_relax(). > > Regards > AnilKumar -- Regards and Thanks, Keerthy
next prev parent reply other threads:[~2012-05-07 5:21 UTC|newest] Thread overview: 141+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-04-26 17:40 [PATCH V3 00/10] PM: Create the AVS(Adaptive Voltage Scaling) Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 01/10] ARM: OMAP2+: SmartReflex: move the smartreflex header to include/linux/power Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 02/10] ARM: OMAP3+: SmartReflex: class drivers should use struct omap_sr * Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 03/10] ARM: OMAP2+: smartreflex: Use the names from hwmod data instead of voltage domains Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 04/10] ARM: OMAP3: hwmod: rename the smartreflex entries Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-05-04 8:30 ` AnilKumar, Chimata 2012-05-04 8:30 ` AnilKumar, Chimata 2012-05-04 8:30 ` AnilKumar, Chimata 2012-05-04 10:11 ` J, KEERTHY 2012-05-04 10:11 ` J, KEERTHY 2012-05-04 10:11 ` J, KEERTHY 2012-05-07 23:39 ` Kevin Hilman 2012-05-07 23:39 ` Kevin Hilman 2012-05-07 23:39 ` Kevin Hilman 2012-05-07 23:55 ` Kevin Hilman 2012-05-07 23:55 ` Kevin Hilman 2012-05-07 23:55 ` Kevin Hilman 2012-05-08 3:44 ` J, KEERTHY 2012-05-08 3:44 ` J, KEERTHY 2012-05-08 3:44 ` J, KEERTHY 2012-04-26 17:40 ` [PATCH V3 05/10] ARM: OMAP2+: SmartReflex: introduce a busy loop condition test macro Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-05-04 9:12 ` AnilKumar, Chimata 2012-05-04 9:12 ` AnilKumar, Chimata 2012-05-04 9:12 ` AnilKumar, Chimata 2012-05-07 5:21 ` J, KEERTHY [this message] 2012-05-07 5:21 ` J, KEERTHY 2012-05-07 5:21 ` J, KEERTHY 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-10 6:19 ` J, KEERTHY 2012-05-10 6:19 ` J, KEERTHY 2012-05-10 6:19 ` J, KEERTHY 2012-04-26 17:40 ` [PATCH V3 06/10] ARM: OMAP2+: Voltage: Move the omap_volt_data structure to plat Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 07/10] ARM: OMAP2+: SmartReflex: Use per-OPP data structure Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-05-10 19:11 ` Guyotte, Greg 2012-05-10 19:11 ` Guyotte, Greg 2012-05-10 19:11 ` Guyotte, Greg 2012-05-11 3:51 ` J, KEERTHY 2012-05-11 3:51 ` J, KEERTHY 2012-05-11 3:51 ` J, KEERTHY 2012-04-26 17:40 ` [PATCH V3 08/10] ARM: OMAP2+: SmartReflex: Create per-opp debugfs node for errminlimit Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 09/10] ARM: OMAP2+: SmartReflex: add POWER_AVS Kconfig options Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` [PATCH V3 10/10] ARM: OMAP: SmartReflex: Move smartreflex driver to drivers/ Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 17:40 ` Keerthy 2012-04-26 19:11 ` [PATCH V3 00/10] PM: Create the AVS(Adaptive Voltage Scaling) Mark Brown 2012-04-26 19:11 ` Mark Brown 2012-04-26 19:11 ` Mark Brown 2012-04-27 5:39 ` J, KEERTHY 2012-04-27 5:39 ` J, KEERTHY 2012-04-27 17:56 ` Mark Brown 2012-04-27 17:56 ` Mark Brown 2012-04-27 17:56 ` Mark Brown 2012-04-27 21:01 ` Kevin Hilman 2012-04-27 21:01 ` Kevin Hilman 2012-04-27 21:01 ` Kevin Hilman 2012-04-30 4:25 ` J, KEERTHY 2012-04-30 4:25 ` J, KEERTHY 2012-04-30 4:25 ` J, KEERTHY 2012-04-30 9:54 ` Mark Brown 2012-04-30 9:54 ` Mark Brown 2012-04-30 9:54 ` Mark Brown 2012-04-30 21:51 ` Kevin Hilman 2012-04-30 21:51 ` Kevin Hilman 2012-04-30 21:51 ` Kevin Hilman 2012-05-02 5:04 ` J, KEERTHY 2012-05-02 5:04 ` J, KEERTHY 2012-05-02 5:04 ` J, KEERTHY 2012-05-04 5:05 ` J, KEERTHY 2012-05-04 5:05 ` J, KEERTHY 2012-05-04 5:05 ` J, KEERTHY 2012-05-04 8:21 ` AnilKumar, Chimata 2012-05-04 8:21 ` AnilKumar, Chimata 2012-05-04 8:21 ` AnilKumar, Chimata 2012-05-07 23:48 ` Kevin Hilman 2012-05-07 23:48 ` Kevin Hilman 2012-05-07 23:48 ` Kevin Hilman 2012-05-08 3:48 ` J, KEERTHY 2012-05-08 3:48 ` J, KEERTHY 2012-05-08 3:48 ` J, KEERTHY 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-08 10:17 ` AnilKumar, Chimata 2012-05-08 20:38 ` Woodruff, Richard 2012-05-08 20:38 ` Woodruff, Richard 2012-05-08 20:38 ` Woodruff, Richard 2012-05-08 22:16 ` [linux-pm] " Kevin Hilman 2012-05-08 22:16 ` Kevin Hilman 2012-05-08 22:16 ` Kevin Hilman 2012-05-09 0:39 ` Woodruff, Richard 2012-05-09 0:39 ` Woodruff, Richard 2012-05-09 0:39 ` Woodruff, Richard 2012-05-09 8:19 ` [linux-pm] " Koen Kooi 2012-05-09 8:19 ` Koen Kooi 2012-05-09 8:19 ` Koen Kooi 2012-05-09 18:29 ` Kevin Hilman 2012-05-09 18:29 ` Kevin Hilman 2012-05-09 18:29 ` Kevin Hilman 2012-05-23 13:27 ` Menon, Nishanth 2012-05-23 13:27 ` Menon, Nishanth 2012-05-23 13:27 ` Menon, Nishanth 2012-05-24 23:16 ` [linux-pm] " Kevin Hilman 2012-05-24 23:16 ` Kevin Hilman 2012-05-24 23:16 ` Kevin Hilman 2012-05-07 23:51 ` Kevin Hilman 2012-05-07 23:51 ` Kevin Hilman 2012-05-07 23:51 ` Kevin Hilman 2012-05-15 5:46 ` J, KEERTHY 2012-05-15 5:46 ` J, KEERTHY 2012-05-15 5:46 ` J, KEERTHY 2012-05-23 4:51 ` J, KEERTHY 2012-05-23 4:51 ` J, KEERTHY 2012-05-24 17:24 ` Kevin Hilman 2012-05-24 17:24 ` Kevin Hilman 2012-05-24 17:24 ` Kevin Hilman 2012-05-31 22:40 ` Kevin Hilman 2012-05-31 22:40 ` Kevin Hilman 2012-05-31 22:40 ` Kevin Hilman 2012-06-01 3:45 ` J, KEERTHY 2012-06-01 3:45 ` J, KEERTHY
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='CAJ6a13aA9nutZvRkcj8GHok9cEe8A=J2bwzSXt=Sd0Hu_WPaPw@mail.gmail.com' \ --to=j-keerthy@ti.com \ --cc=anilkumar@ti.com \ --cc=j-pihet@ti.com \ --cc=khilman@ti.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=linux-pm@lists.linux-foundation.org \ --cc=rjw@sisk.pl \ /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: linkBe 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.