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: Walk crtcs in pipe order

Currently our crtcs are registered in pipe order, and thus
all the for_intel_crtc*() iterators walk the crtcs in pipe
order. There are a bunch of places that more or less depend
on that. Eg. during plane updates and such we want joined
pipes to be processed back-to-back to give a better chance
of an atomic update across the whole set.

When we start to register crtcs in a different order we don't
want to change the order in which the pipes get handled.
Decouple the for_each_intel_crtc*() iterators from the crtc
registration order by using a separate list which will be
sorted by the pipe rather than the crtc index.

We could probably use a simple array or something, but that
would require some kind of extra iterator variable for the
macros, and thus would require a lot more changes. Using
a linked list keeps the fallout minimal. We can look at
using a more optimal data structure later.

I also added this extra junk to the atomic state iterators:
"(__i) = drm_crtc_index(&(crtc)->base), (void)(__i)"
even though the macro itself no longer needs the "__i" iterator.
This in case the "__i" is used by the caller, and to
avoid compiler warnings if it's completely unused now.

v2: Flip the pipe comparison (Jani)

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

authored by

Ville Syrjälä and committed by
Jani Nikula
f49499e6 482bcc7e

+64 -52
+20
drivers/gpu/drm/i915/display/intel_crtc.c
··· 209 209 crtc->base.state = &crtc_state->uapi; 210 210 crtc->config = crtc_state; 211 211 212 + INIT_LIST_HEAD(&crtc->pipe_head); 213 + 212 214 return crtc; 213 215 } 214 216 ··· 223 221 static void intel_crtc_destroy(struct drm_crtc *_crtc) 224 222 { 225 223 struct intel_crtc *crtc = to_intel_crtc(_crtc); 224 + 225 + list_del(&crtc->pipe_head); 226 226 227 227 cpu_latency_qos_remove_request(&crtc->vblank_pm_qos); 228 228 ··· 311 307 .disable_vblank = i8xx_disable_vblank, 312 308 .get_vblank_timestamp = intel_crtc_get_vblank_timestamp, 313 309 }; 310 + 311 + static void add_crtc_to_pipe_list(struct intel_display *display, struct intel_crtc *crtc) 312 + { 313 + struct intel_crtc *iter; 314 + 315 + list_for_each_entry(iter, &display->pipe_list, pipe_head) { 316 + if (crtc->pipe < iter->pipe) { 317 + list_add_tail(&crtc->pipe_head, &iter->pipe_head); 318 + return; 319 + } 320 + } 321 + 322 + list_add_tail(&crtc->pipe_head, &display->pipe_list); 323 + } 314 324 315 325 static int __intel_crtc_init(struct intel_display *display, enum pipe pipe) 316 326 { ··· 415 397 416 398 if (HAS_CASF(display) && crtc->num_scalers >= 2) 417 399 drm_crtc_create_sharpness_strength_property(&crtc->base); 400 + 401 + add_crtc_to_pipe_list(display, crtc); 418 402 419 403 return 0; 420 404
+38 -52
drivers/gpu/drm/i915/display/intel_display.h
··· 212 212 base.head) \ 213 213 for_each_if((intel_plane)->pipe == (intel_crtc)->pipe) 214 214 215 - #define for_each_intel_crtc(dev, intel_crtc) \ 216 - list_for_each_entry(intel_crtc, \ 217 - &(dev)->mode_config.crtc_list, \ 218 - base.head) 215 + #define for_each_intel_crtc(dev, crtc) \ 216 + list_for_each_entry((crtc), \ 217 + &to_intel_display(dev)->pipe_list, \ 218 + pipe_head) 219 219 220 - #define for_each_intel_crtc_in_pipe_mask(dev, intel_crtc, pipe_mask) \ 221 - list_for_each_entry(intel_crtc, \ 222 - &(dev)->mode_config.crtc_list, \ 223 - base.head) \ 224 - for_each_if((pipe_mask) & BIT(intel_crtc->pipe)) 220 + #define for_each_intel_crtc_reverse(dev, crtc) \ 221 + list_for_each_entry_reverse((crtc), \ 222 + &to_intel_display(dev)->pipe_list, \ 223 + pipe_head) 225 224 226 - #define for_each_intel_crtc_in_pipe_mask_reverse(dev, intel_crtc, pipe_mask) \ 227 - list_for_each_entry_reverse((intel_crtc), \ 228 - &(dev)->mode_config.crtc_list, \ 229 - base.head) \ 230 - for_each_if((pipe_mask) & BIT((intel_crtc)->pipe)) 225 + #define for_each_intel_crtc_in_pipe_mask(dev, crtc, pipe_mask) \ 226 + for_each_intel_crtc((dev), (crtc)) \ 227 + for_each_if((pipe_mask) & BIT((crtc)->pipe)) 228 + 229 + #define for_each_intel_crtc_in_pipe_mask_reverse(dev, crtc, pipe_mask) \ 230 + for_each_intel_crtc_reverse((dev), (crtc)) \ 231 + for_each_if((pipe_mask) & BIT((crtc)->pipe)) 231 232 232 233 #define for_each_intel_encoder(dev, intel_encoder) \ 233 234 list_for_each_entry(intel_encoder, \ ··· 270 269 (__i)++) \ 271 270 for_each_if(plane) 272 271 273 - #define for_each_old_intel_crtc_in_state(__state, crtc, old_crtc_state, __i) \ 274 - for ((__i) = 0; \ 275 - (__i) < (__state)->base.dev->mode_config.num_crtc && \ 276 - ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \ 277 - (old_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].old_state), 1); \ 278 - (__i)++) \ 279 - for_each_if(crtc) 280 - 281 272 #define for_each_new_intel_plane_in_state(__state, plane, new_plane_state, __i) \ 282 273 for ((__i) = 0; \ 283 274 (__i) < (__state)->base.dev->mode_config.num_total_plane && \ ··· 277 284 (new_plane_state) = to_intel_plane_state((__state)->base.planes[__i].new_state), 1); \ 278 285 (__i)++) \ 279 286 for_each_if(plane) 280 - 281 - #define for_each_new_intel_crtc_in_state(__state, crtc, new_crtc_state, __i) \ 282 - for ((__i) = 0; \ 283 - (__i) < (__state)->base.dev->mode_config.num_crtc && \ 284 - ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \ 285 - (new_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].new_state), 1); \ 286 - (__i)++) \ 287 - for_each_if(crtc) 288 - 289 - #define for_each_new_intel_crtc_in_state_reverse(__state, crtc, new_crtc_state, __i) \ 290 - for ((__i) = (__state)->base.dev->mode_config.num_crtc - 1; \ 291 - (__i) >= 0 && \ 292 - ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \ 293 - (new_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].new_state), 1); \ 294 - (__i)--) \ 295 - for_each_if(crtc) 296 287 297 288 #define for_each_oldnew_intel_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \ 298 289 for ((__i) = 0; \ ··· 287 310 (__i)++) \ 288 311 for_each_if(plane) 289 312 313 + #define for_each_old_intel_crtc_in_state(__state, crtc, old_crtc_state, __i) \ 314 + for_each_intel_crtc((__state)->base.dev, (crtc)) \ 315 + for_each_if(((__i) = drm_crtc_index(&(crtc)->base), (void)(__i), \ 316 + (old_crtc_state) = intel_atomic_get_old_crtc_state((__state), (crtc)))) 317 + 318 + #define for_each_new_intel_crtc_in_state(__state, crtc, new_crtc_state, __i) \ 319 + for_each_intel_crtc((__state)->base.dev, (crtc)) \ 320 + for_each_if(((__i) = drm_crtc_index(&(crtc)->base), (void)(__i), \ 321 + (new_crtc_state) = intel_atomic_get_new_crtc_state((__state), (crtc)))) 322 + 323 + #define for_each_new_intel_crtc_in_state_reverse(__state, crtc, new_crtc_state, __i) \ 324 + for_each_intel_crtc_reverse((__state)->base.dev, (crtc)) \ 325 + for_each_if(((__i) = drm_crtc_index(&(crtc)->base), (void)(__i), \ 326 + (new_crtc_state) = intel_atomic_get_new_crtc_state((__state), (crtc)))) 327 + 290 328 #define for_each_oldnew_intel_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \ 291 - for ((__i) = 0; \ 292 - (__i) < (__state)->base.dev->mode_config.num_crtc && \ 293 - ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \ 294 - (old_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].old_state), \ 295 - (new_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].new_state), 1); \ 296 - (__i)++) \ 297 - for_each_if(crtc) 329 + for_each_intel_crtc((__state)->base.dev, (crtc)) \ 330 + for_each_if(((__i) = drm_crtc_index(&(crtc)->base), (void)(__i), \ 331 + (old_crtc_state) = intel_atomic_get_old_crtc_state((__state), (crtc)), \ 332 + (new_crtc_state) = intel_atomic_get_new_crtc_state((__state), (crtc)))) 298 333 299 334 #define for_each_oldnew_intel_crtc_in_state_reverse(__state, crtc, old_crtc_state, new_crtc_state, __i) \ 300 - for ((__i) = (__state)->base.dev->mode_config.num_crtc - 1; \ 301 - (__i) >= 0 && \ 302 - ((crtc) = to_intel_crtc((__state)->base.crtcs[__i].ptr), \ 303 - (old_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].old_state), \ 304 - (new_crtc_state) = to_intel_crtc_state((__state)->base.crtcs[__i].new_state), 1); \ 305 - (__i)--) \ 306 - for_each_if(crtc) 335 + for_each_intel_crtc_reverse((__state)->base.dev, (crtc)) \ 336 + for_each_if(((__i) = drm_crtc_index(&(crtc)->base), (void)(__i), \ 337 + (old_crtc_state) = intel_atomic_get_old_crtc_state((__state), (crtc)), \ 338 + (new_crtc_state) = intel_atomic_get_new_crtc_state((__state), (crtc)))) 307 339 308 340 #define intel_atomic_crtc_state_for_each_plane_state( \ 309 341 plane, plane_state, \
+3
drivers/gpu/drm/i915/display/intel_display_core.h
··· 294 294 /* Parent, or core, driver functions exposed to display */ 295 295 const struct intel_display_parent_interface *parent; 296 296 297 + /* list of all intel_crtcs sorted by pipe */ 298 + struct list_head pipe_list; 299 + 297 300 /* Display functions */ 298 301 struct { 299 302 /* Top level crtc-ish functions */
+1
drivers/gpu/drm/i915/display/intel_display_driver.c
··· 117 117 118 118 drm_mode_config_init(display->drm); 119 119 INIT_LIST_HEAD(&display->global.obj_list); 120 + INIT_LIST_HEAD(&display->pipe_list); 120 121 121 122 mode_config->min_width = 0; 122 123 mode_config->min_height = 0;
+1
drivers/gpu/drm/i915/display/intel_display_types.h
··· 1484 1484 1485 1485 struct intel_crtc { 1486 1486 struct drm_crtc base; 1487 + struct list_head pipe_head; 1487 1488 enum pipe pipe; 1488 1489 /* 1489 1490 * Whether the crtc and the connected output pipeline is active. Implies
+1
drivers/gpu/drm/xe/display/xe_display.c
··· 21 21 #include "intel_audio.h" 22 22 #include "intel_bw.h" 23 23 #include "intel_display.h" 24 + #include "intel_display_core.h" 24 25 #include "intel_display_device.h" 25 26 #include "intel_display_driver.h" 26 27 #include "intel_display_irq.h"