From patchwork Tue Jan 7 09:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 213096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7C2CC33C9E for ; Tue, 7 Jan 2020 08:58:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 944ED20715 for ; Tue, 7 Jan 2020 08:58:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="vHf9CCkv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgAGI63 (ORCPT ); Tue, 7 Jan 2020 03:58:29 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:47729 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbgAGI6U (ORCPT ); Tue, 7 Jan 2020 03:58:20 -0500 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200107085816epoutp039af1d7976eb2e16e895f0e05e5aec2db~njxC_e4yC2237722377epoutp03D for ; Tue, 7 Jan 2020 08:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200107085816epoutp039af1d7976eb2e16e895f0e05e5aec2db~njxC_e4yC2237722377epoutp03D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1578387496; bh=k9VIX2Tvv1UVySMUsRa2IWtltfDMnfFeAPgI6gGcGHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHf9CCkvoxllcNPGHrHVpAHfLMc44ycvfd7ogkCLVfUGbhH+wScQ+VYGSnOkJp08Y w8RBeBRjtAc3CYmWPenVoi0pXrCMxI4KOikutqG6C5rvV5vzNbdKlAWGXVr/2muTY5 K1mcbcHVDhhSgksxQg88C+AWwpnn92GeKXimvJOU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20200107085815epcas1p4ed89ae42fd35a5941bcd16ed882cbbff~njxCb0u3v1742217422epcas1p4b; Tue, 7 Jan 2020 08:58:15 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.154]) by epsnrtp4.localdomain (Postfix) with ESMTP id 47sR9d2RqMzMqYkn; Tue, 7 Jan 2020 08:58:13 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 57.F6.57028.528441E5; Tue, 7 Jan 2020 17:58:13 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200107085812epcas1p12121f8ef6492ed78053dea4977216788~njw-jzdDJ1960019600epcas1p1a; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200107085812epsmtrp2d23f986dfb3de9d995c4981fcb622cbb~njw-hNMsy1554315543epsmtrp25; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) X-AuditID: b6c32a35-974d39c00001dec4-14-5e14482551db Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 29.81.10238.428441E5; Tue, 7 Jan 2020 17:58:12 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200107085812epsmtip2edf435cc31e434fe580e701db94c97c3~njw-T6jXc2461724617epsmtip2k; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) From: Chanwoo Choi To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: leonard.crestez@nxp.com, lukasz.luba@arm.com, a.swigon@samsung.com, m.szyprowski@samsung.com, enric.balletbo@collabora.com, hl@rock-chips.com, digetx@gmail.com, bjorn.andersson@linaro.org, jcrouse@codeaurora.org, cw00.choi@samsung.com, chanwoo@kernel.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com Subject: [PATCH 1/2] PM / devfreq: Add debugfs support with devfreq_summary file Date: Tue, 7 Jan 2020 18:05:18 +0900 Message-Id: <20200107090519.3231-2-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200107090519.3231-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmnq6qh0icwYFvQhb357UyWpze/47F YuKNKywW1788Z7VY/fExo8Wa24cYLX5sOMVssXFBtsXZpjfsFivufmS1uLxrDpvF594jjBYL m1rYLdYeuctucbtxBZsDv8eaeWsYPS739TJ57Li7hNFj56y77B6bVnWyedy5tofNY+O7HUwe f2ftZ/Ho27KK0ePzJrkArqhsm4zUxJTUIoXUvOT8lMy8dFsl7+B453hTMwNDXUNLC3MlhbzE 3FRbJRefAF23zBygN5QUyhJzSoFCAYnFxUr6djZF+aUlqQoZ+cUltkqpBSk5BZYFesWJucWl eel6yfm5VoYGBkamQIUJ2Rknmx6wFXSaVJxZuJ6pgbFJrYuRk0NCwETi2MWlrF2MXBxCAjsY JRad3scCkhAS+MQosaktG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RXSwgNWwCWhL7 X0DUiwjYSNxdfI0FpIhZ4DyTRPvyqYwgCWGBAImD/88zgdgsAqoSW96/YQaxeQUsJSYtXscC sUxeYvWGA2BxTgEriS+v37OD2EJANWu2XmCcwMi3gJFhFaNkakFxbnpusWGBYV5quV5xYm5x aV66XnJ+7iZGcNhrae5gvLwk/hCjAAejEg+vhZRwnBBrYllxZe4hRgkOZiURXi0dkTgh3pTE yqrUovz4otKc1OJDjNIcLErivE/zjkUKCaQnlqRmp6YWpBbBZJk4OKUaGJkrzly/fKJCRUlz csjKnML3LmZ1MkUr2CzOKbRPPj9x0eZfWoYOE/Z+PfnPcrHL1SmMnsenOCjJczBPmRx07Wuv PDvre7GO9FvZG/iaH6/gSo3U19ua9jW77vAM0Q5febNn4Vd5s1+J1tmdrvXT/rWjRzls5lrb iYubl+/+W+zwu+v+599JxUosxRmJhlrMRcWJAGBQqV13AgAA X-CMS-MailID: 20200107085812epcas1p12121f8ef6492ed78053dea4977216788 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200107085812epcas1p12121f8ef6492ed78053dea4977216788 References: <20200107090519.3231-1-cw00.choi@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add debugfs interface to provide debugging information of devfreq device. It contains 'devfreq_summary' entry to show the summary of registered devfreq devices as following and the additional debugfs file will be added. - /sys/kernel/debug/devfreq/devfreq_summary [Detailed description of each field of 'devfreq_summary' debugfs file] - dev_name : Device name of h/w. - dev : Device name made by devfreq core. - parent_dev : If devfreq device uses the passive governor, show parent devfreq device name. - governor : Devfreq governor. - polling_ms : If devfreq device uses the simple_ondemand governor, polling_ms is necessary for the period. (unit: millisecond) - cur_freq_hz : Current Frequency (unit: hz) - old_freq_hz : Frequency before changing. (unit: hz) - new_freq_hz : Frequency after changed. (unit: hz) [For example on Exynos5422-based Odroid-XU3 board] - In order to show the multiple governors on devfreq_summay result, change the governor of devfreq0 from simple_ondemand to userspace. $ cat /sys/kernel/debug/devfreq/devfreq_summary dev_name dev parent_dev governor polling_ms cur_freq_hz min_freq_hz max_freq_hz ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------ 10c20000.memory-controller devfreq0 userspace 0 206000000 165000000 825000000 soc:bus_wcore devfreq1 simple_ondemand 50 532000000 88700000 532000000 soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000 soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000 soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000 soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000 soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000 soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000 soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000 soc:bus_g2d devfreq9 devfreq1 passive 0 0 83250000 333000000 soc:bus_g2d_acp devfreq10 devfreq1 passive 0 0 66500000 266000000 soc:bus_jpeg devfreq11 devfreq1 passive 0 0 75000000 300000000 soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 0 83250000 166500000 soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 0 120000000 200000000 soc:bus_disp1 devfreq14 devfreq1 passive 0 0 120000000 300000000 soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 0 150000000 300000000 soc:bus_mscl devfreq16 devfreq1 passive 0 0 84000000 666000000 Reported-by: kbuild test robot Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 254f11b31824..c7f5e4e06420 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #define HZ_PER_KHZ 1000 static struct class *devfreq_class; +static struct dentry *devfreq_debugfs; /* * devfreq core provides delayed work based load monitoring helper @@ -1717,6 +1719,74 @@ static struct attribute *devfreq_attrs[] = { }; ATTRIBUTE_GROUPS(devfreq); +/** + * devfreq_summary_show() - Show the summary of the registered devfreq devices + * via 'devfreq_summary' debugfs file. + */ +static int devfreq_summary_show(struct seq_file *s, void *data) +{ + struct devfreq *devfreq; + struct devfreq *p_devfreq = NULL; + unsigned long cur_freq, min_freq, max_freq; + unsigned int polling_ms; + + seq_printf(s, "%-30s %-10s %-10s %-15s %-10s %-12s %-12s %-12s\n", + "dev_name", + "dev", + "parent_dev", + "governor", + "polling_ms", + "cur_freq_hz", + "min_freq_hz", + "max_freq_hz"); + seq_printf(s, "%-30s %-10s %-10s %-15s %-10s %-12s %-12s %-12s\n", + "------------------------------", + "----------", + "----------", + "---------------", + "----------", + "------------", + "------------", + "------------"); + + mutex_lock(&devfreq_list_lock); + + list_for_each_entry_reverse(devfreq, &devfreq_list, node) { +#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE, + DEVFREQ_NAME_LEN)) { + struct devfreq_passive_data *data = devfreq->data; + + if (data) + p_devfreq = data->parent; + } else { + p_devfreq = NULL; + } +#endif + mutex_lock(&devfreq->lock); + cur_freq = devfreq->previous_freq, + get_freq_range(devfreq, &min_freq, &max_freq); + polling_ms = devfreq->profile->polling_ms, + mutex_unlock(&devfreq->lock); + + seq_printf(s, + "%-30s %-10s %-10s %-15s %-10d %-12ld %-12ld %-12ld\n", + dev_name(devfreq->dev.parent), + dev_name(&devfreq->dev), + p_devfreq ? dev_name(&p_devfreq->dev) : "", + devfreq->governor_name, + polling_ms, + cur_freq, + min_freq, + max_freq); + } + + mutex_unlock(&devfreq_list_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(devfreq_summary); + static int __init devfreq_init(void) { devfreq_class = class_create(THIS_MODULE, "devfreq"); @@ -1733,6 +1803,16 @@ static int __init devfreq_init(void) } devfreq_class->dev_groups = devfreq_groups; + devfreq_debugfs = debugfs_create_dir("devfreq", NULL); + if (PTR_ERR(devfreq_debugfs) != -ENODEV && IS_ERR(devfreq_debugfs)) { + devfreq_debugfs = NULL; + pr_warn("%s: couldn't create debugfs dir\n", __FILE__); + } else { + debugfs_create_file("devfreq_summary", 0444, + devfreq_debugfs, NULL, + &devfreq_summary_fops); + } + return 0; } subsys_initcall(devfreq_init); From patchwork Tue Jan 7 09:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 213097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E213C33C9B for ; Tue, 7 Jan 2020 08:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D8C220715 for ; Tue, 7 Jan 2020 08:58:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="FUNbeCBR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727658AbgAGI6W (ORCPT ); Tue, 7 Jan 2020 03:58:22 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:47751 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbgAGI6W (ORCPT ); Tue, 7 Jan 2020 03:58:22 -0500 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200107085818epoutp03f2b149b790b70897a8fd3a25766e22f8~njxEY6Ua02237122371epoutp03O for ; Tue, 7 Jan 2020 08:58:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200107085818epoutp03f2b149b790b70897a8fd3a25766e22f8~njxEY6Ua02237122371epoutp03O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1578387498; bh=FLa4KnUZ5rMfMlLM4VPxHFp24QTpTY3HFoTJ1AO15RE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUNbeCBRYT/mopcqJC2ouD2A2a5XEhPahctky1fl3q7eFn+cXtSi+loxSggLiyZDv nhpgEqCMxa27W+9Zloubh07KeOzAadbaQsTIW4rgbYOI7gMlRKSVLn0ReW0qzBA2m6 CXA/7RqWwE2PxfLhcln9CT5hKcRzorwCJGH30vnY= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20200107085817epcas1p3e38ddb1e54d731ff285cf691ddf7034c~njxD3XnVz1830918309epcas1p3Z; Tue, 7 Jan 2020 08:58:17 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.156]) by epsnrtp3.localdomain (Postfix) with ESMTP id 47sR9g3r5GzMqYkq; Tue, 7 Jan 2020 08:58:15 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 85.6B.51241.528441E5; Tue, 7 Jan 2020 17:58:13 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20200107085812epcas1p4670ae2265573d887aa75cab36c04b1ea~njw-ojZJw1742217422epcas1p4R; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200107085812epsmtrp274fa39990b38887cf12918ac3c7c06e3~njw-nnD8Z1572115721epsmtrp2x; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) X-AuditID: b6c32a39-14bff7000001c829-a4-5e1448258564 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 4A.81.10238.428441E5; Tue, 7 Jan 2020 17:58:12 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200107085812epsmtip2a359407b35a7795572e68c44cd8d4f38~njw-a7LSb2373423734epsmtip24; Tue, 7 Jan 2020 08:58:12 +0000 (GMT) From: Chanwoo Choi To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: leonard.crestez@nxp.com, lukasz.luba@arm.com, a.swigon@samsung.com, m.szyprowski@samsung.com, enric.balletbo@collabora.com, hl@rock-chips.com, digetx@gmail.com, bjorn.andersson@linaro.org, jcrouse@codeaurora.org, cw00.choi@samsung.com, chanwoo@kernel.org, myungjoo.ham@samsung.com, kyungmin.park@samsung.com Subject: [PATCH 2/2] PM / devfreq: Add devfreq_transitions debugfs file Date: Tue, 7 Jan 2020 18:05:19 +0900 Message-Id: <20200107090519.3231-3-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200107090519.3231-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA02SWUwTURSGvTPtdECrkwJ6RaMwBhcEy1irFyJq1OgYecBgfECljnQCSLd0 ClH0AXHDRhBjIoKIEJRgQS2kMQWtJbVxQxSDG2pdonFBRRFcqjHYMhh9++65/zn/PeceElfY iEgyx2Dhz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xhb357UyWpze/47F YuKNKywW1788Z7VY/fExo8Wa24cYLX5sOMVssXFBtsXZpjfsFivufmS1uLxrDpvF594jjBYL m1rYLdYeuctucbtxBZsDv8eaeWsYPS739TJ57Li7hNFj56y77B6bVnWyedy5tofNY+O7HUwe f2ftZ/Ho27KK0ePzJrkArigum5TUnMyy1CJ9uwSujDWztzAV3Aqs+Pn/GksD4z37LkZODgkB E4lDN6+ydzFycQgJ7GaU6D6xkg0iISkx7eJR5i5GDiBbWOLw4WKImk+MEo+O72AHqWET0JLY /+IGWL2IgI3E3cXXWECKmAXOM0m0L5/KCJIQFnCXWNU/mRXEZhFQlXjy8DATiM0rYCnx6uM8 Vohl8hKrNxxgBrE5Bawkvrx+D7ZACKhmzdYLjBMY+RYwMqxilEwtKM5Nzy02LDDMSy3XK07M LS7NS9dLzs/dxAgOey3NHYyXl8QfYhTgYFTi4bWQEo4TYk0sK67MPcQowcGsJMKrpSMSJ8Sb klhZlVqUH19UmpNafIhRmoNFSZz3ad6xSCGB9MSS1OzU1ILUIpgsEwenVANj5Lp/JRv582PO MPkuPv/2IoPE2nahjAKHSSFC7PunOfR6PJuq9uaXzqS/Pc0BWx9eff5TxDnjUu+/bWc+Zxoy 7bc0e+j+x6Bcmc/53vQHbLPCmW2WlXD47lS/lshl8kJt7eG19UHGX1wW1v5KPZxXUn9J7efn xymsUu8Uzk6zTAuSSPj6sbpFiaU4I9FQi7moOBEAc0lDtncCAAA= X-CMS-MailID: 20200107085812epcas1p4670ae2265573d887aa75cab36c04b1ea X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200107085812epcas1p4670ae2265573d887aa75cab36c04b1ea References: <20200107090519.3231-1-cw00.choi@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add new devfreq_transitions debugfs file to track the frequency transitions of all devfreq devices for the simple profiling as following: - /sys/kernel/debug/devfreq/devfreq_transitions And the user can decide the storage size (CONFIG_NR_DEVFREQ_TRANSITIONS) in Kconfig in order to save the transition history. [Detailed description of each field of 'devfreq_transitions' debugfs file] - time_ms : Change time of frequency transition. (unit: millisecond) - dev_name : Device name of h/w. - dev : Device name made by devfreq core. - parent_dev : If devfreq device uses the passive governor, show parent devfreq device name. - load_% : If devfreq device uses the simple_ondemand governor, load is used by governor whene deciding the new frequency. (unit: percentage) - old_freq_hz : Frequency before changing. (unit: hz) - new_freq_hz : Frequency after changed. (unit: hz) [For example on Exynos5422-based Odroid-XU3 board] $ cat /sys/kernel/debug/devfreq/devfreq_transitions time_ms dev_name dev parent_dev load_% old_freq_hz new_freq_hz ---------- ------------------------------ ---------- ---------- ---------- ------------ ------------ 14600 soc:bus_noc devfreq2 devfreq1 0 100000000 67000000 14600 soc:bus_fsys_apb devfreq3 devfreq1 0 200000000 100000000 14600 soc:bus_fsys devfreq4 devfreq1 0 200000000 100000000 14600 soc:bus_fsys2 devfreq5 devfreq1 0 150000000 75000000 14602 soc:bus_mfc devfreq6 devfreq1 0 222000000 96000000 14602 soc:bus_gen devfreq7 devfreq1 0 267000000 89000000 14602 soc:bus_g2d devfreq9 devfreq1 0 300000000 84000000 14602 soc:bus_g2d_acp devfreq10 devfreq1 0 267000000 67000000 14602 soc:bus_jpeg devfreq11 devfreq1 0 300000000 75000000 14602 soc:bus_jpeg_apb devfreq12 devfreq1 0 167000000 84000000 14603 soc:bus_disp1_fimd devfreq13 devfreq1 0 200000000 120000000 14603 soc:bus_disp1 devfreq14 devfreq1 0 300000000 120000000 14606 soc:bus_gscl_scaler devfreq15 devfreq1 0 300000000 150000000 14606 soc:bus_mscl devfreq16 devfreq1 0 333000000 84000000 14608 soc:bus_wcore devfreq1 9 333000000 84000000 14783 10c20000.memory-controller devfreq0 35 825000000 633000000 15873 soc:bus_wcore devfreq1 41 84000000 400000000 15873 soc:bus_noc devfreq2 devfreq1 0 67000000 100000000 [snip] Signed-off-by: Chanwoo Choi --- drivers/devfreq/Kconfig | 13 +++ drivers/devfreq/devfreq.c | 126 +++++++++++++++++++++++++++++ drivers/devfreq/governor.h | 3 + drivers/devfreq/governor_passive.c | 2 + include/linux/devfreq.h | 1 + 5 files changed, 145 insertions(+) diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig index 0b1df12e0f21..84936eec0ef9 100644 --- a/drivers/devfreq/Kconfig +++ b/drivers/devfreq/Kconfig @@ -74,6 +74,19 @@ config DEVFREQ_GOV_PASSIVE through sysfs entries. The passive governor recommends that devfreq device uses the OPP table to get the frequency/voltage. +comment "DEVFREQ Debugging" + +config NR_DEVFREQ_TRANSITIONS + int "Maximum storage size to save DEVFREQ Transitions (10-1000)" + depends on DEBUG_FS + range 10 1000 + default "100" + help + Show the frequency transitions of all devfreq devices via + '/sys/kernel/debug/devfreq/devfreq_transitions' for the simple + profiling. It needs to decide the storage size to save transition + history of all devfreq devices. + comment "DEVFREQ Drivers" config ARM_EXYNOS_BUS_DEVFREQ diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index c7f5e4e06420..7abaae06fa65 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -268,6 +268,57 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) } EXPORT_SYMBOL(devfreq_update_status); +/** + * devfreq_update_transitions() - Update frequency transitions for debugfs file + * @devfreq: the devfreq instance + * @old_freq: the previous frequency before changing the frequency + * @new_freq: the new frequency after frequency is changed + */ +struct devfreq_transitions { + struct devfreq *devfreq; + struct devfreq_freqs freqs; + unsigned long load; +} debugfs_transitions[CONFIG_NR_DEVFREQ_TRANSITIONS]; + +static spinlock_t devfreq_debugfs_lock; +static int debugfs_transitions_index; + +void devfreq_update_transitions(struct devfreq *devfreq, + unsigned long old_freq, unsigned long new_freq, + unsigned long busy_time, unsigned long total_time) +{ + unsigned long load; + int i; + + if (!devfreq_debugfs || !devfreq || (old_freq == new_freq)) + return; + + spin_lock_nested(&devfreq_debugfs_lock, SINGLE_DEPTH_NESTING); + + i = debugfs_transitions_index; + + /* + * Calculate the load and if load is larger than 100, + * initialize to 100 because the unit of load is percentage. + */ + load = (total_time == 0 ? 0 : (100 * busy_time) / total_time); + if (load > 100) + load = 100; + + debugfs_transitions[i].devfreq = devfreq; + debugfs_transitions[i].freqs.time = ktime_to_ms(ktime_get()); + debugfs_transitions[i].freqs.old = old_freq; + debugfs_transitions[i].freqs.new = new_freq; + debugfs_transitions[i].load = load; + + if (++i == CONFIG_NR_DEVFREQ_TRANSITIONS) + i = 0; + debugfs_transitions_index = i; + + spin_unlock(&devfreq_debugfs_lock); +} +EXPORT_SYMBOL(devfreq_update_transitions); + /** * find_devfreq_governor() - Find devfreq governor from name * @name: name of the governor @@ -401,6 +452,10 @@ static int set_target(struct devfreq *devfreq, return err; } + devfreq_update_transitions(devfreq, cur_freq, new_freq, + devfreq->last_status.busy_time, + devfreq->last_status.total_time); + freqs.new = new_freq; notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); @@ -1787,6 +1842,72 @@ static int devfreq_summary_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(devfreq_summary); +/** + * devfreq_transitions_show() - Show the frequency transitions of the registered + * devfreq devices via 'devfreq_transitions' debugfs file. + */ +static int devfreq_transitions_show(struct seq_file *s, void *data) +{ + struct devfreq *devfreq = NULL; + struct devfreq *p_devfreq = NULL; + struct devfreq_freqs *freqs = NULL; + unsigned long load; + int i = debugfs_transitions_index; + int count; + + seq_printf(s, "%-10s %-30s %-10s %-10s %-6s %-12s %-12s\n", + "time_ms", + "dev_name", + "dev", + "parent_dev", + "load_%", + "old_freq_hz", + "new_freq_hz"); + seq_printf(s, "%-10s %-30s %-10s %-10s %-6s %-12s %-12s\n", + "----------", + "------------------------------", + "----------", + "----------", + "----------", + "------------", + "------------"); + + spin_lock(&devfreq_debugfs_lock); + for (count = 0; count < CONFIG_NR_DEVFREQ_TRANSITIONS; count++) { + devfreq = debugfs_transitions[i].devfreq; + freqs = &debugfs_transitions[i].freqs; + load = debugfs_transitions[i].load; + + i = (CONFIG_NR_DEVFREQ_TRANSITIONS == ++i) ? 0 : i; + if (!devfreq) + continue; + +#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) + if (!strncmp(devfreq->governor_name, + DEVFREQ_GOV_PASSIVE, DEVFREQ_NAME_LEN)) { + struct devfreq_passive_data *data = devfreq->data; + + if (data) + p_devfreq = data->parent; + } else { + p_devfreq = NULL; + } +#endif + seq_printf(s, "%-10lld %-30s %-10s %-10s %-6ld %-12ld %-12ld\n", + freqs->time, + dev_name(devfreq->dev.parent), + dev_name(&devfreq->dev), + p_devfreq ? dev_name(&p_devfreq->dev) : "", + load, + freqs->old, + freqs->new); + } + spin_unlock(&devfreq_debugfs_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(devfreq_transitions); + static int __init devfreq_init(void) { devfreq_class = class_create(THIS_MODULE, "devfreq"); @@ -1808,9 +1929,14 @@ static int __init devfreq_init(void) devfreq_debugfs = NULL; pr_warn("%s: couldn't create debugfs dir\n", __FILE__); } else { + spin_lock_init(&devfreq_debugfs_lock); + debugfs_create_file("devfreq_summary", 0444, devfreq_debugfs, NULL, &devfreq_summary_fops); + debugfs_create_file("devfreq_transitions", 0444, + devfreq_debugfs, NULL, + &devfreq_transitions_fops); } return 0; diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index dc7533ccc3db..01eecfdaf2d6 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -68,6 +68,9 @@ extern int devfreq_add_governor(struct devfreq_governor *governor); extern int devfreq_remove_governor(struct devfreq_governor *governor); extern int devfreq_update_status(struct devfreq *devfreq, unsigned long freq); +extern void devfreq_update_transitions(struct devfreq *devfreq, + unsigned long old_freq, unsigned long new_freq, + unsigned long busy_time, unsigned long total_time); static inline int devfreq_update_stats(struct devfreq *df) { diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index be6eeab9c814..05fa654239f5 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -109,6 +109,8 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) if (ret < 0) goto out; + devfreq_update_transitions(devfreq, devfreq->previous_freq, freq, 0, 0); + if (devfreq->profile->freq_table && (devfreq_update_status(devfreq, freq))) dev_err(&devfreq->dev, diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 49cdb2378030..933692e5d867 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -196,6 +196,7 @@ struct devfreq { }; struct devfreq_freqs { + s64 time; unsigned long old; unsigned long new; };