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: further deduplicate intel_find_initial_plane_obj()

Move intel_reuse_initial_plane_obj() into common display code, and split
the ->find_obj hook into ->alloc_obj and ->setup hooks.

Return the struct drm_gem_object from ->alloc_obj in preparation for
moving more things to display.

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

+88 -111
+54 -1
drivers/gpu/drm/i915/display/intel_initial_plane.c
··· 14 14 display->parent->initial_plane->vblank_wait(&crtc->base); 15 15 } 16 16 17 + static const struct intel_plane_state * 18 + intel_reuse_initial_plane_obj(struct intel_crtc *this, 19 + const struct intel_initial_plane_config plane_configs[]) 20 + { 21 + struct intel_display *display = to_intel_display(this); 22 + struct intel_crtc *crtc; 23 + 24 + for_each_intel_crtc(display->drm, crtc) { 25 + struct intel_plane *plane = 26 + to_intel_plane(crtc->base.primary); 27 + const struct intel_plane_state *plane_state = 28 + to_intel_plane_state(plane->base.state); 29 + const struct intel_crtc_state *crtc_state = 30 + to_intel_crtc_state(crtc->base.state); 31 + 32 + if (!crtc_state->hw.active) 33 + continue; 34 + 35 + if (!plane_state->ggtt_vma) 36 + continue; 37 + 38 + if (plane_configs[this->pipe].base == plane_configs[crtc->pipe].base) 39 + return plane_state; 40 + } 41 + 42 + return NULL; 43 + } 44 + 45 + static struct drm_gem_object * 46 + intel_alloc_initial_plane_obj(struct intel_crtc *crtc, 47 + struct intel_initial_plane_config *plane_config) 48 + { 49 + struct intel_display *display = to_intel_display(crtc); 50 + 51 + return display->parent->initial_plane->alloc_obj(&crtc->base, plane_config); 52 + } 53 + 17 54 static void 18 55 intel_find_initial_plane_obj(struct intel_crtc *crtc, 19 56 struct intel_initial_plane_config plane_configs[]) ··· 58 21 struct intel_display *display = to_intel_display(crtc); 59 22 struct intel_initial_plane_config *plane_config = &plane_configs[crtc->pipe]; 60 23 struct intel_plane *plane = to_intel_plane(crtc->base.primary); 24 + struct drm_framebuffer *fb; 25 + struct i915_vma *vma; 61 26 int ret; 62 27 63 28 /* ··· 70 31 if (!plane_config->fb) 71 32 return; 72 33 73 - ret = display->parent->initial_plane->find_obj(&crtc->base, plane_configs); 34 + if (intel_alloc_initial_plane_obj(crtc, plane_config)) { 35 + fb = &plane_config->fb->base; 36 + vma = plane_config->vma; 37 + } else { 38 + const struct intel_plane_state *other_plane_state; 39 + 40 + other_plane_state = intel_reuse_initial_plane_obj(crtc, plane_configs); 41 + if (!other_plane_state) 42 + goto nofb; 43 + 44 + fb = other_plane_state->hw.fb; 45 + vma = other_plane_state->ggtt_vma; 46 + } 47 + 48 + ret = display->parent->initial_plane->setup(&crtc->base, plane_config, fb, vma); 74 49 if (ret) 75 50 goto nofb; 76 51
+14 -56
drivers/gpu/drm/i915/i915_initial_plane.c
··· 25 25 intel_crtc_wait_for_next_vblank(to_intel_crtc(crtc)); 26 26 } 27 27 28 - static const struct intel_plane_state * 29 - intel_reuse_initial_plane_obj(struct intel_crtc *this, 30 - const struct intel_initial_plane_config plane_configs[]) 31 - { 32 - struct intel_display *display = to_intel_display(this); 33 - struct intel_crtc *crtc; 34 - 35 - for_each_intel_crtc(display->drm, crtc) { 36 - struct intel_plane *plane = 37 - to_intel_plane(crtc->base.primary); 38 - const struct intel_plane_state *plane_state = 39 - to_intel_plane_state(plane->base.state); 40 - const struct intel_crtc_state *crtc_state = 41 - to_intel_crtc_state(crtc->base.state); 42 - 43 - if (!crtc_state->hw.active) 44 - continue; 45 - 46 - if (!plane_state->ggtt_vma) 47 - continue; 48 - 49 - if (plane_configs[this->pipe].base == plane_configs[crtc->pipe].base) 50 - return plane_state; 51 - } 52 - 53 - return NULL; 54 - } 55 - 56 28 static enum intel_memory_type 57 29 initial_plane_memory_type(struct intel_display *display) 58 30 { ··· 230 258 return NULL; 231 259 } 232 260 233 - static bool 234 - intel_alloc_initial_plane_obj(struct intel_crtc *crtc, 235 - struct intel_initial_plane_config *plane_config) 261 + static struct drm_gem_object * 262 + i915_alloc_initial_plane_obj(struct drm_crtc *_crtc, 263 + struct intel_initial_plane_config *plane_config) 236 264 { 265 + struct intel_crtc *crtc = to_intel_crtc(_crtc); 237 266 struct intel_display *display = to_intel_display(crtc); 238 267 struct drm_mode_fb_cmd2 mode_cmd = {}; 239 268 struct drm_framebuffer *fb = &plane_config->fb->base; ··· 250 277 drm_dbg(display->drm, 251 278 "Unsupported modifier for initial FB: 0x%llx\n", 252 279 fb->modifier); 253 - return false; 280 + return NULL; 254 281 } 255 282 256 283 vma = initial_plane_vma(display, plane_config); 257 284 if (!vma) 258 - return false; 285 + return NULL; 259 286 260 287 mode_cmd.pixel_format = fb->format->format; 261 288 mode_cmd.width = fb->width; ··· 272 299 } 273 300 274 301 plane_config->vma = vma; 275 - return true; 302 + return intel_bo_to_drm_bo(vma->obj); 276 303 277 304 err_vma: 278 305 i915_vma_put(vma); 279 - return false; 306 + return NULL; 280 307 } 281 308 282 309 static int 283 - i915_find_initial_plane_obj(struct drm_crtc *_crtc, 284 - struct intel_initial_plane_config plane_configs[]) 310 + i915_initial_plane_setup(struct drm_crtc *_crtc, 311 + struct intel_initial_plane_config *plane_config, 312 + struct drm_framebuffer *fb, 313 + struct i915_vma *vma) 285 314 { 286 315 struct intel_crtc *crtc = to_intel_crtc(_crtc); 287 316 struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); 288 - struct intel_initial_plane_config *plane_config = 289 - &plane_configs[crtc->pipe]; 290 317 struct intel_plane *plane = 291 318 to_intel_plane(crtc->base.primary); 292 319 struct intel_plane_state *plane_state = 293 320 to_intel_plane_state(plane->base.state); 294 - struct drm_framebuffer *fb; 295 - struct i915_vma *vma; 296 - 297 - if (intel_alloc_initial_plane_obj(crtc, plane_config)) { 298 - fb = &plane_config->fb->base; 299 - vma = plane_config->vma; 300 - } else { 301 - const struct intel_plane_state *other_plane_state; 302 - 303 - other_plane_state = intel_reuse_initial_plane_obj(crtc, plane_configs); 304 - if (!other_plane_state) 305 - return -EINVAL; 306 - 307 - fb = other_plane_state->hw.fb; 308 - vma = other_plane_state->ggtt_vma; 309 - } 310 321 311 322 plane_state->uapi.rotation = plane_config->rotation; 312 323 intel_fb_fill_view(to_intel_framebuffer(fb), ··· 336 379 337 380 const struct intel_display_initial_plane_interface i915_display_initial_plane_interface = { 338 381 .vblank_wait = i915_initial_plane_vblank_wait, 339 - .find_obj = i915_find_initial_plane_obj, 382 + .alloc_obj = i915_alloc_initial_plane_obj, 383 + .setup = i915_initial_plane_setup, 340 384 .config_fini = i915_plane_config_fini, 341 385 };
+14 -53
drivers/gpu/drm/xe/display/xe_initial_plane.c
··· 45 45 drm_warn(&xe->drm, "waiting for early vblank failed with %i\n", ret); 46 46 } 47 47 48 - static const struct intel_plane_state * 49 - intel_reuse_initial_plane_obj(struct intel_crtc *this, 50 - const struct intel_initial_plane_config plane_configs[]) 51 - { 52 - struct xe_device *xe = to_xe_device(this->base.dev); 53 - struct intel_crtc *crtc; 54 - 55 - for_each_intel_crtc(&xe->drm, crtc) { 56 - struct intel_plane *plane = 57 - to_intel_plane(crtc->base.primary); 58 - const struct intel_plane_state *plane_state = 59 - to_intel_plane_state(plane->base.state); 60 - const struct intel_crtc_state *crtc_state = 61 - to_intel_crtc_state(crtc->base.state); 62 - 63 - if (!crtc_state->hw.active) 64 - continue; 65 - 66 - if (!plane_state->ggtt_vma) 67 - continue; 68 - 69 - if (plane_configs[this->pipe].base == plane_configs[crtc->pipe].base) 70 - return plane_state; 71 - } 72 - 73 - return NULL; 74 - } 75 - 76 48 static struct xe_bo * 77 49 initial_plane_bo(struct xe_device *xe, 78 50 struct intel_initial_plane_config *plane_config) ··· 124 152 return bo; 125 153 } 126 154 127 - static bool 128 - intel_alloc_initial_plane_obj(struct intel_crtc *crtc, 129 - struct intel_initial_plane_config *plane_config) 155 + static struct drm_gem_object * 156 + xe_alloc_initial_plane_obj(struct drm_crtc *_crtc, 157 + struct intel_initial_plane_config *plane_config) 130 158 { 159 + struct intel_crtc *crtc = to_intel_crtc(_crtc); 131 160 struct xe_device *xe = to_xe_device(crtc->base.dev); 132 161 struct drm_mode_fb_cmd2 mode_cmd = { 0 }; 133 162 struct drm_framebuffer *fb = &plane_config->fb->base; ··· 144 171 drm_dbg_kms(&xe->drm, 145 172 "Unsupported modifier for initial FB: 0x%llx\n", 146 173 fb->modifier); 147 - return false; 174 + return NULL; 148 175 } 149 176 150 177 mode_cmd.pixel_format = fb->format->format; ··· 156 183 157 184 bo = initial_plane_bo(xe, plane_config); 158 185 if (!bo) 159 - return false; 186 + return NULL; 160 187 161 188 if (intel_framebuffer_init(to_intel_framebuffer(fb), 162 189 &bo->ttm.base, fb->format, &mode_cmd)) { ··· 166 193 /* Reference handed over to fb */ 167 194 xe_bo_put(bo); 168 195 169 - return true; 196 + return &bo->ttm.base; 170 197 171 198 err_bo: 172 199 xe_bo_unpin_map_no_vm(bo); 173 - return false; 200 + return NULL; 174 201 } 175 202 176 203 static int 177 - xe_find_initial_plane_obj(struct drm_crtc *_crtc, 178 - struct intel_initial_plane_config plane_configs[]) 204 + xe_initial_plane_setup(struct drm_crtc *_crtc, 205 + struct intel_initial_plane_config *plane_config, 206 + struct drm_framebuffer *fb, 207 + struct i915_vma *_unused) 179 208 { 180 209 struct intel_crtc *crtc = to_intel_crtc(_crtc); 181 - struct intel_initial_plane_config *plane_config = 182 - &plane_configs[crtc->pipe]; 183 210 struct intel_plane *plane = 184 211 to_intel_plane(crtc->base.primary); 185 212 struct intel_plane_state *plane_state = 186 213 to_intel_plane_state(plane->base.state); 187 - struct drm_framebuffer *fb; 188 214 struct i915_vma *vma; 189 - 190 - if (intel_alloc_initial_plane_obj(crtc, plane_config)) { 191 - fb = &plane_config->fb->base; 192 - } else { 193 - const struct intel_plane_state *other_plane_state; 194 - 195 - other_plane_state = intel_reuse_initial_plane_obj(crtc, plane_configs); 196 - if (!other_plane_state) 197 - return -EINVAL; 198 - 199 - fb = other_plane_state->hw.fb; 200 - } 201 215 202 216 plane_state->uapi.rotation = plane_config->rotation; 203 217 intel_fb_fill_view(to_intel_framebuffer(fb), ··· 228 268 229 269 const struct intel_display_initial_plane_interface xe_display_initial_plane_interface = { 230 270 .vblank_wait = xe_initial_plane_vblank_wait, 231 - .find_obj = xe_find_initial_plane_obj, 271 + .alloc_obj = xe_alloc_initial_plane_obj, 272 + .setup = xe_initial_plane_setup, 232 273 .config_fini = xe_plane_config_fini, 233 274 };
+6 -1
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_framebuffer; 13 + struct drm_gem_object; 12 14 struct drm_scanout_buffer; 15 + struct i915_vma; 13 16 struct intel_hdcp_gsc_context; 14 17 struct intel_initial_plane_config; 15 18 struct intel_panic; ··· 32 29 33 30 struct intel_display_initial_plane_interface { 34 31 void (*vblank_wait)(struct drm_crtc *crtc); 35 - int (*find_obj)(struct drm_crtc *crtc, struct intel_initial_plane_config *plane_configs); 32 + struct drm_gem_object *(*alloc_obj)(struct drm_crtc *crtc, struct intel_initial_plane_config *plane_config); 33 + int (*setup)(struct drm_crtc *crtc, struct intel_initial_plane_config *plane_config, 34 + struct drm_framebuffer *fb, struct i915_vma *vma); 36 35 void (*config_fini)(struct intel_initial_plane_config *plane_configs); 37 36 }; 38 37