From patchwork Mon Sep 3 14:29:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 11157 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 2826523F26 for ; Mon, 3 Sep 2012 14:32:12 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6C91EA181E9 for ; Mon, 3 Sep 2012 14:31:24 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so3445356iea.11 for ; Mon, 03 Sep 2012 07:32:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=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=2kfSxjAtz3O++m1Lq/GgSF8+bpm57aZ0zb3l/uHVE/w=; b=Ss56fww2N/LFaNScdXJBYlAjtmd0vzYEMagdrEZOtMQ+1oIzcgC4kLO1WXnXH/Rc21 NzxPQhYkP4Qp3IJPRlYDD6+Q5U6Q2gYQxOO1uNCVfMtkOH5dlZvFVGw+ZrM/y+maapG0 PkIIXUM1J0kn0xdv/R/XofffYgsx876hgOZ07o7i3dxE/CXjuWFW7GGbFQQ/k6ziMe7s 6+JOAaaJx3pSw18dkJM5O8OVhM5MpM52n9i2mV+zHscLNgNl/sPB1WxYui6lF+TDh5k4 nAfPo4chzGVdqur2E8Phr9nQz2udewD8wUaqdDLUb1I28yqLIuMsFyWrBEEddr4I7b45 uIhg== Received: by 10.50.217.227 with SMTP id pb3mr10989991igc.28.1346682731612; Mon, 03 Sep 2012 07:32:11 -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.50.184.232 with SMTP id ex8csp139882igc; Mon, 3 Sep 2012 07:32:11 -0700 (PDT) Received: by 10.66.79.166 with SMTP id k6mr34457611pax.44.1346682730905; Mon, 03 Sep 2012 07:32:10 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id px6si22745743pbc.244.2012.09.03.07.32.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 07:32:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by dade7 with SMTP id e7so4078528dad.37 for ; Mon, 03 Sep 2012 07:32:10 -0700 (PDT) Received: by 10.68.204.169 with SMTP id kz9mr10873065pbc.39.1346682730433; Mon, 03 Sep 2012 07:32:10 -0700 (PDT) Received: from localhost.localdomain ([101.63.135.0]) by mx.google.com with ESMTPS id kp3sm10029261pbc.64.2012.09.03.07.32.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Sep 2012 07:32:09 -0700 (PDT) From: Rajagopal Venkat To: mturquette@linaro.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, rjw@sisk.pl Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajagopal Venkat Subject: [PATCH 3/3] devfreq: Add current freq callback in device profile Date: Mon, 3 Sep 2012 19:59:38 +0530 Message-Id: <1346682578-24312-4-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1346682578-24312-1-git-send-email-rajagopal.venkat@linaro.org> References: <1346682578-24312-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQnkEpeQ5gdw45T1nGLbPH+2yCOpcNYRcqTnedajuLfr4fAkTsZXJjn1w+ehAUILk1tVYNeW Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. Its driver responsibility to maintain current frequency at which device is operating. Add a callback in device profile to fix this. Also add a new sysfs node to expose governor predicted next target frequency. Signed-off-by: Rajagopal Venkat --- Documentation/ABI/testing/sysfs-class-devfreq | 7 +++++++ drivers/devfreq/devfreq.c | 14 ++++++++++++++ include/linux/devfreq.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index 23d78b5..9df5205 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq @@ -21,6 +21,13 @@ Description: The /sys/class/devfreq/.../cur_freq shows the current frequency of the corresponding devfreq object. +What: /sys/class/devfreq/.../target_freq +Date: September 2012 +Contact: MyungJoo Ham +Description: + The /sys/class/devfreq/.../target_freq shows the next governor + predicted target frequency of the corresponding devfreq object. + What: /sys/class/devfreq/.../central_polling Date: September 2011 Contact: MyungJoo Ham diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 3a5f126..55e9046 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -400,6 +400,19 @@ static ssize_t show_governor(struct device *dev, static ssize_t show_freq(struct device *dev, struct device_attribute *attr, char *buf) { + unsigned long freq; + struct devfreq *devfreq = to_devfreq(dev); + + if (devfreq->profile->get_cur_freq) + if (!devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) + return sprintf(buf, "%lu\n", freq); + + return sprintf(buf, ""); +} + +static ssize_t show_target_freq(struct device *dev, + struct device_attribute *attr, char *buf) +{ return sprintf(buf, "%lu\n", to_devfreq(dev)->previous_freq); } @@ -503,6 +516,7 @@ static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr, static struct device_attribute devfreq_attrs[] = { __ATTR(governor, S_IRUGO, show_governor, NULL), __ATTR(cur_freq, S_IRUGO, show_freq, NULL), + __ATTR(target_freq, S_IRUGO, show_target_freq, NULL), __ATTR(polling_interval, S_IRUGO | S_IWUSR, show_polling_interval, store_polling_interval), __ATTR(min_freq, S_IRUGO | S_IWUSR, show_min_freq, store_min_freq), diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 7c7e179..d12ed41 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -66,6 +66,8 @@ struct devfreq_dev_status { * explained above with "DEVFREQ_FLAG_*" macros. * @get_dev_status The device should provide the current performance * status to devfreq, which is used by governors. + * @get_cur_freq The device should provide the current frequency + * at which it is operating. * @exit An optional callback that is called when devfreq * is removing the devfreq object due to error or * from devfreq_remove_device() call. If the user @@ -79,6 +81,7 @@ struct devfreq_dev_profile { int (*target)(struct device *dev, unsigned long *freq, u32 flags); int (*get_dev_status)(struct device *dev, struct devfreq_dev_status *stat); + int (*get_cur_freq)(struct device *dev, unsigned long *freq); void (*exit)(struct device *dev); };