From patchwork Thu Mar 29 13:15:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 7520 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D28FE23E29 for ; Thu, 29 Mar 2012 13:15:51 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9AA1EA185F7 for ; Thu, 29 Mar 2012 13:15:51 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so4050832iag.11 for ; Thu, 29 Mar 2012 06:15:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-forwarded-to:x-forwarded-for:delivered-to :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=WulDarg+DaPsA5H4yFx32NFdqVup72cyzCr1yqbn7k4=; b=ij1geuiudylUW+0WF6VncltK19+iQxNaq5g+MppSJeUhJTjdbptguwgucJtR8gpaAi P+dQRcHQ9hgp0lV/Bi0XGuVy7xWXu0eAJs5aDrXnYXS0UV57nMMQ0ffm/m/cjJusykfc ucrkBAEJMVd6jREjLYXZUf9rJgXU5taNU3kJaOJRR21jISqQ8wVJcu3U5f+Lb+eCof6O oqOgxB3qU24Z80DKKfHMTaScHYFMZn4d9wiTNYRFIoD7TKV8xs+yqR6bsYto2Io9Wxtw Hsi80bLeb0wFlXFobbjC+fRCbFlo+aqcZ8W/HMdMqB+ZO/V0i7ozMvqUNw1ccIqQh1qC 0+Cw== MIME-Version: 1.0 Received: by 10.50.46.164 with SMTP id w4mr1475761igm.54.1333026951389; Thu, 29 Mar 2012 06:15:51 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.5.205 with SMTP id 13csp30187ibw; Thu, 29 Mar 2012 06:15:50 -0700 (PDT) Received: by 10.204.128.204 with SMTP id l12mr2928423bks.9.1333026949986; Thu, 29 Mar 2012 06:15:49 -0700 (PDT) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id il18si3406385bkc.128.2012.03.29.06.15.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Mar 2012 06:15:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by mail-bk0-f50.google.com with SMTP id w11so2812908bku.37 for ; Thu, 29 Mar 2012 06:15:49 -0700 (PDT) Received: by 10.205.125.142 with SMTP id gs14mr14214120bkc.95.1333026949302; Thu, 29 Mar 2012 06:15:49 -0700 (PDT) Received: from e103592.peterhouse.linaro.org (fw-lnat.cambridge.arm.com. [217.140.96.63]) by mx.google.com with ESMTPS id z14sm10772032bky.15.2012.03.29.06.15.47 (version=SSLv3 cipher=OTHER); Thu, 29 Mar 2012 06:15:48 -0700 (PDT) From: Dave Martin To: linaro-big-little@lists.linaro.org Cc: patches@linaro.org, Chris Redpath , Morten Rasmussen , Robin Randhawa , Dave Martin Subject: [PATCH v3 2/2] cpufreq/arm-bl-cpufreq: cpufreq transition notifications support Date: Thu, 29 Mar 2012 14:15:34 +0100 Message-Id: <1333026934-21429-3-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1333026934-21429-1-git-send-email-dave.martin@linaro.org> References: <1333026934-21429-1-git-send-email-dave.martin@linaro.org> X-Gm-Message-State: ALoCoQnJIk/TbdXpPcBE3reSTLbsDnRVeaKv49fE41shhbPrNHpSgKh37myVE2Hcnnkfmuda8vzY This patch adds transition notifications using cpufreq_notify_transition(). This is needed in order for the expected values to appear when reading scaling_cur_freq and scaling_setspeed in /sys/devices/system/cpu/*/cpufreq/. To make this easier, some minor refactoring is done so that struct cpufreq_frequency_table * is passed around instead of frequencies/cluster numbers, where appropriate. This makes it easier to get the frquency and cluster values for a given performance point. Signed-off-by: Dave Martin --- drivers/cpufreq/arm-bl-cpufreq_driver.c | 51 +++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/arm-bl-cpufreq_driver.c b/drivers/cpufreq/arm-bl-cpufreq_driver.c index ffcd03b..df657c6 100644 --- a/drivers/cpufreq/arm-bl-cpufreq_driver.c +++ b/drivers/cpufreq/arm-bl-cpufreq_driver.c @@ -54,17 +54,34 @@ static struct cpufreq_frequency_table __read_mostly bl_freqs[] = { /* Miscellaneous helpers */ -static unsigned int cluster_to_freq(int cluster) +static unsigned int entry_to_freq( + struct cpufreq_frequency_table const *entry) +{ + return entry->frequency; +} + +static unsigned int entry_to_cluster( + struct cpufreq_frequency_table const *entry) +{ + return entry->index; +} + +static struct cpufreq_frequency_table const *find_entry_by_cluster(int cluster) { unsigned int i; - for(i = 0; bl_freqs[i].frequency != CPUFREQ_TABLE_END; i++) - if(bl_freqs[i].index == cluster) - return bl_freqs[i].frequency; + for(i = 0; entry_to_freq(&bl_freqs[i]) != CPUFREQ_TABLE_END; i++) + if(entry_to_cluster(&bl_freqs[i]) == cluster) + return &bl_freqs[i]; WARN(1, pr_fmt("%s(): invalid cluster number %d, assuming 0\n"), __func__, cluster); - return bl_freqs[0].frequency; + return &bl_freqs[0]; +} + +static unsigned int cluster_to_freq(int cluster) +{ + return entry_to_freq(find_entry_by_cluster(cluster)); } /* @@ -89,13 +106,27 @@ static unsigned int get_current_freq(void) * There is no "switch_to_frequency" function, because the cpufreq frequency * table helpers can easily look up the appropriate cluster number for us. */ -static void switch_to_cluster(int cluster) +static void switch_to_entry(struct cpufreq_frequency_table const *target) { - pr_info("Switching to cluster %d\n", cluster); + int old_cluster; + struct cpufreq_freqs freqs; + + pr_info("Switching to cluster %d\n", entry_to_cluster(target)); spin_lock(&switcher_lock); - if(cluster != get_current_cluster()) + freqs.cpu = get_cpu(); + + old_cluster = get_current_cluster(); + if(entry_to_cluster(target) != old_cluster) { + freqs.old = cluster_to_freq(old_cluster); + freqs.new = entry_to_freq(target); + + cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); __arm_bl_switch_cluster(); + cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); + } + + put_cpu(); spin_unlock(&switcher_lock); } @@ -160,7 +191,7 @@ static int bl_cpufreq_target(struct cpufreq_policy *policy, if(err) return err; - switch_to_cluster(bl_freqs[index].index); + switch_to_entry(&bl_freqs[index]); return 0; } @@ -204,7 +235,7 @@ static void __exit bl_cpufreq_module_exit(void) cpufreq_unregister_driver(&bl_cpufreq_driver); /* Restore the "default" cluster: */ - switch_to_cluster(CLUSTER_BIG); + switch_to_entry(find_entry_by_cluster(CLUSTER_BIG)); pr_info("cpufreq backend driver unloaded.\n"); }