From patchwork Thu Oct 4 09:28:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajagopal Venkat X-Patchwork-Id: 1545801 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 432C940AC9 for ; Thu, 4 Oct 2012 09:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756629Ab2JDJck (ORCPT ); Thu, 4 Oct 2012 05:32:40 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:56622 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756557Ab2JDJch (ORCPT ); Thu, 4 Oct 2012 05:32:37 -0400 Received: by mail-pa0-f46.google.com with SMTP id hz1so324759pad.19 for ; Thu, 04 Oct 2012 02:32:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=hi0HFlVNwqbotuBGNINHB+2fNIW8jtZAh0mrhohnr3Y=; b=RizO2W8H9VORAGCJu9/hbG5abnqfSc8Qg+2jBaJo36L8zZo+WSwJpxOGZwPXiPNAvx 2rqQNE5tED4aFxLv3upU3h/eudZZwZ8xTTbirAZ4rNDJoZkP3PG5HTgw311m0z7XmfRK YYwqZ62yv+HK76aQCpZRbOUH/LwP55dXqkBruqNQR0hqz/Hx1merGXo9bSFZn6Y5qD0t PxKpp+kfMLelhuZH493KCqoqVUJ1DRq34X+gnOrOuoYhDN/iaQRULx5R3TYCt2C6QCbx nj8DeW/3/vwNC0UPXKqFpIqs5lgU6OBgTi8ce9kqA66c8IvfiA14CzXbtSuBMg5w2YxO vf6A== Received: by 10.68.129.233 with SMTP id nz9mr20192623pbb.136.1349343156768; Thu, 04 Oct 2012 02:32:36 -0700 (PDT) Received: from localhost.localdomain ([115.184.98.135]) by mx.google.com with ESMTPS id mn5sm4084933pbc.12.2012.10.04.02.32.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 02:32:36 -0700 (PDT) From: Rajagopal Venkat To: myungjoo.ham@samsung.com, mturquette@linaro.org, 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 v4 3/3] devfreq: Add current freq callback in device profile Date: Thu, 4 Oct 2012 14:58:34 +0530 Message-Id: <1349342914-7095-4-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1349342914-7095-1-git-send-email-rajagopal.venkat@linaro.org> References: <1349342914-7095-1-git-send-email-rajagopal.venkat@linaro.org> X-Gm-Message-State: ALoCoQnadMwMj9wmH5hUroSprCORMhWvm8uL0dXtAyNe8fuOz6euXyTQ2FS1x3PIpU8kcHOi9GEh Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. So add a callback in device profile to get current freq from driver. Also add a new sysfs node to expose governor predicted next target frequency. Signed-off-by: Rajagopal Venkat Acked-by: MyungJoo Ham --- Documentation/ABI/testing/sysfs-class-devfreq | 11 ++++++++++- drivers/devfreq/devfreq.c | 14 ++++++++++++++ include/linux/devfreq.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index 89283b1..e6cf08e 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq @@ -19,7 +19,16 @@ Date: September 2011 Contact: MyungJoo Ham Description: The /sys/class/devfreq/.../cur_freq shows the current - frequency of the corresponding devfreq object. + frequency of the corresponding devfreq object. Same as + target_freq when get_cur_freq() is not implemented by + devfreq driver. + +What: /sys/class/devfreq/.../target_freq +Date: September 2012 +Contact: Rajagopal Venkat +Description: + The /sys/class/devfreq/.../target_freq shows the next governor + predicted target frequency of the corresponding devfreq object. What: /sys/class/devfreq/.../polling_interval Date: September 2011 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 63e075e..9fdcb5d 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -465,6 +465,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 && + !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq)) + return sprintf(buf, "%lu\n", freq); + + return sprintf(buf, "%lu\n", devfreq->previous_freq); +} + +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); } @@ -564,6 +577,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 ee243a3..7e2e2ea 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); };