From patchwork Fri Jul 5 19:32:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 810642 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 7C452170843; Fri, 5 Jul 2024 19:34:02 +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=1720208045; cv=none; b=Gf+GDpO4ieZlgzTetLO6iz48aVoGHIw4j/NSZZ+ygMab51PucBEiO3ax9wZpGT/rHmKCN1a7TaLQx8P7lWRVDhH4+8Tf9LSrtaOeKHjpL4426mQr1uqEs26ElLEmhI2kL8wHlGDhI+OSPTBuWZVlrqcZu06oHVGHzEFEkLAFj7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720208045; c=relaxed/simple; bh=hOnndz40p3dLR7Q7W8bzL2Ty5pUkFq6GNMa34qE/HUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lu6MBiwsZHiXcUFQycaPvYqGCBI37EQ+yTsG0r8REZ7xURkS/FKN3hrr5qrveng4AFC5sU7IJ+6lcub7mUg1lMYpz6tC4FvVvWvmJ4KDZq/brW9+vCr6kvRW4Z3oZE7YSWv8DaEY95oqXDF4RVWiDuxyR/D5ziavJqJMbX02Pqo= 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=dAZtqxuq 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 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="dAZtqxuq" 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.2.0) id 21aecca496d61b59; Fri, 5 Jul 2024 21:34:00 +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 CA10F7F5773; Fri, 5 Jul 2024 21:33:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1720208040; bh=hOnndz40p3dLR7Q7W8bzL2Ty5pUkFq6GNMa34qE/HUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dAZtqxuqRIyLYa17RiBEE7Ch33F6c2f8i7HJOc2VTxljI4lwmEmUdmKLFMztvClPz TvTGtes9Y63y8AItiJahaOfSgrpJ2yptRnIqt70nympT2qM/OIAtxbLuNmif0yUOJC yCnocHH3IjxdeCkvqZrw9MoBxQurIu0r6qgpYGUp0dtC2KadHrKhUWqDYRS7TIdSZc /D2KqzTqizgbH6FZXzUy9PbOOBf1uubdVmsyihQG8IhohqdeJJkC7bb57eIDUNyS5R cA7u/PW+ud3beDoHt6k6W2TjDk1VPvdpyBkdjLZDRa6okIvcIoiUZ2Zqo8vAjaKPeT GwZ8v3frYalpw== From: "Rafael J. Wysocki" To: Linux PM Cc: Daniel Lezcano , LKML , Lukasz Luba Subject: [PATCH v1 1/2] thermal: core: Change passive_delay and polling_delay data type Date: Fri, 05 Jul 2024 21:32:40 +0200 Message-ID: <1898833.tdWV9SEqCh@rjwysocki.net> In-Reply-To: <4585590.LvFx2qVVIh@rjwysocki.net> References: <4585590.LvFx2qVVIh@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugddufeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 From: Rafael J. Wysocki It is better to use unsigned int as the data type for the passive_delay and polling_delay arguments of thermal_zone_device_register_with_trips() because they are implicitly cast to unsigned int anyway in thermal_set_delay_jiffies() and if they happen to be negative at that point, the resulting behavior may not be as desired. Update the thermal_zone_device_register_with_trips() definition accordingly. Signed-off-by: Rafael J. Wysocki --- This also allows the second patch to be simpler because it need not worry about possible negative polling delay values. --- drivers/thermal/thermal_core.c | 3 ++- include/linux/thermal.h | 3 ++- 2 files 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 @@ -1359,7 +1359,8 @@ thermal_zone_device_register_with_trips( int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp, - int passive_delay, int polling_delay) + unsigned int passive_delay, + unsigned int polling_delay) { const struct thermal_trip *trip = trips; struct thermal_zone_device *tz; Index: linux-pm/include/linux/thermal.h =================================================================== --- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -221,7 +221,8 @@ struct thermal_zone_device *thermal_zone int num_trips, void *devdata, const struct thermal_zone_device_ops *ops, const struct thermal_zone_params *tzp, - int passive_delay, int polling_delay); + unsigned int passive_delay, + unsigned int polling_delay); struct thermal_zone_device *thermal_tripless_zone_device_register( const char *type, From patchwork Fri Jul 5 19:33:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 811145 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 95B6116FF43; Fri, 5 Jul 2024 19:34:01 +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=1720208044; cv=none; b=u5l2sDng4B1RzF0DPopvDt64q9V5jgiLw+PlWQQaGP37sCZdXkJ20UICoail0Wl30KZDVimHTWb4Y6Mn6KYl1VU6mN+cHymc7/KyPtzZzG//rY0BQs9D3Jqjb2OJZ/Wid+eYkCjDk8waRIy4cx96qUt35eGCnp/3MhpACLqcfVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720208044; c=relaxed/simple; bh=q10SjI3kjD1CMjeLuNHAQc1nnmz7VXt02YiDk9Ev+8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UyblEFxraUgf8njPfLhWyO1jL+9lihS8WJDbIsoUPuhhDCtt7OJpqCOEmaaFwiLNHYQXMsEHuiDaPwo5P1CGcBdzaLhYIcUu70OutRyQBcZ3znsVeQVrByQ9zu1NFFGIEBy/OP92tVlVwD0mK0HJCo+idNu1FpnHxput+KA2yhs= 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=hKA9SSIB 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 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="hKA9SSIB" 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.2.0) id c0a784eed57324a2; Fri, 5 Jul 2024 21:33:59 +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 D450B7F5773; Fri, 5 Jul 2024 21:33:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1720208039; bh=q10SjI3kjD1CMjeLuNHAQc1nnmz7VXt02YiDk9Ev+8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hKA9SSIBXbAgczYJoRXcSgvYPV+aI9eEeGryFBh/Fs5h26CyXfgc7oVX3mCGsVbXu EmMUrKhI/dnpIbrTK3ylXEDdY1AJpW4Z+WTldST2BXpDa3G3VjAOmo/YV/RflXjv9G twLUnLxhs6dak7JT5aeKolyhHYIEcvHsLsVmgzbIzcgMKHYxNDXyi3GxOHZzKIVCPE Y7Uei8eEqx/daYzxJ7gm9WOv1R70FtahAykPyMDR0kgIz/plbHIVxtdP103lIZmC/D 0bN6v3YbQMlpeMDiOWuifVN0Rj4xdY3xvdhaIhasfVbgP6R82dfEWKlkJSjCMSGTO7 iXWe8TqOcozqQ== From: "Rafael J. Wysocki" To: Linux PM Cc: Daniel Lezcano , LKML , Lukasz Luba Subject: [PATCH v1 2/2] thermal: core: Add sanity check for polling_delay and passive_delay Date: Fri, 05 Jul 2024 21:33:52 +0200 Message-ID: <13555515.uLZWGnKmhe@rjwysocki.net> In-Reply-To: <4585590.LvFx2qVVIh@rjwysocki.net> References: <4585590.LvFx2qVVIh@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: gggruggvucftvghtrhhoucdtuddrgeeftddrvddugddufeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrhhordhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhukhgrshiirdhluhgsrgesrghrmhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 From: Rafael J. Wysocki If polling_delay is nonzero and passive_delay is 0, the thermal zone will use polling except when tz->passive is nonzero, which does not make sense. Also if polling_delay is nonzero and passive_delay is greater than polling_delay, the thermal zone temperature will be updated less often when tz->passive is nonzero. This does not make sense either. Ensure that none of the above will happen. Signed-off-by: Rafael J. Wysocki --- drivers/thermal/thermal_core.c | 3 +++ 1 file changed, 3 insertions(+) Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -1440,6 +1440,9 @@ thermal_zone_device_register_with_trips( td->threshold = INT_MAX; } + if (polling_delay > 0 && passive_delay > polling_delay) + passive_delay = polling_delay; + thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);