PM / OPP: Add debugfs support
Subsystems (4)
PATCH v4 1/1 PM / OPP: Add debugfs support
This patch adds debugfs support to OPP layer to export OPPs and their properties for all the devices.
This creates a top level directory: /sys/kernel/debug/opp and then device specific directories (based on device names) inside it. For
example: 'cpu0', 'cpu1', etc..
If multiple devices share the OPP table, then the real directory is created only for the first device. For all others, links are created to the real directory.
Inside the device specific directory, a separate directory is created for each OPP. And within that files per opp property.
---
Hi Rafael,
This was applied to pm/linux-next earlier, but then we dropped it citing few merge conflicts with driver-core changes. i.e. debugfs_create_bool() and debugfs_create_ulong() changes.
All that is merged by Linus and so we can get this merged back again, once you are comfortable.
@Stephen: I have dropped your Reviewed by tag as there were minor changes here, please give it again :)
V3->V4:
- debugfs_create_bool() takes boolean now, no need to typecast.
- debugfs_create_ulong() is present now, use it.
- Add another debugfs file to show if OPP is suspend-opp or not.
drivers/base/power/opp/Makefile | 1 + drivers/base/power/opp/core.c | 21 +++- drivers/base/power/opp/debugfs.c | 216 +++++++++++++++++++++++++++++++++++++++ drivers/base/power/opp/opp.h | 44 ++++++++ 4 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/opp/debugfs.c
drivers/base/power/opp/Makefile +1 -0
@@ -1,2 +1,3 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG obj-y += core.o cpu.o +obj-$(CONFIG_DEBUG_FS) += debugfs.o
drivers/base/power/opp/core.c +19 -2
@@ -457,6 +457,7 @@ static void _kfree_list_dev_rcu(struct rcu_head *head)static void _remove_list_dev (struct device_list_opp *list_dev,struct device_opp *dev_opp) { +opp_debug_unregister (list_dev, dev_opp);list_del (&list_dev->node);call_srcu (&dev_opp->srcu_head.srcu, &list_dev->rcu_head, _kfree_list_dev_rcu);
@@ -466,6 +467,7 @@ struct device_list_opp *_add_list_dev(const struct device *dev, struct device_opp *dev_opp) {struct device_list_opp *list_dev; +int ret; list_dev =kzalloc (sizeof (*list_dev),GFP_KERNEL );if (!list_dev)
@@ -475,6 +477,12 @@ struct device_list_opp *_add_list_dev(const struct device *dev, list_dev->dev = dev;list_add_rcu (&list_dev->node, &dev_opp->dev_list); +/* Create debugfs entries for the dev_opp */ + ret =opp_debug_register (list_dev, dev_opp); +if (ret) +dev_err (dev,"%s: Failed to register opp debugfs (%d)\n" , + __func__, ret); +return list_dev; }
@@ -590,6 +598,7 @@ static void _opp_remove(struct device_opp *dev_opp,*/ if (notify)srcu_notifier_call_chain (&dev_opp->srcu_head,OPP_EVENT_REMOVE , opp); +opp_debug_remove_one (opp);list_del_rcu (&opp->node);call_srcu (&dev_opp->srcu_head.srcu, &opp->rcu_head, _kfree_opp_rcu);
@@ -667,6 +676,7 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, {struct dev_pm_opp *opp;struct list_head *head = &dev_opp->opp_list; +int ret;/* * Insert new OPP in order of increasing frequency and discard if
@@ -697,6 +707,11 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, new_opp->dev_opp = dev_opp;list_add_rcu (&new_opp->node, head); + ret =opp_debug_create_one (new_opp, dev_opp); +if (ret) +dev_err (dev,"%s: Failed to register opp to debugfs (%d)\n" , + __func__, ret); +return 0 ; }
@@ -882,12 +897,14 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np)/* OPP to select on device suspend */ if (of_property_read_bool (np,"opp-suspend" )) { -if (dev_opp->suspend_opp) +if (dev_opp->suspend_opp) {dev_warn (dev,"%s: Multiple suspend OPPs found (%lu %lu)\n" , __func__, dev_opp->suspend_opp->rate, new_opp->rate); -else + }else { + new_opp->suspend = true; dev_opp->suspend_opp = new_opp; + } }if (new_opp->clock_latency_ns > dev_opp->clock_latency_ns_max)
drivers/base/power/opp/debugfs.c new file +216 -0
216 lines not on this page · raw message
drivers/base/power/opp/opp.h +44 -0
96 lines not on this page · raw message
Signature · 1 line
2.6.2.198.g614a2ac
Quoted 22 lines · Viresh Kumar
This patch adds debugfs support to OPP layer to export OPPs and their properties for all the devices.
This creates a top level directory:
/sys/kernel/debug/oppand then device specific directories (based on device names) inside it. For
example: 'cpu0', 'cpu1', etc..If multiple devices share the OPP table, then the real directory is created only for the first device. For all others, links are created to the real directory.
Inside the device specific directory, a separate directory is created for each OPP. And within that files per opp property.
Signed-off-by Viresh Kumar <[email protected]>---
Hi Rafael,This was applied to pm/linux-next earlier, but then we dropped it citing few merge conflicts with driver-core changes. i.e.
debugfs_create_bool()anddebugfs_create_ulong()changes.
Quoted 5 lines
All that is merged by Linus and so we can get this merged back again, once you are comfortable.
@Stephen: I have dropped your Reviewed by tag as there were minor changes here, please give it again :)
So I'll wait for the response from Stephen and then I'll queue up this one for v4.5.
Thanks,
Rafael
Minor nitpicks. Looks mostly fine.
Quoted 10 lines · Viresh Kumar
drivers/base/power/opp/debugfs.c new file +4
-0@@ -0,0 +1,216 @@ +/* +* Generic OPP debugfs interface +* +* Copyright (C) 2015-2016 Viresh Kumar <[email protected]>
drivers/base/power/opp/debugfs.c line 14
Quoted 10 lines
drivers/base/power/opp/debugfs.c new file +10
-0+* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/debugfs.h> +#include <linux/err.h>
#include <linux/init.h>
#include <linux/limits.h>
#include <linux/device.h>
Quoted 3 lines
drivers/base/power/opp/debugfs.c new file +3
-0+ +#include "opp.h" +
[..]
drivers/base/power/opp/debugfs.c struct dev_pm_opp { · line 74
Quoted 5 lines
drivers/base/power/opp/debugfs.c new file +1
-0@@ -69,6 +71,7 @@ struct dev_pm_opp {bool available;bool dynamic;bool turbo; +bool suspend;
This should be documented as well.
drivers/base/power/opp/debugfs.c struct dev_pm_opp { · line 89
Quoted 10 lines
drivers/base/power/opp/debugfs.c new file +3
-0unsigned long rate;unsigned long u_volt;@@ -81,6 +84,11 @@ struct dev_pm_opp {struct rcu_head rcu_head;struct device_node *np; + +#ifdef CONFIG_DEBUG_FS +/* debugfs */
This comment is pretty useless (for all three instances).
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v5 1/1 PM / OPP: Add debugfs support
This patch adds debugfs support to OPP layer to export OPPs and their properties for all the devices.
This creates a top level directory: /sys/kernel/debug/opp and then device specific directories (based on device names) inside it. For
example: 'cpu0', 'cpu1', etc..
If multiple devices share the OPP table, then the real directory is created only for the first device. For all others, links are created to the real directory.
Inside the device specific directory, a separate directory is created for each OPP. And within that files per opp property.
---V4->V5:
- include more headers
- document new field 'suspend'
- remove useless 'debugfs' comments
drivers/base/power/opp/Makefile | 1 + drivers/base/power/opp/core.c | 21 +++- drivers/base/power/opp/debugfs.c | 219 +++++++++++++++++++++++++++++++++++++++ drivers/base/power/opp/opp.h | 42 ++++++++ 4 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 drivers/base/power/opp/debugfs.c
drivers/base/power/opp/Makefile +1 -0
@@ -1,2 +1,3 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG obj-y += core.o cpu.o +obj-$(CONFIG_DEBUG_FS) += debugfs.o
drivers/base/power/opp/core.c +19 -2
@@ -463,6 +463,7 @@ static void _kfree_list_dev_rcu(struct rcu_head *head)static void _remove_list_dev (struct device_list_opp *list_dev,struct device_opp *dev_opp) { +opp_debug_unregister (list_dev, dev_opp);list_del (&list_dev->node);call_srcu (&dev_opp->srcu_head.srcu, &list_dev->rcu_head, _kfree_list_dev_rcu);
@@ -472,6 +473,7 @@ struct device_list_opp *_add_list_dev(const struct device *dev, struct device_opp *dev_opp) {struct device_list_opp *list_dev; +int ret; list_dev =kzalloc (sizeof (*list_dev),GFP_KERNEL );if (!list_dev)
@@ -481,6 +483,12 @@ struct device_list_opp *_add_list_dev(const struct device *dev, list_dev->dev = dev;list_add_rcu (&list_dev->node, &dev_opp->dev_list); +/* Create debugfs entries for the dev_opp */ + ret =opp_debug_register (list_dev, dev_opp); +if (ret) +dev_err (dev,"%s: Failed to register opp debugfs (%d)\n" , + __func__, ret); +return list_dev; }
@@ -596,6 +604,7 @@ static void _opp_remove(struct device_opp *dev_opp,*/ if (notify)srcu_notifier_call_chain (&dev_opp->srcu_head,OPP_EVENT_REMOVE , opp); +opp_debug_remove_one (opp);list_del_rcu (&opp->node);call_srcu (&dev_opp->srcu_head.srcu, &opp->rcu_head, _kfree_opp_rcu);
@@ -673,6 +682,7 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, {struct dev_pm_opp *opp;struct list_head *head = &dev_opp->opp_list; +int ret;/* * Insert new OPP in order of increasing frequency and discard if
@@ -703,6 +713,11 @@ static int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, new_opp->dev_opp = dev_opp;list_add_rcu (&new_opp->node, head); + ret =opp_debug_create_one (new_opp, dev_opp); +if (ret) +dev_err (dev,"%s: Failed to register opp to debugfs (%d)\n" , + __func__, ret); +return 0 ; }
@@ -889,12 +904,14 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np)/* OPP to select on device suspend */ if (of_property_read_bool (np,"opp-suspend" )) { -if (dev_opp->suspend_opp) +if (dev_opp->suspend_opp) {dev_warn (dev,"%s: Multiple suspend OPPs found (%lu %lu)\n" , __func__, dev_opp->suspend_opp->rate, new_opp->rate); -else + }else { + new_opp->suspend = true; dev_opp->suspend_opp = new_opp; + } }if (new_opp->clock_latency_ns > dev_opp->clock_latency_ns_max)
drivers/base/power/opp/debugfs.c new file +219 -0
219 lines not on this page · raw message
drivers/base/power/opp/opp.h +42 -0
100 lines not on this page · raw message
Signature · 1 line
2.6.2.198.g614a2ac
Quoted 11 lines · Viresh Kumar
This patch adds debugfs support to OPP layer to export OPPs and their properties for all the devices.
This creates a top level directory:
/sys/kernel/debug/oppand then device specific directories (based on device names) inside it. For
example: 'cpu0', 'cpu1', etc..If multiple devices share the OPP table, then the real directory is created only for the first device. For all others, links are created to the real directory.
Quoted 5 lines
Inside the device specific directory, a separate directory is created for each OPP. And within that files per opp property.
Signed-off-by Viresh Kumar <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project