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

Configure Feed

Select the types of activity you want to include in your feed.

drm/i915/overlay: Convert overlay to parent interface

Convert the direct i915_overlay_*() calls from the display
side to go over a new parent interface instead.

v2: Correctly handle the ERR_PTR returned by
i915_overlay_obj_lookup() (Jani)
v3: Rebase due to the NULL check in intel_overlay_cleanup()

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20260226130150.16816-1-ville.syrjala@linux.intel.com

+193 -101
+18 -18
drivers/gpu/drm/i915/display/intel_overlay.c
··· 30 30 #include <drm/drm_gem.h> 31 31 #include <drm/drm_print.h> 32 32 33 - #include "i915_overlay.h" 34 33 #include "intel_color_regs.h" 35 34 #include "intel_de.h" 36 35 #include "intel_display_regs.h" 37 36 #include "intel_display_types.h" 38 37 #include "intel_frontbuffer.h" 39 38 #include "intel_overlay.h" 39 + #include "intel_parent.h" 40 40 #include "intel_pfit_regs.h" 41 41 42 42 /* Limits for overlay size. According to intel doc, the real limits are: ··· 199 199 overlay->old_yscale = 0; 200 200 overlay->crtc = NULL; 201 201 202 - i915_overlay_reset(display->drm); 202 + intel_parent_overlay_reset(display); 203 203 } 204 204 205 205 static int packed_depth_bytes(u32 format) ··· 477 477 drm_WARN_ON(display->drm, 478 478 !drm_modeset_is_locked(&display->drm->mode_config.connection_mutex)); 479 479 480 - ret = i915_overlay_release_old_vid(display->drm); 480 + ret = intel_parent_overlay_release_old_vid(display); 481 481 if (ret != 0) 482 482 return ret; 483 483 484 484 atomic_inc(&display->restore.pending_fb_pin); 485 485 486 - vma = i915_overlay_pin_fb(display->drm, obj, &offset); 486 + vma = intel_parent_overlay_pin_fb(display, obj, &offset); 487 487 if (IS_ERR(vma)) { 488 488 ret = PTR_ERR(vma); 489 489 goto out_pin_section; 490 490 } 491 491 492 - if (!i915_overlay_is_active(display->drm)) { 492 + if (!intel_parent_overlay_is_active(display)) { 493 493 const struct intel_crtc_state *crtc_state = 494 494 overlay->crtc->config; 495 495 u32 oconfig = 0; ··· 505 505 OCONF_PIPE_A : OCONF_PIPE_B; 506 506 iowrite32(oconfig, &regs->OCONFIG); 507 507 508 - ret = i915_overlay_on(display->drm, INTEL_FRONTBUFFER_OVERLAY(pipe)); 508 + ret = intel_parent_overlay_on(display, INTEL_FRONTBUFFER_OVERLAY(pipe)); 509 509 if (ret != 0) 510 510 goto out_unpin; 511 511 } ··· 563 563 if (tmp & (1 << 17)) 564 564 drm_dbg(display->drm, "overlay underrun, DOVSTA: %x\n", tmp); 565 565 566 - ret = i915_overlay_continue(display->drm, vma, scale_changed); 566 + ret = intel_parent_overlay_continue(display, vma, scale_changed); 567 567 if (ret) 568 568 goto out_unpin; 569 569 570 570 return 0; 571 571 572 572 out_unpin: 573 - i915_overlay_unpin_fb(display->drm, vma); 573 + intel_parent_overlay_unpin_fb(display, vma); 574 574 out_pin_section: 575 575 atomic_dec(&display->restore.pending_fb_pin); 576 576 ··· 585 585 drm_WARN_ON(display->drm, 586 586 !drm_modeset_is_locked(&display->drm->mode_config.connection_mutex)); 587 587 588 - ret = i915_overlay_recover_from_interrupt(display->drm); 588 + ret = intel_parent_overlay_recover_from_interrupt(display); 589 589 if (ret != 0) 590 590 return ret; 591 591 592 - if (!i915_overlay_is_active(display->drm)) 592 + if (!intel_parent_overlay_is_active(display)) 593 593 return 0; 594 594 595 - ret = i915_overlay_release_old_vid(display->drm); 595 + ret = intel_parent_overlay_release_old_vid(display); 596 596 if (ret != 0) 597 597 return ret; 598 598 ··· 601 601 overlay->crtc->overlay = NULL; 602 602 overlay->crtc = NULL; 603 603 604 - return i915_overlay_off(display->drm); 604 + return intel_parent_overlay_off(display); 605 605 } 606 606 607 607 static int check_overlay_possible_on_crtc(struct intel_overlay *overlay, ··· 822 822 return -ENOENT; 823 823 crtc = to_intel_crtc(drmmode_crtc); 824 824 825 - obj = i915_overlay_obj_lookup(dev, file_priv, params->bo_handle); 825 + obj = intel_parent_overlay_obj_lookup(display, file_priv, params->bo_handle); 826 826 if (IS_ERR(obj)) 827 827 return PTR_ERR(obj); 828 828 829 829 drm_modeset_lock_all(dev); 830 830 831 - ret = i915_overlay_recover_from_interrupt(dev); 831 + ret = intel_parent_overlay_recover_from_interrupt(display); 832 832 if (ret != 0) 833 833 goto out_unlock; 834 834 ··· 998 998 if (DISPLAY_VER(display) == 2) 999 999 goto out_unlock; 1000 1000 1001 - if (i915_overlay_is_active(display->drm)) { 1001 + if (intel_parent_overlay_is_active(display)) { 1002 1002 ret = -EBUSY; 1003 1003 goto out_unlock; 1004 1004 } ··· 1036 1036 if (!overlay) 1037 1037 return; 1038 1038 1039 - regs = i915_overlay_setup(display->drm, 1040 - OVERLAY_NEEDS_PHYSICAL(display)); 1039 + regs = intel_parent_overlay_setup(display, 1040 + OVERLAY_NEEDS_PHYSICAL(display)); 1041 1041 if (IS_ERR(regs)) 1042 1042 goto out_free; 1043 1043 ··· 1071 1071 if (!display->overlay) 1072 1072 return; 1073 1073 1074 - i915_overlay_cleanup(display->drm); 1074 + intel_parent_overlay_cleanup(display); 1075 1075 1076 1076 kfree(display->overlay); 1077 1077 display->overlay = NULL;
-30
drivers/gpu/drm/i915/display/intel_overlay.h
··· 14 14 struct intel_display; 15 15 struct intel_overlay; 16 16 17 - #ifdef I915 18 17 void intel_overlay_setup(struct intel_display *display); 19 18 bool intel_overlay_available(struct intel_display *display); 20 19 void intel_overlay_cleanup(struct intel_display *display); ··· 23 24 int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, 24 25 struct drm_file *file_priv); 25 26 void intel_overlay_reset(struct intel_display *display); 26 - #else 27 - static inline void intel_overlay_setup(struct intel_display *display) 28 - { 29 - } 30 - static inline bool intel_overlay_available(struct intel_display *display) 31 - { 32 - return false; 33 - } 34 - static inline void intel_overlay_cleanup(struct intel_display *display) 35 - { 36 - } 37 - static inline int intel_overlay_switch_off(struct intel_overlay *overlay) 38 - { 39 - return 0; 40 - } 41 - static inline int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data, 42 - struct drm_file *file_priv) 43 - { 44 - return 0; 45 - } 46 - static inline int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data, 47 - struct drm_file *file_priv) 48 - { 49 - return 0; 50 - } 51 - static inline void intel_overlay_reset(struct intel_display *display) 52 - { 53 - } 54 - #endif 55 27 56 28 #endif /* __INTEL_OVERLAY_H__ */
+76
drivers/gpu/drm/i915/display/intel_parent.c
··· 87 87 display->parent->irq->synchronize(display->drm); 88 88 } 89 89 90 + /* overlay */ 91 + bool intel_parent_overlay_is_active(struct intel_display *display) 92 + { 93 + return display->parent->overlay->is_active(display->drm); 94 + } 95 + 96 + int intel_parent_overlay_on(struct intel_display *display, 97 + u32 frontbuffer_bits) 98 + { 99 + return display->parent->overlay->overlay_on(display->drm, 100 + frontbuffer_bits); 101 + } 102 + 103 + int intel_parent_overlay_continue(struct intel_display *display, 104 + struct i915_vma *vma, 105 + bool load_polyphase_filter) 106 + { 107 + return display->parent->overlay->overlay_continue(display->drm, vma, 108 + load_polyphase_filter); 109 + } 110 + 111 + int intel_parent_overlay_off(struct intel_display *display) 112 + { 113 + return display->parent->overlay->overlay_off(display->drm); 114 + } 115 + 116 + int intel_parent_overlay_recover_from_interrupt(struct intel_display *display) 117 + { 118 + return display->parent->overlay->recover_from_interrupt(display->drm); 119 + } 120 + 121 + int intel_parent_overlay_release_old_vid(struct intel_display *display) 122 + { 123 + return display->parent->overlay->release_old_vid(display->drm); 124 + } 125 + 126 + void intel_parent_overlay_reset(struct intel_display *display) 127 + { 128 + display->parent->overlay->reset(display->drm); 129 + } 130 + 131 + struct i915_vma *intel_parent_overlay_pin_fb(struct intel_display *display, 132 + struct drm_gem_object *obj, 133 + u32 *offset) 134 + { 135 + return display->parent->overlay->pin_fb(display->drm, obj, offset); 136 + } 137 + 138 + void intel_parent_overlay_unpin_fb(struct intel_display *display, 139 + struct i915_vma *vma) 140 + { 141 + return display->parent->overlay->unpin_fb(display->drm, vma); 142 + } 143 + 144 + struct drm_gem_object *intel_parent_overlay_obj_lookup(struct intel_display *display, 145 + struct drm_file *filp, 146 + u32 handle) 147 + { 148 + return display->parent->overlay->obj_lookup(display->drm, 149 + filp, handle); 150 + } 151 + 152 + void __iomem *intel_parent_overlay_setup(struct intel_display *display, 153 + bool needs_physical) 154 + { 155 + if (drm_WARN_ON_ONCE(display->drm, !display->parent->overlay)) 156 + return ERR_PTR(-ENODEV); 157 + 158 + return display->parent->overlay->setup(display->drm, needs_physical); 159 + } 160 + 161 + void intel_parent_overlay_cleanup(struct intel_display *display) 162 + { 163 + display->parent->overlay->cleanup(display->drm); 164 + } 165 + 90 166 /* panic */ 91 167 struct intel_panic *intel_parent_panic_alloc(struct intel_display *display) 92 168 {
+25
drivers/gpu/drm/i915/display/intel_parent.h
··· 7 7 #include <linux/types.h> 8 8 9 9 struct dma_fence; 10 + struct drm_file; 10 11 struct drm_gem_object; 11 12 struct drm_scanout_buffer; 13 + struct i915_vma; 12 14 struct intel_display; 13 15 struct intel_dpt; 14 16 struct intel_hdcp_gsc_context; ··· 37 35 /* irq */ 38 36 bool intel_parent_irq_enabled(struct intel_display *display); 39 37 void intel_parent_irq_synchronize(struct intel_display *display); 38 + 39 + /* overlay */ 40 + bool intel_parent_overlay_is_active(struct intel_display *display); 41 + int intel_parent_overlay_on(struct intel_display *display, 42 + u32 frontbuffer_bits); 43 + int intel_parent_overlay_continue(struct intel_display *display, 44 + struct i915_vma *vma, 45 + bool load_polyphase_filter); 46 + int intel_parent_overlay_off(struct intel_display *display); 47 + int intel_parent_overlay_recover_from_interrupt(struct intel_display *display); 48 + int intel_parent_overlay_release_old_vid(struct intel_display *display); 49 + void intel_parent_overlay_reset(struct intel_display *display); 50 + struct i915_vma *intel_parent_overlay_pin_fb(struct intel_display *display, 51 + struct drm_gem_object *obj, 52 + u32 *offset); 53 + void intel_parent_overlay_unpin_fb(struct intel_display *display, 54 + struct i915_vma *vma); 55 + struct drm_gem_object *intel_parent_overlay_obj_lookup(struct intel_display *display, 56 + struct drm_file *filp, 57 + u32 handle); 58 + void __iomem *intel_parent_overlay_setup(struct intel_display *display, 59 + bool needs_physical); 60 + void intel_parent_overlay_cleanup(struct intel_display *display); 40 61 41 62 /* panic */ 42 63 struct intel_panic *intel_parent_panic_alloc(struct intel_display *display);
+2
drivers/gpu/drm/i915/i915_driver.c
··· 107 107 #include "i915_ioctl.h" 108 108 #include "i915_irq.h" 109 109 #include "i915_memcpy.h" 110 + #include "i915_overlay.h" 110 111 #include "i915_panic.h" 111 112 #include "i915_perf.h" 112 113 #include "i915_query.h" ··· 768 767 .hdcp = &i915_display_hdcp_interface, 769 768 .initial_plane = &i915_display_initial_plane_interface, 770 769 .irq = &i915_display_irq_interface, 770 + .overlay = &i915_display_overlay_interface, 771 771 .panic = &i915_display_panic_interface, 772 772 .pc8 = &i915_display_pc8_interface, 773 773 .pcode = &i915_display_pcode_interface,
+37 -20
drivers/gpu/drm/i915/i915_overlay.c
··· 5 5 6 6 #include <drm/drm_print.h> 7 7 8 + #include <drm/intel/display_parent_interface.h> 8 9 #include <drm/intel/intel_gmd_interrupt_regs.h> 9 10 10 11 #include "gem/i915_gem_internal.h" ··· 89 88 return rq; 90 89 } 91 90 92 - bool i915_overlay_is_active(struct drm_device *drm) 91 + static bool i915_overlay_is_active(struct drm_device *drm) 93 92 { 94 93 struct drm_i915_private *i915 = to_i915(drm); 95 94 struct i915_overlay *overlay = i915->overlay; ··· 98 97 } 99 98 100 99 /* overlay needs to be disable in OCMD reg */ 101 - int i915_overlay_on(struct drm_device *drm, 102 - u32 frontbuffer_bits) 100 + static int i915_overlay_on(struct drm_device *drm, 101 + u32 frontbuffer_bits) 103 102 { 104 103 struct drm_i915_private *i915 = to_i915(drm); 105 104 struct i915_overlay *overlay = i915->overlay; ··· 160 159 } 161 160 162 161 /* overlay needs to be enabled in OCMD reg */ 163 - int i915_overlay_continue(struct drm_device *drm, 164 - struct i915_vma *vma, 165 - bool load_polyphase_filter) 162 + static int i915_overlay_continue(struct drm_device *drm, 163 + struct i915_vma *vma, 164 + bool load_polyphase_filter) 166 165 { 167 166 struct drm_i915_private *i915 = to_i915(drm); 168 167 struct i915_overlay *overlay = i915->overlay; ··· 211 210 i915_vma_put(vma); 212 211 } 213 212 214 - static void i915_overlay_release_old_vid_tail(struct i915_overlay *overlay) 213 + static void 214 + i915_overlay_release_old_vid_tail(struct i915_overlay *overlay) 215 215 { 216 216 i915_overlay_release_old_vma(overlay); 217 217 } ··· 239 237 } 240 238 241 239 /* overlay needs to be disabled in OCMD reg */ 242 - int i915_overlay_off(struct drm_device *drm) 240 + static int i915_overlay_off(struct drm_device *drm) 243 241 { 244 242 struct drm_i915_private *i915 = to_i915(drm); 245 243 struct i915_overlay *overlay = i915->overlay; ··· 288 286 * Recover from an interruption due to a signal. 289 287 * We have to be careful not to repeat work forever an make forward progress. 290 288 */ 291 - int i915_overlay_recover_from_interrupt(struct drm_device *drm) 289 + static int i915_overlay_recover_from_interrupt(struct drm_device *drm) 292 290 { 293 291 struct drm_i915_private *i915 = to_i915(drm); 294 292 struct i915_overlay *overlay = i915->overlay; ··· 301 299 * Needs to be called before the overlay register are changed 302 300 * via intel_overlay_(un)map_regs. 303 301 */ 304 - int i915_overlay_release_old_vid(struct drm_device *drm) 302 + static int i915_overlay_release_old_vid(struct drm_device *drm) 305 303 { 306 304 struct drm_i915_private *i915 = to_i915(drm); 307 305 struct i915_overlay *overlay = i915->overlay; ··· 339 337 return i915_active_wait(&overlay->last_flip); 340 338 } 341 339 342 - void i915_overlay_reset(struct drm_device *drm) 340 + static void i915_overlay_reset(struct drm_device *drm) 343 341 { 344 342 struct drm_i915_private *i915 = to_i915(drm); 345 343 struct i915_overlay *overlay = i915->overlay; ··· 350 348 overlay->frontbuffer_bits = 0; 351 349 } 352 350 353 - struct i915_vma *i915_overlay_pin_fb(struct drm_device *drm, 354 - struct drm_gem_object *obj, 355 - u32 *offset) 351 + static struct i915_vma *i915_overlay_pin_fb(struct drm_device *drm, 352 + struct drm_gem_object *obj, 353 + u32 *offset) 356 354 { 357 355 struct drm_i915_gem_object *new_bo = to_intel_bo(obj); 358 356 struct i915_gem_ww_ctx ww; ··· 381 379 return vma; 382 380 } 383 381 384 - void i915_overlay_unpin_fb(struct drm_device *drm, 385 - struct i915_vma *vma) 382 + static void i915_overlay_unpin_fb(struct drm_device *drm, 383 + struct i915_vma *vma) 386 384 { 387 385 i915_vma_unpin(vma); 388 386 } 389 387 390 - struct drm_gem_object * 388 + static struct drm_gem_object * 391 389 i915_overlay_obj_lookup(struct drm_device *drm, 392 390 struct drm_file *file_priv, 393 391 u32 handle) ··· 446 444 return err; 447 445 } 448 446 449 - void __iomem *i915_overlay_setup(struct drm_device *drm, 450 - bool needs_physical) 447 + static void __iomem *i915_overlay_setup(struct drm_device *drm, 448 + bool needs_physical) 451 449 { 452 450 struct drm_i915_private *i915 = to_i915(drm); 453 451 struct intel_engine_cs *engine; ··· 479 477 return overlay->regs; 480 478 } 481 479 482 - void i915_overlay_cleanup(struct drm_device *drm) 480 + static void i915_overlay_cleanup(struct drm_device *drm) 483 481 { 484 482 struct drm_i915_private *i915 = to_i915(drm); 485 483 struct i915_overlay *overlay; ··· 500 498 501 499 kfree(overlay); 502 500 } 501 + 502 + const struct intel_display_overlay_interface i915_display_overlay_interface = { 503 + .is_active = i915_overlay_is_active, 504 + .overlay_on = i915_overlay_on, 505 + .overlay_continue = i915_overlay_continue, 506 + .overlay_off = i915_overlay_off, 507 + .recover_from_interrupt = i915_overlay_recover_from_interrupt, 508 + .release_old_vid = i915_overlay_release_old_vid, 509 + .reset = i915_overlay_reset, 510 + .obj_lookup = i915_overlay_obj_lookup, 511 + .pin_fb = i915_overlay_pin_fb, 512 + .unpin_fb = i915_overlay_unpin_fb, 513 + .setup = i915_overlay_setup, 514 + .cleanup = i915_overlay_cleanup, 515 + };
+1 -33
drivers/gpu/drm/i915/i915_overlay.h
··· 6 6 #ifndef __I915_OVERLAY_H__ 7 7 #define __I915_OVERLAY_H__ 8 8 9 - #include <linux/types.h> 10 - 11 - struct drm_device; 12 - struct drm_file; 13 - struct drm_gem_object; 14 - struct i915_vma; 15 - 16 - bool i915_overlay_is_active(struct drm_device *drm); 17 - int i915_overlay_on(struct drm_device *drm, 18 - u32 frontbuffer_bits); 19 - int i915_overlay_continue(struct drm_device *drm, 20 - struct i915_vma *vma, 21 - bool load_polyphase_filter); 22 - int i915_overlay_off(struct drm_device *drm); 23 - int i915_overlay_recover_from_interrupt(struct drm_device *drm); 24 - int i915_overlay_release_old_vid(struct drm_device *drm); 25 - 26 - void i915_overlay_reset(struct drm_device *drm); 27 - 28 - struct i915_vma *i915_overlay_pin_fb(struct drm_device *drm, 29 - struct drm_gem_object *obj, 30 - u32 *offset); 31 - void i915_overlay_unpin_fb(struct drm_device *drm, 32 - struct i915_vma *vma); 33 - 34 - struct drm_gem_object * 35 - i915_overlay_obj_lookup(struct drm_device *drm, 36 - struct drm_file *file_priv, 37 - u32 handle); 38 - 39 - void __iomem *i915_overlay_setup(struct drm_device *drm, 40 - bool needs_physical); 41 - void i915_overlay_cleanup(struct drm_device *drm); 9 + extern const struct intel_display_overlay_interface i915_display_overlay_interface; 42 10 43 11 #endif /* __I915_OVERLAY_H__ */
+1
drivers/gpu/drm/xe/Makefile
··· 303 303 i915-display/intel_modeset_lock.o \ 304 304 i915-display/intel_modeset_setup.o \ 305 305 i915-display/intel_modeset_verify.o \ 306 + i915-display/intel_overlay.o \ 306 307 i915-display/intel_panel.o \ 307 308 i915-display/intel_parent.o \ 308 309 i915-display/intel_pch.o \
+33
include/drm/intel/display_parent_interface.h
··· 9 9 struct dma_fence; 10 10 struct drm_crtc; 11 11 struct drm_device; 12 + struct drm_file; 12 13 struct drm_framebuffer; 13 14 struct drm_gem_object; 14 15 struct drm_plane_state; ··· 62 61 struct intel_display_irq_interface { 63 62 bool (*enabled)(struct drm_device *drm); 64 63 void (*synchronize)(struct drm_device *drm); 64 + }; 65 + 66 + struct intel_display_overlay_interface { 67 + bool (*is_active)(struct drm_device *drm); 68 + 69 + int (*overlay_on)(struct drm_device *drm, 70 + u32 frontbuffer_bits); 71 + int (*overlay_continue)(struct drm_device *drm, 72 + struct i915_vma *vma, 73 + bool load_polyphase_filter); 74 + int (*overlay_off)(struct drm_device *drm); 75 + int (*recover_from_interrupt)(struct drm_device *drm); 76 + int (*release_old_vid)(struct drm_device *drm); 77 + 78 + void (*reset)(struct drm_device *drm); 79 + 80 + struct i915_vma *(*pin_fb)(struct drm_device *drm, 81 + struct drm_gem_object *obj, 82 + u32 *offset); 83 + void (*unpin_fb)(struct drm_device *drm, 84 + struct i915_vma *vma); 85 + 86 + struct drm_gem_object *(*obj_lookup)(struct drm_device *drm, 87 + struct drm_file *filp, 88 + u32 handle); 89 + 90 + void __iomem *(*setup)(struct drm_device *drm, 91 + bool needs_physical); 92 + void (*cleanup)(struct drm_device *drm); 65 93 }; 66 94 67 95 struct intel_display_panic_interface { ··· 179 149 180 150 /** @panic: Panic interface */ 181 151 const struct intel_display_panic_interface *panic; 152 + 153 + /** @overlay: Overlay. Optional. */ 154 + const struct intel_display_overlay_interface *overlay; 182 155 183 156 /** @pc8: PC8 interface. Optional. */ 184 157 const struct intel_display_pc8_interface *pc8;