]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/rps: call RPS functions via the parent interface
authorJani Nikula <jani.nikula@intel.com>
Mon, 17 Nov 2025 09:16:14 +0000 (11:16 +0200)
committerJani Nikula <jani.nikula@intel.com>
Wed, 19 Nov 2025 17:33:43 +0000 (19:33 +0200)
Add struct intel_display_rps_interface to the display parent interface,
and call the RPS functions through it. The RPS interface is optional.

v2: s/boost/boost_if_not_started/ and keep comment in caller (Ville)

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/6a6c4420d9f2d9a545ee6df4cad5fdc32a86636b.1763370931.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_display_rps.c
drivers/gpu/drm/i915/display/intel_parent.c
drivers/gpu/drm/i915/display/intel_parent.h
drivers/gpu/drm/i915/gt/intel_rps.c
drivers/gpu/drm/i915/gt/intel_rps.h
drivers/gpu/drm/i915/i915_driver.c
include/drm/intel/display_parent_interface.h

index b6720f7c09d9afbd6b12853ce2fefa9719a32084..d639d9152bf5bd89ae96246b9db8ff1e80f52365 100644 (file)
@@ -3,16 +3,18 @@
  * 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"
 #include "intel_display_types.h"
+#include "intel_parent.h"
 
 struct wait_rps_boost {
        struct wait_queue_entry wait;
@@ -25,15 +27,15 @@ static int do_rps_boost(struct wait_queue_entry *_wait,
                        unsigned mode, int sync, void *key)
 {
        struct wait_rps_boost *wait = container_of(_wait, typeof(*wait), wait);
-       struct i915_request *rq = to_request(wait->fence);
+       struct intel_display *display = to_intel_display(wait->crtc->dev);
 
        /*
         * If we missed the vblank, but the request is already running it
         * is reasonable to assume that it will complete before the next
-        * vblank without our intervention, so leave RPS alone.
+        * vblank without our intervention, so leave RPS alone if not started.
         */
-       if (!i915_request_started(rq))
-               intel_rps_boost(rq);
+       intel_parent_rps_boost_if_not_started(display, wait->fence);
+
        dma_fence_put(wait->fence);
 
        drm_crtc_vblank_put(wait->crtc);
@@ -49,6 +51,9 @@ void intel_display_rps_boost_after_vblank(struct drm_crtc *crtc,
        struct intel_display *display = to_intel_display(crtc->dev);
        struct wait_rps_boost *wait;
 
+       if (!intel_parent_rps_available(display))
+               return;
+
        if (!dma_fence_is_i915(fence))
                return;
 
@@ -77,12 +82,14 @@ 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 (!intel_parent_rps_available(display))
+               return;
 
        if (state->rps_interactive == interactive)
                return;
 
-       intel_rps_mark_interactive(&to_gt(i915)->rps, interactive);
+       intel_parent_rps_mark_interactive(display, interactive);
+
        state->rps_interactive = interactive;
 }
 
@@ -102,7 +109,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);
+       intel_parent_rps_ilk_irq_handler(display);
 }
index 535065e572134be0d17a0197dedb404c927b592c..6c131196718e8bf9eadd24c133022ae98283aef8 100644 (file)
@@ -32,6 +32,29 @@ void intel_parent_irq_synchronize(struct intel_display *display)
        display->parent->irq->synchronize(display->drm);
 }
 
