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/dpt: pass opaque struct intel_dpt around instead of i915_address_space

struct i915_address_space is used in an opaque fashion in the display
parent interface, but it's just one include away from being
non-opaque. And anyway the name is rather specific.

Switch to using the struct intel_dpt instead, which embeds struct
i915_address_space anyway. With the definition hidden in i915_dpt.c,
this can't be accidentally made non-opaque, and the type seems rather
more generic anyway.

We do have to add a new helper i915_dpt_to_vm(), as there's one case in
intel_fb_pin_to_dpt() that requires direct access to struct
i915_address_space. But this just underlines the point about opacity.

Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Link: https://patch.msgid.link/daa39178c0b0305b010564952d691f06e3cd63ca.1772030909.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

+56 -55
+1 -1
drivers/gpu/drm/i915/display/intel_display_types.h
··· 145 145 struct intel_fb_view remapped_view; 146 146 }; 147 147 148 - struct i915_address_space *dpt_vm; 148 + struct intel_dpt *dpt; 149 149 150 150 unsigned int min_alignment; 151 151 unsigned int vtd_guard;
+4 -4
drivers/gpu/drm/i915/display/intel_dpt.c
··· 57 57 drm_for_each_fb(drm_fb, display->drm) { 58 58 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); 59 59 60 - if (fb->dpt_vm) 61 - intel_parent_dpt_suspend(display, fb->dpt_vm); 60 + if (fb->dpt) 61 + intel_parent_dpt_suspend(display, fb->dpt); 62 62 } 63 63 64 64 mutex_unlock(&display->drm->mode_config.fb_lock); ··· 87 87 drm_for_each_fb(drm_fb, display->drm) { 88 88 struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb); 89 89 90 - if (fb->dpt_vm) 91 - intel_parent_dpt_resume(display, fb->dpt_vm); 90 + if (fb->dpt) 91 + intel_parent_dpt_resume(display, fb->dpt); 92 92 } 93 93 mutex_unlock(&display->drm->mode_config.fb_lock); 94 94 }
+7 -7
drivers/gpu/drm/i915/display/intel_fb.c
··· 2109 2109 drm_framebuffer_cleanup(fb); 2110 2110 2111 2111 if (intel_fb_uses_dpt(fb)) 2112 - intel_parent_dpt_destroy(display, intel_fb->dpt_vm); 2112 + intel_parent_dpt_destroy(display, intel_fb->dpt); 2113 2113 2114 2114 intel_fb_bo_framebuffer_fini(intel_fb_bo(fb)); 2115 2115 ··· 2305 2305 2306 2306 if (intel_fb_uses_dpt(fb)) { 2307 2307 struct drm_gem_object *obj = intel_fb_bo(&intel_fb->base); 2308 - struct i915_address_space *vm; 2308 + struct intel_dpt *dpt; 2309 2309 size_t size = 0; 2310 2310 2311 2311 if (intel_fb_needs_pot_stride_remap(intel_fb)) 2312 2312 size = intel_remapped_info_size(&intel_fb->remapped_view.gtt.remapped); 2313 2313 2314 - vm = intel_parent_dpt_create(display, obj, size); 2315 - if (IS_ERR(vm)) { 2314 + dpt = intel_parent_dpt_create(display, obj, size); 2315 + if (IS_ERR(dpt)) { 2316 2316 drm_dbg_kms(display->drm, "failed to create DPT\n"); 2317 - ret = PTR_ERR(vm); 2317 + ret = PTR_ERR(dpt); 2318 2318 goto err_frontbuffer_put; 2319 2319 } 2320 2320 2321 - intel_fb->dpt_vm = vm; 2321 + intel_fb->dpt = dpt; 2322 2322 } 2323 2323 2324 2324 ret = drm_framebuffer_init(display->drm, fb, &intel_fb_funcs); ··· 2331 2331 2332 2332 err_free_dpt: 2333 2333 if (intel_fb_uses_dpt(fb)) 2334 - intel_parent_dpt_destroy(display, intel_fb->dpt_vm); 2334 + intel_parent_dpt_destroy(display, intel_fb->dpt); 2335 2335 err_bo_framebuffer_fini: 2336 2336 intel_fb_bo_framebuffer_fini(obj); 2337 2337 err_frontbuffer_put:
+6 -5
drivers/gpu/drm/i915/display/intel_fb_pin.c
··· 27 27 const struct i915_gtt_view *view, 28 28 unsigned int alignment, 29 29 unsigned long *out_flags, 30 - struct i915_address_space *vm) 30 + struct intel_dpt *dpt) 31 31 { 32 32 struct drm_device *dev = fb->dev; 33 33 struct intel_display *display = to_intel_display(dev); 34 34 struct drm_i915_private *dev_priv = to_i915(dev); 35 35 struct drm_gem_object *_obj = intel_fb_bo(fb); 36 36 struct drm_i915_gem_object *obj = to_intel_bo(_obj); 37 + struct i915_address_space *vm = i915_dpt_to_vm(dpt); 37 38 struct i915_gem_ww_ctx ww; 38 39 struct i915_vma *vma; 39 40 int ret; ··· 285 284 } else { 286 285 unsigned int alignment = intel_plane_fb_min_alignment(plane_state); 287 286 288 - vma = i915_dpt_pin_to_ggtt(fb->dpt_vm, alignment / 512); 287 + vma = i915_dpt_pin_to_ggtt(fb->dpt, alignment / 512); 289 288 if (IS_ERR(vma)) 290 289 return PTR_ERR(vma); 291 290 ··· 293 292 294 293 vma = intel_fb_pin_to_dpt(&fb->base, &plane_state->view.gtt, 295 294 alignment, &plane_state->flags, 296 - fb->dpt_vm); 295 + fb->dpt); 297 296 if (IS_ERR(vma)) { 298 - i915_dpt_unpin_from_ggtt(fb->dpt_vm); 297 + i915_dpt_unpin_from_ggtt(fb->dpt); 299 298 plane_state->ggtt_vma = NULL; 300 299 return PTR_ERR(vma); 301 300 } ··· 347 346 348 347 vma = fetch_and_zero(&old_plane_state->ggtt_vma); 349 348 if (vma) 350 - i915_dpt_unpin_from_ggtt(fb->dpt_vm); 349 + i915_dpt_unpin_from_ggtt(fb->dpt); 351 350 } 352 351 } 353 352
+8 -9
drivers/gpu/drm/i915/display/intel_parent.c
··· 24 24 #include "intel_parent.h" 25 25 26 26 /* dpt */ 27 - struct i915_address_space *intel_parent_dpt_create(struct intel_display *display, 28 - struct drm_gem_object *obj, 29 - size_t size) 27 + struct intel_dpt *intel_parent_dpt_create(struct intel_display *display, 28 + struct drm_gem_object *obj, size_t size) 30 29 { 31 30 if (display->parent->dpt) 32 31 return display->parent->dpt->create(obj, size); ··· 33 34 return NULL; 34 35 } 35 36 36 - void intel_parent_dpt_destroy(struct intel_display *display, struct i915_address_space *vm) 37 + void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt) 37 38 { 38 39 if (display->parent->dpt) 39 - display->parent->dpt->destroy(vm); 40 + display->parent->dpt->destroy(dpt); 40 41 } 41 42 42 - void intel_parent_dpt_suspend(struct intel_display *display, struct i915_address_space *vm) 43 + void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt) 43 44 { 44 45 if (display->parent->dpt) 45 - display->parent->dpt->suspend(vm); 46 + display->parent->dpt->suspend(dpt); 46 47 } 47 48 48 - void intel_parent_dpt_resume(struct intel_display *display, struct i915_address_space *vm) 49 + void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt) 49 50 { 50 51 if (display->parent->dpt) 51 - display->parent->dpt->resume(vm); 52 + display->parent->dpt->resume(dpt); 52 53 } 53 54 54 55 /* hdcp */
+6 -7
drivers/gpu/drm/i915/display/intel_parent.h
··· 9 9 struct dma_fence; 10 10 struct drm_gem_object; 11 11 struct drm_scanout_buffer; 12 - struct i915_address_space; 13 12 struct intel_display; 13 + struct intel_dpt; 14 14 struct intel_hdcp_gsc_context; 15 15 struct intel_panic; 16 16 struct intel_stolen_node; 17 17 18 18 /* dpt */ 19 - struct i915_address_space *intel_parent_dpt_create(struct intel_display *display, 20 - struct drm_gem_object *obj, 21 - size_t size); 22 - void intel_parent_dpt_destroy(struct intel_display *display, struct i915_address_space *vm); 23 - void intel_parent_dpt_suspend(struct intel_display *display, struct i915_address_space *vm); 24 - void intel_parent_dpt_resume(struct intel_display *display, struct i915_address_space *vm); 19 + struct intel_dpt *intel_parent_dpt_create(struct intel_display *display, 20 + struct drm_gem_object *obj, size_t size); 21 + void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt); 22 + void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt); 23 + void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt); 25 24 26 25 /* hdcp */ 27 26 ssize_t intel_parent_hdcp_gsc_msg_send(struct intel_display *display,
+15 -15
drivers/gpu/drm/i915/i915_dpt.c
··· 33 33 return container_of(vm, struct intel_dpt, vm); 34 34 } 35 35 36 + struct i915_address_space *i915_dpt_to_vm(struct intel_dpt *dpt) 37 + { 38 + return &dpt->vm; 39 + } 40 + 36 41 static void gen8_set_pte(void __iomem *addr, gen8_pte_t pte) 37 42 { 38 43 writeq(pte, addr); ··· 126 121 i915_gem_object_put(dpt->obj); 127 122 } 128 123 129 - struct i915_vma *i915_dpt_pin_to_ggtt(struct i915_address_space *vm, unsigned int alignment) 124 + struct i915_vma *i915_dpt_pin_to_ggtt(struct intel_dpt *dpt, unsigned int alignment) 130 125 { 131 - struct drm_i915_private *i915 = vm->i915; 126 + struct drm_i915_private *i915 = dpt->vm.i915; 132 127 struct intel_display *display = i915->display; 133 - struct intel_dpt *dpt = i915_vm_to_dpt(vm); 134 128 struct ref_tracker *wakeref; 135 129 struct i915_vma *vma; 136 130 void __iomem *iomem; ··· 177 173 return err ? ERR_PTR(err) : vma; 178 174 } 179 175 180 - void i915_dpt_unpin_from_ggtt(struct i915_address_space *vm) 176 + void i915_dpt_unpin_from_ggtt(struct intel_dpt *dpt) 181 177 { 182 - struct intel_dpt *dpt = i915_vm_to_dpt(vm); 183 - 184 178 i915_vma_unpin_iomap(dpt->vma); 185 179 i915_vma_put(dpt->vma); 186 180 } 187 181 188 - static struct i915_address_space *i915_dpt_create(struct drm_gem_object *obj, size_t size) 182 + static struct intel_dpt *i915_dpt_create(struct drm_gem_object *obj, size_t size) 189 183 { 190 184 struct drm_i915_private *i915 = to_i915(obj->dev); 191 185 struct drm_i915_gem_object *dpt_obj; ··· 245 243 dpt->obj = dpt_obj; 246 244 dpt->obj->is_dpt = true; 247 245 248 - return &dpt->vm; 246 + return dpt; 249 247 } 250 248 251 - static void i915_dpt_destroy(struct i915_address_space *vm) 249 + static void i915_dpt_destroy(struct intel_dpt *dpt) 252 250 { 253 - struct intel_dpt *dpt = i915_vm_to_dpt(vm); 254 - 255 251 dpt->obj->is_dpt = false; 256 252 i915_vm_put(&dpt->vm); 257 253 } 258 254 259 - static void i915_dpt_suspend(struct i915_address_space *vm) 255 + static void i915_dpt_suspend(struct intel_dpt *dpt) 260 256 { 261 - i915_ggtt_suspend_vm(vm, true); 257 + i915_ggtt_suspend_vm(&dpt->vm, true); 262 258 } 263 259 264 - static void i915_dpt_resume(struct i915_address_space *vm) 260 + static void i915_dpt_resume(struct intel_dpt *dpt) 265 261 { 266 - i915_ggtt_resume_vm(vm, true); 262 + i915_ggtt_resume_vm(&dpt->vm, true); 267 263 } 268 264 269 265 u64 i915_dpt_offset(struct i915_vma *dpt_vma)
+4 -2
drivers/gpu/drm/i915/i915_dpt.h
··· 8 8 9 9 struct i915_address_space; 10 10 struct i915_vma; 11 + struct intel_dpt; 11 12 12 - struct i915_vma *i915_dpt_pin_to_ggtt(struct i915_address_space *vm, unsigned int alignment); 13 - void i915_dpt_unpin_from_ggtt(struct i915_address_space *vm); 13 + struct i915_address_space *i915_dpt_to_vm(struct intel_dpt *dpt); 14 + struct i915_vma *i915_dpt_pin_to_ggtt(struct intel_dpt *dpt, unsigned int alignment); 15 + void i915_dpt_unpin_from_ggtt(struct intel_dpt *dpt); 14 16 u64 i915_dpt_offset(struct i915_vma *dpt_vma); 15 17 16 18 extern const struct intel_display_dpt_interface i915_display_dpt_interface;
+5 -5
include/drm/intel/display_parent_interface.h
··· 13 13 struct drm_gem_object; 14 14 struct drm_plane_state; 15 15 struct drm_scanout_buffer; 16 - struct i915_address_space; 17 16 struct i915_vma; 17 + struct intel_dpt; 18 18 struct intel_dsb_buffer; 19 19 struct intel_hdcp_gsc_context; 20 20 struct intel_initial_plane_config; ··· 25 25 /* Keep struct definitions sorted */ 26 26 27 27 struct intel_display_dpt_interface { 28 - struct i915_address_space *(*create)(struct drm_gem_object *obj, size_t size); 29 - void (*destroy)(struct i915_address_space *vm); 30 - void (*suspend)(struct i915_address_space *vm); 31 - void (*resume)(struct i915_address_space *vm); 28 + struct intel_dpt *(*create)(struct drm_gem_object *obj, size_t size); 29 + void (*destroy)(struct intel_dpt *dpt); 30 + void (*suspend)(struct intel_dpt *dpt); 31 + void (*resume)(struct intel_dpt *dpt); 32 32 }; 33 33 34 34 struct intel_display_dsb_interface {