Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp301025lqj; Wed, 10 Apr 2024 10:46:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV94ssEkFVK8cKvvkC/xPieAjuvq2w3SA/qwwgERMRFQLUN4xHu0bO+DuLKcJ06T6I4sOKrVWft+gFRGEnHGCGhMS2zDLwwJUeJYY3A/w== X-Google-Smtp-Source: AGHT+IEf0twAyMb0L5t2Yw494BQ1jEPEuWZpFZjk79vEZ+8KoA7UMFcxJFgRXuQizrvWPi6g+8lj X-Received: by 2002:a05:6808:3a99:b0:3c6:11c9:d6e9 with SMTP id fb25-20020a0568083a9900b003c611c9d6e9mr979973oib.7.1712771200694; Wed, 10 Apr 2024 10:46:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712771200; cv=pass; d=google.com; s=arc-20160816; b=Qr+nEeQIZZVDwjGU384i6umtFGUZsspfTi0GbfUs96czQ/+Di0FSD7c1wlaql03Cmz 3T3s6OkUiDMEX1eAiFcjre0CXPZn3hkpzHX6oUhpbS9T+KwzdpSCbkkvL3nLJeQsGTA+ ZXQWflpobzYb4qizV2UOyh7Z6zwttS7sIesBxiVrUMzF+QKPvOoKaupU3GP6TgQ4Zay6 +gTwULtHG7G2QQiRj0oG94Mirz0SMogIjweEBF6BYDQE5INld6u8MJuDb7G6EMzG6Qlk txW17vCp3MVJvaL0Z1cxaW85qTbSq9yIgAZ6gYyNUoRuR9Co6WpHSxFyZH7hxFmhHvRW rNWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5WbmMzInG0lrVoORtQBjPBf+AmPZEn7AEHJoAfB1rmg=; fh=0I/rqIlL4373pOps8oaBYF1ECx5xbCzL9wLU5PgpMhU=; b=vAh63ighMtFU/dPg4tJJMDN5bg3S7FvlRj4XBt7Oh8O+10jtOioYqyA/h994SIWuVQ 7ix+08HQzDS5hQMLqstH+269YaSvSh0iE3jFMgsWoEFzyijQ0JHWzpvTBk4naKzJvgKl vq9/nE0DjBQM6G32vg1dzpJjmd9G41GOhf+QVWxeZcXrnC5JbpzHDNMAjpJPAEdfH3hQ MQi7DQPH9iv/dagYzvAD44uuaoCKKZhU3TSBY4o5zDKJVoqsaWDeTmJpgRQNNTAliMwo VHI49S5LE8nvvp8qRD4PuGf/vKThFsqmL4/C3Bs6cOndW8qS1sV52ddQK2j1fa6fN7HO bvZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=M3OuAZmo; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139124-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j11-20020ac85f8b000000b00432d0eb5abcsi13334018qta.80.2024.04.10.10.46.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=M3OuAZmo; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139124-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139124-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 506B11C23203 for ; Wed, 10 Apr 2024 17:46:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53603181CFA; Wed, 10 Apr 2024 17:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="M3OuAZmo" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32EDC17F36B; Wed, 10 Apr 2024 17:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771099; cv=none; b=iOeydLCTZefl58A4PGBDmXy45fl4kUm361XR7WMNtS24vys6Xg1rAM5ekr948WBGKPfHNCCiG9jG9n0GA7rboSF+6CNnfR+kaPX19eahHhp65IRnknIJnxbRUfSK55YR6GjhnFtsgpfcUarDYALieo2AP+bYvPX1mCVbhaxnRUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771099; c=relaxed/simple; bh=6ytj9DA2mXccOWmIrWdStZbef+qLEGZrkbosfSivSz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NvggQ9cggfeuO7AcstDT53D+2iQNX9eMP8+4JjKWilLZCeDPDOgoXLNs0hAqOli2xW5w8UvepyMX6dz0zwct1hnz+A/d8iayLEEZEsBsAOWIrH9k7SIuAmsJ4WJOla3Yw2yYJN7Nzjia3jHFy/EyOmuL9Wj4oAvvRJS6LduTyQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=M3OuAZmo reason="signature verification failed"; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id 08b050b7cb17d430; Wed, 10 Apr 2024 19:44:54 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id A09E766C66F; Wed, 10 Apr 2024 19:44:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1712771094; bh=6ytj9DA2mXccOWmIrWdStZbef+qLEGZrkbosfSivSz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M3OuAZmoCwrUIRv+om+PU5ix93rnpCxQlpPugkVbZBrFRtX9/lyou8hi4JdbsoV0B mD0keTs2qWvAXT8IkhXNuCsFtTKVLLWYAi9U6Iur1lCqyAEbaq9MDqeCveryPOVB/y ps3KHMKQ1TAQEEUoh9t5KNozVIMwsR8nb0gPw05hu3PQ/PVfKQhOKIiiYZS5sMPTqg x2hEwbaBkFx1yFhD2sRkwyrOrBo4mQZsSBfSLsWfsd1LQIdiOWvfK8cceYsQlzlNa+ yVq0Q2aiPEzn3ZqeZHgKi+SVnX6BIP2LsFS4ETjTW1Ft7pobSHP7nv7siVcDY41p4m j9GYYFx6nb8WA== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Srinivas Pandruvada Subject: [PATCH v1 09/16] thermal: gov_step_wise: Use trip thresholds instead of trip temperatures Date: Wed, 10 Apr 2024 18:43:07 +0200 Message-ID: <3769085.MHq7AAxBmi@kreacher> In-Reply-To: <13515747.uLZWGnKmhe@kreacher> References: <13515747.uLZWGnKmhe@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedguddugecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki In principle, the Step-Wise governor should take trip hystereses into account. After all, once a trip has been crossed on the way up, mitigation is still needed until it is crossed on the way down. For this reason, make it use trip thresholds that are computed by the core when trips are crossed, so as to apply mitigations in the hysteresis rages of trips that were crossed on the way up, but have not been crossed on the way down yet. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/gov_step_wise.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) Index: linux-pm/drivers/thermal/gov_step_wise.c =================================================================== --- linux-pm.orig/drivers/thermal/gov_step_wise.c +++ linux-pm/drivers/thermal/gov_step_wise.c @@ -62,7 +62,8 @@ static unsigned long get_target_state(st } static void thermal_zone_trip_update(struct thermal_zone_device *tz, - const struct thermal_trip *trip) + const struct thermal_trip *trip, + int trip_threshold) { int trip_id = thermal_zone_trip_id(tz, trip); enum thermal_trend trend; @@ -72,13 +73,13 @@ static void thermal_zone_trip_update(str trend = get_tz_trend(tz, trip); - if (tz->temperature >= trip->temperature) { + if (tz->temperature >= trip_threshold) { throttle = true; trace_thermal_zone_trip(tz, trip_id, trip->type); } dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", - trip_id, trip->type, trip->temperature, trend, throttle); + trip_id, trip->type, trip_threshold, trend, throttle); list_for_each_entry(instance, &tz->thermal_instances, tz_node) { if (instance->trip != trip) @@ -131,7 +132,7 @@ static void step_wise_manage(struct ther trip->type == THERMAL_TRIP_HOT) continue; - thermal_zone_trip_update(tz, trip); + thermal_zone_trip_update(tz, trip, td->threshold); } list_for_each_entry(instance, &tz->thermal_instances, tz_node)