1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright © 2022-2023 Intel Corporation
4 *
5 * High level display driver entry points. This is a layer between top level
6 * driver code and low level display functionality; no low level display code or
7 * details here.
8 */
9
10 #include <linux/vga_switcheroo.h>
11 #include <acpi/video.h>
12 #include <drm/display/drm_dp_mst_helper.h>
13 #include <drm/drm_atomic_helper.h>
14 #include <drm/drm_client_event.h>
15 #include <drm/drm_mode_config.h>
16 #include <drm/drm_privacy_screen_consumer.h>
17 #include <drm/drm_probe_helper.h>
18 #include <drm/drm_vblank.h>
19
20 #include "i915_drv.h"
21 #include "i9xx_wm.h"
22 #include "intel_acpi.h"
23 #include "intel_atomic.h"
24 #include "intel_audio.h"
25 #include "intel_bios.h"
26 #include "intel_bw.h"
27 #include "intel_cdclk.h"
28 #include "intel_color.h"
29 #include "intel_crtc.h"
30 #include "intel_display_debugfs.h"
31 #include "intel_display_driver.h"
32 #include "intel_display_irq.h"
33 #include "intel_display_power.h"
34 #include "intel_display_types.h"
35 #include "intel_display_wa.h"
36 #include "intel_dkl_phy.h"
37 #include "intel_dmc.h"
38 #include "intel_dp.h"
39 #include "intel_dp_tunnel.h"
40 #include "intel_dpll.h"
41 #include "intel_dpll_mgr.h"
42 #include "intel_fb.h"
43 #include "intel_fbc.h"
44 #include "intel_fbdev.h"
45 #include "intel_fdi.h"
46 #include "intel_gmbus.h"
47 #include "intel_hdcp.h"
48 #include "intel_hotplug.h"
49 #include "intel_hti.h"
50 #include "intel_modeset_lock.h"
51 #include "intel_modeset_setup.h"
52 #include "intel_opregion.h"
53 #include "intel_overlay.h"
54 #include "intel_plane_initial.h"
55 #include "intel_pmdemand.h"
56 #include "intel_pps.h"
57 #include "intel_quirks.h"
58 #include "intel_vga.h"
59 #include "intel_wm.h"
60 #include "skl_watermark.h"
61
intel_display_driver_probe_defer(struct pci_dev * pdev)62 bool intel_display_driver_probe_defer(struct pci_dev *pdev)
63 {
64 struct drm_privacy_screen *privacy_screen;
65
66 /*
67 * apple-gmux is needed on dual GPU MacBook Pro
68 * to probe the panel if we're the inactive GPU.
69 */
70 if (vga_switcheroo_client_probe_defer(pdev))
71 return true;
72
73 /* If the LCD panel has a privacy-screen, wait for it */
74 privacy_screen = drm_privacy_screen_get(&pdev->dev, NULL);
75 if (IS_ERR(privacy_screen) && PTR_ERR(privacy_screen) == -EPROBE_DEFER)
76 return true;
77
78 drm_privacy_screen_put(privacy_screen);
79
80 return false;
81 }
82
intel_display_driver_init_hw(struct intel_display * display)83 void intel_display_driver_init_hw(struct intel_display *display)
84 {
85 struct drm_i915_private *i915 = to_i915(display->drm);
86 struct intel_cdclk_state *cdclk_state;
87
88 if (!HAS_DISPLAY(display))
89 return;
90
91 cdclk_state = to_intel_cdclk_state(display->cdclk.obj.state);
92
93 intel_update_cdclk(display);
94 intel_cdclk_dump_config(display, &display->cdclk.hw, "Current CDCLK");
95 cdclk_state->logical = cdclk_state->actual = display->cdclk.hw;
96
97 intel_display_wa_apply(i915);
98 }
99
100 static const struct drm_mode_config_funcs intel_mode_funcs = {
101 .fb_create = intel_user_framebuffer_create,
102 .get_format_info = intel_fb_get_format_info,
103 .mode_valid = intel_mode_valid,
104 .atomic_check = intel_atomic_check,
105 .atomic_commit = intel_atomic_commit,
106 .atomic_state_alloc = intel_atomic_state_alloc,
107 .atomic_state_clear = intel_atomic_state_clear,
108 .atomic_state_free = intel_atomic_state_free,
109 };
110
111 static const struct drm_mode_config_helper_funcs intel_mode_config_funcs = {
112 .atomic_commit_setup = drm_dp_mst_atomic_setup_commit,
113 };
114
intel_mode_config_init(struct intel_display * display)115 static void intel_mode_config_init(struct intel_display *display)
116 {
117 struct drm_mode_config *mode_config = &display->drm->mode_config;
118
119 drm_mode_config_init(display->drm);
120 INIT_LIST_HEAD(&display->global.obj_list);
121
122 mode_config->min_width = 0;
123 mode_config->min_height = 0;
124
125 mode_config->preferred_depth = 24;
126 mode_config->prefer_shadow = 1;
127
128 mode_config->funcs = &intel_mode_funcs;
129 mode_config->helper_private = &intel_mode_config_funcs;
130
131 mode_config->async_page_flip = HAS_ASYNC_FLIPS(display);
132
133 /*
134 * Maximum framebuffer dimensions, chosen to match
135 * the maximum render engine surface size on gen4+.
136 */
137 if (DISPLAY_VER(display) >= 7) {
138 mode_config->max_width = 16384;
139 mode_config->max_height = 16384;
140 } else if (DISPLAY_VER(display) >= 4) {
141 mode_config->max_width = 8192;
142 mode_config->max_height = 8192;
143 } else if (DISPLAY_VER(display) == 3) {
144 mode_config->max_width = 4096;
145 mode_config->max_height = 4096;
146 } else {
147 mode_config->max_width = 2048;
148 mode_config->max_height = 2048;
149 }
150
151 if (display->platform.i845g || display->platform.i865g) {
152 mode_config->cursor_width = display->platform.i845g ? 64 : 512;
153 mode_config->cursor_height = 1023;
154 } else if (display->platform.i830 || display->platform.i85x ||
155 display->platform.i915g || display->platform.i915gm) {
156 mode_config->cursor_width = 64;
157 mode_config->cursor_height = 64;
158 } else {
159 mode_config->cursor_width = 256;
160 mode_config->cursor_height = 256;
161 }
162 }
163
intel_mode_config_cleanup(struct intel_display * display)164 static void intel_mode_config_cleanup(struct intel_display *display)
165 {
166 intel_atomic_global_obj_cleanup(display);
167 drm_mode_config_cleanup(display->drm);
168 }
169
intel_plane_possible_crtcs_init(struct intel_display * display)170 static void intel_plane_possible_crtcs_init(struct intel_display *display)
171 {
172 struct intel_plane *plane;
173
174 for_each_intel_plane(display->drm, plane) {
175 struct intel_crtc *crtc = intel_crtc_for_pipe(display,
176 plane->pipe);
177
178 plane->base.possible_crtcs = drm_crtc_mask(&crtc->base);
179 }
180 }
181
intel_display_driver_early_probe(struct intel_display * display)182 void intel_display_driver_early_probe(struct intel_display *display)
183 {
184 struct drm_i915_private *i915 = to_i915(display->drm);
185
186 if (!HAS_DISPLAY(display))
187 return;
188
189 spin_lock_init(&display->fb_tracking.lock);
190 mutex_init(&display->backlight.lock);
191 mutex_init(&display->audio.mutex);
192 mutex_init(&display->wm.wm_mutex);
193 mutex_init(&display->pps.mutex);
194 mutex_init(&display->hdcp.hdcp_mutex);
195
196 intel_display_irq_init(i915);
197 intel_dkl_phy_init(display);
198 intel_color_init_hooks(display);
199 intel_init_cdclk_hooks(display);
200 intel_audio_hooks_init(display);
201 intel_dpll_init_clock_hook(i915);
202 intel_init_display_hooks(display);
203 intel_fdi_init_hook(display);
204 intel_dmc_wl_init(display);
205 }
206
207 /* part #1: call before irq install */
intel_display_driver_probe_noirq(struct intel_display * display)208 int intel_display_driver_probe_noirq(struct intel_display *display)
209 {
210 struct drm_i915_private *i915 = to_i915(display->drm);
211 int ret;
212
213 if (i915_inject_probe_failure(i915))
214 return -ENODEV;
215
216 if (HAS_DISPLAY(display)) {
217 ret = drm_vblank_init(display->drm,
218 INTEL_NUM_PIPES(display));
219 if (ret)
220 return ret;
221 }
222
223 intel_bios_init(display);
224
225 ret = intel_vga_register(display);
226 if (ret)
227 goto cleanup_bios;
228
229 /* FIXME: completely on the wrong abstraction layer */
230 ret = intel_power_domains_init(display);
231 if (ret < 0)
232 goto cleanup_vga;
233
234 intel_pmdemand_init_early(display);
235
236 intel_power_domains_init_hw(display, false);
237
238 if (!HAS_DISPLAY(display))
239 return 0;
240
241 intel_dmc_init(display);
242
243 display->wq.modeset = alloc_ordered_workqueue("i915_modeset", 0);
244 display->wq.flip = alloc_workqueue("i915_flip", WQ_HIGHPRI |
245 WQ_UNBOUND, WQ_UNBOUND_MAX_ACTIVE);
246 display->wq.cleanup = alloc_workqueue("i915_cleanup", WQ_HIGHPRI, 0);
247
248 intel_mode_config_init(display);
249
250 ret = intel_cdclk_init(display);
251 if (ret)
252 goto cleanup_vga_client_pw_domain_dmc;
253
254 ret = intel_color_init(display);
255 if (ret)
256 goto cleanup_vga_client_pw_domain_dmc;
257
258 ret = intel_dbuf_init(i915);
259 if (ret)
260 goto cleanup_vga_client_pw_domain_dmc;
261
262 ret = intel_bw_init(i915);
263 if (ret)
264 goto cleanup_vga_client_pw_domain_dmc;
265
266 ret = intel_pmdemand_init(display);
267 if (ret)
268 goto cleanup_vga_client_pw_domain_dmc;
269
270 intel_init_quirks(display);
271
272 intel_fbc_init(display);
273
274 return 0;
275
276 cleanup_vga_client_pw_domain_dmc:
277 intel_dmc_fini(display);
278 intel_power_domains_driver_remove(display);
279 cleanup_vga:
280 intel_vga_unregister(display);
281 cleanup_bios:
282 intel_bios_driver_remove(display);
283
284 return ret;
285 }
286
set_display_access(struct intel_display * display,bool any_task_allowed,struct task_struct * allowed_task)287 static void set_display_access(struct intel_display *display,
288 bool any_task_allowed,
289 struct task_struct *allowed_task)
290 {
291 struct drm_modeset_acquire_ctx ctx;
292 int err;
293
294 intel_modeset_lock_ctx_retry(&ctx, NULL, 0, err) {
295 err = drm_modeset_lock_all_ctx(display->drm, &ctx);
296 if (err)
297 continue;
298
299 display->access.any_task_allowed = any_task_allowed;
300 display->access.allowed_task = allowed_task;
301 }
302
303 drm_WARN_ON(display->drm, err);
304 }
305
306 /**
307 * intel_display_driver_enable_user_access - Enable display HW access for all threads
308 * @display: display device instance
309 *
310 * Enable the display HW access for all threads. Examples for such accesses
311 * are modeset commits and connector probing.
312 *
313 * This function should be called during driver loading and system resume once
314 * all the HW initialization steps are done.
315 */
intel_display_driver_enable_user_access(struct intel_display * display)316 void intel_display_driver_enable_user_access(struct intel_display *display)
317 {
318 struct drm_i915_private *i915 = to_i915(display->drm);
319
320 set_display_access(display, true, NULL);
321
322 intel_hpd_enable_detection_work(i915);
323 }
324
325 /**
326 * intel_display_driver_disable_user_access - Disable display HW access for user threads
327 * @display: display device instance
328 *
329 * Disable the display HW access for user threads. Examples for such accesses
330 * are modeset commits and connector probing. For the current thread the
331 * access is still enabled, which should only perform HW init/deinit
332 * programming (as the initial modeset during driver loading or the disabling
333 * modeset during driver unloading and system suspend/shutdown). This function
334 * should be followed by calling either intel_display_driver_enable_user_access()
335 * after completing the HW init programming or
336 * intel_display_driver_suspend_access() after completing the HW deinit
337 * programming.
338 *
339 * This function should be called during driver loading/unloading and system
340 * suspend/shutdown before starting the HW init/deinit programming.
341 */
intel_display_driver_disable_user_access(struct intel_display * display)342 void intel_display_driver_disable_user_access(struct intel_display *display)
343 {
344 struct drm_i915_private *i915 = to_i915(display->drm);
345
346 intel_hpd_disable_detection_work(i915);
347
348 set_display_access(display, false, current);
349 }
350
351 /**
352 * intel_display_driver_suspend_access - Suspend display HW access for all threads
353 * @display: display device instance
354 *
355 * Disable the display HW access for all threads. Examples for such accesses
356 * are modeset commits and connector probing. This call should be either
357 * followed by calling intel_display_driver_resume_access(), or the driver
358 * should be unloaded/shutdown.
359 *
360 * This function should be called during driver unloading and system
361 * suspend/shutdown after completing the HW deinit programming.
362 */
intel_display_driver_suspend_access(struct intel_display * display)363 void intel_display_driver_suspend_access(struct intel_display *display)
364 {
365 set_display_access(display, false, NULL);
366 }
367
368 /**
369 * intel_display_driver_resume_access - Resume display HW access for the resume thread
370 * @display: display device instance
371 *
372 * Enable the display HW access for the current resume thread, keeping the
373 * access disabled for all other (user) threads. Examples for such accesses
374 * are modeset commits and connector probing. The resume thread should only
375 * perform HW init programming (as the restoring modeset). This function
376 * should be followed by calling intel_display_driver_enable_user_access(),
377 * after completing the HW init programming steps.
378 *
379 * This function should be called during system resume before starting the HW
380 * init steps.
381 */
intel_display_driver_resume_access(struct intel_display * display)382 void intel_display_driver_resume_access(struct intel_display *display)
383 {
384 set_display_access(display, false, current);
385 }
386
387 /**
388 * intel_display_driver_check_access - Check if the current thread has disaplay HW access
389 * @display: display device instance
390 *
391 * Check whether the current thread has display HW access, print a debug
392 * message if it doesn't. Such accesses are modeset commits and connector
393 * probing. If the function returns %false any HW access should be prevented.
394 *
395 * Returns %true if the current thread has display HW access, %false
396 * otherwise.
397 */
intel_display_driver_check_access(struct intel_display * display)398 bool intel_display_driver_check_access(struct intel_display *display)
399 {
400 char current_task[TASK_COMM_LEN + 16];
401 char allowed_task[TASK_COMM_LEN + 16] = "none";
402
403 if (display->access.any_task_allowed ||
404 display->access.allowed_task == current)
405 return true;
406
407 snprintf(current_task, sizeof(current_task), "%s[%d]",
408 current->comm, task_pid_vnr(current));
409
410 if (display->access.allowed_task)
411 snprintf(allowed_task, sizeof(allowed_task), "%s[%d]",
412 display->access.allowed_task->comm,
413 task_pid_vnr(display->access.allowed_task));
414
415 drm_dbg_kms(display->drm,
416 "Reject display access from task %s (allowed to %s)\n",
417 current_task, allowed_task);
418
419 return false;
420 }
421
422 /* part #2: call after irq install, but before gem init */
intel_display_driver_probe_nogem(struct intel_display * display)423 int intel_display_driver_probe_nogem(struct intel_display *display)
424 {
425 struct drm_i915_private *i915 = to_i915(display->drm);
426 enum pipe pipe;
427 int ret;
428
429 if (!HAS_DISPLAY(display))
430 return 0;
431
432 intel_wm_init(i915);
433
434 intel_panel_sanitize_ssc(display);
435
436 intel_pps_setup(display);
437
438 intel_gmbus_setup(display);
439
440 drm_dbg_kms(display->drm, "%d display pipe%s available.\n",
441 INTEL_NUM_PIPES(display),
442 INTEL_NUM_PIPES(display) > 1 ? "s" : "");
443
444 for_each_pipe(display, pipe) {
445 ret = intel_crtc_init(display, pipe);
446 if (ret)
447 goto err_mode_config;
448 }
449
450 intel_plane_possible_crtcs_init(display);
451 intel_shared_dpll_init(display);
452 intel_fdi_pll_freq_update(display);
453
454 intel_update_czclk(display);
455 intel_display_driver_init_hw(display);
456 intel_dpll_update_ref_clks(display);
457
458 if (display->cdclk.max_cdclk_freq == 0)
459 intel_update_max_cdclk(display);
460
461 intel_hti_init(display);
462
463 /* Just disable it once at startup */
464 intel_vga_disable(display);
465 intel_setup_outputs(display);
466
467 ret = intel_dp_tunnel_mgr_init(display);
468 if (ret)
469 goto err_hdcp;
470
471 intel_display_driver_disable_user_access(display);
472
473 drm_modeset_lock_all(display->drm);
474 intel_modeset_setup_hw_state(i915, display->drm->mode_config.acquire_ctx);
475 intel_acpi_assign_connector_fwnodes(display);
476 drm_modeset_unlock_all(display->drm);
477
478 intel_initial_plane_config(display);
479
480 /*
481 * Make sure hardware watermarks really match the state we read out.
482 * Note that we need to do this after reconstructing the BIOS fb's
483 * since the watermark calculation done here will use pstate->fb.
484 */
485 if (!HAS_GMCH(display))
486 ilk_wm_sanitize(i915);
487
488 return 0;
489
490 err_hdcp:
491 intel_hdcp_component_fini(display);
492 err_mode_config:
493 intel_mode_config_cleanup(display);
494
495 return ret;
496 }
497
498 /* part #3: call after gem init */
intel_display_driver_probe(struct intel_display * display)499 int intel_display_driver_probe(struct intel_display *display)
500 {
501 struct drm_i915_private *i915 = to_i915(display->drm);
502 int ret;
503
504 if (!HAS_DISPLAY(display))
505 return 0;
506
507 /*
508 * This will bind stuff into ggtt, so it needs to be done after
509 * the BIOS fb takeover and whatever else magic ggtt reservations
510 * happen during gem/ggtt init.
511 */
512 intel_hdcp_component_init(display);
513
514 /*
515 * Force all active planes to recompute their states. So that on
516 * mode_setcrtc after probe, all the intel_plane_state variables
517 * are already calculated and there is no assert_plane warnings
518 * during bootup.
519 */
520 ret = intel_initial_commit(display);
521 if (ret)
522 drm_dbg_kms(display->drm, "Initial modeset failed, %d\n", ret);
523
524 intel_overlay_setup(display);
525
526 /* Only enable hotplug handling once the fbdev is fully set up. */
527 intel_hpd_init(i915);
528
529 skl_watermark_ipc_init(i915);
530
531 return 0;
532 }
533
intel_display_driver_register(struct intel_display * display)534 void intel_display_driver_register(struct intel_display *display)
535 {
536 struct drm_i915_private *i915 = to_i915(display->drm);
537 struct drm_printer p = drm_dbg_printer(display->drm, DRM_UT_KMS,
538 "i915 display info:");
539
540 if (!HAS_DISPLAY(display))
541 return;
542
543 /* Must be done after probing outputs */
544 intel_opregion_register(display);
545 intel_acpi_video_register(display);
546
547 intel_audio_init(display);
548
549 intel_display_driver_enable_user_access(display);
550
551 intel_audio_register(display);
552
553 intel_display_debugfs_register(display);
554
555 /*
556 * We need to coordinate the hotplugs with the asynchronous
557 * fbdev configuration, for which we use the
558 * fbdev->async_cookie.
559 */
560 drm_kms_helper_poll_init(display->drm);
561 intel_hpd_poll_disable(i915);
562
563 intel_fbdev_setup(i915);
564
565 intel_display_device_info_print(DISPLAY_INFO(display),
566 DISPLAY_RUNTIME_INFO(display), &p);
567
568 intel_register_dsm_handler();
569 }
570
571 /* part #1: call before irq uninstall */
intel_display_driver_remove(struct intel_display * display)572 void intel_display_driver_remove(struct intel_display *display)
573 {
574 if (!HAS_DISPLAY(display))
575 return;
576
577 flush_workqueue(display->wq.flip);
578 flush_workqueue(display->wq.modeset);
579 flush_workqueue(display->wq.cleanup);
580
581 /*
582 * MST topology needs to be suspended so we don't have any calls to
583 * fbdev after it's finalized. MST will be destroyed later as part of
584 * drm_mode_config_cleanup()
585 */
586 intel_dp_mst_suspend(display);
587 }
588
589 /* part #2: call after irq uninstall */
intel_display_driver_remove_noirq(struct intel_display * display)590 void intel_display_driver_remove_noirq(struct intel_display *display)
591 {
592 struct drm_i915_private *i915 = to_i915(display->drm);
593
594 if (!HAS_DISPLAY(display))
595 return;
596
597 intel_display_driver_suspend_access(display);
598
599 /*
600 * Due to the hpd irq storm handling the hotplug work can re-arm the
601 * poll handlers. Hence disable polling after hpd handling is shut down.
602 */
603 intel_hpd_poll_fini(i915);
604
605 intel_unregister_dsm_handler();
606
607 /* flush any delayed tasks or pending work */
608 flush_workqueue(i915->unordered_wq);
609
610 intel_hdcp_component_fini(display);
611
612 intel_mode_config_cleanup(display);
613
614 intel_dp_tunnel_mgr_cleanup(display);
615
616 intel_overlay_cleanup(display);
617
618 intel_gmbus_teardown(display);
619
620 destroy_workqueue(display->wq.flip);
621 destroy_workqueue(display->wq.modeset);
622 destroy_workqueue(display->wq.cleanup);
623
624 intel_fbc_cleanup(display);
625 }
626
627 /* part #3: call after gem init */
intel_display_driver_remove_nogem(struct intel_display * display)628 void intel_display_driver_remove_nogem(struct intel_display *display)
629 {
630 intel_dmc_fini(display);
631
632 intel_power_domains_driver_remove(display);
633
634 intel_vga_unregister(display);
635
636 intel_bios_driver_remove(display);
637 }
638
intel_display_driver_unregister(struct intel_display * display)639 void intel_display_driver_unregister(struct intel_display *display)
640 {
641 if (!HAS_DISPLAY(display))
642 return;
643
644 intel_unregister_dsm_handler();
645
646 drm_client_dev_unregister(display->drm);
647
648 /*
649 * After flushing the fbdev (incl. a late async config which
650 * will have delayed queuing of a hotplug event), then flush
651 * the hotplug events.
652 */
653 drm_kms_helper_poll_fini(display->drm);
654
655 intel_display_driver_disable_user_access(display);
656
657 intel_audio_deinit(display);
658
659 drm_atomic_helper_shutdown(display->drm);
660
661 acpi_video_unregister();
662 intel_opregion_unregister(display);
663 }
664
665 /*
666 * turn all crtc's off, but do not adjust state
667 * This has to be paired with a call to intel_modeset_setup_hw_state.
668 */
intel_display_driver_suspend(struct intel_display * display)669 int intel_display_driver_suspend(struct intel_display *display)
670 {
671 struct drm_atomic_state *state;
672 int ret;
673
674 if (!HAS_DISPLAY(display))
675 return 0;
676
677 state = drm_atomic_helper_suspend(display->drm);
678 ret = PTR_ERR_OR_ZERO(state);
679 if (ret)
680 drm_err(display->drm, "Suspending crtc's failed with %i\n",
681 ret);
682 else
683 display->restore.modeset_state = state;
684
685 /* ensure all DPT VMAs have been unpinned for intel_dpt_suspend() */
686 flush_workqueue(display->wq.cleanup);
687
688 intel_dp_mst_suspend(display);
689
690 return ret;
691 }
692
693 int
__intel_display_driver_resume(struct intel_display * display,struct drm_atomic_state * state,struct drm_modeset_acquire_ctx * ctx)694 __intel_display_driver_resume(struct intel_display *display,
695 struct drm_atomic_state *state,
696 struct drm_modeset_acquire_ctx *ctx)
697 {
698 struct drm_i915_private *i915 = to_i915(display->drm);
699 struct drm_crtc_state *crtc_state;
700 struct drm_crtc *crtc;
701 int ret, i;
702
703 intel_modeset_setup_hw_state(i915, ctx);
704 intel_vga_redisable(display);
705
706 if (!state)
707 return 0;
708
709 /*
710 * We've duplicated the state, pointers to the old state are invalid.
711 *
712 * Don't attempt to use the old state until we commit the duplicated state.
713 */
714 for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
715 /*
716 * Force recalculation even if we restore
717 * current state. With fast modeset this may not result
718 * in a modeset when the state is compatible.
719 */
720 crtc_state->mode_changed = true;
721 }
722
723 /* ignore any reset values/BIOS leftovers in the WM registers */
724 if (!HAS_GMCH(display))
725 to_intel_atomic_state(state)->skip_intermediate_wm = true;
726
727 ret = drm_atomic_helper_commit_duplicated_state(state, ctx);
728
729 drm_WARN_ON(display->drm, ret == -EDEADLK);
730
731 return ret;
732 }
733
intel_display_driver_resume(struct intel_display * display)734 void intel_display_driver_resume(struct intel_display *display)
735 {
736 struct drm_i915_private *i915 = to_i915(display->drm);
737 struct drm_atomic_state *state = display->restore.modeset_state;
738 struct drm_modeset_acquire_ctx ctx;
739 int ret;
740
741 if (!HAS_DISPLAY(display))
742 return;
743
744 /* MST sideband requires HPD interrupts enabled */
745 intel_dp_mst_resume(display);
746
747 display->restore.modeset_state = NULL;
748 if (state)
749 state->acquire_ctx = &ctx;
750
751 drm_modeset_acquire_init(&ctx, 0);
752
753 while (1) {
754 ret = drm_modeset_lock_all_ctx(display->drm, &ctx);
755 if (ret != -EDEADLK)
756 break;
757
758 drm_modeset_backoff(&ctx);
759 }
760
761 if (!ret)
762 ret = __intel_display_driver_resume(display, state, &ctx);
763
764 skl_watermark_ipc_update(i915);
765 drm_modeset_drop_locks(&ctx);
766 drm_modeset_acquire_fini(&ctx);
767
768 if (ret)
769 drm_err(display->drm,
770 "Restoring old state failed with %i\n", ret);
771 if (state)
772 drm_atomic_state_put(state);
773 }
774