From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: platform-driver-x86@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
ibm-acpi-devel@lists.sourceforge.net, mario.limonciello@amd.com,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: Add support for improved performance mode
Date: Thu, 9 Nov 2023 12:10:33 +0200 (EET) [thread overview]
Message-ID: <8b29ab8-fef4-8a60-e6c5-447f31f144a7@linux.intel.com> (raw)
In-Reply-To: <20231108162039.13737-1-mpearson-lenovo@squebb.ca>
On Wed, 8 Nov 2023, Mark Pearson wrote:
> Some new Thinkpads have a new improved performance mode available.
> Add support to make this mode usable.
>
> To avoid having to create a new profile, just use the improved performance
> mode in place of the existing performance mode, when available.
>
> Tested on T14 AMD G4 AMD.
>
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
> drivers/platform/x86/thinkpad_acpi.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index ad460417f901..eba701ab340e 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10136,6 +10136,7 @@ static struct ibm_struct proxsensor_driver_data = {
>
> #define DYTC_CMD_SET 1 /* To enable/disable IC function mode */
> #define DYTC_CMD_MMC_GET 8 /* To get current MMC function and mode */
> +#define DYTC_CMD_UP_CAP 0xA /* To get Ultra-performance capability */
> #define DYTC_CMD_RESET 0x1ff /* To reset back to default */
>
> #define DYTC_CMD_FUNC_CAP 3 /* To get DYTC capabilities */
> @@ -10152,6 +10153,7 @@ static struct ibm_struct proxsensor_driver_data = {
>
> #define DYTC_FUNCTION_STD 0 /* Function = 0, standard mode */
> #define DYTC_FUNCTION_CQL 1 /* Function = 1, lap mode */
> +#define DYTC_FUNCTION_TMS 9 /* Function = 9, TMS mode */
> #define DYTC_FUNCTION_MMC 11 /* Function = 11, MMC mode */
> #define DYTC_FUNCTION_PSC 13 /* Function = 13, PSC mode */
> #define DYTC_FUNCTION_AMT 15 /* Function = 15, AMT mode */
> @@ -10163,11 +10165,14 @@ static struct ibm_struct proxsensor_driver_data = {
> #define DYTC_MODE_MMC_LOWPOWER 3 /* Low power mode */
> #define DYTC_MODE_MMC_BALANCE 0xF /* Default mode aka balanced */
> #define DYTC_MODE_MMC_DEFAULT 0 /* Default mode from MMC_GET, aka balanced */
> +#define DYTC_NOMODE 0xF /* When Function does not have a mode */
>
> #define DYTC_MODE_PSC_LOWPOWER 3 /* Low power mode */
> #define DYTC_MODE_PSC_BALANCE 5 /* Default mode aka balanced */
> #define DYTC_MODE_PSC_PERFORM 7 /* High power mode aka performance */
>
> +#define DYTC_UP_SUPPORT_BIT 8 /* Bit 8 - 1 = supported, 0 = not */
It would be preferrable to comment what is supported rather than have a
comment like above which isn't particularly helpful.
> #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
> #define DYTC_ERR_SUCCESS 1 /* CMD completed successful */
>
> @@ -10185,6 +10190,7 @@ static enum platform_profile_option dytc_current_profile;
> static atomic_t dytc_ignore_event = ATOMIC_INIT(0);
> static DEFINE_MUTEX(dytc_mutex);
> static int dytc_capabilities;
> +static bool dytc_ultraperf_cap; /* ultra performance capable */
> static bool dytc_mmc_get_available;
> static int profile_force;
>
> @@ -10355,6 +10361,17 @@ static int dytc_profile_set(struct platform_profile_handler *pprof,
> if (err)
> goto unlock;
>
> + /* Set TMS mode appropriately (enable for performance), if available */
> + if (dytc_ultraperf_cap) {
> + int cmd;
> +
> + cmd = DYTC_SET_COMMAND(DYTC_FUNCTION_TMS, DYTC_NOMODE,
> + profile == PLATFORM_PROFILE_PERFORMANCE);
> + err = dytc_command(cmd, &output);
> + if (err)
> + return err;
> + }
> +
> if (dytc_capabilities & BIT(DYTC_FC_MMC)) {
> if (profile == PLATFORM_PROFILE_BALANCED) {
> /*
> @@ -10429,6 +10446,7 @@ static struct platform_profile_handler dytc_profile = {
> static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
> {
> int err, output;
> + int cmd;
>
> /* Setup supported modes */
> set_bit(PLATFORM_PROFILE_LOW_POWER, dytc_profile.choices);
> @@ -10484,6 +10502,16 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
> dbg_printk(TPACPI_DBG_INIT, "No DYTC support available\n");
> return -ENODEV;
> }
> + err = dytc_command(DYTC_CMD_UP_CAP, &output);
> + dytc_ultraperf_cap = output & BIT(DYTC_UP_SUPPORT_BIT) ? true : false;
It would be better to put this BIT() into the define itself and remove
_BIT from the name because it doesn't really add that much information.
Since you're assigning to bool, ? true : false construct is not required
but implicit cast will handle it for you. So in the end, this line would
be:
dytc_ultraperf_cap = output & DYTC_UP_SUPPORT;
Looking into the driver a bit more, there are a few other defines which
could also move BIT() from the code into defines. Please tell if you're
going to look at those because if not, I might try to make the patches.
> + if (dytc_ultraperf_cap) {
> + pr_debug("TMS is supported\n");
> + /* Disable TMS by default - only use with performance mode */
> + cmd = DYTC_SET_COMMAND(DYTC_FUNCTION_TMS, DYTC_NOMODE, 0);
> + err = dytc_command(cmd, &output);
> + if (err)
> + return err;
> + }
>
> dbg_printk(TPACPI_DBG_INIT,
> "DYTC version %d: thermal mode available\n", dytc_version);
>
--
i.
next prev parent reply other threads:[~2023-11-09 10:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 16:20 Mark Pearson
2023-11-09 10:10 ` Ilpo Järvinen [this message]
2023-11-09 17:57 ` Mark Pearson
2023-11-10 12:37 ` Ilpo Järvinen
2023-11-13 14:00 ` Mark Pearson
2023-11-13 14:24 ` Ilpo Järvinen
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=8b29ab8-fef4-8a60-e6c5-447f31f144a7@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mpearson-lenovo@squebb.ca \
--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
all inboxes | Powered by JetHome®