From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.4 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_SANE_1 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 98579C33CAF for ; Mon, 13 Jan 2020 07:18:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 658C0207FF for ; Mon, 13 Jan 2020 07:18:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="b344l4LL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728783AbgAMHSJ (ORCPT ); Mon, 13 Jan 2020 02:18:09 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:49836 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbgAMHSJ (ORCPT ); Mon, 13 Jan 2020 02:18:09 -0500 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200113071805epoutp01d93d5cb9ad5ab5f2798d416490f7581b~pYRS0XaDK0084000840epoutp01I for ; Mon, 13 Jan 2020 07:18:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200113071805epoutp01d93d5cb9ad5ab5f2798d416490f7581b~pYRS0XaDK0084000840epoutp01I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1578899885; bh=OyPXwD//gNxYGJwrwgpCEXEZipA1ItAsHI0I6WwlA/M=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=b344l4LLqP/kDei7OPJzpZYULTtccgYb8+Pl427+bqy5X1GQmDke+I4nC4tcr3EGN vDphEakTXbcybOyFymRzbRG+aCkSAm4lxs9sLPzeMUNM1lYtOAan3WSEu7cVEaXIVE ig4AFjsGqVUJuGMk8zaWwRqUCDteJFVksCA8DESQ= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20200113071804epcas1p43eb9a65dd0de9c8deedf823fb2fdf8c2~pYRRjHviC2466724667epcas1p4N; Mon, 13 Jan 2020 07:18:04 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.152]) by epsnrtp2.localdomain (Postfix) with ESMTP id 47x4gG22xbzMqYkV; Mon, 13 Jan 2020 07:18:02 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 7F.A0.48019.AA91C1E5; Mon, 13 Jan 2020 16:18:02 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20200113071801epcas1p3d1cbe0cebee63c3457512a94850d4784~pYROv4MOL2902829028epcas1p3T; Mon, 13 Jan 2020 07:18:01 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200113071801epsmtrp12603314cdc809345ebaace8e4cef546f~pYROuvc0i1720517205epsmtrp1U; Mon, 13 Jan 2020 07:18:01 +0000 (GMT) X-AuditID: b6c32a38-257ff7000001bb93-e7-5e1c19aa9c7a Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9B.5A.10238.9A91C1E5; Mon, 13 Jan 2020 16:18:01 +0900 (KST) Received: from [10.113.221.102] (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200113071801epsmtip109f2a3ceff7afc3b3ae4423d958fad0b~pYROdnFmN1946319463epsmtip1t; Mon, 13 Jan 2020 07:18:01 +0000 (GMT) Subject: Re: [PATCH 1/2] thermal: devfreq_cooling: Use PM QoS to set frequency limits To: Matthias Kaehlcke , MyungJoo Ham , Kyungmin Park , Zhang Rui , Daniel Lezcano , Amit Kucheria Cc: Leonard Crestez , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org From: Chanwoo Choi Organization: Samsung Electronics Message-ID: Date: Mon, 13 Jan 2020 16:25:17 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Thunderbird/59.0 MIME-Version: 1.0 In-Reply-To: <20200110094913.1.I146403d05b9ec82f48b807efd416a57f545b447a@changeid> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01SfUyMcRz3u+d67sk6/VzS13nLg6Gt3FMdD66bEbut/mhsbDblWT27y726 5zInJq+9yGGYuSRmtooNKZIs6yL9IU4IvZCaFdLUSt7d3ZPpv8/v+/l8Xz7f35ciFJWkksq0 OHi7hTPR5ETpTc+imOjyaTNSVbdzMfu1+ZuEPTc0k32075OMLe34EsS21Jwl2aEjDYgdutaN 2La9pSTb0+UiVwbrinK8Ut3F2j6Jrv1FLam7/rlaonNVliNdXqNTN1QxK0W2yagx8FwGb4/k LenWjEyLPoFOWp+2Ok29RMVEM8vYpXSkhTPzCXRickr02kyTbzA6cjtnyvKFUjhBoBdrNXZr loOPNFgFRwLN2zJMtmW2GIEzC1kWfUy61bycUali1T7hFqOhauSWxOaau2Ow+heRg/5ML0AU BTgePo5oC9BESoGrEfQPvyELULDvMYggt5UQiREEl991Sf4lNJYvEDV3ETTsSxY1Awj2luQT fiIMbwSXp1vqJ6bgnwgODvwOEATWwwPPd5kfkz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tJyywkLbOQtCxgZFnFKJlaUJybnltsWGCY l1quV5yYW1yal66XnJ+7iREcb1qaOxgvL4k/xCjAwajEwytRKx0nxJpYVlyZe4hRgoNZSYR3 0zmpOCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8T/OORQoJpCeWpGanphakFsFkmTg4pRoY8/4s SPp25MPxuRxVanq7Gn68CKu8JFwn9uO759sS7h1t6cfOTJ7hLVnx1HXxNHPGc643f5RYnL3i wnPIwv8KR+M1CYPmHia/+uBp3Ua+TLs2Zrh+1ZiV9a3GJOLIxGLVmpe2KWlKv8QuT+0pmNBy 4fAH/33X1Y4wz1vlFZBZdD3qf5B2xCkjJZbijERDLeai4kQALv4pgLMCAAA= X-CMS-MailID: 20200113071801epcas1p3d1cbe0cebee63c3457512a94850d4784 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200110174931epcas1p49c79567945e125829188174293d99850 References: <20200110094913.1.I146403d05b9ec82f48b807efd416a57f545b447a@changeid> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 1/11/20 2:49 AM, Matthias Kaehlcke wrote: > Now that devfreq supports limiting the frequency range of a device > through PM QoS make use of it instead of disabling OPPs that should > not be used. > > Signed-off-by: Matthias Kaehlcke > --- > > drivers/thermal/devfreq_cooling.c | 66 ++++++++++--------------------- > 1 file changed, 20 insertions(+), 46 deletions(-) > > diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c > index ef59256887ff..3a63603afcf2 100644 > --- a/drivers/thermal/devfreq_cooling.c > +++ b/drivers/thermal/devfreq_cooling.c > @@ -24,11 +24,13 @@ > #include > #include > #include > +#include > #include > > #include > > -#define SCALE_ERROR_MITIGATION 100 > +#define HZ_PER_KHZ 1000 > +#define SCALE_ERROR_MITIGATION 100 > > static DEFINE_IDA(devfreq_ida); > > @@ -65,49 +67,9 @@ struct devfreq_cooling_device { > struct devfreq_cooling_power *power_ops; > u32 res_util; > int capped_state; > + struct dev_pm_qos_request req_max_freq; Need to add the description of 'req_max_freq'. > }; > > -/** > - * partition_enable_opps() - disable all opps above a given state > - * @dfc: Pointer to devfreq we are operating on > - * @cdev_state: cooling device state we're setting > - * > - * Go through the OPPs of the device, enabling all OPPs until > - * @cdev_state and disabling those frequencies above it. > - */ > -static int partition_enable_opps(struct devfreq_cooling_device *dfc, > - unsigned long cdev_state) > -{ > - int i; > - struct device *dev = dfc->devfreq->dev.parent; > - > - for (i = 0; i < dfc->freq_table_size; i++) { > - struct dev_pm_opp *opp; > - int ret = 0; > - unsigned int freq = dfc->freq_table[i]; > - bool want_enable = i >= cdev_state ? true : false; > - > - opp = dev_pm_opp_find_freq_exact(dev, freq, !want_enable); > - > - if (PTR_ERR(opp) == -ERANGE) > - continue; > - else if (IS_ERR(opp)) > - return PTR_ERR(opp); > - > - dev_pm_opp_put(opp); > - > - if (want_enable) > - ret = dev_pm_opp_enable(dev, freq); > - else > - ret = dev_pm_opp_disable(dev, freq); > - > - if (ret) > - return ret; > - } > - > - return 0; > -} > - > static int devfreq_cooling_get_max_state(struct thermal_cooling_device *cdev, > unsigned long *state) > { > @@ -134,7 +96,7 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev, > struct devfreq_cooling_device *dfc = cdev->devdata; > struct devfreq *df = dfc->devfreq; > struct device *dev = df->dev.parent; > - int ret; > + unsigned long freq; > > if (state == dfc->cooling_state) > return 0; > @@ -144,9 +106,10 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev, > if (state >= dfc->freq_table_size) > return -EINVAL; > > - ret = partition_enable_opps(dfc, state); > - if (ret) > - return ret; > + freq = dfc->freq_table[state]; > + > + dev_pm_qos_update_request(&dfc->req_max_freq, > + DIV_ROUND_UP(freq, HZ_PER_KHZ)); > > dfc->cooling_state = state; > > @@ -529,6 +492,12 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, > if (err) > goto free_dfc; > > + err = dev_pm_qos_add_request(df->dev.parent, &dfc->req_max_freq, > + DEV_PM_QOS_MAX_FREQUENCY, > + PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE); > + if (err < 0) > + goto remove_qos_req; Jump 'free_table' instead of 'remove_qos_req'. > + > err = ida_simple_get(&devfreq_ida, 0, 0, GFP_KERNEL); > if (err < 0) > goto free_tables; Jump remove_qos_req. > @@ -552,6 +521,10 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df, > > release_ida: > ida_simple_remove(&devfreq_ida, dfc->id); > + > +remove_qos_req: > + dev_pm_qos_remove_request(&dfc->req_max_freq); > + > free_tables: > kfree(dfc->power_table); > kfree(dfc->freq_table); > @@ -600,6 +573,7 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev) > > thermal_cooling_device_unregister(dfc->cdev); > ida_simple_remove(&devfreq_ida, dfc->id); > + dev_pm_qos_remove_request(&dfc->req_max_freq); > kfree(dfc->power_table); > kfree(dfc->freq_table); > > -- Best Regards, Chanwoo Choi Samsung Electronics