From patchwork Thu Aug 27 09:13:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 511206 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 876F71401EF for ; Thu, 27 Aug 2015 19:14:36 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 6D39C1A1D92 for ; Thu, 27 Aug 2015 19:14:36 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [103.22.144.67]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 9171A1A0545 for ; Thu, 27 Aug 2015 19:13:37 +1000 (AEST) Received: by ozlabs.org (Postfix) id 864391401F0; Thu, 27 Aug 2015 19:13:37 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Received: from e28smtp03.in.ibm.com (e28smtp03.in.ibm.com [122.248.162.3]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F3CEC1401EF for ; Thu, 27 Aug 2015 19:13:36 +1000 (AEST) Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Aug 2015 14:43:34 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 27 Aug 2015 14:43:31 +0530 X-Helo: d28dlp01.in.ibm.com X-MailFrom: shilpa.bhat@linux.vnet.ibm.com X-RcptTo: linuxppc-dev@ozlabs.org Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 006FAE0059 for ; Thu, 27 Aug 2015 14:42:58 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7R9DTsJ60227622 for ; Thu, 27 Aug 2015 14:43:29 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7R9DXaU031144 for ; Thu, 27 Aug 2015 14:43:33 +0530 Received: from localhost.in.ibm.com ([9.79.205.226]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t7R9DW7S031120; Thu, 27 Aug 2015 14:43:33 +0530 From: Shilpasri G Bhat To: rjw@rjwysocki.net Subject: [PATCH] cpufreq: powernv: Export frequency throttle state of the chip through sysfs Date: Thu, 27 Aug 2015 14:43:26 +0530 Message-Id: <1440666806-11760-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.3 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15082709-0009-0000-0000-00000750613D X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stewart@linux.vnet.ibm.com, linux-pm@vger.kernel.org, viresh.kumar@linaro.org, linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, Shilpasri G Bhat MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Create a sysfs 'throttle' attribute per-chip(per-numa-node) to reflect the throttle state of the chip. The usersapce programs can poll on this attribute to keep an eye on the throttle state. Currently we print a log message to notify the user of throttling event. The performance-sensitive applications can monitor the throttle state using this attribute. Following file is created in sysfs: /sys/devices/system/node/nodeN/throttle 'throttle' attribute has the following values: 0 : frequency is unthrottled 1 : frequency is throttled Suggested-by: Stewart Smith Signed-off-by: Shilpasri G Bhat --- This patch is based on top of linux-next/master drivers/cpufreq/powernv-cpufreq.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 64994e1..aed6c34 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include @@ -413,6 +415,23 @@ static struct notifier_block powernv_cpufreq_reboot_nb = { .notifier_call = powernv_cpufreq_reboot_notifier, }; +static ssize_t throttle_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int i; + + for (i = 0; i < nr_chips; i++) + if (chips[i].id == dev->id) { + smp_call_function_any(&chips[i].mask, + powernv_cpufreq_throttle_check, + NULL, 1); + return sprintf(buf, "%d\n", throttled || + chips[i].throttled); + } +} + +static DEVICE_ATTR(throttle, 0400, throttle_show, NULL); + void powernv_cpufreq_work_fn(struct work_struct *work) { struct chip *chip = container_of(work, struct chip, throttle); @@ -570,6 +589,8 @@ static int init_chip_info(void) cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i])); INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn); chips[i].restore = false; + device_create_file(&node_devices[chip[i]]->dev, + &dev_attr_throttle); } return 0;