Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Tvrtko Ursulin <tursulin@ursulin.net>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/rps: convert rps interface to struct drm_device
Date: Thu, 23 Oct 2025 11:55:20 +0300	[thread overview]
Message-ID: <6b663098ad7777fbb87cc954d11b68b4f911d44e@intel.com> (raw)
In-Reply-To: <4b33f6ee-3e73-4b46-8638-811db6d8dfb8@ursulin.net>

On Thu, 23 Oct 2025, Tvrtko Ursulin <tursulin@ursulin.net> wrote:
> On 23/10/2025 08:45, Jani Nikula wrote:
>> Reduce the display dependency on struct drm_i915_private and i915_drv.h
>> by converting the rps interface to struct drm_device.
>> 
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>   .../gpu/drm/i915/display/intel_display_rps.c   | 12 +++++-------
>>   drivers/gpu/drm/i915/gt/intel_rps.c            | 18 ++++++++++++++++--
>>   drivers/gpu/drm/i915/gt/intel_rps.h            |  7 ++++---
>>   3 files changed, 25 insertions(+), 12 deletions(-)
>> 
>> diff --git a/drivers/gpu/drm/i915/display/intel_display_rps.c b/drivers/gpu/drm/i915/display/intel_display_rps.c
>> index 82ea1ec482e4..8bf0f8cb6574 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display_rps.c
>> +++ b/drivers/gpu/drm/i915/display/intel_display_rps.c
>> @@ -3,12 +3,14 @@
>>    * Copyright © 2023 Intel Corporation
>>    */
>>   
>> +#include <linux/dma-fence.h>
>> +
>>   #include <drm/drm_crtc.h>
>>   #include <drm/drm_vblank.h>
>>   
>>   #include "gt/intel_rps.h"
>> -#include "i915_drv.h"
>>   #include "i915_reg.h"
>> +#include "i915_request.h"
>>   #include "intel_display_core.h"
>>   #include "intel_display_irq.h"
>>   #include "intel_display_rps.h"
>> @@ -77,12 +79,10 @@ void intel_display_rps_mark_interactive(struct intel_display *display,
>>   					struct intel_atomic_state *state,
>>   					bool interactive)
>>   {
>> -	struct drm_i915_private *i915 = to_i915(display->drm);
>> -
>>   	if (state->rps_interactive == interactive)
>>   		return;
>>   
>> -	intel_rps_mark_interactive(&to_gt(i915)->rps, interactive);
>> +	intel_rps_mark_interactive(display->drm, interactive);
>>   	state->rps_interactive = interactive;
>>   }
>>   
>> @@ -102,7 +102,5 @@ void ilk_display_rps_disable(struct intel_display *display)
>>   
>>   void ilk_display_rps_irq_handler(struct intel_display *display)
>>   {
>> -	struct drm_i915_private *i915 = to_i915(display->drm);
>> -
>> -	gen5_rps_irq_handler(&to_gt(i915)->rps);
>> +	gen5_rps_irq_handler(display->drm);
>>   }
>> diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
>> index b01c837ab646..a2c502609d96 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_rps.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_rps.c
>> @@ -782,7 +782,7 @@ static void gen6_rps_set_thresholds(struct intel_rps *rps, u8 val)
>>   	mutex_unlock(&rps->power.mutex);
>>   }
>>   
>> -void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive)
>> +static void _intel_rps_mark_interactive(struct intel_rps *rps, bool interactive)
>>   {
>>   	GT_TRACE(rps_to_gt(rps), "mark interactive: %s\n",
>>   		 str_yes_no(interactive));
>> @@ -798,6 +798,13 @@ void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive)
>>   	mutex_unlock(&rps->power.mutex);
>>   }
>>   
>> +void intel_rps_mark_interactive(struct drm_device *drm, bool interactive)
>> +{
>> +	struct drm_i915_private *i915 = to_i915(drm);
>> +
>> +	_intel_rps_mark_interactive(&to_gt(i915)->rps, interactive);
>> +}
>> +
>>   static int gen6_rps_set(struct intel_rps *rps, u8 val)
>>   {
>>   	struct intel_uncore *uncore = rps_to_uncore(rps);
>> @@ -1953,7 +1960,7 @@ void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir)
>>   			"Command parser error, pm_iir 0x%08x\n", pm_iir);
>>   }
>>   
>> -void gen5_rps_irq_handler(struct intel_rps *rps)
>> +static void _gen5_rps_irq_handler(struct intel_rps *rps)
>>   {
>>   	struct intel_uncore *uncore = rps_to_uncore(rps);
>>   	u32 busy_up, busy_down, max_avg, min_avg;
>> @@ -1987,6 +1994,13 @@ void gen5_rps_irq_handler(struct intel_rps *rps)
>>   	spin_unlock(&mchdev_lock);
>>   }
>>   
>> +void gen5_rps_irq_handler(struct drm_device *drm)
>> +{
>> +	struct drm_i915_private *i915 = to_i915(drm);
>> +
>> +	_gen5_rps_irq_handler(&to_gt(i915)->rps);
>> +}
>> +
>>   void intel_rps_init_early(struct intel_rps *rps)
>>   {
>>   	mutex_init(&rps->lock);
>> diff --git a/drivers/gpu/drm/i915/gt/intel_rps.h b/drivers/gpu/drm/i915/gt/intel_rps.h
>> index 92fb01f5a452..c817a70fb3aa 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_rps.h
>> +++ b/drivers/gpu/drm/i915/gt/intel_rps.h
>> @@ -9,8 +9,9 @@
>>   #include "intel_rps_types.h"
>>   #include "i915_reg_defs.h"
>>   
>> -struct i915_request;
>> +struct drm_device;
>>   struct drm_printer;
>> +struct i915_request;
>>   
>>   #define GT_FREQUENCY_MULTIPLIER 50
>>   #define GEN9_FREQ_SCALER 3
>> @@ -33,7 +34,7 @@ u32 intel_rps_get_boost_frequency(struct intel_rps *rps);
>>   int intel_rps_set_boost_frequency(struct intel_rps *rps, u32 freq);
>>   
>>   int intel_rps_set(struct intel_rps *rps, u8 val);
>> -void intel_rps_mark_interactive(struct intel_rps *rps, bool interactive);
>> +void intel_rps_mark_interactive(struct drm_device *drm, bool interactive);
>
> This one breaks the design a bit since RPS is supposed to be per GT. On 
> the other hand intel_display_rps_mark_interactive is the only caller so 
> if it only wants to care about the primary GT thats probably okay.
>
> Presumably you don't want a for_each_gt in the display code either.
>
> Would it work to put a helper which did it for you somewhere one level 
> up from per gt (gt/) components? Sounds like for the end goal of proper 
> abstraction that would be the way. Getting rid of the #ifdef from 
> intel_display_rps.h and each driver would then implement the required 
> hooks to do what they want.

See [1]. We might add display->parent->rps, and call the hooks via
that. But even so, they'll need interfaces that are independent of gt,
so something like the patch at hand will be needed. I don't particularly
care if the functions on i915 core side are in gt/ or somewhere else.

BR,
Jani.


[1] https://lore.kernel.org/r/20251022085548.876150-2-jouni.hogander@intel.com

>
> Regards,
>
> Tvrtko
>>   int intel_gpu_freq(struct intel_rps *rps, int val);
>>   int intel_freq_opcode(struct intel_rps *rps, int val);
>> @@ -64,7 +65,7 @@ bool rps_read_mask_mmio(struct intel_rps *rps, i915_reg_t reg32, u32 mask);
>>   
>>   void gen6_rps_frequency_dump(struct intel_rps *rps, struct drm_printer *p);
>>   
>> -void gen5_rps_irq_handler(struct intel_rps *rps);
>> +void gen5_rps_irq_handler(struct drm_device *drm);
>>   void gen6_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
>>   void gen11_rps_irq_handler(struct intel_rps *rps, u32 pm_iir);
>>   
>

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-10-23  8:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23  7:45 [PATCH] drm/i915/rps: convert rps interface to struct drm_device Jani Nikula
2025-10-23  8:39 ` Tvrtko Ursulin
2025-10-23  8:55   ` Jani Nikula [this message]
2025-10-23  9:13     ` Tvrtko Ursulin
2025-10-23 12:00       ` Jani Nikula
2025-10-23  9:24 ` ✓ i915.CI.BAT: success for " Patchwork
2025-10-23 17:50 ` ✗ 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=6b663098ad7777fbb87cc954d11b68b4f911d44e@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    /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