On 23/10/2025 09:55, Jani Nikula wrote:
On Thu, 23 Oct 2025, Tvrtko Ursulin <[email protected]> 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 <[email protected]>
---
   .../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.

Okay, but from my point of view intel_rps_mark_interactive() should remain taking rps. This is the design of all components under gt/ and I do not think we should break it for this case. So for me a new helper somewhere one level above gt/ sounds like the way to go. That one is then perfectly fine to operate on the device. Pull out existing intel_display_rps_mark_interactive() out from display and rename to something like intel_display_mark_interactive(). As a first step. Xe can stub it out in compat headers rather than #ifdefs in the display code.

Regards,

Tvrtko
[1] https://lore.kernel.org/r/[email protected]


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);



Reply via email to