From patchwork Mon Dec 9 14:44:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11279523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87C39112B for ; Mon, 9 Dec 2019 14:45:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6677A207FF for ; Mon, 9 Dec 2019 14:45:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="RWTtgsSw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727907AbfLIOon (ORCPT ); Mon, 9 Dec 2019 09:44:43 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53791 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbfLIOon (ORCPT ); Mon, 9 Dec 2019 09:44:43 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20191209144442euoutp020d59962f912bbd8b2c2703fc7926f624~euyPNQl1W2561025610euoutp02G for ; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191209144442euoutp020d59962f912bbd8b2c2703fc7926f624~euyPNQl1W2561025610euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1575902682; bh=HSFFoFiOo0swpbY+DWz76dNsC/W3cBBhFIOvJXJuUMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWTtgsSwIn9JRxeDbschkYpwUvFZz3F/mrTn2stiMnxglJa/Jqfaut9ca1HEewJac wjH1NzxYXWXEZEpL3HzDZO/9TWNdfeBNT6ga5/5YjyUh0jVAwla2wznpnQGCoUI32L ntXZhy8scnkzXbWWy8LpahTe9LhiBdj0fjR7bvYg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191209144441eucas1p1e2fd2160c44410e8462c0ef9eeda7844~euyO7alLw2849128491eucas1p1E; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6D.28.60698.9DD5EED5; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191209144441eucas1p16945780c1a1ff3302a233414ae6aace2~euyOkRiqq1586515865eucas1p1U; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191209144441eusmtrp2796e72b048fb8833b0fe8d0a31d5a5da~euyOjpYGv2834828348eusmtrp2i; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-14-5dee5dd9e231 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3A.C9.07950.9DD5EED5; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191209144440eusmtip2d0aedf96da3be9749a458fb850d20de4~euyODqXWa1447214472eusmtip2r; Mon, 9 Dec 2019 14:44:40 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH 1/4] PM / devfreq: reuse system workqueue machanism Date: Mon, 9 Dec 2019 15:44:22 +0100 Message-Id: <20191209144425.13321-2-k.konieczny@samsung.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209144425.13321-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djPc7o3Y9/FGjzbq2mxccZ6VovrX56z Wiz4NIPV4vz5DewWZ5vesFtc3jWHzeJz7xFGi7VH7rJb3G5cwebA6bFpVSebR9+WVYwenzfJ BTBHcdmkpOZklqUW6dslcGU8vraapeAYe8WWL49YGxg3s3UxcnJICJhI/Lk5mb2LkYtDSGAF o8S93h1sEM4XRonJc24xQzifGSU+nt0I13L8UzMTRGI5o0T/0SPMcC1fzj1nBaliE9CXOHj2 JAuILSIgLdG5aCJYB7PAMSaJXYf+ghUJCzhLrHn3GcxmEVCVOLDjB5jNK2AjcenceqAGDqB1 8hJz3mqAhDkFbCVef5zCDFEiKHFy5hOw+cxAJc1bZzNDXNfPLjHxQB5Eq4vEvg9MEGFhiVfH t7BD2DIS/3fOh4qXSzxd2Af2v4RAC6PEg/aPLBAJa4nDxy+ygsxhFtCUWL9LHyLsKDH3/zNm iPF8EjfeCkJcwCcxadt0qDCvREebEES1qsTzUz1Qm6Qluv6vY4WwPSQWNsxlm8CoOAvJL7OQ /DILYe8CRuZVjOKppcW56anFxnmp5XrFibnFpXnpesn5uZsYgYnm9L/jX3cw7vuTdIhRgINR iYd3gcO7WCHWxLLiytxDjBIczEoivEsmvooV4k1JrKxKLcqPLyrNSS0+xCjNwaIkzmu86GWs kEB6YklqdmpqQWoRTJaJg1OqgVGk6sap1eo18RFvntyQLL6au7yQ6YKL12LWNU6vG/MmqzIW eayc2ynqH3Lc8DF/5PZDx/oDfn+f15tu96XoT8N8drdlG35cWZAg5Zo+f8/mXXO65Bx3bpvN sMziwg7zVT+WWso94/oSWyYn5hu3JSpe89zjX2e5mCXko/42tASHxUr01N7pb1FiKc5INNRi LipOBAB+2nwjMAMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeLIzCtJLcpLzFFi42I5/e/4Pd2bse9iDXauEbLYOGM9q8X1L89Z LRZ8msFqcf78BnaLs01v2C0u75rDZvG59wijxdojd9ktbjeuYHPg9Ni0qpPNo2/LKkaPz5vk Apij9GyK8ktLUhUy8otLbJWiDS2M9AwtLfSMTCz1DI3NY62MTJX07WxSUnMyy1KL9O0S9DIe X1vNUnCMvWLLl0esDYyb2boYOTkkBEwkjn9qZupi5OIQEljKKLHh1iVmiIS0ROPp1UwQtrDE n2tdbBBFnxgl+qd0sIMk2AT0JQ6ePckCYosANXQumgjWwCxwhkniV0sFiC0s4Cyx5t1nVhCb RUBV4sCOH2A2r4CNxKVz64HqOYAWyEvMeasBEuYUsJV4/XEK2A1CQCXt//+zQJQLSpyc+YQF Yry8RPPW2cwTGAVmIUnNQpJawMi0ilEktbQ4Nz232EivODG3uDQvXS85P3cTIzAmth37uWUH Y9e74EOMAhyMSjy8CxzexQqxJpYVV+YeYpTgYFYS4V0y8VWsEG9KYmVValF+fFFpTmrxIUZT oB8mMkuJJucD4zWvJN7Q1NDcwtLQ3Njc2MxCSZy3Q+BgjJBAemJJanZqakFqEUwfEwenVAOj prFtVpi8lPvnps+y/935QxtW7702P1h3a9Y/hnShT0VmG6//yqztDXnzp9zjWr+O/7P4mTfc yjYvLA78qr50q/CW2LNJsSasdexScosO5il7id7le6jhXXVr5Qb7tlnHc/wcdjy0m3Ds/DcZ tn8+Hgf3HpJpTAkq2XXQ+E3gvawdfgeCCxcpsRRnJBpqMRcVJwIA+IJM/58CAAA= X-CMS-MailID: 20191209144441eucas1p16945780c1a1ff3302a233414ae6aace2 X-Msg-Generator: CA X-RootMTR: 20191209144441eucas1p16945780c1a1ff3302a233414ae6aace2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191209144441eucas1p16945780c1a1ff3302a233414ae6aace2 References: <20191209144425.13321-1-k.konieczny@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There is no need for creating another workqueue, it is enough to reuse system_freezable_power_efficient one. Signed-off-by: Kamil Konieczny --- drivers/devfreq/devfreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 46a7ff7c2994..955949c6fc1f 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1532,11 +1532,11 @@ static int __init devfreq_init(void) return PTR_ERR(devfreq_class); } - devfreq_wq = create_freezable_workqueue("devfreq_wq"); + devfreq_wq = system_freezable_power_efficient_wq; if (!devfreq_wq) { class_destroy(devfreq_class); - pr_err("%s: couldn't create workqueue\n", __FILE__); - return -ENOMEM; + pr_err("%s: system_freezable_power_efficient_wq isn't initialized\n", __FILE__); + return -EINVAL; } devfreq_class->dev_groups = devfreq_groups; From patchwork Mon Dec 9 14:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11279517 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 43930138C for ; Mon, 9 Dec 2019 14:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E5AC207FF for ; Mon, 9 Dec 2019 14:44:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="rB550LHd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727568AbfLIOor (ORCPT ); Mon, 9 Dec 2019 09:44:47 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53794 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbfLIOoo (ORCPT ); Mon, 9 Dec 2019 09:44:44 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20191209144442euoutp02e5be9bfe2ef5f10a2c87beb1473ca5da~euyPtEQjX2487524875euoutp02n for ; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191209144442euoutp02e5be9bfe2ef5f10a2c87beb1473ca5da~euyPtEQjX2487524875euoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1575902682; bh=Yj16QJuX/DQ6hPG7qS0AfAwbCc+kp0oVo/nwlvCOC70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB550LHdPgCE4dR0N9u6JEYZAT8NZxLr/XEYcSJG/US6jZlZ9y4I1KH9KLeQIIntm nGq3vXZk9Pcvedw2u56X7apmbNDB7G2Poh6luLE/PyhNS+phX8ti4ThjK4gm+I1HfG atpK4Q4PG5sx2OjpyP9VSdJ3t1ZfSB6qY6RiZ03M= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191209144442eucas1p1555f3b5e71ee5101e7e5f8dff43afda1~euyPTTYkP1801118011eucas1p18; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 8E.28.60698.ADD5EED5; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20191209144441eucas1p2ccd371e5861e8c0a3948cdc6640ad0d5~euyO8HO4V1767717677eucas1p2e; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191209144441eusmtrp2ff0dcd4baf345c5881830dbbd9e014d8~euyO7fit42834828348eusmtrp2j; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-15-5dee5dda6e32 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DA.C9.07950.9DD5EED5; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191209144441eusmtip2c4378d18a7579f554199001e774c7429~euyOhAYgG1467314673eusmtip2K; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH 2/4] PM / devfreq: add possibility for delayed work Date: Mon, 9 Dec 2019 15:44:23 +0100 Message-Id: <20191209144425.13321-3-k.konieczny@samsung.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209144425.13321-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djPc7q3Yt/FGuy4w2yxccZ6VovrX56z Wiz4NIPV4vz5DewWZ5vesFtc3jWHzeJz7xFGi7VH7rJb3G5cwebA6bFpVSebR9+WVYwenzfJ BTBHcdmkpOZklqUW6dslcGU8nrWUtWClakXPnedsDYwt8l2MnBwSAiYSe+dPZ+9i5OIQEljB KNFxbSojhPOFUWLLks2sEM5nRonF9y4zw7QcvfeHEcQWEljOKHFlgTBcx+HVX1lAEmwC+hIH z54Es0UEpCU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Jy3GiBhTgFbidcfpzBD3GMj0f7/PwtEuaDEyZlPWCDG y0s0b53NPIFRYBaS1CwkqQWMTKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzECI2LbsZ9bdjB2 vQs+xCjAwajEw7vA4V2sEGtiWXFl7iFGCQ5mJRHeJRNfxQrxpiRWVqUW5ccXleakFh9iNAX6 YSKzlGhyPjBa80riDU0NzS0sDc2NzY3NLJTEeTsEDsYICaQnlqRmp6YWpBbB9DFxcEo1MJYb fuNzzTYtEvVUC9lnFrhp4jTPkmPMB9uMd/3Wab7uFDFno62+0u/Ewpgd196fSFHxC4544iu1 32DjKXuj658SN1mtKK41845e/YLt7qM9VpdXJH2V2ix69+ibLy2sQh0Ts3S4JhvPefWXZ87V Bd3KnKpTHka9mf005PCXf/G3Mi8d+n/i9F4lluKMREMt5qLiRACS268ZngIAAA== X-CMS-MailID: 20191209144441eucas1p2ccd371e5861e8c0a3948cdc6640ad0d5 X-Msg-Generator: CA X-RootMTR: 20191209144441eucas1p2ccd371e5861e8c0a3948cdc6640ad0d5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191209144441eucas1p2ccd371e5861e8c0a3948cdc6640ad0d5 References: <20191209144425.13321-1-k.konieczny@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Current devfreq workqueue uses deferred timer. Introduce sysfs file delayed_timer and use it for change from deferred to delayed work. The default is to use old deferred one, which saves power, but can miss increased demand for higher bus frequency if timer was assigned to idle cpu. Signed-off-by: Kamil Konieczny --- Documentation/ABI/testing/sysfs-class-devfreq | 10 ++++ drivers/devfreq/devfreq.c | 46 ++++++++++++++++++- include/linux/devfreq.h | 2 + 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq index 9758eb85ade3..07bfd0df6a4a 100644 --- a/Documentation/ABI/testing/sysfs-class-devfreq +++ b/Documentation/ABI/testing/sysfs-class-devfreq @@ -30,6 +30,16 @@ Description: target_freq when get_cur_freq() is not implemented by devfreq driver. +What: /sys/class/devfreq/.../delayed_timer +Date: December 2019 +Contact: Kamil Konieczny +Description: + This ABI shows or clears timer type used by devfreq + workqueue. When 0, it uses default deferred timer. + When set to 1 devfreq will use delayed timer. Example + useage: + echo 1 > /sys/class/devfreq/.../delayed_timer + What: /sys/class/devfreq/.../target_freq Date: September 2012 Contact: Rajagopal Venkat diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 955949c6fc1f..c277d1770fef 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -445,7 +445,11 @@ void devfreq_monitor_start(struct devfreq *devfreq) if (devfreq->governor->interrupt_driven) return; - INIT_DEFERRABLE_WORK(&devfreq->work, devfreq_monitor); + if (devfreq->delayed_timer) + INIT_DELAYED_WORK(&devfreq->work, devfreq_monitor); + else + INIT_DEFERRABLE_WORK(&devfreq->work, devfreq_monitor); + if (devfreq->profile->polling_ms) queue_delayed_work(devfreq_wq, &devfreq->work, msecs_to_jiffies(devfreq->profile->polling_ms)); @@ -698,6 +702,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call; + devfreq->delayed_timer = false; if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { mutex_unlock(&devfreq->lock); @@ -1288,6 +1293,44 @@ static ssize_t available_governors_show(struct device *d, } static DEVICE_ATTR_RO(available_governors); +static ssize_t delayed_timer_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int i; + + i = to_devfreq(dev)->delayed_timer ? 1 : 0; + return sprintf(buf, "%d\n", i); +} + +static ssize_t delayed_timer_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct devfreq *df = to_devfreq(dev); + bool old_timer; + int value, ret; + + if (!df->governor) + return -EINVAL; + + ret = kstrtoint(buf, 10, &value); + if (ret || (value != 1 && value != 0)) + return -EINVAL; + + mutex_lock(&df->lock); + old_timer = df->delayed_timer; + df->delayed_timer = value == 0 ? false : true; + mutex_unlock(&df->lock); + + if (old_timer != df->delayed_timer) { + devfreq_monitor_stop(df); + devfreq_monitor_start(df); + } + + return count; +} +static DEVICE_ATTR_RW(delayed_timer); + static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1513,6 +1556,7 @@ static struct attribute *devfreq_attrs[] = { &dev_attr_name.attr, &dev_attr_governor.attr, &dev_attr_available_governors.attr, + &dev_attr_delayed_timer.attr, &dev_attr_cur_freq.attr, &dev_attr_available_frequencies.attr, &dev_attr_target_freq.attr, diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index de2fdc56aa5b..761aa0a09db7 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -134,6 +134,7 @@ struct devfreq_stats { * reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. * @work: delayed work for load monitoring. + * @delayed_timer: use delayed or deferred timer for workqueue. * @previous_freq: previously configured frequency value. * @data: Private data of the governor. The devfreq framework does not * touch this. @@ -166,6 +167,7 @@ struct devfreq { char governor_name[DEVFREQ_NAME_LEN]; struct notifier_block nb; struct delayed_work work; + bool delayed_timer; unsigned long previous_freq; struct devfreq_dev_status last_status; From patchwork Mon Dec 9 14:44:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11279519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3376D138C for ; Mon, 9 Dec 2019 14:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1016A20866 for ; Mon, 9 Dec 2019 14:44:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="SyF8ALsN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbfLIOow (ORCPT ); Mon, 9 Dec 2019 09:44:52 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:59587 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbfLIOoo (ORCPT ); Mon, 9 Dec 2019 09:44:44 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20191209144443euoutp01bfc4b6e0513eb20f9813acfc497b7dee~euyQF-0oC0633006330euoutp01S for ; Mon, 9 Dec 2019 14:44:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20191209144443euoutp01bfc4b6e0513eb20f9813acfc497b7dee~euyQF-0oC0633006330euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1575902683; bh=vmsYHmTYNYlLDIB9n5HoDoLj6M0SpxR24w7UmG0Af50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SyF8ALsNHfopDXgNzhPIgwVaxLjJEh/V7hJg4RMPQh9iqbvRX5K6geozqVL2MjEyk mUxERSVDWBCD9b6ack1OKIX6zTIKV+K3iiId4WjQcSNqCxfU9vHsr0sjvqc3FbuJUl 79kqH7GoVfwxil4WDSVOFYiZDL1AAXPK0KvD0kR4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20191209144442eucas1p2feb35da92f2ba3b14a47d9d1f6546734~euyP3HPvr1762917629eucas1p2A; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5F.28.60698.ADD5EED5; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191209144442eucas1p1e4f5cf4a1716262e2b6715fb41876f91~euyPbvn8y2849928499eucas1p1h; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191209144442eusmtrp27c68c303bdc9a039888bf6d5a33ec8f0~euyPbLpEc2831928319eusmtrp2y; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-17-5dee5dda4d41 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A6.09.08375.ADD5EED5; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191209144441eusmtip2e24a7d14775db59d3a38f850b9345d6a~euyO7yv3f1405314053eusmtip2M; Mon, 9 Dec 2019 14:44:41 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH 3/4] PM / devfreq: Kconfig: add DEVFREQ_DELAYED_TIMER option Date: Mon, 9 Dec 2019 15:44:24 +0100 Message-Id: <20191209144425.13321-4-k.konieczny@samsung.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209144425.13321-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLKsWRmVeSWpSXmKPExsWy7djPc7q3Yt/FGhy8qW2xccZ6VovrX56z Wiz4NIPV4vz5DewWZ5vesFtc3jWHzeJz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O0S9DK2 zF/AXtDEWdExcSZjA+Ma9i5GTg4JAROJZRcXMnUxcnEICSxllDj67SMbREJaovH0aiYIW1ji z7UuNoiiT4wSj//NAStiE9CXOHj2JAuILQLU0LloIlgDs8AZJolfLRUgtrCAj8SPjknMIDaL gKrEmVvnGUFsXgEbiR/v9gDFOYAWyEvMeasBEuYUsJV4/XEKWLkQUEn7//8sEOWCEidnPmGB GC8v0bx1NvMERoFZSFKzkKQWMDKtYhRJLS3OTc8tNtQrTswtLs1L10vOz93ECIyJbcd+bt7B eGlj8CFGAQ5GJR7eBQ7vYoVYE8uKK3MPMUpwMCuJ8C6Z+CpWiDclsbIqtSg/vqg0J7X4EKMp 0A8TmaVEk/OB8ZpXEm9oamhuYWlobmxubGahJM7bIXAwRkggPbEkNTs1tSC1CKaPiYNTqoHR 82Lu99w+451Lt5iu0bZeZFMn/+t/LW8M55ds5ocm4S+VLfp0XnwO+nCJtdnW9PquOTYcrM0t q7lnLWY/d1b06uWP1pEBJV2B/DJBYibrL3L9cb7Y0TSL0+7hnMrN5yav63w2Z/qTHw96d1ud T4xMZNpRzqh++qqSpZzVkXuLTUIL7i+qYtBWYinOSDTUYi4qTgQA5QC6qZ8CAAA= X-CMS-MailID: 20191209144442eucas1p1e4f5cf4a1716262e2b6715fb41876f91 X-Msg-Generator: CA X-RootMTR: 20191209144442eucas1p1e4f5cf4a1716262e2b6715fb41876f91 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191209144442eucas1p1e4f5cf4a1716262e2b6715fb41876f91 References: <20191209144425.13321-1-k.konieczny@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add Kconfig option DEVFREQ_DELAYED_TIMER. If set, devfreq workqueue will use delayed timer from its start. Signed-off-by: Kamil Konieczny --- drivers/devfreq/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig index 38a94df749a2..c799917c34c9 100644 --- a/drivers/devfreq/Kconfig +++ b/drivers/devfreq/Kconfig @@ -74,6 +74,18 @@ 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 Options" + +config DEVFREQ_DELAYED_TIMER + bool "Use delayed timer in Simple Ondemand Governor" + default false + help + Simple Ondemand Governor uses polling for reading buses counters. + A default timer used is deferred, which saves power, but can + miss increased demand for higher bus frequency if timer was + assigned to idle cpu. If you want to change this to delayed + timer at the cost of more power used, say Yes here. + comment "DEVFREQ Drivers" config ARM_EXYNOS_BUS_DEVFREQ From patchwork Mon Dec 9 14:44:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamil Konieczny X-Patchwork-Id: 11279521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF93C138C for ; Mon, 9 Dec 2019 14:44:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C465B207FF for ; Mon, 9 Dec 2019 14:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Xo4Pkq5p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727936AbfLIOow (ORCPT ); Mon, 9 Dec 2019 09:44:52 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53806 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727913AbfLIOoo (ORCPT ); Mon, 9 Dec 2019 09:44:44 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20191209144443euoutp026060cd75772f4e79d72ae24085771e30~euyQgBa9h2421224212euoutp02I for ; Mon, 9 Dec 2019 14:44:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191209144443euoutp026060cd75772f4e79d72ae24085771e30~euyQgBa9h2421224212euoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1575902683; bh=WzxcJ59gNp8il6neN2DdkauTkF314FsLCY6M8Z2mAPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xo4Pkq5p94MZjF1xE9mpkIO18EK9iRU49ssF4tlWcSL9Unfhd3vKVESAaq5BqCdsy 62hrOxKsya/XqfyZW1d99XwedhXSMhJEctU9Q3m7Y/lEN8dc7oWp7l3jC4nw0w7e25 dER8pu4ihe3Q+0CAdtVRQmM3Jlv/CbRRTNcmewPA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20191209144443eucas1p13af02c6d9c3ee96923731419cac4d131~euyQO_GzB1796517965eucas1p1M; Mon, 9 Dec 2019 14:44:43 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FF.28.60698.BDD5EED5; Mon, 9 Dec 2019 14:44:43 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20191209144442eucas1p214c553519b7a9d3d005802984bc6fb31~euyP5moCq1662616626eucas1p2w; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20191209144442eusmtrp2c0d5e4c9bda2feaf9c4b23e408e4bc1b~euyP4-lhL2834828348eusmtrp2m; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-18-5dee5ddb09d1 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 67.09.08375.ADD5EED5; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) Received: from AMDC3218.digital.local (unknown [106.120.51.18]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20191209144442eusmtip2429bc4ca617da4080f05b8994f119bcd~euyPYHo0o1707917079eusmtip2E; Mon, 9 Dec 2019 14:44:42 +0000 (GMT) From: Kamil Konieczny To: k.konieczny@samsung.com Cc: Bartlomiej Zolnierkiewicz , Chanwoo Choi , Krzysztof Kozlowski , Kyungmin Park , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Marek Szyprowski , MyungJoo Ham Subject: [PATCH 4/4] PM / devfreq: use delayed work if DEVFREQ_DELAYED_TIMER set Date: Mon, 9 Dec 2019 15:44:25 +0100 Message-Id: <20191209144425.13321-5-k.konieczny@samsung.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209144425.13321-1-k.konieczny@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA01SfSxVcRje757Pa107DuWNYt1NXytqWjtFTcuWrLZqba3aTUfOfMSle3xd f1GtizBKEoasibtQ0lW3xeJGCLO2Utj8kYmQr/KRjxyH8t/zPu/zPO/7bi+NsXmEAx2sjRR0 Wj5UTVrhpoaZtt1dmhHNnp/tJPcsu4LgPk/2E1zheDbBtbc/pbjW60MU99GcR3ITqRbElVl6 KK4roYT0UvpUGpNIn7QqI/KZqHQ6hV2w8gwQQoOjBZ3b4ctWQWVF+VSEkYpdXDBT8aiYTEZK Gph9YEptx5ORFc0yJQj6R6couZhEYOqYJOViAkFDy3ds1TLfl6+QMMs8RmA0Rv9zZBUbl3NJ xg3etjbhErZjHCGpKEMhiTCmQQHmunlCatgyZ6CzZw4lI5rGGReoN1yUaBXjCfdmc0mJBsYZ 8oa3S7SSOQQ/xjIxWWIDTQ++LcdjS5IbL3IxKR6Y2xSUvl/1ekNmX4i8sy0MNlZRMt4Ei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amltYGpobmxubWSiJ83YIHIwREkhPLEnNTk0tSC2C6WPi4JRqYPSr Oda76EqBsk9XX3Ai5649bK0+hklsRzQty6zTt/NezX11MSHlm6V0URhLzVLGKUuuz14apMLA uvmnn4qUz2ZDm82M5pNFJmQY29aWpdm8/W7aIs59jG3rTFetMLkdR7bEnnZr3bWxe476co1G x12J1ln77lQZVExzqgvby3XwxEOLTdsvKrEUZyQaajEXFScCABkg26udAgAA X-CMS-MailID: 20191209144442eucas1p214c553519b7a9d3d005802984bc6fb31 X-Msg-Generator: CA X-RootMTR: 20191209144442eucas1p214c553519b7a9d3d005802984bc6fb31 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20191209144442eucas1p214c553519b7a9d3d005802984bc6fb31 References: <20191209144425.13321-1-k.konieczny@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If option DEVFREQ_DELAYED_TIMER is set use delayed work in devfreq workqueue from devfreq start. Signed-off-by: Kamil Konieczny --- drivers/devfreq/devfreq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index c277d1770fef..d9edf648a09e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -702,7 +702,10 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call; - devfreq->delayed_timer = false; + if (IS_ENABLED(CONFIG_DEVFREQ_DELAYED_TIMER)) + devfreq->delayed_timer = true; + else + devfreq->delayed_timer = false; if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { mutex_unlock(&devfreq->lock);