intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: <intel-gfx@lists.freedesktop.org>,
	<intel-xe@lists.freedesktop.org>, <imre.deak@intel.com>
Subject: Re: [PATCH 3/3] drm/i915/power: convert {SKL, ICL}_PW_CTL_IDX_TO_PG() macros to a function
Date: Wed, 25 Jun 2025 09:54:11 -0400	[thread overview]
Message-ID: <aFv_g_8vzoRa58nP@intel.com> (raw)
In-Reply-To: <3aa74825db0b900f93b94aa89d0242a354929b85.1750855148.git.jani.nikula@intel.com>

On Wed, Jun 25, 2025 at 03:39:38PM +0300, Jani Nikula wrote:
> Add pw_ctl_idx_to_pg() helper function to deduplicate the open-coded
> usage of the {SKL,ICL}_PW_CTL_IDX_TO_PG() macros.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  .../i915/display/intel_display_power_well.c   | 24 +++++++++----------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display_power_well.c b/drivers/gpu/drm/i915/display/intel_display_power_well.c
> index 9d60dfc4939d..4a876fa815bd 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_power_well.c
> +++ b/drivers/gpu/drm/i915/display/intel_display_power_well.c
> @@ -36,16 +36,15 @@
>  
>  /*
>   * PG0 is HW controlled, so doesn't have a corresponding power well control knob
> - * SKL_DISP_PW1_IDX..SKL_DISP_PW2_IDX -> PG1..PG2
> - */
> -#define  SKL_PW_CTL_IDX_TO_PG(pw_idx)		\
> -	((pw_idx) - SKL_PW_CTL_IDX_PW_1 + SKL_PG1)
> -/*
> - * PG0 is HW controlled, so doesn't have a corresponding power well control knob
> - * ICL_DISP_PW1_IDX..ICL_DISP_PW4_IDX -> PG1..PG4
> + *
> + * {ICL,SKL}_DISP_PW1_IDX..{ICL,SKL}_DISP_PW4_IDX -> PG1..PG4
>   */
> -#define  ICL_PW_CTL_IDX_TO_PG(pw_idx)		\
> -	((pw_idx) - ICL_PW_CTL_IDX_PW_1 + SKL_PG1)
> +static enum skl_power_gate pw_idx_to_pg(struct intel_display *display, int pw_idx)
> +{
> +	int pw1_idx = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_PW_1 : SKL_PW_CTL_IDX_PW_1;
> +
> +	return pw_idx - pw1_idx + SKL_PG1;

\o/ I hate macros! :)

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> +}
>  
>  struct i915_power_well_regs {
>  	i915_reg_t bios;
> @@ -363,8 +362,7 @@ static void hsw_power_well_enable(struct intel_display *display,
>  	if (power_well->desc->has_fuses) {
>  		enum skl_power_gate pg;
>  
> -		pg = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_TO_PG(pw_idx) :
> -						 SKL_PW_CTL_IDX_TO_PG(pw_idx);
> +		pg = pw_idx_to_pg(display, pw_idx);
>  
>  		/* Wa_16013190616:adlp */
>  		if (display->platform.alderlake_p && pg == SKL_PG1)
> @@ -388,8 +386,8 @@ static void hsw_power_well_enable(struct intel_display *display,
>  	if (power_well->desc->has_fuses) {
>  		enum skl_power_gate pg;
>  
> -		pg = DISPLAY_VER(display) >= 11 ? ICL_PW_CTL_IDX_TO_PG(pw_idx) :
> -						 SKL_PW_CTL_IDX_TO_PG(pw_idx);
> +		pg = pw_idx_to_pg(display, pw_idx);
> +
>  		gen9_wait_for_power_well_fuses(display, pg);
>  	}
>  
> -- 
> 2.39.5
> 

  reply	other threads:[~2025-06-25 13:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 12:39 [PATCH 0/3] drm/i915/power: power well register cleanups Jani Nikula
2025-06-25 12:39 ` [PATCH 1/3] drm/i915/power: move enum skl_power_gate under display Jani Nikula
2025-06-25 13:52   ` Rodrigo Vivi
2025-06-25 12:39 ` [PATCH 2/3] drm/i915/power: relocate {SKL,ICL}_PW_CTL_IDX_TO_PG() Jani Nikula
2025-06-25 13:52   ` [PATCH 2/3] drm/i915/power: relocate {SKL, ICL}_PW_CTL_IDX_TO_PG() Rodrigo Vivi
2025-06-25 12:39 ` [PATCH 3/3] drm/i915/power: convert {SKL, ICL}_PW_CTL_IDX_TO_PG() macros to a function Jani Nikula
2025-06-25 13:54   ` Rodrigo Vivi [this message]
2025-06-25 13:30 ` ✓ i915.CI.BAT: success for drm/i915/power: power well register cleanups Patchwork
2025-06-25 19:53 ` ✗ i915.CI.Full: failure " Patchwork

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=aFv_g_8vzoRa58nP@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).