Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp103677lqb; Tue, 28 May 2024 09:58:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUznb4jykfG/pt89LqxWFGuW5cEOs8jdNjMPQqShk11f9SDwXwEYkD378DV7fIW3agVlXp146HMFH0+cwdLus1Vou52SKZ6bIGZhJYDTQ== X-Google-Smtp-Source: AGHT+IFaKY7bNyY7SKTGEfa/zfXn3Bayg9R5uaLOu13nMsNu3yT90K3NldHjNEca4PJcN/JJsJQx X-Received: by 2002:a17:90a:b97:b0:2bd:d42a:f81f with SMTP id 98e67ed59e1d1-2bf5e0ee840mr15137415a91.0.1716915538003; Tue, 28 May 2024 09:58:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716915537; cv=pass; d=google.com; s=arc-20160816; b=o5t3lGLCLBhGSMkpY7LyakEISi0r2oxtkr0ZPkgx1vsH2pCMiUZ7TKSpnU2lonf7hT y3/GdXSnqSWU+q8L4cKHwjUck2MO/MV/WNcmMrQJ5qyPxnB1z4GkQMY/7EOqgIVZ6m8d 5abIWtKRvMtDcWre5lzzkoY5Q+Smf7UeL+s37fdrpWshMaypSqiyeREhZ4rOwcU6FswX vg2LZjqMx0Mj9NG2gyl8I/Pc5nQ6SLbL9o0/2iOlF5KbChFxibqvh9PisySAU3NSK3XU qATKRlusgfvigbr7BAg6mLzPsdp7bQL2+G3VG0/vFmgBtxNkke0tsdwm/5ijw587muPt 8I3w== 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=LzmE66Xj7k1TMI+AVukhK7NlOtmUky9wGxSPG6FbfIA=; fh=GzCkp9dboMjnsRASvUnR8RkBPyyMxU6lLzxcgnbmqi0=; b=GSdkMRcSCHMfZy3JaDT6+xbQWEeC9RccLDOQTFCGDvi43m13CD0KMq1TdK7wegCGts /6Z3DcDJk2TXP3dCJXvmTF+fyHJ2gTv4YW11P9hq4hE0ENfxIFiuGuxzhbsUb3mNl6Xs gM24c/UU5UEKoWG9QzSELvnze1HxNgJCHnLivFATN4bxzwzhnXXVHbrsjcCKLlgt+qA5 lDXTNzNbfbZ3ku7I29wK5uP+vS/bM/rMdJjtnWJ9ERFMHyJPsz7tNjNb6mSa565aSxtz SuczT51t5w+4fVEUwq8o4lvRz42TEhl6+qjFaELPp2N05f5bsyjYJFjkzgpuAnnWvbTS /Xyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=fBRQsmap; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-192782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192782-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdfaa609a7si9317367a91.173.2024.05.28.09.58.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 09:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=fBRQsmap; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-192782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192782-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4A314B24C36 for ; Tue, 28 May 2024 16:55:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 878C1175550; Tue, 28 May 2024 16:54:27 +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="fBRQsmap" 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 B92E6173320; Tue, 28 May 2024 16:54:24 +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=1716915266; cv=none; b=J/5IWkXOZBJUIrQmOx6h/3USWQK4RYdx+nq1b7pxS9gCp+5Mrih8ErjWAJWNj5Ds+hRhB66QYayeJp6b/eNYKKaC7sgLp6/ByNcsqZen+Fsho22n9i/UIhIPXEe+i/IEA8h9BmEcepfcyEEbyRJEj0GgLOO2JMJPSyY3F4HXifI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716915266; c=relaxed/simple; bh=ERK2R1qqQZ6vDmaMYJThtKTcWISqjAhym/ORlWiQoqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UEqQfeg7b9FR/FRRmufwXorhlsai0OHE1AvxFifJSY7ldRQ/AXdO6lx728vBDlca09SAjjpfZrfx8sK3ZLHNbdoywb5wqcfeEnh2qf7Y/gKAasZwtm20A+fUNHUBmN7eZQcr4dCvBrOM63kbXPApTKLBjRcUB4osAhicWzda9m8= 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=fBRQsmap 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.1.0) id 46509cfd70e61ec7; Tue, 28 May 2024 18:54:22 +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 392876A5036; Tue, 28 May 2024 18:54:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1716915262; bh=ERK2R1qqQZ6vDmaMYJThtKTcWISqjAhym/ORlWiQoqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fBRQsmapOYMgPGtEPriXsC1EIS27DXyfua6qTC8QTynlpPXvNNGNrLhd3zbAYu1+G KgeyYWis9TbMOdGwgI9g3YKRBojxb1GOMmJADUbBGiXAjIPeTyYnaINmKEZiICXFaj pEVM/VJqxlowrIC9BONWgPbd1uxRvtppsnfgsOQYTcNhWX/6yMfdlBYFWAd4y1+QMq hKdF/O9VMUwlkK5MrKtNrA85AFnM69J6wvYGhuLRdnPMpsYUnjHhJ+aDG3EG1DkHqr EMPYPTsDIGJr0VobQQ+6xV2aUeBIo5wtqz4F4bmQA3wKKAdwr0gXnIt+9JOpnJV1H4 9Bf+KK0VeD84A== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v2 2/5] thermal: trip: Make thermal_zone_set_trips() use trip thresholds Date: Tue, 28 May 2024 18:51:11 +0200 Message-ID: <2340783.ElGaqSPkdT@kreacher> In-Reply-To: <12458899.O9o76ZdvQC@kreacher> References: <12458899.O9o76ZdvQC@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: gggruggvucftvghtrhhoucdtuddrgedvledrvdejkedgjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopegurghnihgvlhdrlhgviigt rghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 From: Rafael J. Wysocki Modify thermal_zone_set_trips() to use trip thresholds instead of computing the low temperature for each trip to avoid deriving both the high and low temperature levels from the same trip (which may happen if the zone temperature falls into the hysteresis range of one trip). Accordingly, make __thermal_zone_device_update() call thermal_zone_set_trips() later, when threshold values have been updated for all trips. Signed-off-by: Rafael J. Wysocki --- v1 -> v2: Rebase. --- drivers/thermal/thermal_core.c | 4 ++-- drivers/thermal/thermal_trip.c | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -513,13 +513,13 @@ void __thermal_zone_device_update(struct if (tz->temperature == THERMAL_TEMP_INVALID) return; - thermal_zone_set_trips(tz); - tz->notify_event = event; for_each_trip_desc(tz, td) handle_thermal_trip(tz, td, &way_up_list, &way_down_list); + thermal_zone_set_trips(tz); + list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp); list_for_each_entry(td, &way_up_list, notify_list_node) thermal_trip_crossed(tz, &td->trip, governor, true); Index: linux-pm/drivers/thermal/thermal_trip.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_trip.c +++ linux-pm/drivers/thermal/thermal_trip.c @@ -88,17 +88,11 @@ void thermal_zone_set_trips(struct therm return; for_each_trip_desc(tz, td) { - const struct thermal_trip *trip = &td->trip; - int trip_low; + if (td->threshold < tz->temperature && td->threshold > low) + low = td->threshold; - trip_low = trip->temperature - trip->hysteresis; - - if (trip_low < tz->temperature && trip_low > low) - low = trip_low; - - if (trip->temperature > tz->temperature && - trip->temperature < high) - high = trip->temperature; + if (td->threshold > tz->temperature && td->threshold < high) + high = td->threshold; } /* No need to change trip points */