Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4647146rdb; Tue, 12 Dec 2023 05:48:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IECTcCRXzNqTCqFelJw2fYelJKd56O6/s+fz38NrPcb2rXUVTo6UmEieGYJWFMnuq5Gu+xN X-Received: by 2002:a17:90a:ad8d:b0:28a:c362:ffca with SMTP id s13-20020a17090aad8d00b0028ac362ffcamr271912pjq.47.1702388925821; Tue, 12 Dec 2023 05:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702388925; cv=none; d=google.com; s=arc-20160816; b=LOI2hCG5k09cbBH2CNNRxa9FMWXFL67frQjkp0MNd20zVOgiIuOewk6n0/pK8i69p6 b6U5f8EXf/qQc7m/8Fx5Hrbi8EWS/lgX9pfNtyGwn46/XbKW6ywM3ar9VjhJAj39zyQp J8fPwuT1LYDcqblXL9LDRd1N2UWpu3CfLJ8/eikRCPpUGMF6vgx9vOB+bs0hXWoW9nr1 aTou/lSE9fMQOl3H9p8bs4dwkCm6IMPJS3HmaWenRX++RJC/4rxUJiFMTKpZK2rJV8X/ dw3NUA7MPulPke2fK3TpL90NOUEPALKGQMtMwJe4/GlMvz7pqk1lDSMLdWGq9AA7AZsS XG8w== 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=eLXGaA1LS85WOwMbqawEgZPy/h7/JqcNxFNCR9URrsA=; fh=8IgpUQ2T6XGOjA/qDosxdUSIIBz0a6nQ23NA8pgv1Tg=; b=IJFOyTCmV8BLKXydAq23WxZSxXw2R4MK8foAdBtD+xwFKjpuFN6IfZPk8cHuyqqOHw Ouz7zidg89EtYgetD2WnUGVdmjhDxSpcjPOnYRy6KW3jDliNcWO8XJC5hLfqLep3dVSq 4KQ7FYBrP3J3TMxvqjGeJ5tG0R9OLu4DGPUCaFyMyyEaHMlDYB7kRrgbzqAjT0+oXKVo pd5DN3yJUQnuDZJh5nKbaHIL7j3Wxt69pawWZ9C1aOYGsTT0ELRRTzlKbJN+yCBn+kBR 9ZMzPxPsfaqamSCT3OAg/jxkayrd9aydUcZKUF8L4elidK1I5RdsFU8tCjH6MaAaMyFh JEuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e22-20020a17090ac21600b00288649f0550si9166544pjt.40.2023.12.12.05.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 05:48:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 3E3B3803BEF0; Tue, 12 Dec 2023 05:48:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376466AbjLLNs1 (ORCPT + 99 others); Tue, 12 Dec 2023 08:48:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376365AbjLLNsN (ORCPT ); Tue, 12 Dec 2023 08:48:13 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2DCC5194; Tue, 12 Dec 2023 05:48:08 -0800 (PST) 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 C6DAB1474; Tue, 12 Dec 2023 05:48:54 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.82.227]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 43EB03F738; Tue, 12 Dec 2023 05:48:07 -0800 (PST) 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 v2 8/8] thermal: gov_power_allocator: Support new update callback of weights Date: Tue, 12 Dec 2023 13:48:44 +0000 Message-Id: <20231212134844.1213381-9-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231212134844.1213381-1-lukasz.luba@arm.com> References: <20231212134844.1213381-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 05:48:43 -0800 (PST) When the thermal instance's weight is updated from the sysfs the governor update_tz() callback is triggered. Implement proper reaction to this event in the IPA, which would save CPU cycles spent in throttle(). This will speed-up the main throttle() IPA function and clean it up a bit. Signed-off-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 574aa5822112..a9f1549e6355 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -61,6 +61,7 @@ static inline s64 div_frac(s64 x, s64 y) * @trip_switch_on should be NULL. * @trip_max: last passive trip point of the thermal zone. The * temperature we are controlling for. + * @total_weight: Sum of all thermal instances weights * @num_actors: number of cooling devices supporting IPA callbacks * @buffer_size: IPA internal buffer size * @req_power: IPA buffer for requested power @@ -76,6 +77,7 @@ struct power_allocator_params { u32 sustainable_power; const struct thermal_trip *trip_switch_on; const struct thermal_trip *trip_max; + int total_weight; int num_actors; int buffer_size; u32 *req_power; @@ -403,16 +405,11 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) u32 total_req_power = 0; u32 *weighted_req_power; u32 power_range, weight; - int total_weight = 0; int i = 0; if (!params->num_actors) return -ENODEV; - list_for_each_entry(instance, &tz->thermal_instances, tz_node) - if (power_actor_is_valid(params, instance)) - total_weight += instance->weight; - /* Clean all buffers for new power estimations */ memset(params->req_power, 0, params->buffer_size); @@ -430,7 +427,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp) if (cdev->ops->get_requested_power(cdev, &req_power[i])) continue; - if (!total_weight) + if (!params->total_weight) weight = 1 << FRAC_BITS; else weight = instance->weight; @@ -666,6 +663,12 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz, allocate_actors_buffer(params, num_actors); break; + case THERMAL_INSTANCE_WEIGHT_UPDATE: + params->total_weight = 0; + list_for_each_entry(instance, &tz->thermal_instances, tz_node) + if (power_actor_is_valid(params, instance)) + params->total_weight += instance->weight; + break; default: break; } -- 2.25.1