From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Luke Jones <luke@ljones.dev>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-input@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
platform-driver-x86@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
corentin.chary@gmail.com, Mario Limonciello <superm1@kernel.org>
Subject: Re: [PATCH v6 3/9] platform/x86: asus-armoury: move existing tunings to asus-armoury module
Date: Wed, 30 Oct 2024 17:17:53 +0200 (EET) [thread overview]
Message-ID: <c6a37dc9-8dd6-19fc-f004-4818116d062e@linux.intel.com> (raw)
In-Reply-To: <19eefea4-d3b1-436a-8364-3f56a56b83cb@app.fastmail.com>
[-- Attachment #1: Type: text/plain, Size: 5506 bytes --]
On Wed, 30 Oct 2024, Luke Jones wrote:
> On Wed, 16 Oct 2024, at 4:54 PM, Ilpo Järvinen wrote:
> > On Mon, 30 Sep 2024, Luke D. Jones wrote:
> >
> >> The fw_attributes_class provides a much cleaner interface to all of the
> >> attributes introduced to asus-wmi. This patch moves all of these extra
> >> attributes over to fw_attributes_class, and shifts the bulk of these
> >> definitions to a new kernel module to reduce the clutter of asus-wmi
> >> with the intention of deprecating the asus-wmi attributes in future.
> >>
> >> The work applies only to WMI methods which don't have a clearly defined
> >> place within the sysfs and as a result ended up lumped together in
> >> /sys/devices/platform/asus-nb-wmi/ with no standard API.
> >>
> >> Where possible the fw attrs now implement defaults, min, max, scalar,
> >> choices, etc. As en example dgpu_disable becomes:
> >>
> >> /sys/class/firmware-attributes/asus-armoury/attributes/dgpu_disable/
> >> ├── current_value
> >> ├── display_name
> >> ├── possible_values
> >> └── type
> >>
> >> as do other attributes.
> >>
> >> The ppt_* based attributes are removed in this initial patch as the
> >> implementation is somewhat broken due to the WMI methods requiring a
> >> set of limits on the values accepted (which is not provided by WMI).
> >>
> >> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> >> ---
> >> drivers/platform/x86/Kconfig | 12 +
> >> drivers/platform/x86/Makefile | 1 +
> >> drivers/platform/x86/asus-armoury.c | 593 +++++++++++++++++++++
> >> drivers/platform/x86/asus-armoury.h | 146 +++++
> >> drivers/platform/x86/asus-wmi.c | 4 -
> >> include/linux/platform_data/x86/asus-wmi.h | 3 +
> >> 6 files changed, 755 insertions(+), 4 deletions(-)
> >> create mode 100644 drivers/platform/x86/asus-armoury.c
> >> create mode 100644 drivers/platform/x86/asus-armoury.h
> >>
> >> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> >> index 3875abba5a79..80ec8b45022d 100644
> >> --- a/drivers/platform/x86/Kconfig
> >> +++ b/drivers/platform/x86/Kconfig
> >> @@ -265,6 +265,18 @@ config ASUS_WIRELESS
> >> If you choose to compile this driver as a module the module will be
> >> called asus-wireless.
> >>
> >> +config ASUS_ARMOURY
> >> + tristate "ASUS Armoury driver"
> >> + depends on ASUS_WMI
> >> + select FW_ATTR_CLASS
> >> + help
> >> + Say Y here if you have a WMI aware Asus machine and would like to use the
> >> + firmware_attributes API to control various settings typically exposed in
> >> + the ASUS Armoury Crate application available on Windows.
> >> +
> >> + To compile this driver as a module, choose M here: the module will
> >> + be called asus-armoury.
> >> +
> >> config ASUS_WMI
> >> tristate "ASUS WMI Driver"
> >> depends on ACPI_WMI
> >> +static const struct class *fw_attr_class;
> >> +
> >> +struct asus_armoury_priv {
> >> + struct device *fw_attr_dev;
> >> + struct kset *fw_attr_kset;
> >> +
> >> + u32 mini_led_dev_id;
> >> + u32 gpu_mux_dev_id;
> >> +
> >> + struct mutex mutex;
> >
> > Please document what this protects.
>
> I don't fully understand if sysfs writes can be parallel or not, so i
> was making the assumption that they were and if so, we would want to
> prevent trying to write many WMI at once. If my understanding is lacking
> please correct me.
Yes, sysfs write handlers can run parallel so locking necessary.
I believe your mutex is okay solution for concurrency control but you need
to add a comment on what it protects. It could be also named like
wmi_mutex if it's for that only.
> >> +static int asus_fw_attr_add(void)
> >> +{
> >> + int err, i;
> >> +
> >> + err = fw_attributes_class_get(&fw_attr_class);
> >> + if (err)
> >> + return err;
> >> +
> >> + asus_armoury.fw_attr_dev =
> >> + device_create(fw_attr_class, NULL, MKDEV(0, 0), NULL, "%s", DRIVER_NAME);
> >
> > Don't split at = but after MKDEV() arg.
>
> This is another clang-format thing... I'll bite the bullet and manually
> format for rest of style suggestions in review.
If you want to attempt to keep using it, I suggest you try to look if you
can make small adjustment to its config file to solve its worst misses.
> >> +static void __exit asus_fw_exit(void)
> >> +{
> >> + mutex_lock(&asus_armoury.mutex);
> >
> > I'm not sure if this really helps anything. What are you trying to protect
> > against here with it?
>
> I'm not even sure anymore. Was supposed to be due to my assumptions
> about how sysfs writes work.
It doesn't help any. Either you'd deadlock when calling
sysfs_remove_file() (assuming its waiting for the handlers to finish) or
the write handler is still executed after unlock which equals not taking
mutex here at all. I don't see what it could protect with any success.
> One thing in particular is that the dgpu_disable and egpu_enable calls
> can take 20+ seconds to complete in acpi, and I don't want to make other
> WMI calls during that time - TBH I'm not sure of best way to handle it.
>
> >> + sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr);
> >> + kset_unregister(asus_armoury.fw_attr_kset);
> >> + device_destroy(fw_attr_class, MKDEV(0, 0));
> >> + fw_attributes_class_put();
> >> +
> >> + mutex_unlock(&asus_armoury.mutex);
> >> +}
--
i.
next prev parent reply other threads:[~2024-10-30 15:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 0:00 [PATCH v6 0/9] platform/x86: introduce asus-armoury driver Luke D. Jones
2024-09-30 0:00 ` [PATCH v6 1/9] platform/x86: asus-wmi: export symbols used for read/write WMI Luke D. Jones
2024-10-16 13:50 ` Ilpo Järvinen
2024-10-16 14:48 ` Luke Jones
2024-09-30 0:00 ` [PATCH v6 2/9] hid-asus: Add MODULE_IMPORT_NS(ASUS_WMI) Luke D. Jones
2024-10-16 13:58 ` Ilpo Järvinen
2024-09-30 0:00 ` [PATCH v6 3/9] platform/x86: asus-armoury: move existing tunings to asus-armoury module Luke D. Jones
2024-09-30 15:11 ` Mario Limonciello
2024-10-16 14:54 ` Ilpo Järvinen
2024-10-30 14:54 ` Luke Jones
2024-10-30 15:17 ` Ilpo Järvinen [this message]
2024-09-30 0:00 ` [PATCH v6 4/9] platform/x86: asus-armoury: add panel_hd_mode attribute Luke D. Jones
2024-09-30 0:00 ` [PATCH v6 5/9] platform/x86: asus-armoury: add the ppt_* and nv_* tuning knobs Luke D. Jones
2024-09-30 0:00 ` [PATCH v6 6/9] platform/x86: asus-armoury: add dgpu tgp control Luke D. Jones
2024-09-30 0:00 ` [PATCH v6 7/9] platform/x86: asus-armoury: add apu-mem control support Luke D. Jones
2024-09-30 0:00 ` [PATCH v6 8/9] platform/x86: asus-armoury: add core count control Luke D. Jones
2024-10-17 14:41 ` Ilpo Järvinen
2024-10-30 13:54 ` Luke Jones
2024-10-30 14:14 ` Ilpo Järvinen
2024-10-30 14:55 ` Luke Jones
2024-09-30 0:00 ` [PATCH v6 9/9] platform/x86: asus-wmi: deprecate bios features Luke D. Jones
2024-10-15 10:08 ` [PATCH v6 0/9] platform/x86: introduce asus-armoury driver Luke Jones
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=c6a37dc9-8dd6-19fc-f004-4818116d062e@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=superm1@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.