mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mark Pearson <mpearson-lenovo@squebb.ca>
Cc: ilpo.jarvinen@linux.intel.com,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: Support for V9 DYTC platform profiles
Date: Thu, 30 Jan 2025 17:25:47 +0100	[thread overview]
Message-ID: <5a12b6f5-c501-4c7f-b27b-c9e63fbcffa1@redhat.com> (raw)
In-Reply-To: <20250130154520.26469-1-mpearson-lenovo@squebb.ca>

Hi Mark,

On 30-Jan-25 4:45 PM, Mark Pearson wrote:
> Newer Thinkpad AMD platforms are using V9 DYTC and this changes the
> profiles used for PSC mode. Add support for this update.
> Tested on P14s G5 AMD
> 
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
>  drivers/platform/x86/thinkpad_acpi.c | 33 ++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 1fcb0f99695a..cae457bc0b07 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10319,6 +10319,10 @@ static struct ibm_struct proxsensor_driver_data = {
>  #define DYTC_MODE_PSC_BALANCE  5  /* Default mode aka balanced */
>  #define DYTC_MODE_PSC_PERFORM  7  /* High power mode aka performance */
>  
> +#define DYTC_MODE_PSCV9_LOWPOWER 1  /* Low power mode */
> +#define DYTC_MODE_PSCV9_BALANCE  3  /* Default mode aka balanced */
> +#define DYTC_MODE_PSCV9_PERFORM  4  /* High power mode aka performance */
> +
>  #define DYTC_ERR_MASK       0xF  /* Bits 0-3 in cmd result are the error result */
>  #define DYTC_ERR_SUCCESS      1  /* CMD completed successful */
>  
> @@ -10339,6 +10343,10 @@ static int dytc_capabilities;
>  static bool dytc_mmc_get_available;
>  static int profile_force;
>  
> +static int platform_psc_profile_lowpower = DYTC_MODE_PSC_LOWPOWER;
> +static int platform_psc_profile_balanced = DYTC_MODE_PSC_BALANCE;
> +static int platform_psc_profile_performance = DYTC_MODE_PSC_PERFORM;
> +
>  static int convert_dytc_to_profile(int funcmode, int dytcmode,
>  		enum platform_profile_option *profile)
>  {
> @@ -10360,19 +10368,14 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,
>  		}
>  		return 0;
>  	case DYTC_FUNCTION_PSC:
> -		switch (dytcmode) {
> -		case DYTC_MODE_PSC_LOWPOWER:
> +		if (dytcmode == platform_psc_profile_lowpower)
>  			*profile = PLATFORM_PROFILE_LOW_POWER;
> -			break;
> -		case DYTC_MODE_PSC_BALANCE:
> +		else if (dytcmode == platform_psc_profile_balanced)
>  			*profile =  PLATFORM_PROFILE_BALANCED;
> -			break;
> -		case DYTC_MODE_PSC_PERFORM:
> +		else if (dytcmode == platform_psc_profile_performance)
>  			*profile =  PLATFORM_PROFILE_PERFORMANCE;
> -			break;
> -		default: /* Unknown mode */
> +		else
>  			return -EINVAL;
> -		}
>  		return 0;

Maybe replace the removed '}' with an empty line instead of
removing the entire line?

Currently after your patch the new code looks like this:

			...
		else
			return -EINVAL;
		return 0;

which look a bit weird, personally I would prefer:

			...
		else
			return -EINVAL;

		return 0;

Otherwise this looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans





>  	case DYTC_FUNCTION_AMT:
>  		/* For now return balanced. It's the closest we have to 'auto' */
> @@ -10393,19 +10396,19 @@ static int convert_profile_to_dytc(enum platform_profile_option profile, int *pe
>  		if (dytc_capabilities & BIT(DYTC_FC_MMC))
>  			*perfmode = DYTC_MODE_MMC_LOWPOWER;
>  		else if (dytc_capabilities & BIT(DYTC_FC_PSC))
> -			*perfmode = DYTC_MODE_PSC_LOWPOWER;
> +			*perfmode = platform_psc_profile_lowpower;
>  		break;
>  	case PLATFORM_PROFILE_BALANCED:
>  		if (dytc_capabilities & BIT(DYTC_FC_MMC))
>  			*perfmode = DYTC_MODE_MMC_BALANCE;
>  		else if (dytc_capabilities & BIT(DYTC_FC_PSC))
> -			*perfmode = DYTC_MODE_PSC_BALANCE;
> +			*perfmode = platform_psc_profile_balanced;
>  		break;
>  	case PLATFORM_PROFILE_PERFORMANCE:
>  		if (dytc_capabilities & BIT(DYTC_FC_MMC))
>  			*perfmode = DYTC_MODE_MMC_PERFORM;
>  		else if (dytc_capabilities & BIT(DYTC_FC_PSC))
> -			*perfmode = DYTC_MODE_PSC_PERFORM;
> +			*perfmode = platform_psc_profile_performance;
>  		break;
>  	default: /* Unknown profile */
>  		return -EOPNOTSUPP;
> @@ -10599,6 +10602,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
>  	if (output & BIT(DYTC_QUERY_ENABLE_BIT))
>  		dytc_version = (output >> DYTC_QUERY_REV_BIT) & 0xF;
>  
> +	dbg_printk(TPACPI_DBG_INIT, "DYTC version %d\n", dytc_version);
>  	/* Check DYTC is enabled and supports mode setting */
>  	if (dytc_version < 5)
>  		return -ENODEV;
> @@ -10637,6 +10641,11 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
>  		}
>  	} else if (dytc_capabilities & BIT(DYTC_FC_PSC)) { /* PSC MODE */
>  		pr_debug("PSC is supported\n");
> +		if (dytc_version >= 9) { /* update profiles for DYTC 9 and up */
> +			platform_psc_profile_lowpower = DYTC_MODE_PSCV9_LOWPOWER;
> +			platform_psc_profile_balanced = DYTC_MODE_PSCV9_BALANCE;
> +			platform_psc_profile_performance = DYTC_MODE_PSCV9_PERFORM;
> +		}
>  	} else {
>  		dbg_printk(TPACPI_DBG_INIT, "No DYTC support available\n");
>  		return -ENODEV;


  reply	other threads:[~2025-01-30 16:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-30 15:45 Mark Pearson
2025-01-30 16:25 ` Hans de Goede [this message]
2025-01-30 16:35   ` Mark Pearson

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=5a12b6f5-c501-4c7f-b27b-c9e63fbcffa1@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®