Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp301695lqj; Wed, 10 Apr 2024 10:48:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5ZStKPO2Zz19M0vwyK6BIVtQzPl8TENUevGCQ07wTuGS/zh2hTfNTa4ViBY4oPFw8ond6U8Ge+CVDftCESYuwlNszvPcm9l2SM2bQMA== X-Google-Smtp-Source: AGHT+IH93pRQYDBb4D/4tLMMOHLIHNA8AV5oPlS8NuAvQ2uHVvOb0YHqjOdkk79ZVOAh9kqy1IoO X-Received: by 2002:a05:6870:c90e:b0:229:fe6a:8516 with SMTP id hj14-20020a056870c90e00b00229fe6a8516mr4028612oab.22.1712771285400; Wed, 10 Apr 2024 10:48:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712771285; cv=pass; d=google.com; s=arc-20160816; b=EMLFBevlP//q7y8qso6N/q9oRAPJzOJFV335baK8aEemIexTiPF/xb2IZpH0dVRumo 7pNJwiSfiuYQmzvQjyisjf1bm8Rz7oL54i9BRICgwBMEu87cSxoGpRn00otxrFicjqIO oFGbvP6Opv+0eg0A6jc1DG90vDPs4MKwZBNT0yEYFkhPAQDIdePD597IajAL3qropy7X 9kKPpq1Rvd8nKpSOMPg/3Zz7gJ0iU+5aNQQ6amT9EqkkQt89NkeeglLrUq1C5bWIZ/rG GerhEPc7CZp9bZTKTSXT90a/v2wFNStsGEIwpaZLRgZOTnt3qAMusAfh9xJOrGrD8e5F La5A== 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=NZTrU3CAsfYZwSrMJJP1JD4vCuM1GQyxoDEWblyzwmM=; fh=0I/rqIlL4373pOps8oaBYF1ECx5xbCzL9wLU5PgpMhU=; b=LBXpioJ3UHWev6ehPGZWxHG27ozFU+AuRCmV8DkcsBGZO40AMIx5WyBPD2wRy1DBn3 Rn0e4pDwEIP3cdcymTaP2VEEk6V8DwtMlI2WH8PtKnwyBswVWi7sTlYXFn7FleqGmjnq z2dm7UG1iBrWlnRP0Hz47RJjylBa4Lp2wRZqbC1ZD0GA7M9rtFtJeX3f08QF/ZQqmEfA dMCG8uviQFgVsBmp1rpiytVpUYqbm2XB7dRbi8xlfwjQdaTrFlYwPwlziiySxCa8yUEe 63qjQur7OuOsgYZWCWcMa6iytbnpv9hX+r64YagSBuUBEZ6NnDmnXjVMa2zavdw2bfs0 oNQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=vTXNDlrQ; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139132-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139132-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b9-20020a63e709000000b005c600ffa335si10929202pgi.217.2024.04.10.10.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:48:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139132-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=vTXNDlrQ; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-139132-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139132-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DEF4B28885A for ; Wed, 10 Apr 2024 17:47:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECC8F184112; Wed, 10 Apr 2024 17:45:04 +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="vTXNDlrQ" 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 53F4D180A70; Wed, 10 Apr 2024 17:44:59 +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=1712771102; cv=none; b=oa5ZjTH7gFpovmjxb8LKjY5Vy9ryBfMCawef3rn6kp1MLQpz/I1fA6F4JPVqKPN+Qf2Jr9qUzA9/XYyo8Ni69lVqf6QzxC5zS3r70ZuFgpEZPZDieWfmgoZDXWq69pAq/wG1sc/4hlePIEY3vw2S9GTtHpMz8ifIf/Es0/ly8BM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712771102; c=relaxed/simple; bh=B5J+m5y9UQ7/XO42/yL80vp+siK13YMOr1jwCBLtv20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RjldZiuiPQyCX47x4tgUbQP/o8T73dRkw9IACd37vqUIlErLg+lCaIXyctK0z0oQC0Pa/BezMFapCuW3EFKUyn0WFk9Jl3dVTLfvcyuP5dtlOkDf7Eu91YqP0/Lm/2IZJJPSjIPLM+jUHMgEqYO4q/3ogWlqngCzVBx+jFAZU6Y= 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=vTXNDlrQ 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 8e9c8fcf2b46ca6d; Wed, 10 Apr 2024 19:44:58 +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 B120C66C66F; Wed, 10 Apr 2024 19:44:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1712771098; bh=B5J+m5y9UQ7/XO42/yL80vp+siK13YMOr1jwCBLtv20=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vTXNDlrQrLZLZ+DIPbKXtKFERmXMFd/BKaq5iY/ptj3X5BHn0QHbPpvRYPdZ042Or R8kwjnhzNUQODnlTH1/7uXBZG3QiUOrKQMOSSdnjKT8u7ieiCKnYmEzIDBS+ru/v7I C84N3nrZAXrrwHEQ8pLQyo3Ggidt0UTNb8MjQZPGO+EnmhRl2Z+xEQCBcnjsVpiOVG c48sE/eb0GbsbhYaW4gmnEbPwxUxe6lYXAAzILyMS5baK7h/EbJbyAO1mc7QUhLYLY QX5Cjlq6rPlRCx9IeCHSXT9z0FnKhXtnatGu2K1nIZrqM3x1ce7cMNl2rpxhNbBy1s 5MzUjy64bhK+w== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Srinivas Pandruvada Subject: [PATCH v1 05/16] thermal: core: Introduce .manage() callback for thermal governors Date: Wed, 10 Apr 2024 18:08:12 +0200 Message-ID: <3242862.5fSG56mABF@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: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedguddufecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki Introduce a new thermal governor callback called .manage() that will be invoked once per thermal zone update after processing all of the trip points in the core. This will allow governors that look at multiple trip points together to check all of them in a consistent configuration, so they don't need to play tricks with skipping .throttle() invocations that they are not interested in and they can avoid carrying out the same computations for multiple times in one cycle. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 3 +++ drivers/thermal/thermal_core.h | 2 ++ 2 files changed, 5 insertions(+) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -516,6 +516,9 @@ void __thermal_zone_device_update(struct governor->trip_crossed(tz, &td->trip, false); } + if (governor->manage) + governor->manage(tz); + monitor_thermal_zone(tz); } Index: linux-pm/drivers/thermal/thermal_core.h =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.h +++ linux-pm/drivers/thermal/thermal_core.h @@ -31,6 +31,7 @@ struct thermal_trip_desc { * @unbind_from_tz: callback called when a governor is unbound from a * thermal zone. * @trip_crossed: called for trip points that have just been crossed + * @manage: called on thermal zone temperature updates * @throttle: callback called for every trip point even if temperature is * below the trip point temperature * @update_tz: callback called when thermal zone internals have changed, e.g. @@ -44,6 +45,7 @@ struct thermal_governor { void (*trip_crossed)(struct thermal_zone_device *tz, const struct thermal_trip *trip, bool crossed_up); + void (*manage)(struct thermal_zone_device *tz); int (*throttle)(struct thermal_zone_device *tz, const struct thermal_trip *trip); void (*update_tz)(struct thermal_zone_device *tz,