Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp490999lqt; Fri, 19 Apr 2024 01:47:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQegonXItO8dnNWBHfESrlxS+mIohTShLlua0sgHcv+WcPMQAtWNkFXTx3kFZqqtQlh3t4zeIoqXVHSsd368zBTzmfRDALtKdoRFCYTg== X-Google-Smtp-Source: AGHT+IFmt0DyfbkCpDSC3MZIRq+REkmRN/1MgfJ6saIBL/G1lfhlXwPkkr6+bkdrgQiihCimVGTT X-Received: by 2002:a17:906:a11:b0:a53:4006:31a with SMTP id w17-20020a1709060a1100b00a534006031amr956471ejf.59.1713516478209; Fri, 19 Apr 2024 01:47:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713516478; cv=pass; d=google.com; s=arc-20160816; b=ReZB875Ki+tF9SHI4U5cJPiGXpZceIAoCyKrbRJyk13/5OpGkrsTHhFOXm7TAGUdmT FoFcl3a3li92Ya7kkygq6BqsJycG1K75Q43KPoIQOwLY8lIB7A/hpC2ImybwpnZwOtna bEGG0xTjyBcu2wYszElF/rPghTrO6ZQWniHlmBiPOrujKxVTF/2dJf8rh6YjVneGPTSV U36kLmJchPZlkB0mOhtsHDvTyBWpjkF70A/3OlJX/aNLhXg1iwl/QRFvj5Cx9HBWrKxv MnIfaT+PD7OXU9xQmbXBK0LvhDbK9CHa7WjYVyDNxjGQmuhsZxa41BD3ulI0Fi9XnYXG l2Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=DaE0Kszn+rOyItagM1p02ZiagM21lf+OzDKCmlbAh8g=; fh=NWbihT0n2LVGI0eIabKMMzs0D4KhesRC0I1HJGdvI0I=; b=KTjdtNXEf6TyPi8ebT3ORXkdqSEqsgx15PCboTtCHpnA4KKi1ZVOQ146dYBrwCOw7W WEtpVUPeioZpOmbT0Tdcb6nUTO77NnJCUMZF/9pNxZU5wosmaDG6FJve/3CvLu4N2+RW VtGqLLXMBmPIvXxO4LsO/SlzOjXpBS0OUylT8uPcdPu66qcGZvBQAEqPaZll9Etx2jQe ovQcxfZ8qVQckPl8wEZI+5uVa8mWC0iK4Epy9z0DLl0IJB1zk911TMPNM8Oe9Dabamki FzunN+377pfFrBWSsjjPdCglxZXaEAM/nOqeIfZhMdiYAIsGO71F3yK4YIJDUc1R2t7o iSsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id sa7-20020a1709076d0700b00a558952f8c0si462647ejc.393.2024.04.19.01.47.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 01:47:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151189-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id EB4BC1F21D2D for ; Fri, 19 Apr 2024 08:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE9FE71745; Fri, 19 Apr 2024 08:47:49 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBD8A38D; Fri, 19 Apr 2024 08:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713516469; cv=none; b=heAOYsuvwSwxssuA2fAVEop/fzwGs1lQs08s3lclx2eL3ZS8r4ShLI/o1NWcvo2rLQdYB5epSm+lsfvu1/cLzwQD8bv9y48HqmkPwRFOcDhHCfmEQ4WKkVeJCfb0lecV9BJPC4sGMWaJhDixD9Rt8gbWj/XF8BbPxAKSk1wdsO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713516469; c=relaxed/simple; bh=ejQFfEFhwy1828jrRZzifZwAL99YIhldwvw8ing12js=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SQY8PfiE/49yS20ZBmStvbTwR9YAvQU68aiWqkow6TXM8z3zj0dBobt2yzKgsXYlRIc3p7thoUxONH72v7kkrpJ2xRT+gXB0RyAZlCvAtb7kUN7ajTk5fA70FM6EayZLhIrkKYoOKp+xl/9QRT8r5xllurXYXSnp713/Mnx5WVQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 EE6122F; Fri, 19 Apr 2024 01:48:13 -0700 (PDT) Received: from [10.57.77.69] (unknown [10.57.77.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C20B33F792; Fri, 19 Apr 2024 01:47:44 -0700 (PDT) Message-ID: <22041543-cc7c-432d-9f3b-91456b6dc6b2@arm.com> Date: Fri, 19 Apr 2024 09:47:52 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 01/16] thermal: core: Introduce .trip_crossed() callback for thermal governors To: "Rafael J. Wysocki" Cc: LKML , Linux PM , Daniel Lezcano , Srinivas Pandruvada References: <13515747.uLZWGnKmhe@kreacher> <2009494.usQuhbGJ8B@kreacher> Content-Language: en-US From: Lukasz Luba In-Reply-To: <2009494.usQuhbGJ8B@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/10/24 17:10, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Introduce a new thermal governor callback called .trip_crossed() > that will be invoked whenever a trip point is crossed by the zone > temperature, either on the way up or on the way down. > > The trip crossing direction information will be passed to it and if > multiple trips are crossed in the same direction during one thermal zone > update, the new callback will be invoked for them in temperature order, > either ascending or descending, depending on the trip crossing > direction. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/thermal_core.c | 19 +++++++++++++++++-- > drivers/thermal/thermal_core.h | 4 ++++ > 2 files changed, 21 insertions(+), 2 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_core.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_core.c > +++ linux-pm/drivers/thermal/thermal_core.c > @@ -302,11 +302,21 @@ static void monitor_thermal_zone(struct > thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies); > } > > +static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz) > +{ > + if (tz->governor) > + return tz->governor; > + > + return def_governor; > +} > + > static void handle_non_critical_trips(struct thermal_zone_device *tz, > const struct thermal_trip *trip) > { > - tz->governor ? tz->governor->throttle(tz, trip) : > - def_governor->throttle(tz, trip); > + struct thermal_governor *governor = thermal_get_tz_governor(tz); > + > + if (governor->throttle) > + governor->throttle(tz, trip); > } > > void thermal_governor_update_tz(struct thermal_zone_device *tz, > @@ -470,6 +480,7 @@ static int thermal_trip_notify_cmp(void > void __thermal_zone_device_update(struct thermal_zone_device *tz, > enum thermal_notify_event event) > { > + struct thermal_governor *governor = thermal_get_tz_governor(tz); > struct thermal_trip_desc *td; > LIST_HEAD(way_down_list); > LIST_HEAD(way_up_list); > @@ -493,12 +504,16 @@ void __thermal_zone_device_update(struct > list_for_each_entry(td, &way_up_list, notify_list_node) { > thermal_notify_tz_trip_up(tz, &td->trip); > thermal_debug_tz_trip_up(tz, &td->trip); > + if (governor->trip_crossed) > + governor->trip_crossed(tz, &td->trip, true); > } > > list_sort(NULL, &way_down_list, thermal_trip_notify_cmp); > list_for_each_entry(td, &way_down_list, notify_list_node) { > thermal_notify_tz_trip_down(tz, &td->trip); > thermal_debug_tz_trip_down(tz, &td->trip); > + if (governor->trip_crossed) > + governor->trip_crossed(tz, &td->trip, false); > } > > 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 > @@ -30,6 +30,7 @@ struct thermal_trip_desc { > * otherwise it fails. > * @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 > * @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. > @@ -40,6 +41,9 @@ struct thermal_governor { > const char *name; > int (*bind_to_tz)(struct thermal_zone_device *tz); > void (*unbind_from_tz)(struct thermal_zone_device *tz); > + void (*trip_crossed)(struct thermal_zone_device *tz, > + const struct thermal_trip *trip, > + bool crossed_up); > int (*throttle)(struct thermal_zone_device *tz, > const struct thermal_trip *trip); > void (*update_tz)(struct thermal_zone_device *tz, > > > LGTM Reviewed-by: Lukasz Luba