Message ID | 2154273.irdbgypaU6@kreacher |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2434967vqg; Tue, 25 Jul 2023 05:32:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGVg4UxSDSL9YJNvnASagGLALoH4rugzLi8teT90rp+Tk2DrjUHj8IpE/es0V6AoBiBsAuS X-Received: by 2002:a17:903:2282:b0:1bb:c69b:6f6b with SMTP id b2-20020a170903228200b001bbc69b6f6bmr197196plh.6.1690288350369; Tue, 25 Jul 2023 05:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690288350; cv=none; d=google.com; s=arc-20160816; b=hs61XHE07fg3ubrCXDn5RibkZE8zhfnRdrF4WCXA2nUtNAc1Zg8mHI11hZq241HjQ6 /POU3SB9SQz68RZnO8L0DR2RTKMmEXaeSY738sXpaERPrjaCb9rkYIQyKFSvbZPSnRMz fw7YdVNzq2uyH5EcSUhwbCg5zqwb5IAEwBTKqvDcMjEdYSM1hAnJ3OIYVNBYpCBiGt50 W2kOhiA6h+RvCRpyTIvf21x0kxzaQLZUSxrKPN5tofVUvzZL3DgJTxwC0I+9CYRtB8Ku 2RQ12f1HqkUz1C1fgxLdhoj3Amo6m0udksm2D89zAbnqZtx0wU0QYH/ALEC7DP0cr7ol SuhA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=alSq7BdOaSsBYMfAPzfpgZZ7ZOKbiiZNSa0ZsR49irw=; fh=WAm0nkxw3rD71A4QzwJS1JiPPKRsyn91IiWMPsOrzoY=; b=TZ+h70DiXDx6yaWDw1Wvw6dWONKmuYKQu3e/pZdj471aNAv9pJgMe7T2G6YUwniyAq mRBgtpw+b+kMbidLB8g9bjrm95rnxOoBLGF8bIXCHZJRdUQKeVPBVqJW/iNzVf/cuPV6 LtAO6DYgvPVtlAIFZJi8C54LgalHKote+EFKbHAGpfRGxgA3Zo3hgA0OuaCalmAYUMXH 97LEkjfMSkwIngTc5oIMHSxwjwD8oJbvHnvLLIZZw+fPK9hN+XNlxIlMVR91i2aZ4XKD tMPfH39hRhR2boEwssgCKzZVElDN35XLFanDekjnd8DqW6cmnEks06wOmPWaK17xpLqP QVPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a170902ced000b001bbbbb61c71si1670428plg.399.2023.07.25.05.32.15; Tue, 25 Jul 2023 05:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233718AbjGYMZs (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Tue, 25 Jul 2023 08:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbjGYMZe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Jul 2023 08:25:34 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C181E7E; Tue, 25 Jul 2023 05:25:32 -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 a9f50b1ffa9a852c; Tue, 25 Jul 2023 14:25:31 +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 v370.home.net.pl (Postfix) with ESMTPSA id BD62E661B0F; Tue, 25 Jul 2023 14:25:30 +0200 (CEST) From: "Rafael J. Wysocki" <rjw@rjwysocki.net> To: Linux ACPI <linux-acpi@vger.kernel.org> Cc: LKML <linux-kernel@vger.kernel.org>, Linux PM <linux-pm@vger.kernel.org>, Michal Wilczynski <michal.wilczynski@intel.com>, Zhang Rui <rui.zhang@intel.com>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, Daniel Lezcano <daniel.lezcano@linaro.org> Subject: [PATCH v3 3/8] thermal: core: Add routines for locking and unlocking thermal zones Date: Tue, 25 Jul 2023 14:08:02 +0200 Message-ID: <2154273.irdbgypaU6@kreacher> In-Reply-To: <12254967.O9o76ZdvQC@kreacher> References: <13318886.uLZWGnKmhe@kreacher> <12254967.O9o76ZdvQC@kreacher> 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: gggruggvucftvghtrhhoucdtuddrgedviedriedtgdehtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhhitghhrghlrdifihhltgiihihnshhkihesihhnthgvlhdrtghomhdprhgt phhtthhopehruhhirdiihhgrnhhgsehinhhtvghlrdgtohhmpdhrtghpthhtohepshhrihhnihhvrghsrdhprghnughruhhvrggurgeslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772040673538566700 X-GMAIL-MSGID: 1772395797126516167 |
Series |
ACPI: thermal: Use trip point table to register thermal zones
|
|
Commit Message
Rafael J. Wysocki
July 25, 2023, 12:08 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Add thermal_zone_device_lock() and thermal_zone_device_unlock() for acquiring and releasing the thermal zone lock, respectively. They will be used by the ACPI thermal driver to protect trip point temperature updates against races with accesses from elsewhere. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- v2 -> v3: No changes. v1 -> v2: New patch. --- drivers/thermal/thermal_core.c | 13 +++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 15 insertions(+)
Comments
Hi Rafael, On 25/07/2023 14:08, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Add thermal_zone_device_lock() and thermal_zone_device_unlock() for > acquiring and releasing the thermal zone lock, respectively. > > They will be used by the ACPI thermal driver to protect trip point > temperature updates against races with accesses from elsewhere. This change goes to the opposite direction of the previous thermal zone cleanup and encapsulation we have done recently. Here we give the possibility to a driver to act on the thermal core internals. Ideally, we should see tz->lock only in thermal_core.c > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > > v2 -> v3: No changes. > > v1 -> v2: New patch. > > --- > drivers/thermal/thermal_core.c | 13 +++++++++++++ > include/linux/thermal.h | 2 ++ > 2 files changed, 15 insertions(+) > > Index: linux-pm/drivers/thermal/thermal_core.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_core.c > +++ linux-pm/drivers/thermal/thermal_core.c > @@ -497,6 +498,18 @@ void thermal_zone_device_update(struct t > } > EXPORT_SYMBOL_GPL(thermal_zone_device_update); > > +void thermal_zone_device_lock(struct thermal_zone_device *tz) > +{ > + mutex_lock(&tz->lock); > +} > +EXPORT_SYMBOL_GPL(thermal_zone_device_lock); > + > +void thermal_zone_device_unlock(struct thermal_zone_device *tz) > +{ > + mutex_unlock(&tz->lock); > +} > +EXPORT_SYMBOL_GPL(thermal_zone_device_unlock); > + > static void thermal_zone_device_check(struct work_struct *work) > { > struct thermal_zone_device *tz = container_of(work, struct > Index: linux-pm/include/linux/thermal.h > =================================================================== > --- linux-pm.orig/include/linux/thermal.h > +++ linux-pm/include/linux/thermal.h > @@ -336,6 +336,8 @@ int thermal_zone_unbind_cooling_device(s > struct thermal_cooling_device *); > void thermal_zone_device_update(struct thermal_zone_device *, > enum thermal_notify_event); > +void thermal_zone_device_lock(struct thermal_zone_device *tz); > +void thermal_zone_device_unlock(struct thermal_zone_device *tz); > > struct thermal_cooling_device *thermal_cooling_device_register(const char *, > void *, const struct thermal_cooling_device_ops *); > > >
On Tue, Aug 1, 2023 at 8:30 PM Daniel Lezcano <daniel.lezcano@linaro.org> wrote: > > > Hi Rafael, > > > On 25/07/2023 14:08, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > > > Add thermal_zone_device_lock() and thermal_zone_device_unlock() for > > acquiring and releasing the thermal zone lock, respectively. > > > > They will be used by the ACPI thermal driver to protect trip point > > temperature updates against races with accesses from elsewhere. > > This change goes to the opposite direction of the previous thermal zone > cleanup and encapsulation we have done recently. > > Here we give the possibility to a driver to act on the thermal core > internals. > > Ideally, we should see tz->lock only in thermal_core.c There needs to be a way to lock the thing if it needs to be locked. The thermal zone has been registered by the driver after all, and if it needs to be updated, the driver needs to be able to do that safely. I'm guessing that the suggested way is to disable the thermal zone for the time of the update, but I'm kind of unsure if this is going to work. > > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > --- > > > > v2 -> v3: No changes. > > > > v1 -> v2: New patch. > > > > --- > > drivers/thermal/thermal_core.c | 13 +++++++++++++ > > include/linux/thermal.h | 2 ++ > > 2 files changed, 15 insertions(+) > > > > Index: linux-pm/drivers/thermal/thermal_core.c > > =================================================================== > > --- linux-pm.orig/drivers/thermal/thermal_core.c > > +++ linux-pm/drivers/thermal/thermal_core.c > > @@ -497,6 +498,18 @@ void thermal_zone_device_update(struct t > > } > > EXPORT_SYMBOL_GPL(thermal_zone_device_update); > > > > +void thermal_zone_device_lock(struct thermal_zone_device *tz) > > +{ > > + mutex_lock(&tz->lock); > > +} > > +EXPORT_SYMBOL_GPL(thermal_zone_device_lock); > > + > > +void thermal_zone_device_unlock(struct thermal_zone_device *tz) > > +{ > > + mutex_unlock(&tz->lock); > > +} > > +EXPORT_SYMBOL_GPL(thermal_zone_device_unlock); > > + > > static void thermal_zone_device_check(struct work_struct *work) > > { > > struct thermal_zone_device *tz = container_of(work, struct > > Index: linux-pm/include/linux/thermal.h > > =================================================================== > > --- linux-pm.orig/include/linux/thermal.h > > +++ linux-pm/include/linux/thermal.h > > @@ -336,6 +336,8 @@ int thermal_zone_unbind_cooling_device(s > > struct thermal_cooling_device *); > > void thermal_zone_device_update(struct thermal_zone_device *, > > enum thermal_notify_event); > > +void thermal_zone_device_lock(struct thermal_zone_device *tz); > > +void thermal_zone_device_unlock(struct thermal_zone_device *tz); > > > > struct thermal_cooling_device *thermal_cooling_device_register(const char *, > > void *, const struct thermal_cooling_device_ops *); > > > > > >
Index: linux-pm/drivers/thermal/thermal_core.c =================================================================== --- linux-pm.orig/drivers/thermal/thermal_core.c +++ linux-pm/drivers/thermal/thermal_core.c @@ -497,6 +498,18 @@ void thermal_zone_device_update(struct t } EXPORT_SYMBOL_GPL(thermal_zone_device_update); +void thermal_zone_device_lock(struct thermal_zone_device *tz) +{ + mutex_lock(&tz->lock); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_lock); + +void thermal_zone_device_unlock(struct thermal_zone_device *tz) +{ + mutex_unlock(&tz->lock); +} +EXPORT_SYMBOL_GPL(thermal_zone_device_unlock); + static void thermal_zone_device_check(struct work_struct *work) { struct thermal_zone_device *tz = container_of(work, struct Index: linux-pm/include/linux/thermal.h =================================================================== --- linux-pm.orig/include/linux/thermal.h +++ linux-pm/include/linux/thermal.h @@ -336,6 +336,8 @@ int thermal_zone_unbind_cooling_device(s struct thermal_cooling_device *); void thermal_zone_device_update(struct thermal_zone_device *, enum thermal_notify_event); +void thermal_zone_device_lock(struct thermal_zone_device *tz); +void thermal_zone_device_unlock(struct thermal_zone_device *tz); struct thermal_cooling_device *thermal_cooling_device_register(const char *, void *, const struct thermal_cooling_device_ops *);