Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1065664ybi; Fri, 31 May 2019 13:15:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpmypPvqLwvSADUXcVorxtfrHZnLNmFxlk8miT/C1cfH/bSzTQXKcCgfXjpiVmydsRDMG/ X-Received: by 2002:a17:902:8b8b:: with SMTP id ay11mr11784935plb.63.1559333729960; Fri, 31 May 2019 13:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559333729; cv=none; d=google.com; s=arc-20160816; b=QUVO1ZG665E33xjh7XQVlOI36GtVeD+Xl4xf3pZdk7H3KSgFmFZqaMnh2OnqGl4KDf wwiA95bkZYKyr53mrE0Q07D6Xg17jlGpuoHavNOUrghqifV3ZIidqT60NcbZXfGurSyq CkNqGQzbtcFTwFFxlxHjfh18/Je2DQMtR7j6g4Ekdez1byk8qpzkjKnFHs9y4QADAguW LqTisil7FoG32+yNM6upXVHSy1GxoamXQMrGYPcXwcZDdhgmdBrYD/gL7SPurnb8qTLQ SHeZmNo+Hr5al0NioKbi0HBwnpGDU3z+QHsQYs3TfBuMWVtkA1gCptJagK8RyiHHQPbn 9UOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:to:subject :dkim-signature; bh=1veSzmme9xy9EDCdaXF+fOGjs1JaVIDVHse9u2t5kHE=; b=UxiNkVVyveSwtP5KtbSbzWE/f1iRGM+BBnO/m/i2X9jL1KBYBrl3M84CJejCtiUWYa kwIqYaLJgFlP1933aeVAwbGs6J3lZx+jAWnKuhdRkbRw43BMMgbHtvbgef44juliklyl o0jj0YGwcJlAaTh/WkukufmnYDwJ9SqfXFDtqFATB3a0ZX5LWE/HFuEqCJb7A32A+rBY QIf67LONe8qii2Y2vw8oryzqK7ZK44xwFqsIbGAInwrRGuE2eaR7BV0nu3ldeTO7ZxsT X3JTLpbI7pnkL7OISOJMJgC7tHPLGsb2t7WT1o3NXyVbwrFj3xgR5pckFUNqmXw7++G8 HJ8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O35kPx5r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j91si7524255pld.267.2019.05.31.13.15.13; Fri, 31 May 2019 13:15:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O35kPx5r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbfEaUOD (ORCPT + 99 others); Fri, 31 May 2019 16:14:03 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40552 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727461AbfEaUOD (ORCPT ); Fri, 31 May 2019 16:14:03 -0400 Received: by mail-wr1-f66.google.com with SMTP id p11so2441992wre.7 for ; Fri, 31 May 2019 13:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1veSzmme9xy9EDCdaXF+fOGjs1JaVIDVHse9u2t5kHE=; b=O35kPx5r6zUN5pUBRFbzTq/dtlhn75KVRNgPXWArXjSD34YvThVRP0uYM0/vep8/35 9FuvwrJaHehlrkKn3Tn2fw188nhb6N5u+Zh8r+ZTz1LTe/8k0+JhRMTLqPs6sA+SVKjY ivvf2oGkpRJL5Oo7tH72JhEVwpX8TQ7M3PXoIaMksVVko6MvoP3pD0NCSstFZ/EREaq1 jzTQ7qd9u3oQEiqj8MMtvdAarpdEetYEIDbEwkxuA7c/Nif7InjwDIEiL6oMBlJdxtIQ CiirPxzWjuzVHkootO5kD/oMGVcDbRCPsG5dePAhW59AFRq4ZZuseimCM9h4nbiCcVs0 bbUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1veSzmme9xy9EDCdaXF+fOGjs1JaVIDVHse9u2t5kHE=; b=ENjwFEbbWJe1ldW3H35fBptFQtVduDSx6sYMpzkrX2HKz6ZlEObNVG7/rQWenaaL7D 77mKE8MZ1xQWWKDmmZcL93Lv+v9dx8GoYROjxt/avoHxXeoiuWBizbAvGYs+UWIFsiZc F6O4GBDyMqCI35ELGLEDC38tpeGFa+DAnmqMJS2AqeADK9TrZp6D4NSD/lVC33ZYT6rQ sxsjlSmq7vpalTKbBSk7dsgciBOYrKzvUja4qWXCDLi6iA9BUVg383Unhzyvb34rH9YV RaK48GuNMlA491XdQVWlngK/WEWTcfearU1ayMJzsOHQAZbTugmPqT21aD//QCe807+M Zn1g== X-Gm-Message-State: APjAAAWgglEkCtuaFsTIGMcHiXv2totSVW6FjZX+APGcmTCuTJbCid1i Pscx+q+LPYETqtyvfhTH8p5FdA== X-Received: by 2002:adf:dc04:: with SMTP id t4mr8215909wri.126.1559333640803; Fri, 31 May 2019 13:14:00 -0700 (PDT) Received: from [192.168.43.165] ([37.168.13.193]) by smtp.googlemail.com with ESMTPSA id s7sm5819335wmc.2.2019.05.31.13.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 13:14:00 -0700 (PDT) Subject: Re: [PATCH v5 2/3] thermal: cpu_cooling: Make the power-related code depend on IPA To: Quentin Perret , edubezval@gmail.com, rui.zhang@intel.com, javi.merino@kernel.org, viresh.kumar@linaro.org, amit.kachhap@gmail.com, rjw@rjwysocki.net, will.deacon@arm.com, catalin.marinas@arm.com, dietmar.eggemann@arm.com, ionela.voinescu@arm.com, mka@chromium.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20190530092038.12020-1-quentin.perret@arm.com> <20190530092038.12020-3-quentin.perret@arm.com> From: Daniel Lezcano Openpgp: preference=signencrypt Autocrypt: addr=daniel.lezcano@linaro.org; prefer-encrypt=mutual; keydata= mQINBFv/yykBEADDdW8RZu7iZILSf3zxq5y8YdaeyZjI/MaqgnvG/c3WjFaunoTMspeusiFE sXvtg3ehTOoyD0oFjKkHaia1Zpa1m/gnNdT/WvTveLfGA1gH+yGes2Sr53Ht8hWYZFYMZc8V 2pbSKh8wepq4g8r5YI1XUy9YbcTdj5mVrTklyGWA49NOeJz2QbfytMT3DJmk40LqwK6CCSU0 9Ed8n0a+vevmQoRZJEd3Y1qXn2XHys0F6OHCC+VLENqNNZXdZE9E+b3FFW0lk49oLTzLRNIq 0wHeR1H54RffhLQAor2+4kSSu8mW5qB0n5Eb/zXJZZ/bRiXmT8kNg85UdYhvf03ZAsp3qxcr xMfMsC7m3+ADOtW90rNNLZnRvjhsYNrGIKH8Ub0UKXFXibHbafSuq7RqyRQzt01Ud8CAtq+w P9EftUysLtovGpLSpGDO5zQ++4ZGVygdYFr318aGDqCljKAKZ9hYgRimPBToDedho1S1uE6F 6YiBFnI3ry9+/KUnEP6L8Sfezwy7fp2JUNkUr41QF76nz43tl7oersrLxHzj2dYfWUAZWXva wW4IKF5sOPFMMgxoOJovSWqwh1b7hqI+nDlD3m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y1dAFw+dqRcF5gXIh3NKX0gqiAA87NM7nL5ym/CNpJ7z7nRC8 qePOXubgouxumi5RQs1+crBmCDa/AyJHKdG2mqCt9fx5EPbDpw6Zzx7hgURh4ikHoS7/tLjK iqWjuat8/HWc01yEd8rtkGuUcMqbCi1XhcAmkaOnX8FYscMRoyyMrWClRZEQRokqZIj79+PR adkDXtr4MeL8BaB7Ij2oyRVjXUwhFQNKi5Z5Rve0a3zvGkkqw8Mz20BOksjSWjAF6g9byukl CUVjC03PdMSufNLK06x5hPc/c4tFR4J9cLrV+XxdCX7r0zGos9SzTPGNuIk1LK++S3EJhLFj 4eoWtNhMWc1uiTf9ENza0ntqH9XBWEQ6IA1gubCniGG+Xg== Message-ID: <1980a46c-3aaf-2b39-1154-fa2abcfdab50@linaro.org> Date: Fri, 31 May 2019 22:13:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190530092038.12020-3-quentin.perret@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/05/2019 11:20, Quentin Perret wrote: > The core CPU cooling infrastructure has power-related functions > that have only one client: IPA. Since there can be no user of those > functions if IPA is not compiled in, make sure to guard them with > checks on CONFIG_THERMAL_GOV_POWER_ALLOCATOR to not waste space > unnecessarily. > > Suggested-by: Daniel Lezcano > Signed-off-by: Quentin Perret Acked-by: Daniel Lezcano Thanks! -- Daniel > --- > drivers/thermal/cpu_cooling.c | 214 +++++++++++++++++----------------- > 1 file changed, 104 insertions(+), 110 deletions(-) > > diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c > index 4c5db59a619b..498f59ab64b2 100644 > --- a/drivers/thermal/cpu_cooling.c > +++ b/drivers/thermal/cpu_cooling.c > @@ -46,7 +46,9 @@ > */ > struct freq_table { > u32 frequency; > +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR > u32 power; > +#endif > }; > > /** > @@ -96,28 +98,6 @@ static DEFINE_IDA(cpufreq_ida); > static DEFINE_MUTEX(cooling_list_lock); > static LIST_HEAD(cpufreq_cdev_list); > > -/* Below code defines functions to be used for cpufreq as cooling device */ > - > -/** > - * get_level: Find the level for a particular frequency > - * @cpufreq_cdev: cpufreq_cdev for which the property is required > - * @freq: Frequency > - * > - * Return: level corresponding to the frequency. > - */ > -static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev, > - unsigned int freq) > -{ > - struct freq_table *freq_table = cpufreq_cdev->freq_table; > - unsigned long level; > - > - for (level = 1; level <= cpufreq_cdev->max_level; level++) > - if (freq > freq_table[level].frequency) > - break; > - > - return level - 1; > -} > - > /** > * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. > * @nb: struct notifier_block * with callback info. > @@ -171,6 +151,27 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb, > return NOTIFY_OK; > } > > +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR > +/** > + * get_level: Find the level for a particular frequency > + * @cpufreq_cdev: cpufreq_cdev for which the property is required > + * @freq: Frequency > + * > + * Return: level corresponding to the frequency. > + */ > +static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev, > + unsigned int freq) > +{ > + struct freq_table *freq_table = cpufreq_cdev->freq_table; > + unsigned long level; > + > + for (level = 1; level <= cpufreq_cdev->max_level; level++) > + if (freq > freq_table[level].frequency) > + break; > + > + return level - 1; > +} > + > /** > * update_freq_table() - Update the freq table with power numbers > * @cpufreq_cdev: the cpufreq cooling device in which to update the table > @@ -319,80 +320,6 @@ static u32 get_dynamic_power(struct cpufreq_cooling_device *cpufreq_cdev, > return (raw_cpu_power * cpufreq_cdev->last_load) / 100; > } > > -/* cpufreq cooling device callback functions are defined below */ > - > -/** > - * cpufreq_get_max_state - callback function to get the max cooling state. > - * @cdev: thermal cooling device pointer. > - * @state: fill this variable with the max cooling state. > - * > - * Callback for the thermal cooling device to return the cpufreq > - * max cooling state. > - * > - * Return: 0 on success, an error code otherwise. > - */ > -static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, > - unsigned long *state) > -{ > - struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > - > - *state = cpufreq_cdev->max_level; > - return 0; > -} > - > -/** > - * cpufreq_get_cur_state - callback function to get the current cooling state. > - * @cdev: thermal cooling device pointer. > - * @state: fill this variable with the current cooling state. > - * > - * Callback for the thermal cooling device to return the cpufreq > - * current cooling state. > - * > - * Return: 0 on success, an error code otherwise. > - */ > -static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, > - unsigned long *state) > -{ > - struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > - > - *state = cpufreq_cdev->cpufreq_state; > - > - return 0; > -} > - > -/** > - * cpufreq_set_cur_state - callback function to set the current cooling state. > - * @cdev: thermal cooling device pointer. > - * @state: set this variable to the current cooling state. > - * > - * Callback for the thermal cooling device to change the cpufreq > - * current cooling state. > - * > - * Return: 0 on success, an error code otherwise. > - */ > -static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > - unsigned long state) > -{ > - struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > - unsigned int clip_freq; > - > - /* Request state should be less than max_level */ > - if (WARN_ON(state > cpufreq_cdev->max_level)) > - return -EINVAL; > - > - /* Check if the old cooling action is same as new cooling action */ > - if (cpufreq_cdev->cpufreq_state == state) > - return 0; > - > - clip_freq = cpufreq_cdev->freq_table[state].frequency; > - cpufreq_cdev->cpufreq_state = state; > - cpufreq_cdev->clipped_freq = clip_freq; > - > - cpufreq_update_policy(cpufreq_cdev->policy->cpu); > - > - return 0; > -} > - > /** > * cpufreq_get_requested_power() - get the current power > * @cdev: &thermal_cooling_device pointer > @@ -536,22 +463,88 @@ static int cpufreq_power2state(struct thermal_cooling_device *cdev, > power); > return 0; > } > +#endif /* CONFIG_THERMAL_GOV_POWER_ALLOCATOR */ > + > +/* cpufreq cooling device callback functions are defined below */ > + > +/** > + * cpufreq_get_max_state - callback function to get the max cooling state. > + * @cdev: thermal cooling device pointer. > + * @state: fill this variable with the max cooling state. > + * > + * Callback for the thermal cooling device to return the cpufreq > + * max cooling state. > + * > + * Return: 0 on success, an error code otherwise. > + */ > +static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, > + unsigned long *state) > +{ > + struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > + > + *state = cpufreq_cdev->max_level; > + return 0; > +} > + > +/** > + * cpufreq_get_cur_state - callback function to get the current cooling state. > + * @cdev: thermal cooling device pointer. > + * @state: fill this variable with the current cooling state. > + * > + * Callback for the thermal cooling device to return the cpufreq > + * current cooling state. > + * > + * Return: 0 on success, an error code otherwise. > + */ > +static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, > + unsigned long *state) > +{ > + struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > + > + *state = cpufreq_cdev->cpufreq_state; > + > + return 0; > +} > + > +/** > + * cpufreq_set_cur_state - callback function to set the current cooling state. > + * @cdev: thermal cooling device pointer. > + * @state: set this variable to the current cooling state. > + * > + * Callback for the thermal cooling device to change the cpufreq > + * current cooling state. > + * > + * Return: 0 on success, an error code otherwise. > + */ > +static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, > + unsigned long state) > +{ > + struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; > + unsigned int clip_freq; > + > + /* Request state should be less than max_level */ > + if (WARN_ON(state > cpufreq_cdev->max_level)) > + return -EINVAL; > + > + /* Check if the old cooling action is same as new cooling action */ > + if (cpufreq_cdev->cpufreq_state == state) > + return 0; > + > + clip_freq = cpufreq_cdev->freq_table[state].frequency; > + cpufreq_cdev->cpufreq_state = state; > + cpufreq_cdev->clipped_freq = clip_freq; > + > + cpufreq_update_policy(cpufreq_cdev->policy->cpu); > + > + return 0; > +} > > /* Bind cpufreq callbacks to thermal cooling device ops */ > > static struct thermal_cooling_device_ops cpufreq_cooling_ops = { > - .get_max_state = cpufreq_get_max_state, > - .get_cur_state = cpufreq_get_cur_state, > - .set_cur_state = cpufreq_set_cur_state, > -}; > - > -static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { > .get_max_state = cpufreq_get_max_state, > .get_cur_state = cpufreq_get_cur_state, > .set_cur_state = cpufreq_set_cur_state, > - .get_requested_power = cpufreq_get_requested_power, > - .state2power = cpufreq_state2power, > - .power2state = cpufreq_power2state, > }; > > /* Notifier for cpufreq policy change */ > @@ -659,18 +652,19 @@ __cpufreq_cooling_register(struct device_node *np, > pr_debug("%s: freq:%u KHz\n", __func__, freq); > } > > + cooling_ops = &cpufreq_cooling_ops; > +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR > if (capacitance) { > ret = update_freq_table(cpufreq_cdev, capacitance); > if (ret) { > cdev = ERR_PTR(ret); > goto remove_ida; > } > - > - cooling_ops = &cpufreq_power_cooling_ops; > - } else { > - cooling_ops = &cpufreq_cooling_ops; > + cooling_ops->get_requested_power = cpufreq_get_requested_power; > + cooling_ops->state2power = cpufreq_state2power; > + cooling_ops->power2state = cpufreq_power2state; > } > - > +#endif > cdev = thermal_of_cooling_device_register(np, dev_name, cpufreq_cdev, > cooling_ops); > if (IS_ERR(cdev)) > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog