Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/display: add display specific runtime PM wrappers

Add display specific wrappers around the i915 and xe dedicated runtime
PM interfaces. There are no conversions here, just the wrappers.

Implement with_intel_display_rpm() without needing to provide a local
variable, which neatly narrows the scope and hides the type of the
wakeref cookie.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://lore.kernel.org/r/086b312367fa0fbd8de92e9764117aa7ff4a8cc5.1742483007.git.jani.nikula@intel.com

+178
+1
drivers/gpu/drm/i915/Makefile
··· 247 247 display/intel_display_power_map.o \ 248 248 display/intel_display_power_well.o \ 249 249 display/intel_display_reset.o \ 250 + display/intel_display_rpm.o \ 250 251 display/intel_display_rps.o \ 251 252 display/intel_display_snapshot.o \ 252 253 display/intel_display_wa.o \
+68
drivers/gpu/drm/i915/display/intel_display_rpm.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include "i915_drv.h" 5 + #include "intel_display_rpm.h" 6 + #include "intel_runtime_pm.h" 7 + 8 + static struct intel_runtime_pm *display_to_rpm(struct intel_display *display) 9 + { 10 + struct drm_i915_private *i915 = to_i915(display->drm); 11 + 12 + return &i915->runtime_pm; 13 + } 14 + 15 + struct ref_tracker *intel_display_rpm_get_raw(struct intel_display *display) 16 + { 17 + return intel_runtime_pm_get_raw(display_to_rpm(display)); 18 + } 19 + 20 + void intel_display_rpm_put_raw(struct intel_display *display, struct ref_tracker *wakeref) 21 + { 22 + intel_runtime_pm_put_raw(display_to_rpm(display), wakeref); 23 + } 24 + 25 + struct ref_tracker *intel_display_rpm_get(struct intel_display *display) 26 + { 27 + return intel_runtime_pm_get(display_to_rpm(display)); 28 + } 29 + 30 + struct ref_tracker *intel_display_rpm_get_if_in_use(struct intel_display *display) 31 + { 32 + return intel_runtime_pm_get_if_in_use(display_to_rpm(display)); 33 + } 34 + 35 + struct ref_tracker *intel_display_rpm_get_noresume(struct intel_display *display) 36 + { 37 + return intel_runtime_pm_get_noresume(display_to_rpm(display)); 38 + } 39 + 40 + void intel_display_rpm_put(struct intel_display *display, struct ref_tracker *wakeref) 41 + { 42 + intel_runtime_pm_put(display_to_rpm(display), wakeref); 43 + } 44 + 45 + void intel_display_rpm_put_unchecked(struct intel_display *display) 46 + { 47 + intel_runtime_pm_put_unchecked(display_to_rpm(display)); 48 + } 49 + 50 + bool intel_display_rpm_suspended(struct intel_display *display) 51 + { 52 + return intel_runtime_pm_suspended(display_to_rpm(display)); 53 + } 54 + 55 + void assert_display_rpm_held(struct intel_display *display) 56 + { 57 + assert_rpm_wakelock_held(display_to_rpm(display)); 58 + } 59 + 60 + void intel_display_rpm_assert_block(struct intel_display *display) 61 + { 62 + disable_rpm_wakeref_asserts(display_to_rpm(display)); 63 + } 64 + 65 + void intel_display_rpm_assert_unblock(struct intel_display *display) 66 + { 67 + enable_rpm_wakeref_asserts(display_to_rpm(display)); 68 + }
+37
drivers/gpu/drm/i915/display/intel_display_rpm.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #ifndef __INTEL_DISPLAY_RPM__ 5 + #define __INTEL_DISPLAY_RPM__ 6 + 7 + #include <linux/types.h> 8 + 9 + struct intel_display; 10 + struct ref_tracker; 11 + 12 + struct ref_tracker *intel_display_rpm_get(struct intel_display *display); 13 + void intel_display_rpm_put(struct intel_display *display, struct ref_tracker *wakeref); 14 + 15 + #define __with_intel_display_rpm(__display, __wakeref) \ 16 + for (struct ref_tracker *(__wakeref) = intel_display_rpm_get(__display); (__wakeref); \ 17 + intel_display_rpm_put((__display), (__wakeref)), (__wakeref) = NULL) 18 + 19 + #define with_intel_display_rpm(__display) \ 20 + __with_intel_display_rpm((__display), __UNIQUE_ID(wakeref)) 21 + 22 + /* Only for special cases. */ 23 + bool intel_display_rpm_suspended(struct intel_display *display); 24 + 25 + void assert_display_rpm_held(struct intel_display *display); 26 + void intel_display_rpm_assert_block(struct intel_display *display); 27 + void intel_display_rpm_assert_unblock(struct intel_display *display); 28 + 29 + /* Only for display power implementation. */ 30 + struct ref_tracker *intel_display_rpm_get_raw(struct intel_display *display); 31 + void intel_display_rpm_put_raw(struct intel_display *display, struct ref_tracker *wakeref); 32 + 33 + struct ref_tracker *intel_display_rpm_get_if_in_use(struct intel_display *display); 34 + struct ref_tracker *intel_display_rpm_get_noresume(struct intel_display *display); 35 + void intel_display_rpm_put_unchecked(struct intel_display *display); 36 + 37 + #endif /* __INTEL_DISPLAY_RPM__ */
+1
drivers/gpu/drm/xe/Makefile
··· 181 181 display/intel_fbdev_fb.o \ 182 182 display/xe_display.o \ 183 183 display/xe_display_misc.o \ 184 + display/xe_display_rpm.o \ 184 185 display/xe_display_rps.o \ 185 186 display/xe_display_wa.o \ 186 187 display/xe_dsb_buffer.o \
+71
drivers/gpu/drm/xe/display/xe_display_rpm.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* Copyright © 2025 Intel Corporation */ 3 + 4 + #include "intel_display_rpm.h" 5 + #include "xe_device_types.h" 6 + #include "xe_pm.h" 7 + 8 + static struct xe_device *display_to_xe(struct intel_display *display) 9 + { 10 + return container_of(display, struct xe_device, display); 11 + } 12 + 13 + struct ref_tracker *intel_display_rpm_get_raw(struct intel_display *display) 14 + { 15 + return intel_display_rpm_get(display); 16 + } 17 + 18 + void intel_display_rpm_put_raw(struct intel_display *display, struct ref_tracker *wakeref) 19 + { 20 + intel_display_rpm_put(display, wakeref); 21 + } 22 + 23 + struct ref_tracker *intel_display_rpm_get(struct intel_display *display) 24 + { 25 + return xe_pm_runtime_resume_and_get(display_to_xe(display)) ? INTEL_WAKEREF_DEF : NULL; 26 + } 27 + 28 + struct ref_tracker *intel_display_rpm_get_if_in_use(struct intel_display *display) 29 + { 30 + return xe_pm_runtime_get_if_in_use(display_to_xe(display)) ? INTEL_WAKEREF_DEF : NULL; 31 + } 32 + 33 + struct ref_tracker *intel_display_rpm_get_noresume(struct intel_display *display) 34 + { 35 + xe_pm_runtime_get_noresume(display_to_xe(display)); 36 + 37 + return INTEL_WAKEREF_DEF; 38 + } 39 + 40 + void intel_display_rpm_put(struct intel_display *display, struct ref_tracker *wakeref) 41 + { 42 + if (wakeref) 43 + xe_pm_runtime_put(display_to_xe(display)); 44 + } 45 + 46 + void intel_display_rpm_put_unchecked(struct intel_display *display) 47 + { 48 + xe_pm_runtime_put(display_to_xe(display)); 49 + } 50 + 51 + bool intel_display_rpm_suspended(struct intel_display *display) 52 + { 53 + struct xe_device *xe = display_to_xe(display); 54 + 55 + return pm_runtime_suspended(xe->drm.dev); 56 + } 57 + 58 + void assert_display_rpm_held(struct intel_display *display) 59 + { 60 + /* FIXME */ 61 + } 62 + 63 + void intel_display_rpm_assert_block(struct intel_display *display) 64 + { 65 + /* FIXME */ 66 + } 67 + 68 + void intel_display_rpm_assert_unblock(struct intel_display *display) 69 + { 70 + /* FIXME */ 71 + }