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

Merge tag 'drm-intel-fixes-2021-01-21' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes

drm/i915 fixes for v5.11-rc5:
- HDCP fixes
- PMU wakeref fix
- Fix HWSP validity race
- Fix DP protocol converter accidental 4:4:4->4:2:0 conversion for RGB

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/87a6t2kzgb.fsf@intel.com

+74 -38
+1 -1
drivers/gpu/drm/i915/display/intel_ddi.c
··· 3725 3725 intel_ddi_init_dp_buf_reg(encoder, crtc_state); 3726 3726 if (!is_mst) 3727 3727 intel_dp_set_power(intel_dp, DP_SET_POWER_D0); 3728 - intel_dp_configure_protocol_converter(intel_dp); 3728 + intel_dp_configure_protocol_converter(intel_dp, crtc_state); 3729 3729 intel_dp_sink_set_decompression_state(intel_dp, crtc_state, 3730 3730 true); 3731 3731 intel_dp_sink_set_fec_ready(intel_dp, crtc_state);
+5 -4
drivers/gpu/drm/i915/display/intel_dp.c
··· 4014 4014 intel_de_posting_read(dev_priv, intel_dp->output_reg); 4015 4015 } 4016 4016 4017 - void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp) 4017 + void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp, 4018 + const struct intel_crtc_state *crtc_state) 4018 4019 { 4019 4020 struct drm_i915_private *i915 = dp_to_i915(intel_dp); 4020 4021 u8 tmp; ··· 4034 4033 drm_dbg_kms(&i915->drm, "Failed to set protocol converter HDMI mode to %s\n", 4035 4034 enableddisabled(intel_dp->has_hdmi_sink)); 4036 4035 4037 - tmp = intel_dp->dfp.ycbcr_444_to_420 ? 4038 - DP_CONVERSION_TO_YCBCR420_ENABLE : 0; 4036 + tmp = crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444 && 4037 + intel_dp->dfp.ycbcr_444_to_420 ? DP_CONVERSION_TO_YCBCR420_ENABLE : 0; 4039 4038 4040 4039 if (drm_dp_dpcd_writeb(&intel_dp->aux, 4041 4040 DP_PROTOCOL_CONVERTER_CONTROL_1, tmp) != 1) ··· 4089 4088 } 4090 4089 4091 4090 intel_dp_set_power(intel_dp, DP_SET_POWER_D0); 4092 - intel_dp_configure_protocol_converter(intel_dp); 4091 + intel_dp_configure_protocol_converter(intel_dp, pipe_config); 4093 4092 intel_dp_start_link_train(intel_dp, pipe_config); 4094 4093 intel_dp_stop_link_train(intel_dp, pipe_config); 4095 4094
+2 -1
drivers/gpu/drm/i915/display/intel_dp.h
··· 51 51 int intel_dp_retrain_link(struct intel_encoder *encoder, 52 52 struct drm_modeset_acquire_ctx *ctx); 53 53 void intel_dp_set_power(struct intel_dp *intel_dp, u8 mode); 54 - void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp); 54 + void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp, 55 + const struct intel_crtc_state *crtc_state); 55 56 void intel_dp_sink_set_decompression_state(struct intel_dp *intel_dp, 56 57 const struct intel_crtc_state *crtc_state, 57 58 bool enable);
+9
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 2210 2210 if (content_protection_type_changed) { 2211 2211 mutex_lock(&hdcp->mutex); 2212 2212 hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED; 2213 + drm_connector_get(&connector->base); 2213 2214 schedule_work(&hdcp->prop_work); 2214 2215 mutex_unlock(&hdcp->mutex); 2215 2216 } ··· 2222 2221 desired_and_not_enabled = 2223 2222 hdcp->value != DRM_MODE_CONTENT_PROTECTION_ENABLED; 2224 2223 mutex_unlock(&hdcp->mutex); 2224 + /* 2225 + * If HDCP already ENABLED and CP property is DESIRED, schedule 2226 + * prop_work to update correct CP property to user space. 2227 + */ 2228 + if (!desired_and_not_enabled && !content_protection_type_changed) { 2229 + drm_connector_get(&connector->base); 2230 + schedule_work(&hdcp->prop_work); 2231 + } 2225 2232 } 2226 2233 2227 2234 if (desired_and_not_enabled || content_protection_type_changed)
+2 -7
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
··· 134 134 return true; 135 135 } 136 136 137 - static inline bool __request_completed(const struct i915_request *rq) 138 - { 139 - return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno); 140 - } 141 - 142 137 __maybe_unused static bool 143 138 check_signal_order(struct intel_context *ce, struct i915_request *rq) 144 139 { ··· 252 257 list_for_each_entry_rcu(rq, &ce->signals, signal_link) { 253 258 bool release; 254 259 255 - if (!__request_completed(rq)) 260 + if (!__i915_request_is_complete(rq)) 256 261 break; 257 262 258 263 if (!test_and_clear_bit(I915_FENCE_FLAG_SIGNAL, ··· 374 379 * straight onto a signaled list, and queue the irq worker for 375 380 * its signal completion. 376 381 */ 377 - if (__request_completed(rq)) { 382 + if (__i915_request_is_complete(rq)) { 378 383 if (__signal_request(rq) && 379 384 llist_add(&rq->signal_node, &b->signaled_requests)) 380 385 irq_work_queue(&b->irq_work);
+3
drivers/gpu/drm/i915/gt/intel_lrc.c
··· 3988 3988 static void lrc_destroy_wa_ctx(struct intel_engine_cs *engine) 3989 3989 { 3990 3990 i915_vma_unpin_and_release(&engine->wa_ctx.vma, 0); 3991 + 3992 + /* Called on error unwind, clear all flags to prevent further use */ 3993 + memset(&engine->wa_ctx, 0, sizeof(engine->wa_ctx)); 3991 3994 } 3992 3995 3993 3996 typedef u32 *(*wa_bb_func_t)(struct intel_engine_cs *engine, u32 *batch);
+4 -6
drivers/gpu/drm/i915/gt/intel_timeline.c
··· 126 126 struct intel_timeline_cacheline *cl = 127 127 container_of(rcu, typeof(*cl), rcu); 128 128 129 + /* Must wait until after all *rq->hwsp are complete before removing */ 130 + i915_gem_object_unpin_map(cl->hwsp->vma->obj); 131 + __idle_hwsp_free(cl->hwsp, ptr_unmask_bits(cl->vaddr, CACHELINE_BITS)); 132 + 129 133 i915_active_fini(&cl->active); 130 134 kfree(cl); 131 135 } ··· 137 133 static void __idle_cacheline_free(struct intel_timeline_cacheline *cl) 138 134 { 139 135 GEM_BUG_ON(!i915_active_is_idle(&cl->active)); 140 - 141 - i915_gem_object_unpin_map(cl->hwsp->vma->obj); 142 - i915_vma_put(cl->hwsp->vma); 143 - __idle_hwsp_free(cl->hwsp, ptr_unmask_bits(cl->vaddr, CACHELINE_BITS)); 144 - 145 136 call_rcu(&cl->rcu, __rcu_cacheline_free); 146 137 } 147 138 ··· 178 179 return ERR_CAST(vaddr); 179 180 } 180 181 181 - i915_vma_get(hwsp->vma); 182 182 cl->hwsp = hwsp; 183 183 cl->vaddr = page_pack_bits(vaddr, cacheline); 184 184
+16 -14
drivers/gpu/drm/i915/i915_pmu.c
··· 184 184 return val; 185 185 } 186 186 187 + static void init_rc6(struct i915_pmu *pmu) 188 + { 189 + struct drm_i915_private *i915 = container_of(pmu, typeof(*i915), pmu); 190 + intel_wakeref_t wakeref; 191 + 192 + with_intel_runtime_pm(i915->gt.uncore->rpm, wakeref) { 193 + pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 194 + pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur = 195 + pmu->sample[__I915_SAMPLE_RC6].cur; 196 + pmu->sleep_last = ktime_get(); 197 + } 198 + } 199 + 187 200 static void park_rc6(struct drm_i915_private *i915) 188 201 { 189 202 struct i915_pmu *pmu = &i915->pmu; 190 203 191 - if (pmu->enable & config_enabled_mask(I915_PMU_RC6_RESIDENCY)) 192 - pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 193 - 204 + pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 194 205 pmu->sleep_last = ktime_get(); 195 206 } 196 207 ··· 212 201 return __get_rc6(gt); 213 202 } 214 203 204 + static void init_rc6(struct i915_pmu *pmu) { } 215 205 static void park_rc6(struct drm_i915_private *i915) {} 216 206 217 207 #endif ··· 624 612 container_of(event->pmu, typeof(*i915), pmu.base); 625 613 unsigned int bit = event_enabled_bit(event); 626 614 struct i915_pmu *pmu = &i915->pmu; 627 - intel_wakeref_t wakeref; 628 615 unsigned long flags; 629 616 630 - wakeref = intel_runtime_pm_get(&i915->runtime_pm); 631 617 spin_lock_irqsave(&pmu->lock, flags); 632 618 633 619 /* ··· 635 625 BUILD_BUG_ON(ARRAY_SIZE(pmu->enable_count) != I915_PMU_MASK_BITS); 636 626 GEM_BUG_ON(bit >= ARRAY_SIZE(pmu->enable_count)); 637 627 GEM_BUG_ON(pmu->enable_count[bit] == ~0); 638 - 639 - if (pmu->enable_count[bit] == 0 && 640 - config_enabled_mask(I915_PMU_RC6_RESIDENCY) & BIT_ULL(bit)) { 641 - pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur = 0; 642 - pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt); 643 - pmu->sleep_last = ktime_get(); 644 - } 645 628 646 629 pmu->enable |= BIT_ULL(bit); 647 630 pmu->enable_count[bit]++; ··· 676 673 * an existing non-zero value. 677 674 */ 678 675 local64_set(&event->hw.prev_count, __i915_pmu_event_read(event)); 679 - 680 - intel_runtime_pm_put(&i915->runtime_pm, wakeref); 681 676 } 682 677 683 678 static void i915_pmu_disable(struct perf_event *event) ··· 1131 1130 hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1132 1131 pmu->timer.function = i915_sample; 1133 1132 pmu->cpuhp.cpu = -1; 1133 + init_rc6(pmu); 1134 1134 1135 1135 if (!is_igp(i915)) { 1136 1136 pmu->name = kasprintf(GFP_KERNEL,
+32 -5
drivers/gpu/drm/i915/i915_request.h
··· 434 434 435 435 static inline bool __i915_request_has_started(const struct i915_request *rq) 436 436 { 437 - return i915_seqno_passed(hwsp_seqno(rq), rq->fence.seqno - 1); 437 + return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno - 1); 438 438 } 439 439 440 440 /** ··· 465 465 */ 466 466 static inline bool i915_request_started(const struct i915_request *rq) 467 467 { 468 + bool result; 469 + 468 470 if (i915_request_signaled(rq)) 469 471 return true; 470 472 471 - /* Remember: started but may have since been preempted! */ 472 - return __i915_request_has_started(rq); 473 + result = true; 474 + rcu_read_lock(); /* the HWSP may be freed at runtime */ 475 + if (likely(!i915_request_signaled(rq))) 476 + /* Remember: started but may have since been preempted! */ 477 + result = __i915_request_has_started(rq); 478 + rcu_read_unlock(); 479 + 480 + return result; 473 481 } 474 482 475 483 /** ··· 490 482 */ 491 483 static inline bool i915_request_is_running(const struct i915_request *rq) 492 484 { 485 + bool result; 486 + 493 487 if (!i915_request_is_active(rq)) 494 488 return false; 495 489 496 - return __i915_request_has_started(rq); 490 + rcu_read_lock(); 491 + result = __i915_request_has_started(rq) && i915_request_is_active(rq); 492 + rcu_read_unlock(); 493 + 494 + return result; 497 495 } 498 496 499 497 /** ··· 523 509 return !list_empty(&rq->sched.link); 524 510 } 525 511 512 + static inline bool __i915_request_is_complete(const struct i915_request *rq) 513 + { 514 + return i915_seqno_passed(__hwsp_seqno(rq), rq->fence.seqno); 515 + } 516 + 526 517 static inline bool i915_request_completed(const struct i915_request *rq) 527 518 { 519 + bool result; 520 + 528 521 if (i915_request_signaled(rq)) 529 522 return true; 530 523 531 - return i915_seqno_passed(hwsp_seqno(rq), rq->fence.seqno); 524 + result = true; 525 + rcu_read_lock(); /* the HWSP may be freed at runtime */ 526 + if (likely(!i915_request_signaled(rq))) 527 + result = __i915_request_is_complete(rq); 528 + rcu_read_unlock(); 529 + 530 + return result; 532 531 } 533 532 534 533 static inline void i915_request_mark_complete(struct i915_request *rq)