Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp534069lqo; Fri, 10 May 2024 07:21:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCdry5xcgtLCTMnjVWOlFkVLX99RP/vB98w3SfUvpsGC3a/yc3FW25TCLkdLCRgj0iR4IJOBy3v9r7l6E215kE8ZWvgnpMz4JGnnNBiQ== X-Google-Smtp-Source: AGHT+IHATd+E97mhs0E/+PVkekrYU8UXboQnCQj0VKJe3vbRYApkW6ZAcAfWvlmJwxegv89q4g9R X-Received: by 2002:a17:906:4f8d:b0:a59:beb2:62cc with SMTP id a640c23a62f3a-a5a2d6668b0mr150226166b.61.1715350881544; Fri, 10 May 2024 07:21:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715350881; cv=pass; d=google.com; s=arc-20160816; b=nBO2pFUUtRBuGN86ow4o5GOe84DtjtSssJooNKMj5DNCgf7ivfm+s8FMCSaBIzM6h0 HTfKgNCiAO0IBCmfa6C6zRJSyitut3yDtzhPZyd+P5bJB1y9lqs30acjgvvEMnJ8F9FD T21vYpIU5npwQxIS5OZo5tlo7YEU6c2vzaYvrJYFGHYBQk8wW1nFpl58983eSyI+I6Sd FBO3sXUaSqjNcxy3AvDDPp9+TIxwvKy6VDGGEHnlMrQ+DGzCa5br2CTaKkyGMDzMSQDl WKiAUxRzPXHj44IxeLJ/M5Dmsv8U9qHPOazb5jI5ZtuArBKRkRUsHF4/M9ftzpO2L374 cGaw== 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=hepK38slYDuzv9jPV71GiRKEM3mNcGIrNb9XnKRXLzk=; fh=GzCkp9dboMjnsRASvUnR8RkBPyyMxU6lLzxcgnbmqi0=; b=kKzO2IFxnJsH3X/03nQMxAaak0JdYRvr8AG7DHj9xcBS7mydpIVz0BD721p0yCNidn YvstCoUUTsSeExLjMYDSYUUh3XvNJryTQGbBGsBn11ufBmO1CyhbSerey+2i5GcDbT+n bmGKmKzQlDB2uBdoPgkzSOYBH9gzoSdJYPrf6XTsBibPaYAa8MkiyCZ1VNlRlMvpjEYD TtLW8/o48p7A7xZrHHJ39N+N+R8Hx4KqGEPAeKnsiFyE7prKU/XpgKsbFVOMl7n5U7CS wwPr4PAsmrGgFZyQ13CRbQ5jqRabm1lPMCDBlkdgkGptPmxfD9YGRLQybYb8UfFksD0J L2NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=GEEQcbXs; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-175886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175886-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17946b24si202382866b.210.2024.05.10.07.21.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 07:21:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175886-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; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=GEEQcbXs; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-175886-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175886-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 48E5C1F2193A for ; Fri, 10 May 2024 14:21:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E2DD312D1EB; Fri, 10 May 2024 14:20:45 +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="GEEQcbXs" 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 09ADF12FB39; Fri, 10 May 2024 14:20:42 +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=1715350845; cv=none; b=fbdjtjaNZlbywN9bmufdyYNjaNDffaOLtubtYSaTVuTmBG5rAJ9YZ4pMVY0rqNfD+Fayf0+qW6tl/fk9xvB5iz7u2OYvKQ9ssGCKkqHn3W3S9CPAXi8Um8VMB9MzxapKayOq84WBWI+mgaUPsH7qmMFj1WCF9EvP54HweAod9wY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715350845; c=relaxed/simple; bh=kj0fHUv9hccCyohXhp+3qUh/xZKH1f7iQnqBhqFt5TE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aojaQ+FQT2INblqOBIZixuHGnkT1UcOy8XZvBor9xW/PvuUhULuJKXiIqG4B027AfWVJrN9m9T+JtWf3lSeni9TelUb5TyTT2DnhoUlFyMdi2hKSlOF7TUBSiCrmk3eD7dU0iq0IYe71CxJiebvr9x5pwQ/VnnWYYbjsM1MkbYs= 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=GEEQcbXs 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 b8b218a2613aa1f1; Fri, 10 May 2024 16:20:41 +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 6C5912102F3F; Fri, 10 May 2024 16:20:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1715350840; bh=kj0fHUv9hccCyohXhp+3qUh/xZKH1f7iQnqBhqFt5TE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GEEQcbXs9jESdVUXXanIe7JtOdDzKeZihuum5VzN1nBUqYQzTZupbnwfYp0zxh44H ezobRcCEHz2HFaHZMjbF7WE3w1z9vXE7PDINqFT39IGRU3YKu0K6iQY4/A9+RCgDHG VzjlNPGsEQZhEDwXUQZsZNE2JvKzcLbsE45M3qReuKetTtsrJ8CR70xQjP6w2J1xu2 5t5sEJduQeENLBcpkaMUruS7+0xjLjMayHo8Ky9+vr1EvJmQiDBQWqVcLxRt6jRYg/ 8uHXRXva4BGrHvdWbm2y+ZYlfD78sh5SJnPHRnTWR16/JeTV3o95Iz4aS/RnzdJ06a MVmA2Bglf29gQ== From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , "Rafael J. Wysocki" , Lukasz Luba , Daniel Lezcano , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v1 3/6] thermal: trip: Make thermal_zone_set_trips() use trip thresholds Date: Fri, 10 May 2024 16:16:52 +0200 Message-ID: <1974336.PYKUYFuaPT@kreacher> In-Reply-To: <13518388.uLZWGnKmhe@kreacher> References: <13518388.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: gggruggvucftvghtrhhoucdtuddrgedvledrvdefkedgjeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomhdprhgtphhtthhopegurghnihgvlhdrlhgviigt 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 --- 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 @@ -498,13 +498,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_notify_tz_trip_up(tz, &td->trip); 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 */