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 v3] alienware-wmi: Dell AWCC platform_profile support
Date: Wed, 9 Oct 2024 12:39:29 -0300 [thread overview]
Message-ID: <20241009153929.11344-1-kuurtb@gmail.com> (raw)
In-Reply-To: <0b74d43f-ef23-cd6e-19e5-212432f8b95e@linux.intel.com>
Ok.
> > +#define PROFILE_ACTIVATE BIT(0)
>
> Add driver specific prefix to the defines please.
>
Ok.
> > +
> > +static u32 profile_to_wmax_arg(enum WMAX_THERMAL_PROFILE prof)
> > +{
> > + return FIELD_PREP(PROFILE_MASK, prof) | PROFILE_ACTIVATE;
> > +}
> > +
> > +static int thermal_profile_get(struct platform_profile_handler *pprof,
> > + enum platform_profile_option *profile)
> > +{
> > + acpi_status status;
> > + u32 in_args = WMAX_ARG_GET_CURRENT_PROF;
> > + u32 out_data;
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
> > + WMAX_METHOD_THERMAL_INFORMATION, &out_data);
>
> Are you sure you want to keep out_data as u32? I'm not very happy how
> alienware_wmax_command() takes int * but all callers seem to prefer u32 *
> (or pass NULL).
>
I don't have the old WMAX interface but the new one specifies an [out]
uint32 argument for all methods, I guess it's the same for the old one.
> Should the out_data parameter for alienware_wmax_command()
> be u32 * or int *?
I'd say we go with u32 * for everything to resemble as much as possible
the WMAX interface description. That way there won't be confusion in the
future.
I will name 0xFFFFFFFF appropriately.
> In general, if you find something that doesn't make sense, it often just
> is an indication that some cleanup is in order. We're more than happy to
> consider such patches along with the feature patches as then things are
> moving into the correct direction even if the progress would be slow.
All right. I will keep it in mind.
I will send a clean up patch together with the split Armin requested
together with v4.
> > + if (ACPI_FAILURE(status))
> > + return -EOPNOTSUPP;
> > +
> > + if (out_data == 0xFFFFFFFF)
>
> This constant too should be named if the data really is u32 and not a
> negative error code in which case I'd be fine with < 0 (without naming
> the error code) like in the original but it would need int as the type for
> the compare to work.
>
> > + return -EBADRQC;
> > +
> > + 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;
> > +}
> > +
> > +static int thermal_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 = profile_to_wmax_arg(WMAX_THERMAL_LOW_POWER);
> > + break;
> > + case PLATFORM_PROFILE_QUIET:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_QUIET);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED_PERFORMANCE);
> > + break;
> > + case PLATFORM_PROFILE_PERFORMANCE:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_PERFORMANCE);
> > + break;
> > + default:
> > + return -EOPNOTSUPP;
> > + }
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
> > + WMAX_METHOD_THERMAL_CONTROL, &out_data);
> > +
> > + if (ACPI_FAILURE(status))
> > + return -EOPNOTSUPP;
> > +
> > + if (out_data == 0xFFFFFFFF)
>
> Ditto.
>
> > + return -EBADRQC;
> > +
> > + return 0;
> > +}
> > +
> > +static int gmode_thermal_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 = profile_to_wmax_arg(WMAX_THERMAL_LOW_POWER);
> > + break;
> > + case PLATFORM_PROFILE_QUIET:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_QUIET);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED);
> > + break;
> > + case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_BALANCED_PERFORMANCE);
> > + break;
> > + case PLATFORM_PROFILE_PERFORMANCE:
> > + in_args = profile_to_wmax_arg(WMAX_THERMAL_GMODE);
> > + break;
> > + default:
> > + return -EOPNOTSUPP;
> > + }
> > +
> > + status = alienware_wmax_command(&in_args, sizeof(in_args),
> > + WMAX_METHOD_THERMAL_CONTROL, &out_data);
> > +
> > + if (ACPI_FAILURE(status))
> > + return -EOPNOTSUPP;
> > +
> > + if (out_data == 0xFFFFFFFF)
>
> Ditto.
>
> --
> i.
>
Thank you for your feedback!
Kurt
> > + return -EBADRQC;
> > +
> > + return 0;
> > +}
> > +
> > +static int create_thermal_profile(void)
> > +{
> > + pp_handler.profile_get = thermal_profile_get;
> > +
> > + if (quirks->gmode > 0)
> > + pp_handler.profile_set = gmode_thermal_profile_set;
> > + else
> > + pp_handler.profile_set = thermal_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 void remove_thermal_profile(void)
> > +{
> > + if (quirks->thermal > 0)
> > + platform_profile_remove();
> > +}
> > +
> > static int __init alienware_wmi_init(void)
> > {
> > int ret;
> > @@ -807,6 +1011,12 @@ static int __init alienware_wmi_init(void)
> > goto fail_prep_deepsleep;
> > }
> >
> > + if (quirks->thermal > 0) {
> > + ret = create_thermal_profile();
> > + if (ret)
> > + goto fail_prep_thermal_profile;
> > + }
> > +
> > ret = alienware_zone_init(platform_device);
> > if (ret)
> > goto fail_prep_zones;
> > @@ -817,6 +1027,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:
> > @@ -834,6 +1045,7 @@ static void __exit alienware_wmi_exit(void)
> > if (platform_device) {
> > alienware_zone_exit(platform_device);
> > remove_hdmi(platform_device);
> > + remove_thermal_profile();
> > platform_device_unregister(platform_device);
> > platform_driver_unregister(&platform_driver);
> > }
> >
next prev parent reply other threads:[~2024-10-09 15:39 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
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 [this message]
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=20241009153929.11344-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