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

Merge tag 'drm-fixes-2020-12-04' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Dave Airlie:
"This week's regular fixes.

i915 has fixes for a few races, use-after-free, and gpu hangs. Tegra
just has some minor fixes that I didn't see much point in hanging on
to. The nouveau fix is for all pre-nv50 cards and was reported a few
times. Otherwise it's just some amdgpu, and a few misc fixes.

Summary:

amdgpu:
- SMU11 manual fan fix
- Renoir display clock fix
- VCN3 dynamic powergating fix

i915:
- Program mocs:63 for cache eviction on gen9 (Chris)
- Protect context lifetime with RCU (Chris)
- Split the breadcrumb spinlock between global and contexts (Chris)
- Retain default context state across shrinking (Venkata)
- Limit frequency drop to RPe on parking (Chris)
- Return earlier from intel_modeset_init() without display (Jani)
- Defer initial modeset until after GGTT is initialized (Chris)

nouveau:
- pre-nv50 regression fix

rockchip:
- uninitialised LVDS property fix

omap:
- bridge fix

panel:
- race fix

mxsfb:
- fence sync fix
- modifiers fix

tegra:
- idr init fix
- sor fixes
- output/of cleanup fix"

* tag 'drm-fixes-2020-12-04' of git://anongit.freedesktop.org/drm/drm: (22 commits)
drm/amdgpu/vcn3.0: remove old DPG workaround
drm/amdgpu/vcn3.0: stall DPG when WPTR/RPTR reset
drm/amd/display: Init clock value by current vbios CLKs
drm/amdgpu/pm/smu11: Fix fan set speed bug
drm/i915/display: Defer initial modeset until after GGTT is initialised
drm/i915/display: return earlier from intel_modeset_init() without display
drm/i915/gt: Limit frequency drop to RPe on parking
drm/i915/gt: Retain default context state across shrinking
drm/i915/gt: Split the breadcrumb spinlock between global and contexts
drm/i915/gt: Protect context lifetime with RCU
drm/i915/gt: Program mocs:63 for cache eviction on gen9
drm/omap: sdi: fix bridge enable/disable
drm/panel: sony-acx565akm: Fix race condition in probe
drm/rockchip: Avoid uninitialized use of endpoint id in LVDS
drm/tegra: sor: Disable clocks on error in tegra_sor_init()
drm/nouveau: make sure ret is initialized in nouveau_ttm_io_mem_reserve
drm: mxsfb: Implement .format_mod_supported
drm: mxsfb: fix fence synchronization
drm/tegra: output: Do not put OF node twice
drm/tegra: replace idr_init() by idr_init_base()
...

