linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Menon, Nishanth" <nm@ti.com>
To: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: linux-omap@vger.kernel.org, khilman@ti.com,
	Vishwanath BS <vishwanath.bs@ti.com>,
	"Herman, Saquib" <saquib@ti.com>,
	"Revanna, Amarnath" <amarnath@ti.com>
Subject: Re: [PATCH v2 2/2] OMAP2PLUS: cpufreq: Add SMP support to cater OMAP4430
Date: Tue, 10 May 2011 19:41:32 -0500	[thread overview]
Message-ID: <BANLkTinSPpmepfJNC=2SSPF5KzsHcKXGEw@mail.gmail.com> (raw)
In-Reply-To: <1300102729-17276-3-git-send-email-santosh.shilimkar@ti.com>

On Mon, Mar 14, 2011 at 06:38, Santosh Shilimkar
<santosh.shilimkar@ti.com> wrote:
> On OMAP SMP configuartion, both processors share the voltage
> and clock. So both CPUs needs to be scaled together and hence
> needs software co-ordination.
>
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Kevin Hilman <khilman@ti.com>
> cc: Vishwanath BS <vishwanath.bs@ti.com>
> ---
>  arch/arm/mach-omap2/omap2plus-cpufreq.c |   73 ++++++++++++++++++++++++++-----
>  1 files changed, 62 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c

[...]
>        rate = clk_get_rate(mpu_clk) / 1000;
> @@ -74,9 +76,13 @@ static int omap_target(struct cpufreq_policy *policy,
[...]

> -       cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
> +#ifdef CONFIG_SMP
> +       /*
> +        * Note that loops_per_jiffy is not updated on SMP systems in
> +        * cpufreq driver. So, update the per-CPU loops_per_jiffy value
> +        * on frequency transition. We need to update all dependent CPUs.
> +        */
> +       for_each_cpu(i, policy->cpus)
> +               per_cpu(cpu_data, i).loops_per_jiffy =
> +                       cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
> +                                       freqs.old, freqs.new);
We have an issue here - arch/arm/lib/delay.S uses the generic
loops_per_jiffy which is not updated when smp (OMAP4) is active, as a
result loops_per_jiffy contains the value which was updated. with a
trace added as follows:
diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c
b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 0105c8d..8bad854 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -137,10 +137,14 @@ set_freq:
         * cpufreq driver. So, update the per-CPU loops_per_jiffy value
         * on frequency transition. We need to update all dependent CPUs.
         */
-       for_each_cpu(i, policy->cpus)
+       for_each_cpu(i, policy->cpus) {
                per_cpu(cpu_data, i).loops_per_jiffy =
                        cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
                                        freqs.old, freqs.new);
+               pr_err("%s: loops_per_jiffy=%lu cpu%d.loops_per_jiffy=%d\n",
+                               __func__, loops_per_jiffy, i,
+                               per_cpu(cpu_data, i).loops_per_jiffy);
+       }
 #endif

Testing:600000 freq
[   30.319885] omap_target: loops_per_jiffy=7643136 cpu0.loops_per_jiffy=4666514
[   30.327758] omap_target: loops_per_jiffy=7643136 cpu1.loops_per_jiffy=4549484
testing:800000
[   31.419616] omap_target: loops_per_jiffy=7643136 cpu0.loops_per_jiffy=6222018
[   31.427612] omap_target: loops_per_jiffy=7643136 cpu1.loops_per_jiffy=6065978
testing:1008000
[   32.532012] omap_target: loops_per_jiffy=7643136 cpu0.loops_per_jiffy=7839742
[   32.540252] omap_target: loops_per_jiffy=7643136 cpu1.loops_per_jiffy=7643132

Luckily my bootloader was booting up at 1GHz, but for folks booting at
OPP100, well.. at 1GHz, the mdelays and udelays are going to be wrong
badly.

With a quick patch as follows (by Amarnath/Saquib), the output is:
testing:600000
[   27.499603] omap_target: loops_per_jiffy=4666514 cpu0.loops_per_jiffy=4666514
[   27.507507] omap_target: loops_per_jiffy=4666514 cpu1.loops_per_jiffy=4549484
testing:800000
[   28.617553] omap_target: loops_per_jiffy=6222018 cpu0.loops_per_jiffy=6222018
[   28.625518] omap_target: loops_per_jiffy=6222018 cpu1.loops_per_jiffy=6065978
testing:1008000
[   29.724578] omap_target: loops_per_jiffy=7839742 cpu0.loops_per_jiffy=7839742
[   29.732818] omap_target: loops_per_jiffy=7839742 cpu1.loops_per_jiffy=7643132

patch:
diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c
b/arch/arm/mach-omap2/omap2plus-cpufreq.c
index 0105c8d..58a968d 100644
--- a/arch/arm/mach-omap2/omap2plus-cpufreq.c
+++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c
@@ -80,6 +80,7 @@ static int omap_target(struct cpufreq_policy *policy,
        int i, ret = 0;
        struct cpufreq_freqs freqs;
        struct device *mpu_dev = omap2_get_mpuss_device();
+       unsigned int jiffy_loop_cpu = 0;

        /* Changes not allowed until all CPUs are online */
        if (is_smp() && (num_online_cpus() < NR_CPUS))
@@ -137,10 +138,14 @@ set_freq:
         * cpufreq driver. So, update the per-CPU loops_per_jiffy value
         * on frequency transition. We need to update all dependent CPUs.
         */
-       for_each_cpu(i, policy->cpus)
+       for_each_cpu(i, policy->cpus) {
                per_cpu(cpu_data, i).loops_per_jiffy =
                        cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy,
                                        freqs.old, freqs.new);
+               if (per_cpu(cpu_data, i).loops_per_jiffy > jiffy_loop_cpu)
+                       jiffy_loop_cpu = per_cpu(cpu_data, i).loops_per_jiffy;
+       }
+       loops_per_jiffy = jiffy_loop_cpu;
 #endif

        /* notifiers */

Question: what would be the best solution for this? is a solution
isolated to OMAP good enough?

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-05-11  0:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 11:38 [PATCH v2 0/2] [pm-wip/cpufreq] OMAP: CPUfreq cleanup and SMP support Santosh Shilimkar
2011-03-14 11:38 ` [PATCH v2 1/2] OMAP: cpufreq: Split OMAP1 and OMAP2PLUS CPUfreq drivers Santosh Shilimkar
2011-03-14 11:38 ` [PATCH v2 2/2] OMAP2PLUS: cpufreq: Add SMP support to cater OMAP4430 Santosh Shilimkar
2011-05-11  0:41   ` Menon, Nishanth [this message]
2011-05-11  7:10     ` Santosh Shilimkar
2011-03-17 21:50 ` [PATCH v2 0/2] [pm-wip/cpufreq] OMAP: CPUfreq cleanup and SMP support Kevin Hilman

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='BANLkTinSPpmepfJNC=2SSPF5KzsHcKXGEw@mail.gmail.com' \
    --to=nm@ti.com \
    --cc=amarnath@ti.com \
    --cc=khilman@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    --cc=saquib@ti.com \
    --cc=vishwanath.bs@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).