Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp3543rdb; Mon, 15 Jan 2024 09:57:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYnII6FeW/6uG9IpkQAiOQZ8yp6GmNnYM7GCiVf4G6Y8hM9qBIBczylhS4+2BwW5hQtGwR X-Received: by 2002:a17:907:1005:b0:a27:92e1:70c1 with SMTP id ox5-20020a170907100500b00a2792e170c1mr1360463ejb.29.1705341473980; Mon, 15 Jan 2024 09:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705341473; cv=none; d=google.com; s=arc-20160816; b=AUQkquKNiS7407AmInzbOoskixFaSkPqUchg7oaWONDlYWGiZbZDErqQ+B6S7zKTKU Ljpkrza0y43UHgC+4GocD5XnT1bz24I2kiKeIfRCdGe+wi4EFAGtJ3OQ0dGFxYrXMrLx H3qroFV4S+hbrK7nN224hra1ArAkOMTc6RwQkusRynFdrnOkoR7LmfGG2Mwun5cJRQDa 2/bbAOT77l0eZ5a9xPmz7ftF3vSs2r7cA3HK/rPF6iw5OdvesGcA2NRc3ARLnuCQsXhV xjIn9+6w4ebJjUjKx4cqvAAakTBkylvnOm3w0AySNUQCuQFOeutfTfZ0vE8qJEbWLuXg eSgQ== ARC-Message-Signature: i=1; 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; bh=t/EWDzjTWupGkT9a9pMxzGY+5w3N/zX38qBDIDTwMsk=; fh=Pgalyh3MF5eBPi/IPdZYQ5Sy1NRsybLYs3FsYGRssI0=; b=qt+oTta1g4SUPOi4tshayxGU8Iho8ZIAaXBpMga9TkQ9zXpWqWKkIWDGF2R8EU+1+z aS0ZzfOFJU9BYJvHJsUlFytBI7yDHGg4FNN9MdSiyEL+axe7pfkJ4dDkCSi7Kg7GPCOv I20sGTyfyoa3edukRBZ+qPdnMIjmxhQ870ytZ0hkVZk3M7L94YOmx1bRiRtCtNW+taed tdsGglRg8EmK/lwIwQO43j06D0jWi28swpcLff1Mw7/+RZsxY3HaAiZ/ewqzJwBCMcNQ Da+NHddVKR+L9NxrfVq4rGPOuuvpa/w1s+pvfFNPORI1FTCg9nU0MRP4AS4J6SWX/t9d cq6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26334-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y14-20020a170906470e00b00a28bb1abe4csi3863030ejq.703.2024.01.15.09.57.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 09:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26334-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 B36AB1F22C21 for ; Mon, 15 Jan 2024 17:57:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FC3B182A3; Mon, 15 Jan 2024 17:57:43 +0000 (UTC) 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 BD574182A7; Mon, 15 Jan 2024 17:57:40 +0000 (UTC) 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 5.4.0) id 872efcd1a58f9332; Mon, 15 Jan 2024 18:57:31 +0100 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 54BB16692F2; Mon, 15 Jan 2024 18:57:31 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Daniel Lezcano , Lukasz Luba , Srinivas Pandruvada , Zhang Rui Subject: [PATCH v1 2/2] thermal: gov_bang_bang: Fix possible cooling device state ping-pong Date: Mon, 15 Jan 2024 18:57:06 +0100 Message-ID: <2339862.ElGaqSPkdT@kreacher> In-Reply-To: <12389773.O9o76ZdvQC@kreacher> References: <12389773.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: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejuddguddtjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeeipdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepuggrnhhivghlrdhlvgiitggrnhhosehlihhnrghrohdrohhrghdprhgtphhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtohepshhr ihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 From: Rafael J. Wysocki The current behavior of thermal_zone_trip_update() in the bang-bang thermal governor may be problematic for trip points with 0 hysteresis, because when the zone temperature reaches the trip temperature and stays there, it will then cause the cooling device go "on" and "off" alternately, which is not desirable. Address this by requiring the zone temperature to actually fall below trip->temperature - trip->hysteresis for the cooling device to go off. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/gov_bang_bang.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-pm/drivers/thermal/gov_bang_bang.c =================================================================== --- linux-pm.orig/drivers/thermal/gov_bang_bang.c +++ linux-pm/drivers/thermal/gov_bang_bang.c @@ -49,7 +49,7 @@ static int thermal_zone_trip_update(stru if (instance->target == 0 && tz->temperature >= trip->temperature) instance->target = 1; else if (instance->target == 1 && - tz->temperature <= trip->temperature - trip->hysteresis) + tz->temperature < trip->temperature - trip->hysteresis) instance->target = 0; dev_dbg(&instance->cdev->device, "target=%d\n",