[PATCH 6/7] drm/i915/dmc: Extract is_event_handler()
Luca Coelho
luca at coelho.fi
Tue May 13 11:52:18 UTC 2025
On Mon, 2025-05-12 at 13:33 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
>
> Extract the helper to determine if the mmio reg+data are the
> event handler register (DMC_EVT_CTL) for a specific event.
> We'll have another use for this for runtime event handler
> enable/disable.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_dmc.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
> index 238f3cda400c..d758032d1af6 100644
> --- a/drivers/gpu/drm/i915/display/intel_dmc.c
> +++ b/drivers/gpu/drm/i915/display/intel_dmc.c
> @@ -564,6 +564,15 @@ static bool is_dmc_evt_htp_reg(struct intel_display *display,
> return offset >= start && offset < end;
> }
>
> +static bool is_event_handler(struct intel_display *display,
> + enum intel_dmc_id dmc_id,
> + unsigned int event_id,
> + i915_reg_t reg, u32 data)
> +{
> + return is_dmc_evt_ctl_reg(display, dmc_id, reg) &&
> + REG_FIELD_GET(DMC_EVT_CTL_EVENT_ID_MASK, data) == event_id;
> +}
> +
I'm not sure we're getting much with this change in terms of
readability. Are you really going to be using this many more times
later?
The amount of arguments you pass to this function for these simple
checks seems to add almost as much clutter as the original, no?
If the goal is really readability, maybe a macro would be better.
> /**
> * intel_dmc_block_pkgc() - block PKG C-state
> * @display: display instance
> @@ -622,12 +631,12 @@ static bool disable_dmc_evt(struct intel_display *display,
>
> /* also disable the flip queue event on the main DMC on TGL */
> if (display->platform.tigerlake &&
> - REG_FIELD_GET(DMC_EVT_CTL_EVENT_ID_MASK, data) == MAINDMC_EVENT_CLK_MSEC)
> + is_event_handler(display, dmc_id, MAINDMC_EVENT_CLK_MSEC, reg, data))
> return true;
>
> /* also disable the HRR event on the main DMC on TGL/ADLS */
> if ((display->platform.tigerlake || display->platform.alderlake_s) &&
> - REG_FIELD_GET(DMC_EVT_CTL_EVENT_ID_MASK, data) == MAINDMC_EVENT_VBLANK_A)
> + is_event_handler(display, dmc_id, MAINDMC_EVENT_VBLANK_A, reg, data))
> return true;
>
> return false;
--
Cheers,
Luca.
More information about the Intel-gfx
mailing list