mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	rui.zhang@intel.com, Amit Kucheria <amitk@kernel.org>,
	rafael@kernel.org
Subject: Re: [PATCH v4 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions
Date: Fri, 23 Sep 2022 15:49:35 +0100	[thread overview]
Message-ID: <564e6fc6-4734-a60e-d578-a15247a32c5f@arm.com> (raw)
In-Reply-To: <20220921094244.606948-6-daniel.lezcano@linaro.org>

Hi Daniel,


On 9/21/22 10:42, Daniel Lezcano wrote:
> The governors are using the ops->get_trip_* functions, Replace these
> calls with thermal_zone_get_trip().
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>   drivers/thermal/gov_bang_bang.c       | 23 +++++-------
>   drivers/thermal/gov_fair_share.c      | 18 ++++------
>   drivers/thermal/gov_power_allocator.c | 51 ++++++++++++---------------
>   drivers/thermal/gov_step_wise.c       | 22 ++++++------
>   4 files changed, 47 insertions(+), 67 deletions(-)
> 

[snip]

> diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
> index 2d1aeaba38a8..2ef86ced4c7c 100644
> --- a/drivers/thermal/gov_power_allocator.c
> +++ b/drivers/thermal/gov_power_allocator.c
> @@ -125,16 +125,15 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
>   				   u32 sustainable_power, int trip_switch_on,
>   				   int control_temp)
>   {
> +	struct thermal_trip trip;
> +	u32 temperature_threshold = control_temp;
>   	int ret;
> -	int switch_on_temp;
> -	u32 temperature_threshold;
>   	s32 k_i;
>   
> -	ret = tz->ops->get_trip_temp(tz, trip_switch_on, &switch_on_temp);
> -	if (ret)
> -		switch_on_temp = 0;
> +	ret = thermal_zone_get_trip(tz, trip_switch_on, &trip);
> +	if (!ret)
> +		temperature_threshold -= trip.temperature;
>   
> -	temperature_threshold = control_temp - switch_on_temp;
>   	/*
>   	 * estimate_pid_constants() tries to find appropriate default
>   	 * values for thermal zones that don't provide them. If a
> @@ -520,10 +519,10 @@ static void get_governor_trips(struct thermal_zone_device *tz,
>   	last_passive = INVALID_TRIP;
>   
>   	for (i = 0; i < tz->num_trips; i++) {
> -		enum thermal_trip_type type;
> +		struct thermal_trip trip;
>   		int ret;
>   
> -		ret = tz->ops->get_trip_type(tz, i, &type);
> +		ret = thermal_zone_get_trip(tz, i, &trip);
>   		if (ret) {
>   			dev_warn(&tz->device,
>   				 "Failed to get trip point %d type: %d\n", i,
> @@ -531,14 +530,14 @@ static void get_governor_trips(struct thermal_zone_device *tz,
>   			continue;
>   		}
>   
> -		if (type == THERMAL_TRIP_PASSIVE) {
> +		if (trip.type == THERMAL_TRIP_PASSIVE) {
>   			if (!found_first_passive) {
>   				params->trip_switch_on = i;
>   				found_first_passive = true;
>   			} else  {
>   				last_passive = i;
>   			}
> -		} else if (type == THERMAL_TRIP_ACTIVE) {
> +		} else if (trip.type == THERMAL_TRIP_ACTIVE) {
>   			last_active = i;
>   		} else {
>   			break;
> @@ -633,7 +632,7 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
>   {
>   	int ret;
>   	struct power_allocator_params *params;
> -	int control_temp;
> +	struct thermal_trip trip;
>   
>   	ret = check_power_actors(tz);
>   	if (ret)
> @@ -659,13 +658,12 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
>   	get_governor_trips(tz, params);
>   
>   	if (tz->num_trips > 0) {
> -		ret = tz->ops->get_trip_temp(tz,
> -					params->trip_max_desired_temperature,
> -					&control_temp);
> +		ret = thermal_zone_get_trip(tz, params->trip_max_desired_temperature,
> +					    &trip);
>   		if (!ret)
>   			estimate_pid_constants(tz, tz->tzp->sustainable_power,
>   					       params->trip_switch_on,
> -					       control_temp);
> +					       trip.temperature);
>   	}
>   
>   	reset_pid_controller(params);
> @@ -695,11 +693,11 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
>   	tz->governor_data = NULL;
>   }
>   
> -static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
> +static int power_allocator_throttle(struct thermal_zone_device *tz, int trip_id)
>   {
> -	int ret;
> -	int switch_on_temp, control_temp;
>   	struct power_allocator_params *params = tz->governor_data;
> +	struct thermal_trip trip;
> +	int ret;
>   	bool update;
>   
>   	lockdep_assert_held(&tz->lock);
> @@ -708,13 +706,12 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
>   	 * We get called for every trip point but we only need to do
>   	 * our calculations once
>   	 */
> -	if (trip != params->trip_max_desired_temperature)
> +	if (trip_id != params->trip_max_desired_temperature)
>   		return 0;
>   
> -	ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
> -				     &switch_on_temp);
> -	if (!ret && (tz->temperature < switch_on_temp)) {
> -		update = (tz->last_temperature >= switch_on_temp);
> +	ret = thermal_zone_get_trip(tz, params->trip_switch_on, &trip);
> +	if (!ret && (tz->temperature < trip.temperature)) {
> +		update = (tz->last_temperature >= trip.temperature);
>   		tz->passive = 0;
>   		reset_pid_controller(params);
>   		allow_maximum_power(tz, update);
> @@ -723,16 +720,14 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
>   
>   	tz->passive = 1;
>   
> -	ret = tz->ops->get_trip_temp(tz, params->trip_max_desired_temperature,
> -				&control_temp);
> +	ret = thermal_zone_get_trip(tz, params->trip_max_desired_temperature, &trip);
>   	if (ret) {
> -		dev_warn(&tz->device,
> -			 "Failed to get the maximum desired temperature: %d\n",
> +		dev_warn(&tz->device, "Failed to get the maximum desired temperature: %d\n",
>   			 ret);
>   		return ret;
>   	}
>   
> -	return allocate_power(tz, control_temp);
> +	return allocate_power(tz, trip.temperature);
>   }
>   
>   static struct thermal_governor thermal_gov_power_allocator = {

this part of IPA LGTM

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>

  parent reply	other threads:[~2022-09-23 14:49 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21  9:42 [PATCH v4 00/30] Rework the trip points creation Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 01/30] thermal/core: Add a generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-23 13:54   ` Zhang Rui
     [not found]   ` <CGME20220923221936eucas1p1e01148605c9aaf27d8d71969feb99144@eucas1p1.samsung.com>
2022-09-23 22:19     ` Marek Szyprowski
2022-09-24 17:46       ` Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 02/30] thermal/sysfs: Do not make get_trip_hyst optional Daniel Lezcano
2022-09-23 14:19   ` Zhang Rui
2022-09-26 12:55     ` Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 03/30] thermal/core: Add a generic thermal_zone_set_trip() function Daniel Lezcano
2022-09-23 14:21   ` Zhang Rui
2022-09-21  9:42 ` [PATCH v4 04/30] thermal/core: Add a generic thermal_zone_get_crit_temp() function Daniel Lezcano
2022-09-23 14:22   ` Zhang Rui
2022-09-21  9:42 ` [PATCH v4 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions Daniel Lezcano
2022-09-23 14:25   ` Zhang Rui
2022-09-23 14:49   ` Lukasz Luba [this message]
2022-09-21  9:42 ` [PATCH v4 06/30] thermal/of: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 07/30] thermal/of: Remove unused functions Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 08/30] thermal/drivers/exynos: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 09/30] thermal/drivers/exynos: of_thermal_get_ntrips() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 10/30] thermal/drivers/exynos: Replace of_thermal_is_trip_valid() by thermal_zone_get_trip() Daniel Lezcano
2022-09-21 15:24   ` Krzysztof Kozlowski
     [not found]   ` <CGME20220923140903eucas1p180002df0deb308d5148cc6004aef7efe@eucas1p1.samsung.com>
2022-09-23 14:09     ` Marek Szyprowski
2022-09-23 17:40       ` Daniel Lezcano
2022-09-23 22:02         ` Marek Szyprowski
2022-09-21  9:42 ` [PATCH v4 11/30] thermal/drivers/tegra: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 12/30] thermal/drivers/uniphier: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 13/30] thermal/drivers/hisi: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 14/30] thermal/drivers/qcom: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 15/30] thermal/drivers/armada: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 16/30] thermal/drivers/rcar_gen3: Use the generic function to get the number of trips Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 17/30] thermal/of: Remove of_thermal_get_ntrips() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 18/30] thermal/of: Remove of_thermal_is_trip_valid() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 19/30] thermal/of: Remove of_thermal_set_trip_hyst() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 20/30] thermal/of: Remove of_thermal_get_crit_temp() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 21/30] thermal/drivers/st: Use generic trip points Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 22/30] thermal/drivers/imx: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 23/30] thermal/drivers/rcar: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 24/30] thermal/drivers/broadcom: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 25/30] thermal/drivers/da9062: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 26/30] thermal/drivers/ti: Remove unused macros ti_thermal_get_trip_value() / ti_thermal_trip_is_valid() Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 27/30] thermal/drivers/acerhdf: Use generic thermal_zone_get_trip() function Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 28/30] thermal/drivers/cxgb4: " Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 29/30] thermal/intel/int340x: Replace parameter to simplify Daniel Lezcano
2022-09-21  9:42 ` [PATCH v4 30/30] thermal/drivers/intel: Use generic thermal_zone_get_trip() function Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564e6fc6-4734-a60e-d578-a15247a32c5f@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=amitk@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®