History

drm/nouveau: make sure display hardware is reinitialised on runtime resume

Linus commit 05c63c2ff23a80b654d6c088ac3ba21628db0173 modified the runtime suspend/resume paths to skip over display-related tasks to avoid locking issues on resume. Unfortunately, this resulted in the display hardware being left in a partially initialised state, preventing subsequent modesets from completing. This commit unifies the (many) suspend/resume paths, bringing back display (and fbcon) handling in the runtime paths.

Ben Skeggs committed 12 years ago

Commit 6fbb7021 parent 634ffcc3 files · +26 −53Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/nouveau/nouveau_display.c +11 −12
  2. drivers/gpu/drm/nouveau/nouveau_display.h +2 −3
  3. drivers/gpu/drm/nouveau/nouveau_drm.c +13 −38
drivers/gpu/drm/nouveau/nouveau_display.c+11−12
@@ -550,14 +550,12 @@ nouveau_display_destroy(struct drm_device *dev) · 549 unmodified lines
550550 }
551551
552552 int
553−nouveau_display_suspend(struct drm_device *dev)
553+nouveau_display_suspend(struct drm_device *dev, bool runtime)
554554 {
555− struct nouveau_drm *drm = nouveau_drm(dev);
556555 struct drm_crtc *crtc;
557556
558557 nouveau_display_fini(dev);
559558
560− NV_INFO(drm, "unpinning framebuffer(s)...\n");
561559 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
562560 struct nouveau_framebuffer *nouveau_fb;
563561
@@ -579,12 +577,13 @@ nouveau_display_suspend(struct drm_device *dev) · 15 unmodified lines
579577 }
580578
581579 void
582−nouveau_display_repin(struct drm_device *dev)
580+nouveau_display_resume(struct drm_device *dev, bool runtime)
583581 {
584582 struct nouveau_drm *drm = nouveau_drm(dev);
585583 struct drm_crtc *crtc;
586− int ret;
584+ int ret, head;
587585
586+ /* re-pin fb/cursors */
588587 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
589588 struct nouveau_framebuffer *nouveau_fb;
590589
@@ -606,13 +605,6 @@ nouveau_display_repin(struct drm_device *dev) · 15 unmodified lines
606605 if (ret)
607606 NV_ERROR(drm, "Could not pin/map cursor.\n");
608607 }
609−}
610−
611−void
612−nouveau_display_resume(struct drm_device *dev)
613−{
614− struct drm_crtc *crtc;
615− int head;
616608
617609 nouveau_display_init(dev);
618610
@@ -627,6 +619,13 @@ nouveau_display_resume(struct drm_device *dev) · 8 unmodified lines
627619 for (head = 0; head < dev->mode_config.num_crtc; head++)
628620 drm_vblank_on(dev, head);
629621
622+ /* This should ensure we don't hit a locking problem when someone
623+ * wakes us up via a connector. We should never go into suspend
624+ * while the display is on anyways.
625+ */
626+ if (runtime)
627+ return;
628+
630629 drm_helper_resume_force_mode(dev);
631630
632631 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
drivers/gpu/drm/nouveau/nouveau_display.h+2−3
@@ -63,9 +63,8 @@ int nouveau_display_create(struct drm_device *dev); · 62 unmodified lines
6363 void nouveau_display_destroy(struct drm_device *dev);
6464 int nouveau_display_init(struct drm_device *dev);
6565 void nouveau_display_fini(struct drm_device *dev);
66−int nouveau_display_suspend(struct drm_device *dev);
67−void nouveau_display_repin(struct drm_device *dev);
68−void nouveau_display_resume(struct drm_device *dev);
66+int nouveau_display_suspend(struct drm_device *dev, bool runtime);
67+void nouveau_display_resume(struct drm_device *dev, bool runtime);
6968 int nouveau_display_vblank_enable(struct drm_device *, int);
7069 void nouveau_display_vblank_disable(struct drm_device *, int);
7170 int nouveau_display_scanoutpos(struct drm_device *, int, unsigned int,
drivers/gpu/drm/nouveau/nouveau_drm.c+13−38
@@ -547,9 +547,11 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) · 546 unmodified lines
547547 struct nouveau_cli *cli;
548548 int ret;
549549
550− if (dev->mode_config.num_crtc && !runtime) {
550+ if (dev->mode_config.num_crtc) {
551+ NV_INFO(drm, "suspending console...\n");
552+ nouveau_fbcon_set_suspend(dev, 1);
551553 NV_INFO(drm, "suspending display...\n");
552− ret = nouveau_display_suspend(dev);
554+ ret = nouveau_display_suspend(dev, runtime);
553555 if (ret)
554556 return ret;
555557 }
@@ -603,7 +605,7 @@ fail_client: · 47 unmodified lines
603605 fail_display:
604606 if (dev->mode_config.num_crtc) {
605607 NV_INFO(drm, "resuming display...\n");
606− nouveau_display_resume(dev);
608+ nouveau_display_resume(dev, runtime);
607609 }
608610 return ret;
609611 }
@@ -618,9 +620,6 @@ int nouveau_pmops_suspend(struct device *dev) · 8 unmodified lines
618620 drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
619621 return 0;
620622
621− if (drm_dev->mode_config.num_crtc)
622− nouveau_fbcon_set_suspend(drm_dev, 1);
623−
624623 ret = nouveau_do_suspend(drm_dev, false);
625624 if (ret)
626625 return ret;
@@ -633,7 +632,7 @@ int nouveau_pmops_suspend(struct device *dev) · 6 unmodified lines
633632 }
634633
635634 static int
636−nouveau_do_resume(struct drm_device *dev)
635+nouveau_do_resume(struct drm_device *dev, bool runtime)
637636 {
638637 struct nouveau_drm *drm = nouveau_drm(dev);
639638 struct nouveau_cli *cli;
@@ -658,7 +657,9 @@ nouveau_do_resume(struct drm_device *dev) · 18 unmodified lines
658657
659658 if (dev->mode_config.num_crtc) {
660659 NV_INFO(drm, "resuming display...\n");
661− nouveau_display_repin(dev);
660+ nouveau_display_resume(dev, runtime);
661+ NV_INFO(drm, "resuming console...\n");
662+ nouveau_fbcon_set_suspend(dev, 0);
662663 }
663664
664665 return 0;
@@ -681,47 +682,21 @@ int nouveau_pmops_resume(struct device *dev) · 16 unmodified lines
681682 return ret;
682683 pci_set_master(pdev);
683684
684− ret = nouveau_do_resume(drm_dev);
685− if (ret)
686− return ret;
687−
688− if (drm_dev->mode_config.num_crtc) {
689− nouveau_display_resume(drm_dev);
690− nouveau_fbcon_set_suspend(drm_dev, 0);
691− }
692−
693− return 0;
685+ return nouveau_do_resume(drm_dev, false);
694686 }
695687
696688 static int nouveau_pmops_freeze(struct device *dev)
697689 {
698690 struct pci_dev *pdev = to_pci_dev(dev);
699691 struct drm_device *drm_dev = pci_get_drvdata(pdev);
700− int ret;
701−
702− if (drm_dev->mode_config.num_crtc)
703− nouveau_fbcon_set_suspend(drm_dev, 1);
704−
705− ret = nouveau_do_suspend(drm_dev, false);
706− return ret;
692+ return nouveau_do_suspend(drm_dev, false);
707693 }
708694
709695 static int nouveau_pmops_thaw(struct device *dev)
710696 {
711697 struct pci_dev *pdev = to_pci_dev(dev);
712698 struct drm_device *drm_dev = pci_get_drvdata(pdev);
713− int ret;
714−
715− ret = nouveau_do_resume(drm_dev);
716− if (ret)
717− return ret;
718−
719− if (drm_dev->mode_config.num_crtc) {
720− nouveau_display_resume(drm_dev);
721− nouveau_fbcon_set_suspend(drm_dev, 0);
722− }
723−
724− return 0;
699+ return nouveau_do_resume(drm_dev, false);
725700 }
726701
727702
@@ -977,7 +952,7 @@ static int nouveau_pmops_runtime_resume(struct device *dev) · 249 unmodified lines
977952 return ret;
978953 pci_set_master(pdev);
979954
980− ret = nouveau_do_resume(drm_dev);
955+ ret = nouveau_do_resume(drm_dev, true);
981956 drm_kms_helper_poll_enable(drm_dev);
982957 /* do magic */
983958 nvif_mask(device, 0x88488, (1 << 25), (1 << 25));