From patchwork Mon Oct 13 15:37:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dirk.brandewie@gmail.com X-Patchwork-Id: 5076891 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D2959F387 for ; Mon, 13 Oct 2014 15:37:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8528201F5 for ; Mon, 13 Oct 2014 15:37:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A166201BC for ; Mon, 13 Oct 2014 15:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752734AbaJMPhy (ORCPT ); Mon, 13 Oct 2014 11:37:54 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:50782 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753972AbaJMPhy (ORCPT ); Mon, 13 Oct 2014 11:37:54 -0400 Received: by mail-pd0-f176.google.com with SMTP id fp1so5815660pdb.35 for ; Mon, 13 Oct 2014 08:37:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=a/G7JN8n2hXLB6u4fTBCh3tdPtKT/9LdFEOPy2vNzWs=; b=sEj0qK7EpeNmUSHoNCzx7ZAc+gVDtXuYesp0QEvxsM0UhW5S1ySkgOfrVAbI7umNFK in9KaxDhcePhd82F1yFBxwWzoMRbMaO63l0LnQWYdnbDX5jelbH9PBGVcT/BhbIiYsH9 ctDjRrZWKx03xWJDUuw3WWecD5QRbOOpwrONcLDa7His6oPtlkbQ4i1SR5gSbn6xCaFs 4O/pAxl817Hm/ri6coEM4cGwdOd8uPbL2DUPQ3gkmCs4AItI7C9MHAwKJdcbLmOjSHAU VaqPiomUVwkSIqDYiPcu7jSvG9qGXbAUFHh4e+5m7r9/vtGRSMRv5lkISv+LMDgXjSL1 4QiA== X-Received: by 10.66.235.197 with SMTP id uo5mr4815915pac.96.1413214673240; Mon, 13 Oct 2014 08:37:53 -0700 (PDT) Received: from echolake.localdomain (static-50-43-32-60.bvtn.or.frontiernet.net. [50.43.32.60]) by mx.google.com with ESMTPSA id dg5sm10340216pdb.54.2014.10.13.08.37.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Oct 2014 08:37:52 -0700 (PDT) From: dirk.brandewie@gmail.com X-Google-Original-From: dirk.j.brandewie@intel.com To: linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, dirk.brandewie@gmail.com, Dirk Brandewie , stable@vger.kernel.org Subject: [PATCH 1/5] cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers Date: Mon, 13 Oct 2014 08:37:40 -0700 Message-Id: <1413214664-17687-1-git-send-email-dirk.j.brandewie@intel.com> X-Mailer: git-send-email 1.9.3 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dirk Brandewie Currently the core does not expose scaling_cur_freq for set_policy() drivers this breaks some userspace monitoring tools. Change the core to expose this file for all drivers and if the set_policy() driver supports the get() callback use it to retrieve the current frequency. References: https://bugzilla.kernel.org/show_bug.cgi?id=73741 Cc: stable@vger.kernel.org Signed-off-by: Dirk Brandewie --- drivers/cpufreq/cpufreq.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 61190f6..c05821e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -512,7 +512,18 @@ show_one(cpuinfo_max_freq, cpuinfo.max_freq); show_one(cpuinfo_transition_latency, cpuinfo.transition_latency); show_one(scaling_min_freq, min); show_one(scaling_max_freq, max); -show_one(scaling_cur_freq, cur); + +static ssize_t show_scaling_cur_freq( + struct cpufreq_policy *policy, char *buf) +{ + ssize_t ret; + + if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get) + ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu)); + else + ret = sprintf(buf, "%u\n", policy->cur); + return ret; +} static int cpufreq_set_policy(struct cpufreq_policy *policy, struct cpufreq_policy *new_policy); @@ -906,11 +917,11 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, if (ret) goto err_out_kobj_put; } - if (has_target()) { - ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); - if (ret) - goto err_out_kobj_put; - } + + ret = sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); + if (ret) + goto err_out_kobj_put; + if (cpufreq_driver->bios_limit) { ret = sysfs_create_file(&policy->kobj, &bios_limit.attr); if (ret)