From: Alex Yeo <alexyeo362@gmail.com>
To: "Guenter Roeck" <linux@roeck-us.net>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
Kenneth Chan <kenneth.t.chan@gmail.com>,
Hans de Goede <hansg@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-hwmon@vger.kernel.org
Subject: Re: [RFC PATCH v7] platform/x86: panasonic-laptop: add fan speed mode for newer models
Date: Wed, 22 Jul 2026 07:22:32 +0800 [thread overview]
Message-ID: <84b521b8-112b-4fed-ab82-e1e16d770e66@gmail.com> (raw)
In-Reply-To: <531e3c48-bb61-4741-8fe7-a2dbc213eb1e@roeck-us.net>
On 2026/07/20 10:41 PM, Guenter Roeck wrote:
> On 7/20/26 06:46, Ilpo Järvinen wrote:
>> On Sun, 19 Jul 2026, Alex Yeo wrote:
>
> ...
>
>>> diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/
>>> platform/x86/panasonic-laptop.c
>>> index b83113c26f88..2d67188de2a9 100644
>>> --- a/drivers/platform/x86/panasonic-laptop.c
>>> +++ b/drivers/platform/x86/panasonic-laptop.c
>>> @@ -119,6 +119,9 @@
>>> * - v0.1 start from toshiba_acpi driver written by John
>>> Belmonte
>>> */
>>> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>>> +
>>> +#include <linux/printk.h>
>>> #include <linux/acpi.h>
>>> #include <linux/backlight.h>
>>> #include <linux/bits.h>
>>> @@ -136,6 +139,14 @@
>>> #include <linux/types.h>
>>> #include <linux/uaccess.h>
>>> #include <acpi/video.h>
>>> +#include <linux/sysfs.h>
>>> +#include <linux/hwmon.h>
>>> +#include <linux/hwmon-sysfs.h>
>
> FWIW, I don't see why this is needed.
>
If you mean linux/hwmon-sysfs.h, I agree.
I will remove that in v8.
For the other includes:
>>> +#include <linux/sysfs.h>
this was previously missing
>>> +#include <linux/hwmon.h>
used this for registering the fan as a PWM fan on hwmon.
>
>>> struct pcc_acpi {
> ...
>>> + /*
>>> + * This mutex ensures that the hwmon and thermal functions
>>> + * for fan operations do not conflict as the PWM fan is
>>> + * exposed to both.
>>> + */
>>> + struct mutex pwm_fan_lock;
>
> Maybe ask why this additional lock is used instead of relying on
> (for hwmon attributes) and using (for thermal) the hwmon subsystem
> lock.
>
Both the hwmon and thermal devices share the same control path
(pcc_pwm_fan_speed_read and pcc_pwm_fan_speed_set). To prevent them from
executing concurrently and interleaving, I added pwm_fan_lock to
serialize access.
Reading and writing fan speed requires a multi-step ACPI transaction
(e.g., checking/setting manual mode first before accessing or setting
fan speed). This is because I rely on querying ACPI for the current
state instead of keeping state cached in the driver. Because of this,
the mutex is placed in the outer hwmon and thermal callbacks rather than
inside the low-level ACPI helper functions.
If there's a more appropriate way to synchronize this across both
interfaces (e.g. use hwmon_lock in place of a driver level mutex), I'd
be interested to hear it.
Thanks
next prev parent reply other threads:[~2026-07-21 23:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b687f9d8-a996-2f04-d803-e267cf140b57@linux.intel.com>
2026-06-25 11:50 ` [RFC PATCH v3] platform/x86: panasonic-laptop: add fan speed mode for newer models Alex Yeo
2026-06-25 12:04 ` sashiko-bot
2026-06-26 3:25 ` [RFC PATCH v4] " Alex Yeo
2026-06-26 3:34 ` sashiko-bot
2026-06-26 5:32 ` [RFC PATCH v5] " Alex Yeo
2026-06-26 5:47 ` sashiko-bot
2026-06-28 5:33 ` [RFC PATCH v6] " Alex Yeo
2026-07-03 12:11 ` Ilpo Järvinen
2026-07-18 18:57 ` [RFC PATCH v7] " Alex Yeo
2026-07-20 13:46 ` Ilpo Järvinen
2026-07-20 14:41 ` Guenter Roeck
2026-07-21 23:22 ` Alex Yeo [this message]
2026-07-22 0:00 ` Guenter Roeck
2026-07-21 22:10 ` Alex Yeo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84b521b8-112b-4fed-ab82-e1e16d770e66@gmail.com \
--to=alexyeo362@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kenneth.t.chan@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox