From patchwork Thu Sep 14 19:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 139814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp590689vqi; Thu, 14 Sep 2023 12:57:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuljqR6XgfxFClCmPX2K4mFKoENr4i99IDkS+EHKZf5Jb74/XqR6KmVJiEtKTYe56y0lSW X-Received: by 2002:a17:903:489:b0:1c3:9bce:817 with SMTP id jj9-20020a170903048900b001c39bce0817mr6292595plb.3.1694721437725; Thu, 14 Sep 2023 12:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694721437; cv=none; d=google.com; s=arc-20160816; b=TaW68HP8sg9BKy+g2z8QA1z6QcGIYSzdwFAycrIOQjEgKO3sngNYf8clyomFkxcsev nnU0CyJioakmCh7jM8ZUvqv2l58vp6+531HvLPxuaAn8vwMCfW8ASsYqvP13Dk6W0Nu/ o1m1bO1PmK5pEjpVRZNChQTM6wVBgFtaRgJY+vb/CqyRBuTxl5I1LNdr5CYhbtasi27L FzKR2ImrX29Uj5W42YSTrAcPZV8xGKBnIx937Spgww7THf26GZEXRNUD3T3E4eISpwDb fYMDarO+X0UghFDAYUd3XhIX7Rz+DYq08LSQHlt++333KT+82dqf0GzTU3CYFsr3dYTV DfDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=82onFYNqo8ip6wjfj91l+Oz9QWGTLK8M6t8p9TlApeA=; fh=5nP8xJYg5/1jlwEUoBUeXHpDGnl6qrJ8rUAduCFzPJY=; b=xVTqDnb26gCfZp1lDKekDGNkbphI29BT1dj1M8G4jt404httqeYGX/IjDU8w5hpAXE ZQiaDt9WImexus+HbAn8RPXO9vkM8n3k/wJBON9C6yUDhfYp2g1RbH+q9bmo8U0nbTzD 8k8tMIRQ3FkrJycccShXEHlRVexjvviRxZW4rl94ng/IVVw918EamidnZ2Sfd+IAKOB2 D875CpC4RLxD373ekJD9vw8fEndtc16aENJ+SkQsqlOQMtEKgC9eGQHu/o8ZRxQZDyKr lpcalexTaoAqBqR2TjEdvtCZVjsZxW5GekzLvmyzNmSZ2cvbkNC4wYhbTav1TysJdsAJ ACFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u1-20020a170902e80100b001b8ac8008a4si2312542plg.598.2023.09.14.12.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A6E3981E9A57; Thu, 14 Sep 2023 12:42:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231714AbjINTma (ORCPT + 33 others); Thu, 14 Sep 2023 15:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbjINTm2 (ORCPT ); Thu, 14 Sep 2023 15:42:28 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD142698; Thu, 14 Sep 2023 12:42:24 -0700 (PDT) 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 5.2.0) id 51699521a954401f; Thu, 14 Sep 2023 21:42:21 +0200 Authentication-Results: v370.home.net.pl; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=rjwysocki.net (client-ip=195.136.19.94; helo=[195.136.19.94]; envelope-from=rjw@rjwysocki.net; receiver=) 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 v370.home.net.pl (Postfix) with ESMTPSA id 148BA663F73; Thu, 14 Sep 2023 21:42:21 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Zhang Rui , Srinivas Pandruvada , Amit Kucheria Subject: [PATCH v1] thermal: core: Fix disabled trip point check in handle_thermal_trip() Date: Thu, 14 Sep 2023 21:42:20 +0200 Message-ID: <12286279.O9o76ZdvQC@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrudejtddgudefkecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeffffffkefgheehffelteeiveeffeevhfelteejvddvieejjeelvdeiheeuveeuffenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhn ihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopegrmhhithdrkhhutghhvghrihgrsehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 12:42:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777044226264037125 X-GMAIL-MSGID: 1777044226264037125 From: Rafael J. Wysocki Commit bc840ea5f9a9 ("thermal: core: Do not handle trip points with invalid temperature") added a check for invalid temperature to the disabled trip point check in handle_thermal_trip(), but that check was added at a point when the trip structure has not been initialized yet. This may cause handle_thermal_trip() to skip a valid trip point in some cases, so fix it by moving the check to a suitable place, after __thermal_zone_get_trip() has been called to populate the trip structure. Fixes: bc840ea5f9a9 ("thermal: core: Do not handle trip points with invalid temperature") Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 6 ++++-- 1 file changed, 4 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 @@ -348,12 +348,14 @@ static void handle_thermal_trip(struct t struct thermal_trip trip; /* Ignore disabled trip points */ - if (test_bit(trip_id, &tz->trips_disabled) || - trip.temperature == THERMAL_TEMP_INVALID) + if (test_bit(trip_id, &tz->trips_disabled)) return; __thermal_zone_get_trip(tz, trip_id, &trip); + if (trip.temperature == THERMAL_TEMP_INVALID) + return; + if (tz->last_temperature != THERMAL_TEMP_INVALID) { if (tz->last_temperature < trip.temperature && tz->temperature >= trip.temperature)