+233 -185
+19 -6
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
··· 1011 1011 tmp = REG_SET_FIELD(tmp, UVD_RBC_RB_CNTL, RB_RPTR_WR_EN, 1); 1012 1012 WREG32_SOC15(VCN, inst_idx, mmUVD_RBC_RB_CNTL, tmp); 1013 1013 1014 + /* Stall DPG before WPTR/RPTR reset */ 1015 + WREG32_P(SOC15_REG_OFFSET(VCN, inst_idx, mmUVD_POWER_STATUS), 1016 + UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK, 1017 + ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK); 1018 + 1014 1019 /* set the write pointer delay */ 1015 1020 WREG32_SOC15(VCN, inst_idx, mmUVD_RBC_RB_WPTR_CNTL, 0); 1016 1021 ··· 1037 1032 ring->wptr = RREG32_SOC15(VCN, inst_idx, mmUVD_RBC_RB_RPTR); 1038 1033 WREG32_SOC15(VCN, inst_idx, mmUVD_RBC_RB_WPTR, 1039 1034 lower_32_bits(ring->wptr)); 1035 + 1036 + /* Unstall DPG */ 1037 + WREG32_P(SOC15_REG_OFFSET(VCN, inst_idx, mmUVD_POWER_STATUS), 1038 + 0, ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK); 1040 1039 1041 1040 return 0; 1042 1041 } ··· 1565 1556 UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK, 1566 1557 UVD_DPG_PAUSE__NJ_PAUSE_DPG_ACK_MASK); 1567 1558 1559 + /* Stall DPG before WPTR/RPTR reset */ 1560 + WREG32_P(SOC15_REG_OFFSET(VCN, inst_idx, mmUVD_POWER_STATUS), 1561 + UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK, 1562 + ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK); 1563 + 1568 1564 /* Restore */ 1569 1565 ring = &adev->vcn.inst[inst_idx].ring_enc[0]; 1566 + ring->wptr = 0; 1570 1567 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_BASE_LO, ring->gpu_addr); 1571 1568 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_BASE_HI, upper_32_bits(ring->gpu_addr)); 1572 1569 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_SIZE, ring->ring_size / 4); ··· 1580 1565 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_WPTR, lower_32_bits(ring->wptr)); 1581 1566 1582 1567 ring = &adev->vcn.inst[inst_idx].ring_enc[1]; 1568 + ring->wptr = 0; 1583 1569 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_BASE_LO2, ring->gpu_addr); 1584 1570 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_BASE_HI2, upper_32_bits(ring->gpu_addr)); 1585 1571 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_SIZE2, ring->ring_size / 4); 1586 1572 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_RPTR2, lower_32_bits(ring->wptr)); 1587 1573 WREG32_SOC15(VCN, inst_idx, mmUVD_RB_WPTR2, lower_32_bits(ring->wptr)); 1588 1574 1589 - WREG32_SOC15(VCN, inst_idx, mmUVD_RBC_RB_WPTR, 1590 - RREG32_SOC15(VCN, inst_idx, mmUVD_SCRATCH2) & 0x7FFFFFFF); 1575 + /* Unstall DPG */ 1576 + WREG32_P(SOC15_REG_OFFSET(VCN, inst_idx, mmUVD_POWER_STATUS), 1577 + 0, ~UVD_POWER_STATUS__STALL_DPG_POWER_UP_MASK); 1591 1578 1592 1579 SOC15_WAIT_ON_RREG(VCN, inst_idx, mmUVD_POWER_STATUS, 1593 1580 UVD_PGFSM_CONFIG__UVDM_UVDU_PWR_ON, UVD_POWER_STATUS__UVD_POWER_STATUS_MASK); ··· 1646 1629 static void vcn_v3_0_dec_ring_set_wptr(struct amdgpu_ring *ring) 1647 1630 { 1648 1631 struct amdgpu_device *adev = ring->adev; 1649 - 1650 - if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) 1651 - WREG32_SOC15(VCN, ring->me, mmUVD_SCRATCH2, 1652 - lower_32_bits(ring->wptr) | 0x80000000); 1653 1632 1654 1633 if (ring->use_doorbell) { 1655 1634 adev->wb.wb[ring->wptr_offs] = lower_32_bits(ring->wptr);
+11 -2
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
··· 163 163 new_clocks->dppclk_khz = 100000; 164 164 } 165 165 166 - if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr->base.clks.dppclk_khz)) { 167 - if (clk_mgr->base.clks.dppclk_khz > new_clocks->dppclk_khz) 166 + /* 167 + * Temporally ignore thew 0 cases for disp and dpp clks. 168 + * We may have a new feature that requires 0 clks in the future. 169 + */ 170 + if (new_clocks->dppclk_khz == 0 || new_clocks->dispclk_khz == 0) { 171 + new_clocks->dppclk_khz = clk_mgr_base->clks.dppclk_khz; 172 + new_clocks->dispclk_khz = clk_mgr_base->clks.dispclk_khz; 173 + } 174 + 175 + if (should_set_clock(safe_to_lower, new_clocks->dppclk_khz, clk_mgr_base->clks.dppclk_khz)) { 176 + if (clk_mgr_base->clks.dppclk_khz > new_clocks->dppclk_khz) 168 177 dpp_clock_lowered = true; 169 178 clk_mgr_base->clks.dppclk_khz = new_clocks->dppclk_khz; 170 179 update_dppclk = true;
+6 -1
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
··· 1164 1164 if (ret) 1165 1165 return ret; 1166 1166 1167 - crystal_clock_freq = amdgpu_asic_get_xclk(adev); 1167 + /* 1168 + * crystal_clock_freq div by 4 is required since the fan control 1169 + * module refers to 25MHz 1170 + */ 1171 + 1172 + crystal_clock_freq = amdgpu_asic_get_xclk(adev) / 4; 1168 1173 tach_period = 60 * crystal_clock_freq * 10000 / (8 * speed); 1169 1174 WREG32_SOC15(THM, 0, mmCG_TACH_CTRL, 1170 1175 REG_SET_FIELD(RREG32_SOC15(THM, 0, mmCG_TACH_CTRL),
+12 -12
drivers/gpu/drm/i915/display/intel_display.c
··· 18021 18021 if (!HAS_GMCH(i915)) 18022 18022 sanitize_watermarks(i915); 18023 18023 18024 - /* 18025 - * Force all active planes to recompute their states. So that on 18026 - * mode_setcrtc after probe, all the intel_plane_state variables 18027 - * are already calculated and there is no assert_plane warnings 18028 - * during bootup. 18029 - */ 18030 - ret = intel_initial_commit(dev); 18031 - if (ret) 18032 - drm_dbg_kms(&i915->drm, "Initial commit in probe failed.\n"); 18033 - 18034 18024 return 0; 18035 18025 } 18036 18026 ··· 18029 18039 { 18030 18040 int ret; 18031 18041 18032 - intel_overlay_setup(i915); 18033 - 18034 18042 if (!HAS_DISPLAY(i915)) 18035 18043 return 0; 18044 + 18045 + /* 18046 + * Force all active planes to recompute their states. So that on 18047 + * mode_setcrtc after probe, all the intel_plane_state variables 18048 + * are already calculated and there is no assert_plane warnings 18049 + * during bootup. 18050 + */ 18051 + ret = intel_initial_commit(&i915->drm); 18052 + if (ret) 18053 + return ret; 18054 + 18055 + intel_overlay_setup(i915); 18036 18056 18037 18057 ret = intel_fbdev_init(&i915->drm); 18038 18058 if (ret)
+74 -94
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
··· 101 101 intel_gt_pm_put_async(b->irq_engine->gt); 102 102 } 103 103 104 + static void intel_breadcrumbs_disarm_irq(struct intel_breadcrumbs *b) 105 + { 106 + spin_lock(&b->irq_lock); 107 + if (b->irq_armed) 108 + __intel_breadcrumbs_disarm_irq(b); 109 + spin_unlock(&b->irq_lock); 110 + } 111 + 104 112 static void add_signaling_context(struct intel_breadcrumbs *b, 105 113 struct intel_context *ce) 106 114 { 107 - intel_context_get(ce); 108 - list_add_tail(&ce->signal_link, &b->signalers); 115 + lockdep_assert_held(&ce->signal_lock); 116 + 117 + spin_lock(&b->signalers_lock); 118 + list_add_rcu(&ce->signal_link, &b->signalers); 119 + spin_unlock(&b->signalers_lock); 109 120 } 110 121 111 - static void remove_signaling_context(struct intel_breadcrumbs *b, 122 + static bool remove_signaling_context(struct intel_breadcrumbs *b, 112 123 struct intel_context *ce) 113 124 { 114 - list_del(&ce->signal_link); 115 - intel_context_put(ce); 125 + lockdep_assert_held(&ce->signal_lock); 126 + 127 + if (!list_empty(&ce->signals)) 128 + return false; 129 + 130 + spin_lock(&b->signalers_lock); 131 + list_del_rcu(&ce->signal_link); 132 + spin_unlock(&b->signalers_lock); 133 + 134 + return true; 116 135 } 117 136 118 137 static inline bool __request_completed(const struct i915_request *rq) ··· 194 175 195 176 static bool __signal_request(struct i915_request *rq) 196 177 { 178 + GEM_BUG_ON(test_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags)); 179 + 197 180 if (!__dma_fence_signal(&rq->fence)) { 198 181 i915_request_put(rq); 199 182 return false; ··· 216 195 struct intel_breadcrumbs *b = container_of(work, typeof(*b), irq_work); 217 196 const ktime_t timestamp = ktime_get(); 218 197 struct llist_node *signal, *sn; 219 - struct intel_context *ce, *cn; 220 - struct list_head *pos, *next; 198 + struct intel_context *ce; 221 199 222 200 signal = NULL; 223 201 if (unlikely(!llist_empty(&b->signaled_requests))) 224 202 signal = llist_del_all(&b->signaled_requests); 225 - 226 - spin_lock(&b->irq_lock); 227 203 228 204 /* 229 205 * Keep the irq armed until the interrupt after all listeners are gone. ··· 247 229 * interrupt draw less ire from other users of the system and tools 248 230 * like powertop. 249 231 */ 250 - if (!signal && b->irq_armed && list_empty(&b->signalers)) 251 - __intel_breadcrumbs_disarm_irq(b); 232 + if (!signal && READ_ONCE(b->irq_armed) && list_empty(&b->signalers)) 233 + intel_breadcrumbs_disarm_irq(b); 252 234 253 - list_for_each_entry_safe(ce, cn, &b->signalers, signal_link) { 254 - GEM_BUG_ON(list_empty(&ce->signals)); 235 + rcu_read_lock(); 236 + list_for_each_entry_rcu(ce, &b->signalers, signal_link) { 237 + struct i915_request *rq; 255 238 256 - list_for_each_safe(pos, next, &ce->signals) { 257 - struct i915_request *rq = 258 - list_entry(pos, typeof(*rq), signal_link); 239 + list_for_each_entry_rcu(rq, &ce->signals, signal_link) { 240 + bool release; 259 241 260 - GEM_BUG_ON(!check_signal_order(ce, rq)); 261 242 if (!__request_completed(rq)) 243 + break; 244 + 245 + if (!test_and_clear_bit(I915_FENCE_FLAG_SIGNAL, 246 + &rq->fence.flags)) 262 247 break; 263 248 264 249 /* ··· 269 248 * spinlock as the callback chain may end up adding 270 249 * more signalers to the same context or engine. 271 250 */ 272 - clear_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags); 251 + spin_lock(&ce->signal_lock); 252 + list_del_rcu(&rq->signal_link); 253 + release = remove_signaling_context(b, ce); 254 + spin_unlock(&ce->signal_lock); 255 + 273 256 if (__signal_request(rq)) 274 257 /* We own signal_node now, xfer to local list */ 275 258 signal = slist_add(&rq->signal_node, signal); 276 - } 277 259 278 - /* 279 - * We process the list deletion in bulk, only using a list_add 280 - * (not list_move) above but keeping the status of 281 - * rq->signal_link known with the I915_FENCE_FLAG_SIGNAL bit. 282 - */ 283 - if (!list_is_first(pos, &ce->signals)) { 284 - /* Advance the list to the first incomplete request */ 285 - __list_del_many(&ce->signals, pos); 286 - if (&ce->signals == pos) { /* now empty */ 260 + if (release) { 287 261 add_retire(b, ce->timeline); 288 - remove_signaling_context(b, ce); 262 + intel_context_put(ce); 289 263 } 290 264 } 291 265 } 292 - 293 - spin_unlock(&b->irq_lock); 266 + rcu_read_unlock(); 294 267 295 268 llist_for_each_safe(signal, sn, signal) { 296 269 struct i915_request *rq = ··· 313 298 if (!b) 314 299 return NULL; 315 300 316 - spin_lock_init(&b->irq_lock); 301 + b->irq_engine = irq_engine; 302 + 303 + spin_lock_init(&b->signalers_lock); 317 304 INIT_LIST_HEAD(&b->signalers); 318 305 init_llist_head(&b->signaled_requests); 319 306 307 + spin_lock_init(&b->irq_lock); 320 308 init_irq_work(&b->irq_work, signal_irq_work); 321 - 322 - b->irq_engine = irq_engine; 323 309 324 310 return b; 325 311 } ··· 363 347 kfree(b); 364 348 } 365 349 366 - static void insert_breadcrumb(struct i915_request *rq, 367 - struct intel_breadcrumbs *b) 350 + static void insert_breadcrumb(struct i915_request *rq) 368 351 { 352 + struct intel_breadcrumbs *b = READ_ONCE(rq->engine)->breadcrumbs; 369 353 struct intel_context *ce = rq->context; 370 354 struct list_head *pos; 371 355 ··· 387 371 } 388 372 389 373 if (list_empty(&ce->signals)) { 374 + intel_context_get(ce); 390 375 add_signaling_context(b, ce); 391 376 pos = &ce->signals; 392 377 } else { ··· 413 396 break; 414 397 } 415 398 } 416 - list_add(&rq->signal_link, pos); 399 + list_add_rcu(&rq->signal_link, pos); 417 400 GEM_BUG_ON(!check_signal_order(ce, rq)); 401 + GEM_BUG_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags)); 418 402 set_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags); 419 403 420 404 /* ··· 428 410 429 411 bool i915_request_enable_breadcrumb(struct i915_request *rq) 430 412 { 431 - struct intel_breadcrumbs *b; 413 + struct intel_context *ce = rq->context; 432 414 433 415 /* Serialises with i915_request_retire() using rq->lock */ 434 416 if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags)) ··· 443 425 if (!test_bit(I915_FENCE_FLAG_ACTIVE, &rq->fence.flags)) 444 426 return true; 445 427 446 - /* 447 - * rq->engine is locked by rq->engine->active.lock. That however 448 - * is not known until after rq->engine has been dereferenced and 449 - * the lock acquired. Hence we acquire the lock and then validate 450 - * that rq->engine still matches the lock we hold for it. 451 - * 452 - * Here, we are using the breadcrumb lock as a proxy for the 453 - * rq->engine->active.lock, and we know that since the breadcrumb 454 - * will be serialised within i915_request_submit/i915_request_unsubmit, 455 - * the engine cannot change while active as long as we hold the 456 - * breadcrumb lock on that engine. 457 - * 458 - * From the dma_fence_enable_signaling() path, we are outside of the 459 - * request submit/unsubmit path, and so we must be more careful to 460 - * acquire the right lock. 461 - */ 462 - b = READ_ONCE(rq->engine)->breadcrumbs; 463 - spin_lock(&b->irq_lock); 464 - while (unlikely(b != READ_ONCE(rq->engine)->breadcrumbs)) { 465 - spin_unlock(&b->irq_lock); 466 - b = READ_ONCE(rq->engine)->breadcrumbs; 467 - spin_lock(&b->irq_lock); 468 - } 469 - 470 - /* 471 - * Now that we are finally serialised with request submit/unsubmit, 472 - * [with b->irq_lock] and with i915_request_retire() [via checking 473 - * SIGNALED with rq->lock] confirm the request is indeed active. If 474 - * it is no longer active, the breadcrumb will be attached upon 475 - * i915_request_submit(). 476 - */ 428 + spin_lock(&ce->signal_lock); 477 429 if (test_bit(I915_FENCE_FLAG_ACTIVE, &rq->fence.flags)) 478 - insert_breadcrumb(rq, b); 479 - 480 - spin_unlock(&b->irq_lock); 430 + insert_breadcrumb(rq); 431 + spin_unlock(&ce->signal_lock); 481 432 482 433 return true; 483 434 } 484 435 485 436 void i915_request_cancel_breadcrumb(struct i915_request *rq) 486 437 { 487 - struct intel_breadcrumbs *b = rq->engine->breadcrumbs; 438 + struct intel_context *ce = rq->context; 439 + bool release; 488 440 489 - /* 490 - * We must wait for b->irq_lock so that we know the interrupt handler 491 - * has released its reference to the intel_context and has completed 492 - * the DMA_FENCE_FLAG_SIGNALED_BIT/I915_FENCE_FLAG_SIGNAL dance (if 493 - * required). 494 - */ 495 - spin_lock(&b->irq_lock); 496 - if (test_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags)) { 497 - struct intel_context *ce = rq->context; 441 + if (!test_and_clear_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags)) 442 + return; 498 443 499 - list_del(&rq->signal_link); 500 - if (list_empty(&ce->signals)) 501 - remove_signaling_context(b, ce); 444 + spin_lock(&ce->signal_lock); 445 + list_del_rcu(&rq->signal_link); 446 + release = remove_signaling_context(rq->engine->breadcrumbs, ce); 447 + spin_unlock(&ce->signal_lock); 448 + if (release) 449 + intel_context_put(ce); 502 450 503 - clear_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags); 504 - i915_request_put(rq); 505 - } 506 - spin_unlock(&b->irq_lock); 451 + i915_request_put(rq); 507 452 } 508 453 509 454 static void print_signals(struct intel_breadcrumbs *b, struct drm_printer *p) ··· 476 495 477 496 drm_printf(p, "Signals:\n"); 478 497 479 - spin_lock_irq(&b->irq_lock); 480 - list_for_each_entry(ce, &b->signalers, signal_link) { 481 - list_for_each_entry(rq, &ce->signals, signal_link) { 498 + rcu_read_lock(); 499 + list_for_each_entry_rcu(ce, &b->signalers, signal_link) { 500 + list_for_each_entry_rcu(rq, &ce->signals, signal_link) 482 501 drm_printf(p, "\t[%llx:%llx%s] @ %dms\n", 483 502 rq->fence.context, rq->fence.seqno, 484 503 i915_request_completed(rq) ? "!" : 485 504 i915_request_started(rq) ? "*" : 486 505 "", 487 506 jiffies_to_msecs(jiffies - rq->emitted_jiffies)); 488 - } 489 507 } 490 - spin_unlock_irq(&b->irq_lock); 508 + rcu_read_unlock(); 491 509 } 492 510 493 511 void intel_engine_print_breadcrumbs(struct intel_engine_cs *engine,
+2 -4
drivers/gpu/drm/i915/gt/intel_breadcrumbs_types.h
··· 29 29 * the overhead of waking that client is much preferred. 30 30 */ 31 31 struct intel_breadcrumbs { 32 - spinlock_t irq_lock; /* protects the lists used in hardirq context */ 33 - 34 32 /* Not all breadcrumbs are attached to physical HW */ 35 33 struct intel_engine_cs *irq_engine; 36 34 35 + spinlock_t signalers_lock; /* protects the list of signalers */ 37 36 struct list_head signalers; 38 37 struct llist_head signaled_requests; 39 38 39 + spinlock_t irq_lock; /* protects the interrupt from hardirq context */ 40 40 struct irq_work irq_work; /* for use from inside irq_lock */ 41 - 42 41 unsigned int irq_enabled; 43 - 44 42 bool irq_armed; 45 43 }; 46 44
+11 -4
drivers/gpu/drm/i915/gt/intel_context.c
··· 25 25 return kmem_cache_zalloc(global.slab_ce, GFP_KERNEL); 26 26 } 27 27 28 + static void rcu_context_free(struct rcu_head *rcu) 29 + { 30 + struct intel_context *ce = container_of(rcu, typeof(*ce), rcu); 31 + 32 + kmem_cache_free(global.slab_ce, ce); 33 + } 34 + 28 35 void intel_context_free(struct intel_context *ce) 29 36 { 30 - kmem_cache_free(global.slab_ce, ce); 37 + call_rcu(&ce->rcu, rcu_context_free); 31 38 } 32 39 33 40 struct intel_context * ··· 363 356 } 364 357 365 358 void 366 - intel_context_init(struct intel_context *ce, 367 - struct intel_engine_cs *engine) 359 + intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine) 368 360 { 369 361 GEM_BUG_ON(!engine->cops); 370 362 GEM_BUG_ON(!engine->gt->vm); ··· 379 373 380 374 ce->vm = i915_vm_get(engine->gt->vm); 381 375 382 - INIT_LIST_HEAD(&ce->signal_link); 376 + /* NB ce->signal_link/lock is used under RCU */ 377 + spin_lock_init(&ce->signal_lock); 383 378 INIT_LIST_HEAD(&ce->signals); 384 379 385 380 mutex_init(&ce->pin_mutex);
+20 -3
drivers/gpu/drm/i915/gt/intel_context_types.h
··· 25 25 struct i915_gem_context; 26 26 struct i915_gem_ww_ctx; 27 27 struct i915_vma; 28 + struct intel_breadcrumbs; 28 29 struct intel_context; 29 30 struct intel_ring; 30 31 ··· 45 44 }; 46 45 47 46 struct intel_context { 48 - struct kref ref; 47 + /* 48 + * Note: Some fields may be accessed under RCU. 49 + * 50 + * Unless otherwise noted a field can safely be assumed to be protected 51 + * by strong reference counting. 52 + */ 53 + union { 54 + struct kref ref; /* no kref_get_unless_zero()! */ 55 + struct rcu_head rcu; 56 + }; 49 57 50 58 struct intel_engine_cs *engine; 51 59 struct intel_engine_cs *inflight; ··· 64 54 struct i915_address_space *vm; 65 55 struct i915_gem_context __rcu *gem_context; 66 56 67 - struct list_head signal_link; 68 - struct list_head signals; 57 + /* 58 + * @signal_lock protects the list of requests that need signaling, 59 + * @signals. While there are any requests that need signaling, 60 + * we add the context to the breadcrumbs worker, and remove it 61 + * upon completion/cancellation of the last request. 62 + */ 63 + struct list_head signal_link; /* Accessed under RCU */ 64 + struct list_head signals; /* Guarded by signal_lock */ 65 + spinlock_t signal_lock; /* protects signals, the list of requests */ 69 66 70 67 struct i915_vma *state; 71 68 struct intel_ring *ring;
+13 -1
drivers/gpu/drm/i915/gt/intel_mocs.c
··· 131 131 GEN9_MOCS_ENTRIES, 132 132 MOCS_ENTRY(I915_MOCS_CACHED, 133 133 LE_3_WB | LE_TC_2_LLC_ELLC | LE_LRUM(3), 134 - L3_3_WB) 134 + L3_3_WB), 135 + 136 + /* 137 + * mocs:63 138 + * - used by the L3 for all of its evictions. 139 + * Thus it is expected to allow LLC cacheability to enable coherent 140 + * flows to be maintained. 141 + * - used to force L3 uncachable cycles. 142 + * Thus it is expected to make the surface L3 uncacheable. 143 + */ 144 + MOCS_ENTRY(63, 145 + LE_3_WB | LE_TC_1_LLC | LE_LRUM(3), 146 + L3_1_UC) 135 147 }; 136 148 137 149 /* NOTE: the LE_TGT_CACHE is not used on Broxton */
+4
drivers/gpu/drm/i915/gt/intel_rps.c
··· 883 883 adj = -2; 884 884 rps->last_adj = adj; 885 885 rps->cur_freq = max_t(int, rps->cur_freq + adj, rps->min_freq); 886 + if (rps->cur_freq < rps->efficient_freq) { 887 + rps->cur_freq = rps->efficient_freq; 888 + rps->last_adj = 0; 889 + } 886 890 887 891 GT_TRACE(rps_to_gt(rps), "park:%x\n", rps->cur_freq); 888 892 }
+5 -2
drivers/gpu/drm/i915/gt/shmem_utils.c
··· 103 103 return PTR_ERR(page); 104 104 105 105 vaddr = kmap(page); 106 - if (write) 106 + if (write) { 107 107 memcpy(vaddr + offset_in_page(off), ptr, this); 108 - else 108 + set_page_dirty(page); 109 + } else { 109 110 memcpy(ptr, vaddr + offset_in_page(off), this); 111 + } 112 + mark_page_accessed(page); 110 113 kunmap(page); 111 114 put_page(page); 112 115
+2 -4
drivers/gpu/drm/i915/i915_request.h
··· 177 177 struct intel_ring *ring; 178 178 struct intel_timeline __rcu *timeline; 179 179 180 - union { 181 - struct list_head signal_link; 182 - struct llist_node signal_node; 183 - }; 180 + struct list_head signal_link; 181 + struct llist_node signal_node; 184 182 185 183 /* 186 184 * The rcu epoch of when this request was allocated. Used to judiciously
+11
drivers/gpu/drm/mxsfb/mxsfb_kms.c
··· 22 22 #include <drm/drm_fb_cma_helper.h> 23 23 #include <drm/drm_fourcc.h> 24 24 #include <drm/drm_gem_cma_helper.h> 25 + #include <drm/drm_gem_framebuffer_helper.h> 25 26 #include <drm/drm_plane.h> 26 27 #include <drm/drm_plane_helper.h> 27 28 #include <drm/drm_vblank.h> ··· 485 484 writel(ctrl, mxsfb->base + LCDC_AS_CTRL); 486 485 } 487 486 487 + static bool mxsfb_format_mod_supported(struct drm_plane *plane, 488 + uint32_t format, 489 + uint64_t modifier) 490 + { 491 + return modifier == DRM_FORMAT_MOD_LINEAR; 492 + } 493 + 488 494 static const struct drm_plane_helper_funcs mxsfb_plane_primary_helper_funcs = { 495 + .prepare_fb = drm_gem_fb_prepare_fb, 489 496 .atomic_check = mxsfb_plane_atomic_check, 490 497 .atomic_update = mxsfb_plane_primary_atomic_update, 491 498 }; 492 499 493 500 static const struct drm_plane_helper_funcs mxsfb_plane_overlay_helper_funcs = { 501 + .prepare_fb = drm_gem_fb_prepare_fb, 494 502 .atomic_check = mxsfb_plane_atomic_check, 495 503 .atomic_update = mxsfb_plane_overlay_atomic_update, 496 504 }; 497 505 498 506 static const struct drm_plane_funcs mxsfb_plane_funcs = { 507 + .format_mod_supported = mxsfb_format_mod_supported, 499 508 .update_plane = drm_atomic_helper_update_plane, 500 509 .disable_plane = drm_atomic_helper_disable_plane, 501 510 .destroy = drm_plane_cleanup,
+1 -1
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 1214 1214 } 1215 1215 1216 1216 reg->bus.offset = handle; 1217 - ret = 0; 1218 1217 } 1218 + ret = 0; 1219 1219 break; 1220 1220 default: 1221 1221 ret = -EINVAL;
+4 -6
drivers/gpu/drm/omapdrm/dss/sdi.c
··· 195 195 sdi->pixelclock = adjusted_mode->clock * 1000; 196 196 } 197 197 198 - static void sdi_bridge_enable(struct drm_bridge *bridge, 199 - struct drm_bridge_state *bridge_state) 198 + static void sdi_bridge_enable(struct drm_bridge *bridge) 200 199 { 201 200 struct sdi_device *sdi = drm_bridge_to_sdi(bridge); 202 201 struct dispc_clock_info dispc_cinfo; ··· 258 259 regulator_disable(sdi->vdds_sdi_reg); 259 260 } 260 261 261 - static void sdi_bridge_disable(struct drm_bridge *bridge, 262 - struct drm_bridge_state *bridge_state) 262 + static void sdi_bridge_disable(struct drm_bridge *bridge) 263 263 { 264 264 struct sdi_device *sdi = drm_bridge_to_sdi(bridge); 265 265 ··· 276 278 .mode_valid = sdi_bridge_mode_valid, 277 279 .mode_fixup = sdi_bridge_mode_fixup, 278 280 .mode_set = sdi_bridge_mode_set, 279 - .atomic_enable = sdi_bridge_enable, 280 - .atomic_disable = sdi_bridge_disable, 281 + .enable = sdi_bridge_enable, 282 + .disable = sdi_bridge_disable, 281 283 }; 282 284 283 285 static void sdi_bridge_init(struct sdi_device *sdi)
+1 -1
drivers/gpu/drm/panel/panel-sony-acx565akm.c
··· 629 629 lcd->spi = spi; 630 630 mutex_init(&lcd->mutex); 631 631 632 - lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW); 632 + lcd->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); 633 633 if (IS_ERR(lcd->reset_gpio)) { 634 634 dev_err(&spi->dev, "failed to get reset GPIO\n"); 635 635 return PTR_ERR(lcd->reset_gpio);
+1 -1
drivers/gpu/drm/rockchip/rockchip_lvds.c
··· 544 544 struct device_node *port, *endpoint; 545 545 int ret = 0, child_count = 0; 546 546 const char *name; 547 - u32 endpoint_id; 547 + u32 endpoint_id = 0; 548 548 549 549 lvds->drm_dev = drm_dev; 550 550 port = of_graph_get_port_by_id(dev->of_node, 1);
+1 -1
drivers/gpu/drm/tegra/drm.c
··· 90 90 if (!fpriv) 91 91 return -ENOMEM; 92 92 93 - idr_init(&fpriv->contexts); 93 + idr_init_base(&fpriv->contexts, 1); 94 94 mutex_init(&fpriv->lock); 95 95 filp->driver_priv = fpriv; 96 96
-1
drivers/gpu/drm/tegra/output.c
··· 129 129 130 130 if (!output->ddc) { 131 131 err = -EPROBE_DEFER; 132 - of_node_put(ddc); 133 132 return err; 134 133 } 135 134 }
+35 -41
drivers/gpu/drm/tegra/sor.c
··· 397 397 struct tegra_sor_ops { 398 398 const char *name; 399 399 int (*probe)(struct tegra_sor *sor); 400 - int (*remove)(struct tegra_sor *sor); 401 400 void (*audio_enable)(struct tegra_sor *sor); 402 401 void (*audio_disable)(struct tegra_sor *sor); 403 402 }; ··· 2941 2942 .atomic_check = tegra_sor_encoder_atomic_check, 2942 2943 }; 2943 2944 2945 + static void tegra_sor_disable_regulator(void *data) 2946 + { 2947 + struct regulator *reg = data; 2948 + 2949 + regulator_disable(reg); 2950 + } 2951 + 2952 + static int tegra_sor_enable_regulator(struct tegra_sor *sor, struct regulator *reg) 2953 + { 2954 + int err; 2955 + 2956 + err = regulator_enable(reg); 2957 + if (err) 2958 + return err; 2959 + 2960 + return devm_add_action_or_reset(sor->dev, tegra_sor_disable_regulator, reg); 2961 + } 2962 + 2944 2963 static int tegra_sor_hdmi_probe(struct tegra_sor *sor) 2945 2964 { 2946 2965 int err; ··· 2970 2953 return PTR_ERR(sor->avdd_io_supply); 2971 2954 } 2972 2955 2973 - err = regulator_enable(sor->avdd_io_supply); 2956 + err = tegra_sor_enable_regulator(sor, sor->avdd_io_supply); 2974 2957 if (err < 0) { 2975 2958 dev_err(sor->dev, "failed to enable AVDD I/O supply: %d\n", 2976 2959 err); ··· 2984 2967 return PTR_ERR(sor->vdd_pll_supply); 2985 2968 } 2986 2969 2987 - err = regulator_enable(sor->vdd_pll_supply); 2970 + err = tegra_sor_enable_regulator(sor, sor->vdd_pll_supply); 2988 2971 if (err < 0) { 2989 2972 dev_err(sor->dev, "failed to enable VDD PLL supply: %d\n", 2990 2973 err); ··· 2998 2981 return PTR_ERR(sor->hdmi_supply); 2999 2982 } 3000 2983 3001 - err = regulator_enable(sor->hdmi_supply); 2984 + err = tegra_sor_enable_regulator(sor, sor->hdmi_supply); 3002 2985 if (err < 0) { 3003 2986 dev_err(sor->dev, "failed to enable HDMI supply: %d\n", err); 3004 2987 return err; ··· 3009 2992 return 0; 3010 2993 } 3011 2994 3012 - static int tegra_sor_hdmi_remove(struct tegra_sor *sor) 3013 - { 3014 - regulator_disable(sor->hdmi_supply); 3015 - regulator_disable(sor->vdd_pll_supply); 3016 - regulator_disable(sor->avdd_io_supply); 3017 - 3018 - return 0; 3019 - } 3020 - 3021 2995 static const struct tegra_sor_ops tegra_sor_hdmi_ops = { 3022 2996 .name = "HDMI", 3023 2997 .probe = tegra_sor_hdmi_probe, 3024 - .remove = tegra_sor_hdmi_remove, 3025 2998 .audio_enable = tegra_sor_hdmi_audio_enable, 3026 2999 .audio_disable = tegra_sor_hdmi_audio_disable, 3027 3000 }; ··· 3024 3017 if (IS_ERR(sor->avdd_io_supply)) 3025 3018 return PTR_ERR(sor->avdd_io_supply); 3026 3019 3027 - err = regulator_enable(sor->avdd_io_supply); 3020 + err = tegra_sor_enable_regulator(sor, sor->avdd_io_supply); 3028 3021 if (err < 0) 3029 3022 return err; 3030 3023 ··· 3032 3025 if (IS_ERR(sor->vdd_pll_supply)) 3033 3026 return PTR_ERR(sor->vdd_pll_supply); 3034 3027 3035 - err = regulator_enable(sor->vdd_pll_supply); 3028 + err = tegra_sor_enable_regulator(sor, sor->vdd_pll_supply); 3036 3029 if (err < 0) 3037 3030 return err; 3038 - 3039 - return 0; 3040 - } 3041 - 3042 - static int tegra_sor_dp_remove(struct tegra_sor *sor) 3043 - { 3044 - regulator_disable(sor->vdd_pll_supply); 3045 - regulator_disable(sor->avdd_io_supply); 3046 3031 3047 3032 return 0; 3048 3033 } ··· 3042 3043 static const struct tegra_sor_ops tegra_sor_dp_ops = { 3043 3044 .name = "DP", 3044 3045 .probe = tegra_sor_dp_probe, 3045 - .remove = tegra_sor_dp_remove, 3046 3046 }; 3047 3047 3048 3048 static int tegra_sor_init(struct host1x_client *client) ··· 3143 3145 if (err < 0) { 3144 3146 dev_err(sor->dev, "failed to deassert SOR reset: %d\n", 3145 3147 err); 3148 + clk_disable_unprepare(sor->clk); 3146 3149 return err; 3147 3150 } 3148 3151 ··· 3151 3152 } 3152 3153 3153 3154 err = clk_prepare_enable(sor->clk_safe); 3154 - if (err < 0) 3155 + if (err < 0) { 3156 + clk_disable_unprepare(sor->clk); 3155 3157 return err; 3158 + } 3156 3159 3157 3160 err = clk_prepare_enable(sor->clk_dp); 3158 - if (err < 0) 3161 + if (err < 0) { 3162 + clk_disable_unprepare(sor->clk_safe); 3163 + clk_disable_unprepare(sor->clk); 3159 3164 return err; 3165 + } 3160 3166 3161 3167 return 0; 3162 3168 } ··· 3768 3764 return err; 3769 3765 3770 3766 err = tegra_output_probe(&sor->output); 3771 - if (err < 0) { 3772 - dev_err(&pdev->dev, "failed to probe output: %d\n", err); 3773 - return err; 3774 - } 3767 + if (err < 0) 3768 + return dev_err_probe(&pdev->dev, err, 3769 + "failed to probe output\n"); 3775 3770 3776 3771 if (sor->ops && sor->ops->probe) { 3777 3772 err = sor->ops->probe(sor); 3778 3773 if (err < 0) { 3779 3774 dev_err(&pdev->dev, "failed to probe %s: %d\n", 3780 3775 sor->ops->name, err); 3781 - goto output; 3776 + goto remove; 3782 3777 } 3783 3778 } 3784 3779 ··· 3958 3955 rpm_disable: 3959 3956 pm_runtime_disable(&pdev->dev); 3960 3957 remove: 3961 - if (sor->ops && sor->ops->remove) 3962 - sor->ops->remove(sor); 3963 - output: 3964 3958 tegra_output_remove(&sor->output); 3965 3959 return err; 3966 3960 } ··· 3975 3975 } 3976 3976 3977 3977 pm_runtime_disable(&pdev->dev); 3978 - 3979 - if (sor->ops && sor->ops->remove) { 3980 - err = sor->ops->remove(sor); 3981 - if (err < 0) 3982 - dev_err(&pdev->dev, "failed to remove SOR: %d\n", err); 3983 - } 3984 3978 3985 3979 tegra_output_remove(&sor->output); 3986 3980