From: Hans de Goede <hdegoede@redhat.com>
To: Andrew Kallmeyer <kallmeyeras@gmail.com>, Armin Wolf <W_Armin@gmx.de>
Cc: platform-driver-x86@vger.kernel.org, soyer@irl.hu
Subject: Re: [PATCH 2/2] platform/x86: Add driver for Yoga Tablet Mode switch
Date: Mon, 20 Mar 2023 15:41:29 +0100 [thread overview]
Message-ID: <9e54517c-d8e8-841b-e04f-8673cc0891d3@redhat.com> (raw)
In-Reply-To: <CAG4kvq-P=t08+=sjTNcLLgFrvhiyrdjpNyxEhMcV5rDOt3EtZw@mail.gmail.com>
Hi Andrew,
On 3/18/23 18:50, Andrew Kallmeyer wrote:
> On Fri, Mar 17, 2023 at 5:39 AM Armin Wolf <W_Armin@gmx.de> wrote:
>>
>> Am 16.03.23 um 10:00 schrieb Hans de Goede:
>>>
>>> So I really so no need to make the code needlessly complicated with 2 sub-drivers which then notify each other. Let keep things KISS and keep this as is, so for the next version only change
>>> the method_id from 0xab to 0x01.
>>
>> I think that using wmi_evaluate_method() is deprecated and we should try to minimize its usage whenever possible. As for the handling of the WMI GUIDs, i believe that
>> just using the first matching WMI device is not a stable solution. We simply do not know if Lenovo considers both WMI GUIDs singletons or not. This means they could
>> for example decide to have multiple independent data sources for tablet mode events. The chances for this are indeed small, but it will still create a problem for users
>> using such machines. By having two drivers and maybe a global notifier call chain, we would enable the driver to handle such "unlikely situations" correctly.
>>
>> This would also allow the driver to work on machines missing the WMI event GUID. In such a case, userspace could then just poll the data WMI GUID for input, but
>> this is just an idea.
>
> Hi Armin, would it work to add the second GUID to the existing
> wmi_driver wmi_device_id array? Then I could save the wmi_device in
> the driver data on probe. Later when I get the notification on the
> other GUID I would just call wmidev_evaluate_method on the saved
> pointer out of the private data.
>
> I would just need a way to distinguish the two wmi_device structs.
> Seems like the notifier setup wouldn't be needed and it could stay as
> one module for one feature.
>
> I have the code ready to mail a v2 patch series with the remove
> function added and the fixed method id and the input triggering on
> probe, but still using wmi_evaluate_method. Without having much kernel
> experience, I sort of agree with Hans that it would be best to be
> simpler and not have two modules for one feature, the notifier setup
> looks somewhat involved.
Yes the notifier setup is somewhat involved. I believe posting
the v2 which you have ready to post as is is fine.
> However if we can do something like the above
> idea, that doesn't seem to make it much more complicated to avoid the
> deprecated API and I can mail that out instead.
>
> So let me know what you think.
>
>>>> Drivers can be instantiated multiple times, and each time their probe callback is invoked,
>>>> and many older WMI drivers cannot do this, so the allowlist exists.
>>>> The section "State Container" in Documentation/driver-api/driver-model/design-patterns.rst
>>>> explains how to write drivers which can be instantiated multiple times.
>>>>
>>>> If your driver is not a singleton, i.e. it can safely be instantiated multiple times, then
>>>> you can add its WMI GUID to the allowlist.
>>> I'm not sure about adding this to the allowlist, using the new API is good (and nice and clean) but this is still expected to be a singleton.
>>
>> The allowlist is dealing with drivers not jet converted to the WMI bus model. The allowlist should ideally disappear once the conversion has been
>> completed, something which would become difficult if WMI drivers would continue to rely on the older GUID singleton behavior which is not compliant
>> with the ACPI WMI spec AFAIK. If we know that our WMI GUID is a singleton (which we do not), then we should handle this inside our driver, not inside
>> the WMI probing code.
>
> Would it not work to convert this driver to the WMI bus model now? I
> wasn't able to find anything about this bus model code.
Assuming that with "this driver" you mean the Yoga Tablet Mode switch
driver you are working on that already is a WMI BUS driver since
it is a wmi_driver which attached itself to a wmi_device.
The old way of doing things was with drivers which instantiated
their own platform_device-s and then attached to those. These
used the old specify a WMI object to operate on through GUID only
methods like wmi_evaluate_method() everywhere.
Regards,
Hans
next prev parent reply other threads:[~2023-03-20 14:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 21:43 [RFC PATCH] Add Lenovo Yoga Mode Control driver Gergo Koteles
2022-10-05 13:14 ` Hans de Goede
2022-10-05 15:39 ` Barnabás Pőcze
2023-03-10 4:17 ` [PATCH 0/2] platform/x86: Add driver for Yoga Tablet mode switch Andrew Kallmeyer
2023-03-10 4:17 ` [PATCH 1/2] platform/x86: Move ideapad ACPI helpers to a new header Andrew Kallmeyer
2023-03-10 4:17 ` [PATCH 2/2] platform/x86: Add driver for Yoga Tablet Mode switch Andrew Kallmeyer
2023-03-10 10:28 ` Armin Wolf
2023-03-15 3:37 ` Andrew Kallmeyer
2023-03-15 22:33 ` Armin Wolf
2023-03-15 22:39 ` Armin Wolf
2023-03-16 9:02 ` Hans de Goede
2023-03-17 9:43 ` Armin Wolf
2023-03-16 9:00 ` Hans de Goede
2023-03-17 12:39 ` Armin Wolf
2023-03-18 17:50 ` Andrew Kallmeyer
2023-03-18 17:55 ` Andrew Kallmeyer
2023-03-20 14:43 ` Hans de Goede
2023-03-20 14:41 ` Hans de Goede [this message]
2023-03-20 14:38 ` Hans de Goede
2023-03-21 1:05 ` Gergo Koteles
2023-03-21 2:14 ` Andrew Kallmeyer
2023-03-22 20:39 ` Gergo Koteles
2023-03-22 21:03 ` Andrew Kallmeyer
2023-03-22 21:38 ` Gergo Koteles
2023-03-21 9:13 ` Hans de Goede
2023-03-22 20:49 ` Gergo Koteles
2023-03-22 21:23 ` [RFC PATCH] Add Lenovo Yoga Mode Control driver Gergo Koteles
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=9e54517c-d8e8-841b-e04f-8673cc0891d3@redhat.com \
--to=hdegoede@redhat.com \
--cc=W_Armin@gmx.de \
--cc=kallmeyeras@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=soyer@irl.hu \
/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