Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2791596rda; Wed, 25 Oct 2023 12:22:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnBQVgC+BANhptNTeIF5HNzpoSE7fgVEmLP3BVytBGsmi5FoFyXEhgH3pnKgSI0MPG14BU X-Received: by 2002:a25:9c08:0:b0:da0:5e86:32f8 with SMTP id c8-20020a259c08000000b00da05e8632f8mr4421324ybo.4.1698261736864; Wed, 25 Oct 2023 12:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698261736; cv=none; d=google.com; s=arc-20160816; b=IBzsb7js3QyGglGDG51nMXt8bD/CBjn4u5aFsHYHoCGcdD2Kwier+fr8COGLrq5pCG OJMRsUDC8ErJFUlEnTyCiZ3/TgHt7hG7gboXD4cZYuCF7wTCGHTEQguMs5tOk3YAlnmT 4//ozhsI4XY+ZWnP+aA8F0x0jUsHMEEL9ijtxr0HbMy7rfL+71ym8drfQGTVE8i+5oAa vKcFwTCkN7yj0A/N7Gzq4swfxLpbe9+RyVs8jlP0jpLjTa16R5FTEWubzF2FJFKqyS9v dGxzbTI0Z4GeyfZ0QHl6YuBLLp1Bk9n63Ev5DBTZYWWSR+op+1aG3NALgH9JUAKB9jIe 9IoA== 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=rDTp5hKoTU1MjxSeIsR/w1ObjtK5jkk+XvSeHXuzH40=; fh=8IgpUQ2T6XGOjA/qDosxdUSIIBz0a6nQ23NA8pgv1Tg=; b=G/QYJiVXI0SCLgSMtK2uFU75jigyFyfTdlppVSE8cJO0lRMOSkFerOT8lhlJinLR6r X5GLXV1N9SjWdPJFeN1LMyxF5g6zqvz5rbL4dTk+t610mQpx/D35+I6J6bR4jxWOyX6U 94EHP59/0KbWCSNB2ruF+/gIzrX57f+nNyHlSGgAocOGkif51GIHISJTHlx9hnxnWawi 4jBcgi0FUrABiskoVSBOSf//Lf7h9s97ri/x+DAdAm06JNZQsLW+iVhTMptcDE3g9uS5 pCsd/vkR0w6uTFfIP+m/7UxVfT3i57INgMLMTgb4Zn53iYuTxrkGkRmYk/A/h7lILS3X R1NQ== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id i130-20020a256d88000000b00d9a66a308c8si11026330ybc.482.2023.10.25.12.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 12:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 07CF6816EF7F; Wed, 25 Oct 2023 12:22:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230051AbjJYTVs (ORCPT + 99 others); Wed, 25 Oct 2023 15:21:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjJYTVq (ORCPT ); Wed, 25 Oct 2023 15:21:46 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00231137; Wed, 25 Oct 2023 12:21:43 -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 70B181474; Wed, 25 Oct 2023 12:22:25 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.81.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9A9EB3F738; Wed, 25 Oct 2023 12:21:42 -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 2/7] thermal: gov_power_allocator: Setup trip points earlier Date: Wed, 25 Oct 2023 20:22:20 +0100 Message-Id: <20231025192225.468228-3-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 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 25 Oct 2023 12:22:08 -0700 (PDT) Setup the trip points at the beginning of the binding function. This simplifies the code a bit and allows further cleaning. Add also the check if the last passive trip point is found and fail binding if not. Signed-off-by: Lukasz Luba --- drivers/thermal/gov_power_allocator.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 97a8a6e4e1b0b..0dfc5b5ab5235 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -617,14 +617,24 @@ static int power_allocator_bind(struct thermal_zone_device *tz) int ret; struct power_allocator_params *params; - ret = check_power_actors(tz); - if (ret) - return ret; - params = kzalloc(sizeof(*params), GFP_KERNEL); if (!params) return -ENOMEM; + get_governor_trips(tz, params); + if (!params->trip_max) { + dev_warn(&tz->device, "power_allocator: missing trip_max\n"); + kfree(params); + return -EINVAL; + } + + ret = check_power_actors(tz); + if (ret) { + dev_warn(&tz->device, "power_allocator: binding failed\n"); + kfree(params); + return ret; + } + if (!tz->tzp) { tz->tzp = kzalloc(sizeof(*tz->tzp), GFP_KERNEL); if (!tz->tzp) { @@ -638,12 +648,9 @@ static int power_allocator_bind(struct thermal_zone_device *tz) if (!tz->tzp->sustainable_power) dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n"); - get_governor_trips(tz, params); - - if (params->trip_max) - estimate_pid_constants(tz, tz->tzp->sustainable_power, - params->trip_switch_on, - params->trip_max->temperature); + estimate_pid_constants(tz, tz->tzp->sustainable_power, + params->trip_switch_on, + params->trip_max->temperature); reset_pid_controller(params); -- 2.25.1