[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D7SIOS9FABGO.1ZOTYZJ4PWMTA@gmail.com>
Date: Fri, 14 Feb 2025 17:21:00 -0500
From: "Kurt Borja" <kuurtb@...il.com>
To: "Andy Shevchenko" <andriy.shevchenko@...el.com>
Cc: <platform-driver-x86@...r.kernel.org>, Ilpo Järvinen
<ilpo.jarvinen@...ux.intel.com>, "Armin Wolf" <W_Armin@....de>, "Mario
Limonciello" <mario.limonciello@....com>, "Hans de Goede"
<hdegoede@...hat.com>, <Dell.Client.Kernel@...l.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v10 11/14] platform/x86: Split the alienware-wmi driver
Hi Andy,
On Tue Feb 11, 2025 at 2:04 PM -05, Andy Shevchenko wrote:
> On Tue, Feb 11, 2025 at 12:59:53PM -0500, Kurt Borja wrote:
>> On Tue Feb 11, 2025 at 11:56 AM -05, Andy Shevchenko wrote:
>> > On Fri, Feb 07, 2025 at 10:46:07AM -0500, Kurt Borja wrote:
>
> ...
>
>> >> obj-$(CONFIG_ALIENWARE_WMI) += alienware-wmi.o
>> >> alienware-wmi-objs := alienware-wmi-base.o
>> >> +alienware-wmi-y += alienware-wmi-legacy.o
>> >> +alienware-wmi-y += alienware-wmi-wmax.o
>> >
>> > Oh my... it's even inconsistent!
>>
>> Again, this is an already used pattern:
>
>> https://elixir.bootlin.com/linux/v6.14-rc2/source/drivers/platform/x86/dell/Makefile#L14
>>
>> I add configuration entries later. Is the order of the changes wrong? or
>> is it the entire approach? Do other modules here need a fix?
>
> Again, it doesn't mean it's correct.
>
> Maybe other modules also need that, I don't remember, but you may `git log
> --no-merges --author="Andy" --grep objs` to see changes I made in the past.
Sorry!
Everything made more sense after reading the docs and checking your
commits.
I submitted a patch fixing this. Thank you for pointing it out!
>
> ...
>
>> >> + if (!ret) {
>> >> + if (out_data == 0)
>> >> + return sysfs_emit(buf, "[disabled] s5 s5_s4\n");
>> >> + else if (out_data == 1)
>> >> + return sysfs_emit(buf, "disabled [s5] s5_s4\n");
>> >> + else if (out_data == 2)
>> >> + return sysfs_emit(buf, "disabled s5 [s5_s4]\n");
>> >
>> > The whole code inherited same issues like redundant 'else'. Please, refactor.
>>
>> This is not my code, so a separate patch would be needed.
>
> Okay!
>
> ...
>
>> >> + if (strcmp(buf, "disabled\n") == 0)
>> >> + args.arg = 0;
>> >> + else if (strcmp(buf, "s5\n") == 0)
>> >> + args.arg = 1;
>> >> + else
>> >> + args.arg = 2;
>> >
>> > sysfs_match_string()
>>
>> Same as above.
>
> Same as above :-)
>
> ...
>
>> >> + if ((code & WMAX_THERMAL_TABLE_MASK) == WMAX_THERMAL_TABLE_USTT &&
>> >> + (code & WMAX_THERMAL_MODE_MASK) <= THERMAL_MODE_USTT_LOW_POWER)
>> >> + return true;
>> >> +
>> >> + return false;
>> >
>> > return ...
>> >
>> > but if you wish, this one is okay.
>>
>> This was done for readibility. Also this would require a different
>> patch.
>
> No need, I'm fine with the current approach, just to show the alternatives.
>
> ...
>
>> >> + ret = wmax_thermal_information(priv->wdev, WMAX_OPERATION_SYS_DESCRIPTION,
>> >> + 0, (u32 *) &sys_desc);
>> >
>> > How do you guarantee an alignment? Yes, it might be good for the specific
>> > hardware, but in general this is broken code.
>>
>> This is a good question. I'm not really sure how to fix this tho. Is it
>> fine to just pass a __packed struct? Also this would require another
>> patch.
>
> Usual approach here is to use one of get_unaligned_le32(), get_unaligned_be32()
> depending on the byte ordering.
>
>> >> + if (ret < 0)
>> >> + return ret;
>
> ...
>
>> >> + set_bit(profile, choices);
>> >
>> > Do you need it to be atomic?
>>
>> I don't think so. `choices` belongs to this thread only.
>
> So, __set_bit() will suffice then.
For some reason I thought `set_bit` was the non-atomic one. This is good
to know.
>
> ...
>
>> >> +void __exit alienware_wmax_wmi_exit(void)
>> >> +{
>> >> + wmi_driver_unregister(&alienware_wmax_wmi_driver);
>> >> +}
>> >
>> > Why not moving these boilerplate to ->probe() and use module_wmi_driver()?
>>
>> This 3 files are a single module and it has two WMI drivers so this
>> can't be used.
>
> Can it be split to two separate modules then?
These two WMI drivers share a lot of features on old alienware models.
Hence why I decided to link them together. IMO this bit of boilerplate
is a fair tradeoff.
Thank you again for your feedback. I was completely unaware of some
things you pointed out. I will implement your suggestions soon.
--
~ Kurt
Powered by blists - more mailing lists