From: Kurt Borja <kuurtb@gmail.com>
To: ilpo.jarvinen@linux.intel.com
Cc: Dell.Client.Kernel@dell.com, hdegoede@redhat.com,
kuurtb@gmail.com, linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v2] alienware-wmi: Dell AWCC platform_profile support
Date: Tue, 8 Oct 2024 16:34:18 -0300 [thread overview]
Message-ID: <20241008193418.34573-1-kuurtb@gmail.com> (raw)
In-Reply-To: <4c2c29ad-924e-876b-70c3-256f4865fc88@linux.intel.com>
Removed.
> > +static int platform_profile_get(struct platform_profile_handler *pprof,
> > + enum platform_profile_option *profile)
> > +{
> > + acpi_status status;
> > + u32 in_args = 0x0B;
>
> Use a named define instead of a magic number.
>
Done
> > + u32 out_data;
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
> > + WMAX_METHOD_THERMAL_INFORMATION, (u32 *) &out_data);
>
> Casting to the same type??
>
> Also, alienware_wmax_command() inputs int * which makes the cast look even
> more odd?!?
>
> I can see there are pre-existing bogus (u32 *) casts too which would be
> nice to clean up in another patch.
>
Yes I thought it was odd but added them just in case. I can submit a
patch cleaning those up after this one.
> > +
> > + if (ACPI_FAILURE(status) || out_data < 0)
>
> u32 cannot be < 0??
>
> Is this an indication of a problem in the error handling?
>
Yes it was, thank you for catching it.
> > + return -EOPNOTSUPP;
> > +
> > + switch (out_data) {
> > + case WMAX_THERMAL_LOW_POWER:
> > + *profile = PLATFORM_PROFILE_LOW_POWER;
> > + break;
> > + case WMAX_THERMAL_QUIET:
> > + *profile = PLATFORM_PROFILE_QUIET;
> > + break;
> > + case WMAX_THERMAL_BALANCED:
> > + *profile = PLATFORM_PROFILE_BALANCED;
> > + break;
> > + case WMAX_THERMAL_BALANCED_PERFORMANCE:
> > + *profile = PLATFORM_PROFILE_BALANCED_PERFORMANCE;
> > + break;
> > + case WMAX_THERMAL_PERFORMANCE:
> > + case WMAX_THERMAL_GMODE:
> > + *profile = PLATFORM_PROFILE_PERFORMANCE;
> > + break;
> > + default:
> > + return -ENODATA;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +#define SET_MASK(prof) ((prof << 8) | 1)
>
> Name these with two defines. One define for naming that magic 1 and
> another for the profile field, use GENMASK() + FIELD_PREP() for it.
>
> Also, there's no need for this to be macro so change it into a static
> function.
>
Done.
> > +static int platform_profile_set(struct platform_profile_handler *pprof,
> > + enum platform_profile_option profile)
> > +{
> > + acpi_status status;
> > + u32 in_args;
> > + u32 out_data;
> > +
> > + switch (profile) {
> > + case PLATFORM_PROFILE_LOW_POWER:
> > + in_args = SET_MASK(WMAX_THERMAL_LOW_POWER);
> > + break;
> > + case PLATFORM_PROFILE_QUIET:
> > + in_args = SET_MASK(WMAX_THERMAL_QUIET);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED:
> > + in_args = SET_MASK(WMAX_THERMAL_BALANCED);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
> > + in_args = SET_MASK(WMAX_THERMAL_BALANCED_PERFORMANCE);
> > + break;
> > + case PLATFORM_PROFILE_PERFORMANCE:
> > + in_args = SET_MASK(WMAX_THERMAL_PERFORMANCE);
> > + break;
> > + default:
> > + return -EOPNOTSUPP;
> > + }
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
> > + WMAX_METHOD_THERMAL_CONTROL, (u32 *) &out_data);
>
> Cast to same type.
>
> > +
> > + if (ACPI_FAILURE(status) || out_data < 0)
>
> u32 cannot be < 0.
>
> > + return -EOPNOTSUPP;
> > +
> > + return 0;
> > +}
> > +
> > +static int gmode_platform_profile_set(struct platform_profile_handler *pprof,
> > + enum platform_profile_option profile)
> > +{
> > + acpi_status status;
> > + u32 in_args;
> > + u32 out_data;
> > +
> > + switch (profile) {
> > + case PLATFORM_PROFILE_LOW_POWER:
> > + in_args = SET_MASK(WMAX_THERMAL_LOW_POWER);
> > + break;
> > + case PLATFORM_PROFILE_QUIET:
> > + in_args = SET_MASK(WMAX_THERMAL_QUIET);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED:
> > + in_args = SET_MASK(WMAX_THERMAL_BALANCED);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
> > + in_args = SET_MASK(WMAX_THERMAL_BALANCED_PERFORMANCE);
> > + break;
> > + case PLATFORM_PROFILE_PERFORMANCE:
> > + in_args = SET_MASK(WMAX_THERMAL_GMODE);
> > + break;
> > + default:
> > + return -EOPNOTSUPP;
> > + }
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
>
> > + WMAX_METHOD_THERMAL_CONTROL, (u32 *) &out_data);
> > + if (ACPI_FAILURE(status) || out_data < 0)
>
> The same two issues here with the types.
>
> > + return -EOPNOTSUPP;
> > +
> > + return 0;
> > +}
> > +
> > +static int create_platform_profile(void)
> > +{
> > + pp_handler.profile_get = platform_profile_get;
> > +
> > + if (quirks->gmode > 0)
> > + pp_handler.profile_set = gmode_platform_profile_set;
> > + else
> > + pp_handler.profile_set = platform_profile_set;
> > +
> > + set_bit(PLATFORM_PROFILE_LOW_POWER, pp_handler.choices);
> > + set_bit(PLATFORM_PROFILE_QUIET, pp_handler.choices);
> > + set_bit(PLATFORM_PROFILE_BALANCED, pp_handler.choices);
> > + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, pp_handler.choices);
> > + set_bit(PLATFORM_PROFILE_PERFORMANCE, pp_handler.choices);
> > +
> > + return platform_profile_register(&pp_handler);
> > +}
> > +
> > static int __init alienware_wmi_init(void)
> > {
> > int ret;
> > @@ -807,6 +987,12 @@ static int __init alienware_wmi_init(void)
> > goto fail_prep_deepsleep;
> > }
> >
> > + if (quirks->thermal > 0) {
> > + ret = create_platform_profile();
> > + if (ret)
> > + goto fail_prep_thermal_profile;
> > + }
> > +
> > ret = alienware_zone_init(platform_device);
> > if (ret)
> > goto fail_prep_zones;
> > @@ -817,6 +1003,7 @@ static int __init alienware_wmi_init(void)
> > alienware_zone_exit(platform_device);
> > fail_prep_deepsleep:
> > fail_prep_amplifier:
> > +fail_prep_thermal_profile:
> > fail_prep_hdmi:
> > platform_device_del(platform_device);
> > fail_platform_device2:
> > @@ -836,6 +1023,7 @@ static void __exit alienware_wmi_exit(void)
> > remove_hdmi(platform_device);
> > platform_device_unregister(platform_device);
> > platform_driver_unregister(&platform_driver);
> > + platform_profile_remove();
>
> IIRC, I once checked that this will lead to a crash if it wasn't created
> first (which in your driver isn't always the case).
>
Fixed.
> --
> i.
Thank you for your feedback. I will submit v3 with the corrections soon.
Kurt
next prev parent reply other threads:[~2024-10-08 19:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 9:33 [PATCH] Dell AWCC platform_profile support Kurt Borja
2024-10-07 12:24 ` Armin Wolf
2024-10-07 17:24 ` Kurt Borja
2024-10-08 4:42 ` [PATCH v2] alienware-wmi: " Kurt Borja
2024-10-08 10:18 ` Ilpo Järvinen
2024-10-08 19:34 ` Kurt Borja [this message]
2024-10-08 19:37 ` [PATCH] " Kurt Borja
2024-10-08 20:04 ` Kurt Borja
2024-10-08 19:56 ` [PATCH v3] " Kurt Borja
2024-10-09 8:42 ` Armin Wolf
2024-10-09 14:48 ` Kurt Borja
2024-10-09 15:48 ` Armin Wolf
2024-10-09 8:56 ` Ilpo Järvinen
2024-10-09 15:39 ` Kurt Borja
2024-10-10 3:44 ` kernel test robot
2024-10-10 9:46 ` Ilpo Järvinen
2024-10-10 18:39 ` Kurt Borja
2024-10-15 1:35 ` kernel test robot
2024-10-11 6:40 ` [PATCH 0/4] " Kurt Borja
2024-10-11 6:43 ` [PATCH v4 " Kurt Borja
2024-10-11 6:46 ` [PATCH v4 1/4] alienware-wmi: fixed indentation and clean up Kurt Borja
2024-10-11 11:04 ` Ilpo Järvinen
2024-10-12 1:57 ` Kurt Borja
2024-10-11 6:47 ` [PATCH v4 2/4] alienware-wmi: alienware_wmax_command() is now input size agnostic Kurt Borja
2024-10-11 11:07 ` Ilpo Järvinen
2024-10-11 6:47 ` [PATCH v4 3/4] alienware-wmi: added platform profile support Kurt Borja
2024-10-11 6:48 ` [PATCH v4 4/4] alienware-wmi: WMAX interface documentation Kurt Borja
2024-10-11 11:11 ` Ilpo Järvinen
2024-10-12 1:58 ` [PATCH v5 0/4] Dell AWCC platform_profile support Kurt Borja
2024-10-12 2:01 ` [PATCH v5 1/4] alienware-wmi: fixed indentation and clean up Kurt Borja
2024-10-14 16:26 ` Armin Wolf
2024-10-15 2:12 ` Kurt Borja
2024-10-12 2:01 ` [PATCH v5 2/4] alienware-wmi: alienware_wmax_command() is now input size agnostic Kurt Borja
2024-10-14 16:30 ` Armin Wolf
2024-10-15 2:14 ` Kurt Borja
2024-10-12 2:02 ` [PATCH v5 3/4] alienware-wmi: added platform profile support Kurt Borja
2024-10-14 16:40 ` Armin Wolf
2024-10-15 2:22 ` Kurt Borja
2024-10-15 8:20 ` Ilpo Järvinen
2024-10-12 2:03 ` [PATCH v5 4/4] alienware-wmi: WMAX interface documentation Kurt Borja
2024-10-14 17:10 ` Armin Wolf
2024-10-15 2:26 ` Kurt Borja
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=20241008193418.34573-1-kuurtb@gmail.com \
--to=kuurtb@gmail.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--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