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: Split 'struct intel_overlay'

Split the i915 driver specific bits from 'struct intel_overlay'
into a seaarate 'struct i915_overlay'. The latter will move to
the i915 side of the parent vs. display driver split.

The display side will also need to know the virtual address of
the register map. That now gets passed as the return value
from i915_overlay_setup(), so that the display side doesn't
need to know how the mapping was achieved.

v2: Use kzalloc_obj()

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

+81 -52
+78 -52
drivers/gpu/drm/i915/display/intel_overlay.c
··· 187 187 u16 RESERVEDG[0x100 / 2 - N_HORIZ_UV_TAPS * N_PHASES]; 188 188 }; 189 189 190 - struct intel_overlay { 191 - struct intel_display *display; 190 + struct i915_overlay { 191 + struct drm_i915_private *i915; 192 192 struct intel_context *context; 193 - struct intel_crtc *crtc; 194 193 struct i915_vma *vma; 195 194 struct i915_vma *old_vma; 196 195 struct intel_frontbuffer *frontbuffer; 196 + /* register access */ 197 + struct drm_i915_gem_object *reg_bo; 198 + void __iomem *regs; 199 + u32 flip_addr; 200 + u32 frontbuffer_bits; 201 + /* flip handling */ 202 + struct i915_active last_flip; 203 + void (*flip_complete)(struct i915_overlay *overlay); 204 + }; 205 + 206 + struct intel_overlay { 207 + struct intel_display *display; 208 + struct intel_crtc *crtc; 197 209 bool pfit_active; 198 210 u32 pfit_vscale_ratio; /* shifted-point number, (1<<12) == 1.0 */ 199 211 u32 color_key:24; 200 212 u32 color_key_enabled:1; 201 213 u32 brightness, contrast, saturation; 202 214 u32 old_xscale, old_yscale; 203 - /* register access */ 204 - struct drm_i915_gem_object *reg_bo; 205 215 struct overlay_registers __iomem *regs; 206 - u32 flip_addr; 207 - u32 frontbuffer_bits; 208 - /* flip handling */ 209 - struct i915_active last_flip; 210 - void (*flip_complete)(struct intel_overlay *ovl); 211 216 }; 212 217 213 218 static void i830_overlay_clock_gating(struct drm_i915_private *i915, ··· 243 238 } 244 239 245 240 static struct i915_request * 246 - alloc_request(struct intel_overlay *overlay, void (*fn)(struct intel_overlay *)) 241 + alloc_request(struct i915_overlay *overlay, void (*fn)(struct i915_overlay *)) 247 242 { 248 243 struct i915_request *rq; 249 244 int err; ··· 265 260 266 261 static bool i915_overlay_is_active(struct drm_device *drm) 267 262 { 268 - struct intel_display *display = to_intel_display(drm); 269 - struct intel_overlay *overlay = display->overlay; 263 + struct drm_i915_private *i915 = to_i915(drm); 264 + struct i915_overlay *overlay = i915->overlay; 270 265 271 266 return overlay->frontbuffer_bits; 272 267 } ··· 276 271 u32 frontbuffer_bits) 277 272 { 278 273 struct drm_i915_private *i915 = to_i915(drm); 279 - struct intel_display *display = to_intel_display(drm); 280 - struct intel_overlay *overlay = display->overlay; 274 + struct i915_overlay *overlay = i915->overlay; 281 275 struct i915_request *rq; 282 276 u32 *cs; 283 277 ··· 308 304 return i915_active_wait(&overlay->last_flip); 309 305 } 310 306 311 - static void i915_overlay_flip_prepare(struct intel_overlay *overlay, 307 + static void i915_overlay_flip_prepare(struct i915_overlay *overlay, 312 308 struct i915_vma *vma) 313 309 { 314 - struct intel_display *display = overlay->display; 310 + struct drm_i915_private *i915 = overlay->i915; 315 311 struct intel_frontbuffer *frontbuffer = NULL; 316 312 317 - drm_WARN_ON(display->drm, overlay->old_vma); 313 + drm_WARN_ON(&i915->drm, overlay->old_vma); 318 314 319 315 if (vma) 320 316 frontbuffer = intel_frontbuffer_get(intel_bo_to_drm_bo(vma->obj)); ··· 338 334 struct i915_vma *vma, 339 335 bool load_polyphase_filter) 340 336 { 341 - struct intel_display *display = to_intel_display(drm); 342 - struct intel_overlay *overlay = display->overlay; 337 + struct drm_i915_private *i915 = to_i915(drm); 338 + struct i915_overlay *overlay = i915->overlay; 343 339 struct i915_request *rq; 344 340 u32 flip_addr = overlay->flip_addr; 345 341 u32 *cs; ··· 369 365 return 0; 370 366 } 371 367 372 - static void i915_overlay_release_old_vma(struct intel_overlay *overlay) 368 + static void i915_overlay_release_old_vma(struct i915_overlay *overlay) 373 369 { 374 - struct intel_display *display = overlay->display; 370 + struct drm_i915_private *i915 = overlay->i915; 371 + struct intel_display *display = i915->display; 375 372 struct i915_vma *vma; 376 373 377 374 vma = fetch_and_zero(&overlay->old_vma); 378 - if (drm_WARN_ON(display->drm, !vma)) 375 + if (drm_WARN_ON(&i915->drm, !vma)) 379 376 return; 380 377 381 378 intel_frontbuffer_flip(display, overlay->frontbuffer_bits); ··· 385 380 i915_vma_put(vma); 386 381 } 387 382 388 - static void i915_overlay_release_old_vid_tail(struct intel_overlay *overlay) 383 + static void i915_overlay_release_old_vid_tail(struct i915_overlay *overlay) 389 384 { 390 385 i915_overlay_release_old_vma(overlay); 391 386 } 392 387 393 - static void i915_overlay_off_tail(struct intel_overlay *overlay) 388 + static void i915_overlay_off_tail(struct i915_overlay *overlay) 394 389 { 395 - struct intel_display *display = overlay->display; 396 - struct drm_i915_private *i915 = to_i915(display->drm); 390 + struct drm_i915_private *i915 = overlay->i915; 397 391 398 392 i915_overlay_release_old_vma(overlay); 399 393 ··· 404 400 405 401 static void i915_overlay_last_flip_retire(struct i915_active *active) 406 402 { 407 - struct intel_overlay *overlay = 403 + struct i915_overlay *overlay = 408 404 container_of(active, typeof(*overlay), last_flip); 409 405 410 406 if (overlay->flip_complete) ··· 414 410 /* overlay needs to be disabled in OCMD reg */ 415 411 static int i915_overlay_off(struct drm_device *drm) 416 412 { 417 - struct intel_display *display = to_intel_display(drm); 418 - struct intel_overlay *overlay = display->overlay; 413 + struct drm_i915_private *i915 = to_i915(drm); 414 + struct i915_overlay *overlay = i915->overlay; 419 415 struct i915_request *rq; 420 416 u32 *cs, flip_addr = overlay->flip_addr; 421 417 ··· 463 459 */ 464 460 static int i915_overlay_recover_from_interrupt(struct drm_device *drm) 465 461 { 466 - struct intel_display *display = to_intel_display(drm); 467 - struct intel_overlay *overlay = display->overlay; 462 + struct drm_i915_private *i915 = to_i915(drm); 463 + struct i915_overlay *overlay = i915->overlay; 468 464 469 465 return i915_active_wait(&overlay->last_flip); 470 466 } ··· 476 472 */ 477 473 static int i915_overlay_release_old_vid(struct drm_device *drm) 478 474 { 479 - struct intel_display *display = to_intel_display(drm); 480 - struct intel_overlay *overlay = display->overlay; 475 + struct drm_i915_private *i915 = to_i915(drm); 476 + struct i915_overlay *overlay = i915->overlay; 481 477 struct i915_request *rq; 482 478 u32 *cs; 483 479 ··· 488 484 if (!overlay->old_vma) 489 485 return 0; 490 486 491 - if (!(intel_de_read(display, GEN2_ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT)) { 487 + if (!(intel_uncore_read(&i915->uncore, GEN2_ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT)) { 492 488 i915_overlay_release_old_vid_tail(overlay); 493 489 return 0; 494 490 } ··· 514 510 515 511 static void i915_overlay_reset(struct drm_device *drm) 516 512 { 517 - struct intel_display *display = to_intel_display(drm); 518 - struct intel_overlay *overlay = display->overlay; 513 + struct drm_i915_private *i915 = to_i915(drm); 514 + struct i915_overlay *overlay = i915->overlay; 519 515 520 516 if (!overlay) 521 517 return; ··· 1416 1412 return ret; 1417 1413 } 1418 1414 1419 - static int get_registers(struct intel_overlay *overlay, bool use_phys) 1415 + static int get_registers(struct i915_overlay *overlay, bool use_phys) 1420 1416 { 1421 - struct intel_display *display = overlay->display; 1422 - struct drm_i915_private *i915 = to_i915(display->drm); 1417 + struct drm_i915_private *i915 = overlay->i915; 1423 1418 struct drm_i915_gem_object *obj; 1424 1419 struct i915_vma *vma; 1425 1420 int err; ··· 1455 1452 return err; 1456 1453 } 1457 1454 1458 - static int i915_overlay_setup(struct drm_device *drm, 1459 - struct intel_overlay *overlay, 1460 - bool needs_physical) 1455 + static void __iomem *i915_overlay_setup(struct drm_device *drm, 1456 + bool needs_physical) 1461 1457 { 1462 1458 struct drm_i915_private *i915 = to_i915(drm); 1463 1459 struct intel_engine_cs *engine; 1460 + struct i915_overlay *overlay; 1461 + int ret; 1464 1462 1465 1463 engine = to_gt(i915)->engine[RCS0]; 1466 1464 if (!engine || !engine->kernel_context) 1467 - return -ENOENT; 1465 + return ERR_PTR(-ENOENT); 1468 1466 1467 + overlay = kzalloc_obj(*overlay); 1468 + if (!overlay) 1469 + return ERR_PTR(-ENOMEM); 1470 + 1471 + overlay->i915 = i915; 1469 1472 overlay->context = engine->kernel_context; 1470 1473 1471 1474 i915_active_init(&overlay->last_flip, 1472 1475 NULL, i915_overlay_last_flip_retire, 0); 1473 1476 1474 - return get_registers(overlay, needs_physical); 1477 + ret = get_registers(overlay, needs_physical); 1478 + if (ret) { 1479 + kfree(overlay); 1480 + return ERR_PTR(ret); 1481 + } 1482 + 1483 + i915->overlay = overlay; 1484 + 1485 + return overlay->regs; 1475 1486 } 1476 1487 1477 1488 void intel_overlay_setup(struct intel_display *display) 1478 1489 { 1479 1490 struct intel_overlay *overlay; 1480 - int ret; 1491 + void __iomem *regs; 1481 1492 1482 1493 if (!HAS_OVERLAY(display)) 1483 1494 return; ··· 1500 1483 if (!overlay) 1501 1484 return; 1502 1485 1503 - ret = i915_overlay_setup(display->drm, overlay, 1504 - OVERLAY_NEEDS_PHYSICAL(display)); 1505 - if (ret) 1486 + regs = i915_overlay_setup(display->drm, 1487 + OVERLAY_NEEDS_PHYSICAL(display)); 1488 + if (IS_ERR(regs)) 1506 1489 goto out_free; 1507 1490 1508 1491 overlay->display = display; 1492 + overlay->regs = regs; 1509 1493 overlay->color_key = 0x0101fe; 1510 1494 overlay->color_key_enabled = true; 1511 1495 overlay->brightness = -19; ··· 1530 1512 return display->overlay; 1531 1513 } 1532 1514 1533 - static void i915_overlay_cleanup(struct drm_device *drm, 1534 - struct intel_overlay *overlay) 1515 + static void i915_overlay_cleanup(struct drm_device *drm) 1535 1516 { 1517 + struct drm_i915_private *i915 = to_i915(drm); 1518 + struct i915_overlay *overlay; 1519 + 1520 + overlay = fetch_and_zero(&i915->overlay); 1521 + if (!overlay) 1522 + return; 1523 + 1536 1524 /* 1537 1525 * The bo's should be free'd by the generic code already. 1538 1526 * Furthermore modesetting teardown happens beforehand so the ··· 1548 1524 1549 1525 i915_gem_object_put(overlay->reg_bo); 1550 1526 i915_active_fini(&overlay->last_flip); 1527 + 1528 + kfree(overlay); 1551 1529 } 1552 1530 1553 1531 void intel_overlay_cleanup(struct intel_display *display) ··· 1560 1534 if (!overlay) 1561 1535 return; 1562 1536 1563 - i915_overlay_cleanup(display->drm, overlay); 1537 + i915_overlay_cleanup(display->drm); 1564 1538 1565 1539 kfree(overlay); 1566 1540 }
+3
drivers/gpu/drm/i915/i915_drv.h
··· 61 61 #include "intel_uncore.h" 62 62 63 63 struct drm_i915_clock_gating_funcs; 64 + struct i915_overlay; 64 65 struct intel_display; 65 66 struct intel_pxp; 66 67 struct vlv_s0ix_state; ··· 307 306 spinlock_t frontbuffer_lock; /* protects obj->frontbuffer (write-side) */ 308 307 309 308 struct intel_pxp *pxp; 309 + 310 + struct i915_overlay *overlay; 310 311 311 312 struct i915_pmu pmu; 312 313