+bool intel_parent_rps_available(struct intel_display *display)
+{
+       return display->parent->rps;
+}
+
+void intel_parent_rps_boost_if_not_started(struct intel_display *display, struct dma_fence *fence)
+{
+       if (display->parent->rps)
+               display->parent->rps->boost_if_not_started(fence);
+}
+
+void intel_parent_rps_mark_interactive(struct intel_display *display, bool interactive)
+{
+       if (display->parent->rps)
+               display->parent->rps->mark_interactive(display->drm, interactive);
+}
+
+void intel_parent_rps_ilk_irq_handler(struct intel_display *display)
+{
+       if (display->parent->rps)
+               display->parent->rps->ilk_irq_handler(display->drm);
+}
+
 bool intel_parent_vgpu_active(struct intel_display *display)
 {
        return display->parent->vgpu_active && display->parent->vgpu_active(display->drm);
index 04320d9377777d3d8c175f0dae75b923dee3b46d..12cfbea95aa1a83b13704d1a4df4f9e871ba6d97 100644 (file)
@@ -6,11 +6,17 @@
 
 #include <linux/types.h>
 
+struct dma_fence;
 struct intel_display;
 
 bool intel_parent_irq_enabled(struct intel_display *display);
 void intel_parent_irq_synchronize(struct intel_display *display);
 
+bool intel_parent_rps_available(struct intel_display *display);
+void intel_parent_rps_boost_if_not_started(struct intel_display *display, struct dma_fence *fence);
+void intel_parent_rps_mark_interactive(struct intel_display *display, bool interactive);
+void intel_parent_rps_ilk_irq_handler(struct intel_display *display);
+
 bool intel_parent_vgpu_active(struct intel_display *display);
 
 bool intel_parent_has_fenced_regions(struct intel_display *display);
index b01c837ab646aa0ecf4e8f7b30745520b3c1117f..c42a1ee42b58aa0ca1dfe5f3f00a370521be6a71 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/string_helpers.h>
 
 #include <drm/intel/i915_drm.h>
+#include <drm/intel/display_parent_interface.h>
 
 #include "display/intel_display_rps.h"
 #include "display/vlv_clock.h"
@@ -2914,6 +2915,34 @@ bool i915_gpu_turbo_disable(void)
 }
 EXPORT_SYMBOL_GPL(i915_gpu_turbo_disable);
 
+static void boost_if_not_started(struct dma_fence *fence)
+{
+       struct i915_request *rq = to_request(fence);
+
+       if (!i915_request_started(rq))
+               intel_rps_boost(rq);
+}
+
+static void 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 void ilk_irq_handler(struct drm_device *drm)
+{
+       struct drm_i915_private *i915 = to_i915(drm);
+
+       gen5_rps_irq_handler(&to_gt(i915)->rps);
+}
+
+const struct intel_display_rps_interface i915_display_rps_interface = {
+       .boost_if_not_started = boost_if_not_started,
+       .mark_interactive = mark_interactive,
+       .ilk_irq_handler = ilk_irq_handler,
+};
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftest_rps.c"
 #include "selftest_slpc.c"
index 92fb01f5a45242f44452972f3f6fc0db1423507b..5dbcebd7d4a55cfeb795ea03b763270bce23b409 100644 (file)
@@ -128,4 +128,6 @@ static inline void intel_rps_clear_timer(struct intel_rps *rps)
        clear_bit(INTEL_RPS_TIMER, &rps->flags);
 }
 
+extern const struct intel_display_rps_interface i915_display_rps_interface;
+
 #endif /* INTEL_RPS_H */
index 9ba46850da7246227a87f710c00afded42623f32..7e1dedabf0eece7a21536d2be30b2ff0e58c671c 100644 (file)
@@ -81,6 +81,7 @@
 #include "gt/intel_gt_pm.h"
 #include "gt/intel_gt_print.h"
 #include "gt/intel_rc6.h"
+#include "gt/intel_rps.h"
 
 #include "pxp/intel_pxp.h"
 #include "pxp/intel_pxp_debugfs.h"
@@ -752,6 +753,7 @@ static bool has_fenced_regions(struct drm_device *drm)
 static const struct intel_display_parent_interface parent = {
        .rpm = &i915_display_rpm_interface,
        .irq = &i915_display_irq_interface,
+       .rps = &i915_display_rps_interface,
        .vgpu_active = vgpu_active,
        .has_fenced_regions = has_fenced_regions,
 };
index 927d964f20712b8f920890ea16e4811ddb10945a..0a6a26234fbefab7a114247aed0372c76483d929 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/types.h>
 
+struct dma_fence;
 struct drm_device;
 struct ref_tracker;
 
@@ -30,6 +31,12 @@ struct intel_display_irq_interface {
        void (*synchronize)(struct drm_device *drm);
 };
 
+struct intel_display_rps_interface {
+       void (*boost_if_not_started)(struct dma_fence *fence);
+       void (*mark_interactive)(struct drm_device *drm, bool interactive);
+       void (*ilk_irq_handler)(struct drm_device *drm);
+};
+
 /**
  * struct intel_display_parent_interface - services parent driver provides to display
  *
@@ -49,6 +56,9 @@ struct intel_display_parent_interface {
        /** @irq: IRQ interface */
        const struct intel_display_irq_interface *irq;
 
+       /** @rpm: RPS interface. Optional. */
+       const struct intel_display_rps_interface *rps;
+
        /** @vgpu_active: Is vGPU active? Optional. */
        bool (*vgpu_active)(struct drm_device *drm);