Lines Matching refs:display

151 static bool intel_hpd_irq_storm_detect(struct intel_display *display,  in intel_hpd_irq_storm_detect()  argument
154 struct intel_hotplug *hpd = &display->hotplug; in intel_hpd_irq_storm_detect()
162 (!long_hpd && !display->hotplug.hpd_short_storm_enabled)) in intel_hpd_irq_storm_detect()
173 drm_dbg_kms(display->drm, in intel_hpd_irq_storm_detect()
177 drm_dbg_kms(display->drm, in intel_hpd_irq_storm_detect()
186 static bool detection_work_enabled(struct intel_display *display) in detection_work_enabled() argument
188 lockdep_assert_held(&display->irq.lock); in detection_work_enabled()
190 return display->hotplug.detection_work_enabled; in detection_work_enabled()
194 mod_delayed_detection_work(struct intel_display *display, struct delayed_work *work, int delay) in mod_delayed_detection_work() argument
196 lockdep_assert_held(&display->irq.lock); in mod_delayed_detection_work()
198 if (!detection_work_enabled(display)) in mod_delayed_detection_work()
201 return mod_delayed_work(display->wq.unordered, work, delay); in mod_delayed_detection_work()
205 queue_delayed_detection_work(struct intel_display *display, struct delayed_work *work, int delay) in queue_delayed_detection_work() argument
207 lockdep_assert_held(&display->irq.lock); in queue_delayed_detection_work()
209 if (!detection_work_enabled(display)) in queue_delayed_detection_work()
212 return queue_delayed_work(display->wq.unordered, work, delay); in queue_delayed_detection_work()
216 queue_detection_work(struct intel_display *display, struct work_struct *work) in queue_detection_work() argument
218 lockdep_assert_held(&display->irq.lock); in queue_detection_work()
220 if (!detection_work_enabled(display)) in queue_detection_work()
223 return queue_work(display->wq.unordered, work); in queue_detection_work()
227 intel_hpd_irq_storm_switch_to_polling(struct intel_display *display) in intel_hpd_irq_storm_switch_to_polling() argument
233 lockdep_assert_held(&display->irq.lock); in intel_hpd_irq_storm_switch_to_polling()
235 drm_connector_list_iter_begin(display->drm, &conn_iter); in intel_hpd_irq_storm_switch_to_polling()
244 display->hotplug.stats[pin].state != HPD_MARK_DISABLED) in intel_hpd_irq_storm_switch_to_polling()
247 drm_info(display->drm, in intel_hpd_irq_storm_switch_to_polling()
252 display->hotplug.stats[pin].state = HPD_DISABLED; in intel_hpd_irq_storm_switch_to_polling()
261 drm_kms_helper_poll_reschedule(display->drm); in intel_hpd_irq_storm_switch_to_polling()
262 mod_delayed_detection_work(display, in intel_hpd_irq_storm_switch_to_polling()
263 &display->hotplug.reenable_work, in intel_hpd_irq_storm_switch_to_polling()
270 struct intel_display *display = in intel_hpd_irq_storm_reenable_work() local
271 container_of(work, typeof(*display), hotplug.reenable_work.work); in intel_hpd_irq_storm_reenable_work()
277 wakeref = intel_display_rpm_get(display); in intel_hpd_irq_storm_reenable_work()
279 spin_lock_irq(&display->irq.lock); in intel_hpd_irq_storm_reenable_work()
281 drm_connector_list_iter_begin(display->drm, &conn_iter); in intel_hpd_irq_storm_reenable_work()
285 display->hotplug.stats[pin].state != HPD_DISABLED) in intel_hpd_irq_storm_reenable_work()
289 drm_dbg(display->drm, in intel_hpd_irq_storm_reenable_work()
297 if (display->hotplug.stats[pin].state == HPD_DISABLED) in intel_hpd_irq_storm_reenable_work()
298 display->hotplug.stats[pin].state = HPD_ENABLED; in intel_hpd_irq_storm_reenable_work()
301 intel_hpd_irq_setup(display); in intel_hpd_irq_storm_reenable_work()
303 spin_unlock_irq(&display->irq.lock); in intel_hpd_irq_storm_reenable_work()
305 intel_display_rpm_put(display, wakeref); in intel_hpd_irq_storm_reenable_work()
354 static bool hpd_pin_has_pulse(struct intel_display *display, enum hpd_pin pin) in hpd_pin_has_pulse() argument
358 for_each_intel_encoder(display->drm, encoder) { in hpd_pin_has_pulse()
369 static bool hpd_pin_is_blocked(struct intel_display *display, enum hpd_pin pin) in hpd_pin_is_blocked() argument
371 lockdep_assert_held(&display->irq.lock); in hpd_pin_is_blocked()
373 return display->hotplug.stats[pin].blocked_count; in hpd_pin_is_blocked()
376 static u32 get_blocked_hpd_pin_mask(struct intel_display *display) in get_blocked_hpd_pin_mask() argument
382 if (hpd_pin_is_blocked(display, pin)) in get_blocked_hpd_pin_mask()
391 struct intel_display *display = in i915_digport_work_func() local
393 struct intel_hotplug *hotplug = &display->hotplug; in i915_digport_work_func()
399 spin_lock_irq(&display->irq.lock); in i915_digport_work_func()
401 blocked_hpd_pin_mask = get_blocked_hpd_pin_mask(display); in i915_digport_work_func()
407 spin_unlock_irq(&display->irq.lock); in i915_digport_work_func()
409 for_each_intel_encoder(display->drm, encoder) { in i915_digport_work_func()
434 spin_lock_irq(&display->irq.lock); in i915_digport_work_func()
435 display->hotplug.event_bits |= old_bits; in i915_digport_work_func()
436 queue_delayed_detection_work(display, in i915_digport_work_func()
437 &display->hotplug.hotplug_work, 0); in i915_digport_work_func()
438 spin_unlock_irq(&display->irq.lock); in i915_digport_work_func()
451 struct intel_display *display = to_intel_display(dig_port); in intel_hpd_trigger_irq() local
452 struct intel_hotplug *hotplug = &display->hotplug; in intel_hpd_trigger_irq()
455 spin_lock_irq(&display->irq.lock); in intel_hpd_trigger_irq()
458 if (!hpd_pin_is_blocked(display, encoder->hpd_pin)) in intel_hpd_trigger_irq()
461 spin_unlock_irq(&display->irq.lock); in intel_hpd_trigger_irq()
469 struct intel_display *display = in i915_hotplug_work_func() local
471 struct intel_hotplug *hotplug = &display->hotplug; in i915_hotplug_work_func()
481 mutex_lock(&display->drm->mode_config.mutex); in i915_hotplug_work_func()
482 drm_dbg_kms(display->drm, "running encoder hotplug functions\n"); in i915_hotplug_work_func()
484 spin_lock_irq(&display->irq.lock); in i915_hotplug_work_func()
486 blocked_hpd_pin_mask = get_blocked_hpd_pin_mask(display); in i915_hotplug_work_func()
493 intel_hpd_irq_storm_switch_to_polling(display); in i915_hotplug_work_func()
495 spin_unlock_irq(&display->irq.lock); in i915_hotplug_work_func()
498 if (display->hotplug.ignore_long_hpd) { in i915_hotplug_work_func()
499 drm_dbg_kms(display->drm, "Ignore HPD flag on - skip encoder hotplug handlers\n"); in i915_hotplug_work_func()
500 mutex_unlock(&display->drm->mode_config.mutex); in i915_hotplug_work_func()
504 drm_connector_list_iter_begin(display->drm, &conn_iter); in i915_hotplug_work_func()
523 drm_dbg_kms(display->drm, in i915_hotplug_work_func()
546 mutex_unlock(&display->drm->mode_config.mutex); in i915_hotplug_work_func()
551 drm_kms_helper_hotplug_event(display->drm); in i915_hotplug_work_func()
559 spin_lock_irq(&display->irq.lock); in i915_hotplug_work_func()
560 display->hotplug.retry_bits |= retry; in i915_hotplug_work_func()
562 mod_delayed_detection_work(display, in i915_hotplug_work_func()
563 &display->hotplug.hotplug_work, in i915_hotplug_work_func()
565 spin_unlock_irq(&display->irq.lock); in i915_hotplug_work_func()
586 void intel_hpd_irq_handler(struct intel_display *display, in intel_hpd_irq_handler() argument
599 spin_lock(&display->irq.lock); in intel_hpd_irq_handler()
607 for_each_intel_encoder(display->drm, encoder) { in intel_hpd_irq_handler()
619 drm_dbg(display->drm, in intel_hpd_irq_handler()
624 if (!hpd_pin_is_blocked(display, pin)) in intel_hpd_irq_handler()
629 display->hotplug.long_hpd_pin_mask |= BIT(pin); in intel_hpd_irq_handler()
632 display->hotplug.short_hpd_pin_mask |= BIT(pin); in intel_hpd_irq_handler()
643 if (display->hotplug.stats[pin].state == HPD_DISABLED) { in intel_hpd_irq_handler()
650 drm_WARN_ONCE(display->drm, !HAS_GMCH(display), in intel_hpd_irq_handler()
656 if (display->hotplug.stats[pin].state != HPD_ENABLED) in intel_hpd_irq_handler()
667 display->hotplug.event_bits |= BIT(pin); in intel_hpd_irq_handler()
670 if (!hpd_pin_is_blocked(display, pin)) in intel_hpd_irq_handler()
674 if (intel_hpd_irq_storm_detect(display, pin, long_hpd)) { in intel_hpd_irq_handler()
675 display->hotplug.event_bits &= ~BIT(pin); in intel_hpd_irq_handler()
686 intel_hpd_irq_setup(display); in intel_hpd_irq_handler()
695 queue_work(display->hotplug.dp_wq, &display->hotplug.dig_port_work); in intel_hpd_irq_handler()
697 queue_delayed_detection_work(display, in intel_hpd_irq_handler()
698 &display->hotplug.hotplug_work, 0); in intel_hpd_irq_handler()
700 spin_unlock(&display->irq.lock); in intel_hpd_irq_handler()
717 void intel_hpd_init(struct intel_display *display) in intel_hpd_init() argument
721 if (!HAS_DISPLAY(display)) in intel_hpd_init()
725 display->hotplug.stats[i].count = 0; in intel_hpd_init()
726 display->hotplug.stats[i].state = HPD_ENABLED; in intel_hpd_init()
733 spin_lock_irq(&display->irq.lock); in intel_hpd_init()
734 intel_hpd_irq_setup(display); in intel_hpd_init()
735 spin_unlock_irq(&display->irq.lock); in intel_hpd_init()
738 static void i915_hpd_poll_detect_connectors(struct intel_display *display) in i915_hpd_poll_detect_connectors() argument
745 mutex_lock(&display->drm->mode_config.mutex); in i915_hpd_poll_detect_connectors()
747 if (!display->drm->mode_config.poll_enabled) in i915_hpd_poll_detect_connectors()
750 drm_connector_list_iter_begin(display->drm, &conn_iter); in i915_hpd_poll_detect_connectors()
768 mutex_unlock(&display->drm->mode_config.mutex); in i915_hpd_poll_detect_connectors()
776 drm_kms_helper_hotplug_event(display->drm); in i915_hpd_poll_detect_connectors()
783 struct intel_display *display = in i915_hpd_poll_init_work() local
784 container_of(work, typeof(*display), hotplug.poll_init_work); in i915_hpd_poll_init_work()
790 mutex_lock(&display->drm->mode_config.mutex); in i915_hpd_poll_init_work()
792 enabled = READ_ONCE(display->hotplug.poll_enabled); in i915_hpd_poll_init_work()
800 wakeref = intel_display_power_get(display, in i915_hpd_poll_init_work()
802 drm_WARN_ON(display->drm, in i915_hpd_poll_init_work()
803 READ_ONCE(display->hotplug.poll_enabled)); in i915_hpd_poll_init_work()
804 cancel_work(&display->hotplug.poll_init_work); in i915_hpd_poll_init_work()
807 spin_lock_irq(&display->irq.lock); in i915_hpd_poll_init_work()
809 drm_connector_list_iter_begin(display->drm, &conn_iter); in i915_hpd_poll_init_work()
817 if (display->hotplug.stats[pin].state == HPD_DISABLED) in i915_hpd_poll_init_work()
828 spin_unlock_irq(&display->irq.lock); in i915_hpd_poll_init_work()
831 drm_kms_helper_poll_reschedule(display->drm); in i915_hpd_poll_init_work()
833 mutex_unlock(&display->drm->mode_config.mutex); in i915_hpd_poll_init_work()
840 i915_hpd_poll_detect_connectors(display); in i915_hpd_poll_init_work()
842 intel_display_power_put(display, in i915_hpd_poll_init_work()
864 void intel_hpd_poll_enable(struct intel_display *display) in intel_hpd_poll_enable() argument
866 if (!HAS_DISPLAY(display) || !intel_display_device_enabled(display)) in intel_hpd_poll_enable()
869 WRITE_ONCE(display->hotplug.poll_enabled, true); in intel_hpd_poll_enable()
877 spin_lock_irq(&display->irq.lock); in intel_hpd_poll_enable()
878 queue_detection_work(display, in intel_hpd_poll_enable()
879 &display->hotplug.poll_init_work); in intel_hpd_poll_enable()
880 spin_unlock_irq(&display->irq.lock); in intel_hpd_poll_enable()
902 void intel_hpd_poll_disable(struct intel_display *display) in intel_hpd_poll_disable() argument
906 if (!HAS_DISPLAY(display)) in intel_hpd_poll_disable()
909 for_each_intel_dp(display->drm, encoder) in intel_hpd_poll_disable()
912 WRITE_ONCE(display->hotplug.poll_enabled, false); in intel_hpd_poll_disable()
914 spin_lock_irq(&display->irq.lock); in intel_hpd_poll_disable()
915 queue_detection_work(display, in intel_hpd_poll_disable()
916 &display->hotplug.poll_init_work); in intel_hpd_poll_disable()
917 spin_unlock_irq(&display->irq.lock); in intel_hpd_poll_disable()
920 void intel_hpd_poll_fini(struct intel_display *display) in intel_hpd_poll_fini() argument
926 drm_connector_list_iter_begin(display->drm, &conn_iter); in intel_hpd_poll_fini()
934 void intel_hpd_init_early(struct intel_display *display) in intel_hpd_init_early() argument
936 INIT_DELAYED_WORK(&display->hotplug.hotplug_work, in intel_hpd_init_early()
938 INIT_WORK(&display->hotplug.dig_port_work, i915_digport_work_func); in intel_hpd_init_early()
939 INIT_WORK(&display->hotplug.poll_init_work, i915_hpd_poll_init_work); in intel_hpd_init_early()
940 INIT_DELAYED_WORK(&display->hotplug.reenable_work, in intel_hpd_init_early()
943 display->hotplug.hpd_storm_threshold = HPD_STORM_DEFAULT_THRESHOLD; in intel_hpd_init_early()
950 display->hotplug.hpd_short_storm_enabled = !HAS_DP_MST(display); in intel_hpd_init_early()
953 static bool cancel_all_detection_work(struct intel_display *display) in cancel_all_detection_work() argument
957 if (cancel_delayed_work_sync(&display->hotplug.hotplug_work)) in cancel_all_detection_work()
959 if (cancel_work_sync(&display->hotplug.poll_init_work)) in cancel_all_detection_work()
961 if (cancel_delayed_work_sync(&display->hotplug.reenable_work)) in cancel_all_detection_work()
967 void intel_hpd_cancel_work(struct intel_display *display) in intel_hpd_cancel_work() argument
969 if (!HAS_DISPLAY(display)) in intel_hpd_cancel_work()
972 spin_lock_irq(&display->irq.lock); in intel_hpd_cancel_work()
974 drm_WARN_ON(display->drm, get_blocked_hpd_pin_mask(display)); in intel_hpd_cancel_work()
976 display->hotplug.long_hpd_pin_mask = 0; in intel_hpd_cancel_work()
977 display->hotplug.short_hpd_pin_mask = 0; in intel_hpd_cancel_work()
978 display->hotplug.event_bits = 0; in intel_hpd_cancel_work()
979 display->hotplug.retry_bits = 0; in intel_hpd_cancel_work()
981 spin_unlock_irq(&display->irq.lock); in intel_hpd_cancel_work()
983 cancel_work_sync(&display->hotplug.dig_port_work); in intel_hpd_cancel_work()
989 if (cancel_all_detection_work(display)) in intel_hpd_cancel_work()
990 drm_dbg_kms(display->drm, "Hotplug detection work still active\n"); in intel_hpd_cancel_work()
993 static void queue_work_for_missed_irqs(struct intel_display *display) in queue_work_for_missed_irqs() argument
995 struct intel_hotplug *hotplug = &display->hotplug; in queue_work_for_missed_irqs()
1000 lockdep_assert_held(&display->irq.lock); in queue_work_for_missed_irqs()
1002 blocked_hpd_pin_mask = get_blocked_hpd_pin_mask(display); in queue_work_for_missed_irqs()
1007 switch (display->hotplug.stats[pin].state) { in queue_work_for_missed_irqs()
1015 MISSING_CASE(display->hotplug.stats[pin].state); in queue_work_for_missed_irqs()
1023 queue_delayed_detection_work(display, &display->hotplug.hotplug_work, 0); in queue_work_for_missed_irqs()
1026 static bool block_hpd_pin(struct intel_display *display, enum hpd_pin pin) in block_hpd_pin() argument
1028 struct intel_hotplug *hotplug = &display->hotplug; in block_hpd_pin()
1030 lockdep_assert_held(&display->irq.lock); in block_hpd_pin()
1037 static bool unblock_hpd_pin(struct intel_display *display, enum hpd_pin pin) in unblock_hpd_pin() argument
1039 struct intel_hotplug *hotplug = &display->hotplug; in unblock_hpd_pin()
1041 lockdep_assert_held(&display->irq.lock); in unblock_hpd_pin()
1043 if (drm_WARN_ON(display->drm, hotplug->stats[pin].blocked_count == 0)) in unblock_hpd_pin()
1077 struct intel_display *display = to_intel_display(encoder); in intel_hpd_block() local
1078 struct intel_hotplug *hotplug = &display->hotplug; in intel_hpd_block()
1084 spin_lock_irq(&display->irq.lock); in intel_hpd_block()
1086 if (block_hpd_pin(display, encoder->hpd_pin)) in intel_hpd_block()
1089 spin_unlock_irq(&display->irq.lock); in intel_hpd_block()
1091 if (do_flush && hpd_pin_has_pulse(display, encoder->hpd_pin)) in intel_hpd_block()
1106 struct intel_display *display = to_intel_display(encoder); in intel_hpd_unblock() local
1111 spin_lock_irq(&display->irq.lock); in intel_hpd_unblock()
1113 if (unblock_hpd_pin(display, encoder->hpd_pin)) in intel_hpd_unblock()
1114 queue_work_for_missed_irqs(display); in intel_hpd_unblock()
1116 spin_unlock_irq(&display->irq.lock); in intel_hpd_unblock()
1129 struct intel_display *display = to_intel_display(encoder); in intel_hpd_clear_and_unblock() local
1130 struct intel_hotplug *hotplug = &display->hotplug; in intel_hpd_clear_and_unblock()
1136 spin_lock_irq(&display->irq.lock); in intel_hpd_clear_and_unblock()
1138 if (unblock_hpd_pin(display, pin)) { in intel_hpd_clear_and_unblock()
1145 spin_unlock_irq(&display->irq.lock); in intel_hpd_clear_and_unblock()
1148 void intel_hpd_enable_detection_work(struct intel_display *display) in intel_hpd_enable_detection_work() argument
1150 spin_lock_irq(&display->irq.lock); in intel_hpd_enable_detection_work()
1151 display->hotplug.detection_work_enabled = true; in intel_hpd_enable_detection_work()
1152 queue_work_for_missed_irqs(display); in intel_hpd_enable_detection_work()
1153 spin_unlock_irq(&display->irq.lock); in intel_hpd_enable_detection_work()
1156 void intel_hpd_disable_detection_work(struct intel_display *display) in intel_hpd_disable_detection_work() argument
1158 spin_lock_irq(&display->irq.lock); in intel_hpd_disable_detection_work()
1159 display->hotplug.detection_work_enabled = false; in intel_hpd_disable_detection_work()
1160 spin_unlock_irq(&display->irq.lock); in intel_hpd_disable_detection_work()
1162 cancel_all_detection_work(display); in intel_hpd_disable_detection_work()
1165 bool intel_hpd_schedule_detection(struct intel_display *display) in intel_hpd_schedule_detection() argument
1170 spin_lock_irqsave(&display->irq.lock, flags); in intel_hpd_schedule_detection()
1171 ret = queue_delayed_detection_work(display, &display->hotplug.hotplug_work, 0); in intel_hpd_schedule_detection()
1172 spin_unlock_irqrestore(&display->irq.lock, flags); in intel_hpd_schedule_detection()
1179 struct intel_display *display = m->private; in i915_hpd_storm_ctl_show() local
1180 struct drm_i915_private *dev_priv = to_i915(display->drm); in i915_hpd_storm_ctl_show()
1181 struct intel_hotplug *hotplug = &display->hotplug; in i915_hpd_storm_ctl_show()
1187 flush_work(&display->hotplug.dig_port_work); in i915_hpd_storm_ctl_show()
1188 flush_delayed_work(&display->hotplug.hotplug_work); in i915_hpd_storm_ctl_show()
1202 struct intel_display *display = m->private; in i915_hpd_storm_ctl_write() local
1203 struct intel_hotplug *hotplug = &display->hotplug; in i915_hpd_storm_ctl_write()
1228 drm_dbg_kms(display->drm, in i915_hpd_storm_ctl_write()
1232 drm_dbg_kms(display->drm, "Disabling HPD storm detection\n"); in i915_hpd_storm_ctl_write()
1234 spin_lock_irq(&display->irq.lock); in i915_hpd_storm_ctl_write()
1239 spin_unlock_irq(&display->irq.lock); in i915_hpd_storm_ctl_write()
1242 flush_delayed_work(&display->hotplug.reenable_work); in i915_hpd_storm_ctl_write()
1263 struct intel_display *display = m->private; in i915_hpd_short_storm_ctl_show() local
1266 str_yes_no(display->hotplug.hpd_short_storm_enabled)); in i915_hpd_short_storm_ctl_show()
1283 struct intel_display *display = m->private; in i915_hpd_short_storm_ctl_write() local
1284 struct intel_hotplug *hotplug = &display->hotplug; in i915_hpd_short_storm_ctl_write()
1305 new_state = !HAS_DP_MST(display); in i915_hpd_short_storm_ctl_write()
1309 drm_dbg_kms(display->drm, "%sabling HPD short storm detection\n", in i915_hpd_short_storm_ctl_write()
1312 spin_lock_irq(&display->irq.lock); in i915_hpd_short_storm_ctl_write()
1317 spin_unlock_irq(&display->irq.lock); in i915_hpd_short_storm_ctl_write()
1320 flush_delayed_work(&display->hotplug.reenable_work); in i915_hpd_short_storm_ctl_write()
1334 void intel_hpd_debugfs_register(struct intel_display *display) in intel_hpd_debugfs_register() argument
1336 struct drm_minor *minor = display->drm->primary; in intel_hpd_debugfs_register()
1339 display, &i915_hpd_storm_ctl_fops); in intel_hpd_debugfs_register()
1341 display, &i915_hpd_short_storm_ctl_fops); in intel_hpd_debugfs_register()
1343 &display->hotplug.ignore_long_hpd); in intel_hpd_debugfs_register()