From patchwork Wed Oct 25 19:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 158253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp183921vqb; Wed, 25 Oct 2023 12:22:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd9AXa8lP3kSdouoCj2czIjwCBkcp/uh2q98WvJjFLNQnaV2hwNWeD7z9RfUsarH6j8uv0 X-Received: by 2002:a0d:c887:0:b0:5a8:5824:b952 with SMTP id k129-20020a0dc887000000b005a85824b952mr16553092ywd.44.1698261761940; Wed, 25 Oct 2023 12:22:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698261761; cv=none; d=google.com; s=arc-20160816; b=Wk4Qh3HCaOXMIzVXoPHBDduf3yyNFqeSvA84KszOGO4FlqukBCFB3GD0fXzhNNI1jM TTtKLkEilDHDd/vjE/NCc0UvyAuKcP64QxdwOhnOutqmByNe4lEKDRoZ69reSkkGTfsn V8BzBAFp7yjDy87PTJ3pP2+Rq/5DYXZtC6QuWbqV7mYYKXCrMr1c2r0nBuSVqNqn8wdn 7mykI4j9lR7Z21MSk+SiCJr4cAmvMP4bw0UT7754V9n65Z4nBTOVZXyf9EWN4h74YRyt JJbK3yrJ19MXMUATWdTmZJ3GglOvJeQ5LJhUcAW4X1AP8gNswXkZhfJj2H532P85FNW6 RRBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vaW+Tt1xhgg0UrDq0qn2H4IDwhBxU36pSSy4Zt8CsgI=; fh=8IgpUQ2T6XGOjA/qDosxdUSIIBz0a6nQ23NA8pgv1Tg=; b=YSfOyije78WmQ71x3FryZg1TcYupswFqJiL1z/NJViwbAV/xY8cWQ9D5taea6Y/7dT gMqF4DNwAP3EeqYFCjfn8X3HdZIRQg2z36Ek7B2/h1rF+LlM0CTovHzTfzuwFKF5K8fM RYaVm69jcAz/49T9evVHy0rUzB7ol86RUlUiR98G8ECj6l3HQ9Pzg4GE6ou+r32vGh7T gkXEyC3X1c5mcoj/Dis1UcnjdXo2ESjq6UuKYZBxXgBhMIdGmzH0wAGo6BGNYh8SIKms rTwObWJyky6gsx3lYE33PHc8iu9+QQ0O2XHW6uSHz7uGvwH3nXzxtGyvndddp6Dwkc2T xXCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id g188-20020a0dc4c5000000b00577608f6164si11401607ywd.516.2023.10.25.12.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 12:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 06962801C08A; Wed, 25 Oct 2023 12:22:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbjJYTVr (ORCPT + 25 others); Wed, 25 Oct 2023 15:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbjJYTVo (ORCPT ); Wed, 25 Oct 2023 15:21:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E4BC137; Wed, 25 Oct 2023 12:21:42 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 05D521424; Wed, 25 Oct 2023 12:22:24 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.81.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2FF523F738; Wed, 25 Oct 2023 12:21:41 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-pm@vger.kernel.org, rui.zhang@intel.com, lukasz.luba@arm.com Subject: [PATCH 1/7] thermal: gov_power_allocator: Rename trip_max_desired_temperature Date: Wed, 25 Oct 2023 20:22:19 +0100 Message-Id: <20231025192225.468228-2-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231025192225.468228-1-lukasz.luba@arm.com> References: <20231025192225.468228-1-lukasz.luba@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 25 Oct 2023 12:22:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780756525237396089 X-GMAIL-MSGID: 1780756525237396089 Refactor the code and drop the long name for the trip point. There is a comment describing the field properly. Use shorten variable name so that allow to make the code cleaner a bit. This change is not expected to alter the general functionality. Signed-off-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 40 ++++++++++++--------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 83d4f451b1a97..97a8a6e4e1b0b 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -59,9 +59,8 @@ static inline s64 div_frac(s64 x, s64 y) * governor switches on when this trip point is crossed. * If the thermal zone only has one passive trip point, * @trip_switch_on should be NULL. - * @trip_max_desired_temperature: last passive trip point of the thermal - * zone. The temperature we are - * controlling for. + * @trip_max: last passive trip point of the thermal zone. The + * temperature we are controlling for. */ struct power_allocator_params { bool allocated_tzp; @@ -69,7 +68,7 @@ struct power_allocator_params { s32 prev_err; u32 sustainable_power; const struct thermal_trip *trip_switch_on; - const struct thermal_trip *trip_max_desired_temperature; + const struct thermal_trip *trip_max; }; /** @@ -93,7 +92,7 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz) struct thermal_cooling_device *cdev = instance->cdev; u32 min_power; - if (instance->trip != params->trip_max_desired_temperature) + if (instance->trip != params->trip_max) continue; if (!cdev_is_power_actor(cdev)) @@ -379,8 +378,7 @@ static int allocate_power(struct thermal_zone_device *tz, { struct thermal_instance *instance; struct power_allocator_params *params = tz->governor_data; - const struct thermal_trip *trip_max_desired_temperature = - params->trip_max_desired_temperature; + const struct thermal_trip *trip_max = params->trip_max; u32 *req_power, *max_power, *granted_power, *extra_actor_power; u32 *weighted_req_power; u32 total_req_power, max_allocatable_power, total_weighted_req_power; @@ -390,7 +388,7 @@ static int allocate_power(struct thermal_zone_device *tz, num_actors = 0; total_weight = 0; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if ((instance->trip == trip_max_desired_temperature) && + if ((instance->trip == trip_max) && cdev_is_power_actor(instance->cdev)) { num_actors++; total_weight += instance->weight; @@ -429,7 +427,7 @@ static int allocate_power(struct thermal_zone_device *tz, int weight; struct thermal_cooling_device *cdev = instance->cdev; - if (instance->trip != trip_max_desired_temperature) + if (instance->trip != trip_max) continue; if (!cdev_is_power_actor(cdev)) @@ -465,7 +463,7 @@ static int allocate_power(struct thermal_zone_device *tz, total_granted_power = 0; i = 0; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip != trip_max_desired_temperature) + if (instance->trip != trip_max) continue; if (!cdev_is_power_actor(instance->cdev)) @@ -531,13 +529,13 @@ static void get_governor_trips(struct thermal_zone_device *tz, if (last_passive) { params->trip_switch_on = first_passive; - params->trip_max_desired_temperature = last_passive; + params->trip_max = last_passive; } else if (first_passive) { params->trip_switch_on = NULL; - params->trip_max_desired_temperature = first_passive; + params->trip_max = first_passive; } else { params->trip_switch_on = NULL; - params->trip_max_desired_temperature = last_active; + params->trip_max = last_active; } } @@ -556,8 +554,8 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update) list_for_each_entry(instance, &tz->thermal_instances, tz_node) { struct thermal_cooling_device *cdev = instance->cdev; - if (instance->trip != params->trip_max_desired_temperature || - (!cdev_is_power_actor(instance->cdev))) + if (instance->trip != params->trip_max || + !cdev_is_power_actor(instance->cdev)) continue; instance->target = 0; @@ -642,12 +640,10 @@ static int power_allocator_bind(struct thermal_zone_device *tz) get_governor_trips(tz, params); - if (params->trip_max_desired_temperature) { - int temp = params->trip_max_desired_temperature->temperature; - + if (params->trip_max) estimate_pid_constants(tz, tz->tzp->sustainable_power, - params->trip_switch_on, temp); - } + params->trip_switch_on, + params->trip_max->temperature); reset_pid_controller(params); @@ -688,7 +684,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, * 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 != params->trip_max) return 0; trip = params->trip_switch_on; @@ -702,7 +698,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, tz->passive = 1; - return allocate_power(tz, params->trip_max_desired_temperature->temperature); + return allocate_power(tz, params->trip_max->temperature); } static struct thermal_governor thermal_gov_power_allocator = {