Lines Matching +full:disable +full:- +full:hibernation +full:- +full:mode
1 /* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
117 int domain = pci_domain_nr(to_pci_dev(dev_priv->drm.dev)->bus); in i915_get_bridge_dev()
119 dev_priv->bridge_dev = in i915_get_bridge_dev()
121 if (!dev_priv->bridge_dev) { in i915_get_bridge_dev()
122 drm_err(&dev_priv->drm, "bridge device not found\n"); in i915_get_bridge_dev()
123 return -EIO; in i915_get_bridge_dev()
126 return drmm_add_action_or_reset(&dev_priv->drm, i915_release_bridge_dev, in i915_get_bridge_dev()
127 dev_priv->bridge_dev); in i915_get_bridge_dev()
140 pci_read_config_dword(dev_priv->bridge_dev, reg + 4, &temp_hi); in intel_alloc_mchbar_resource()
141 pci_read_config_dword(dev_priv->bridge_dev, reg, &temp_lo); in intel_alloc_mchbar_resource()
152 dev_priv->mch_res.name = "i915 MCHBAR"; in intel_alloc_mchbar_resource()
153 dev_priv->mch_res.flags = IORESOURCE_MEM; in intel_alloc_mchbar_resource()
154 ret = pci_bus_alloc_resource(dev_priv->bridge_dev->bus, in intel_alloc_mchbar_resource()
155 &dev_priv->mch_res, in intel_alloc_mchbar_resource()
159 dev_priv->bridge_dev); in intel_alloc_mchbar_resource()
161 drm_dbg(&dev_priv->drm, "failed bus alloc: %d\n", ret); in intel_alloc_mchbar_resource()
162 dev_priv->mch_res.start = 0; in intel_alloc_mchbar_resource()
167 pci_write_config_dword(dev_priv->bridge_dev, reg + 4, in intel_alloc_mchbar_resource()
168 upper_32_bits(dev_priv->mch_res.start)); in intel_alloc_mchbar_resource()
170 pci_write_config_dword(dev_priv->bridge_dev, reg, in intel_alloc_mchbar_resource()
171 lower_32_bits(dev_priv->mch_res.start)); in intel_alloc_mchbar_resource()
175 /* Setup MCHBAR if possible, return true if we should disable it again */
186 dev_priv->mchbar_need_disable = false; in intel_setup_mchbar()
189 pci_read_config_dword(dev_priv->bridge_dev, DEVEN, &temp); in intel_setup_mchbar()
192 pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); in intel_setup_mchbar()
203 dev_priv->mchbar_need_disable = true; in intel_setup_mchbar()
207 pci_write_config_dword(dev_priv->bridge_dev, DEVEN, in intel_setup_mchbar()
210 pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); in intel_setup_mchbar()
211 pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp | 1); in intel_setup_mchbar()
220 if (dev_priv->mchbar_need_disable) { in intel_teardown_mchbar()
224 pci_read_config_dword(dev_priv->bridge_dev, DEVEN, in intel_teardown_mchbar()
227 pci_write_config_dword(dev_priv->bridge_dev, DEVEN, in intel_teardown_mchbar()
232 pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, in intel_teardown_mchbar()
235 pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, in intel_teardown_mchbar()
240 if (dev_priv->mch_res.start) in intel_teardown_mchbar()
241 release_resource(&dev_priv->mch_res); in intel_teardown_mchbar()
250 * need high-priority retirement, such as waiting for an explicit in i915_workqueues_init()
253 * It is also used for periodic low-priority events, such as in i915_workqueues_init()
254 * idle-timers and recording error state. in i915_workqueues_init()
260 dev_priv->wq = alloc_ordered_workqueue("i915", 0); in i915_workqueues_init()
261 if (dev_priv->wq == NULL) in i915_workqueues_init()
264 dev_priv->display.hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0); in i915_workqueues_init()
265 if (dev_priv->display.hotplug.dp_wq == NULL) in i915_workqueues_init()
271 destroy_workqueue(dev_priv->wq); in i915_workqueues_init()
273 drm_err(&dev_priv->drm, "Failed to allocate workqueues.\n"); in i915_workqueues_init()
275 return -ENOMEM; in i915_workqueues_init()
280 destroy_workqueue(dev_priv->display.hotplug.dp_wq); in i915_workqueues_cleanup()
281 destroy_workqueue(dev_priv->wq); in i915_workqueues_cleanup()
285 * We don't keep the workarounds for pre-production hardware, so we expect our
289 * Our policy for removing pre-production workarounds is to keep the
290 * current gen workarounds as a guide to the bring-up of the next gen
306 drm_err(&dev_priv->drm, "This is a pre-production stepping. " in intel_detect_preproduction_hw()
314 if (!INTEL_INFO(i915)->gpu_reset_clobbers_display) { in sanitize_gpu()
324 * i915_driver_early_probe - setup state not requiring device access
327 * Initialize everything that is a "SW-only" state, that is state not
338 return -ENODEV; in i915_driver_early_probe()
345 spin_lock_init(&dev_priv->irq_lock); in i915_driver_early_probe()
346 spin_lock_init(&dev_priv->gpu_error.lock); in i915_driver_early_probe()
347 mutex_init(&dev_priv->display.backlight.lock); in i915_driver_early_probe()
349 mutex_init(&dev_priv->sb_lock); in i915_driver_early_probe()
350 cpu_latency_qos_add_request(&dev_priv->sb_qos, PM_QOS_DEFAULT_VALUE); in i915_driver_early_probe()
352 mutex_init(&dev_priv->display.audio.mutex); in i915_driver_early_probe()
353 mutex_init(&dev_priv->display.wm.wm_mutex); in i915_driver_early_probe()
354 mutex_init(&dev_priv->display.pps.mutex); in i915_driver_early_probe()
355 mutex_init(&dev_priv->display.hdcp.comp_mutex); in i915_driver_early_probe()
356 spin_lock_init(&dev_priv->display.dkl.phy_lock); in i915_driver_early_probe()
359 intel_runtime_pm_init_early(&dev_priv->runtime_pm); in i915_driver_early_probe()
373 intel_wopcm_init_early(&dev_priv->wopcm); in i915_driver_early_probe()
379 i915_drm_clients_init(&dev_priv->clients, dev_priv); in i915_driver_early_probe()
401 i915_drm_clients_fini(&dev_priv->clients); in i915_driver_early_probe()
412 * i915_driver_late_release - cleanup the setup done in
422 i915_drm_clients_fini(&dev_priv->clients); in i915_driver_late_release()
427 cpu_latency_qos_remove_request(&dev_priv->sb_qos); in i915_driver_late_release()
428 mutex_destroy(&dev_priv->sb_lock); in i915_driver_late_release()
430 i915_params_free(&dev_priv->params); in i915_driver_late_release()
434 * i915_driver_mmio_probe - setup device MMIO
438 * initialization sequence. The setup here should avoid any other device-wide
448 return -ENODEV; in i915_driver_mmio_probe()
455 ret = intel_uncore_init_mmio(gt->uncore); in i915_driver_mmio_probe()
459 ret = drmm_add_action_or_reset(&dev_priv->drm, in i915_driver_mmio_probe()
461 gt->uncore); in i915_driver_mmio_probe()
488 * i915_driver_mmio_release - cleanup the setup done in i915_driver_mmio_probe()
497 * i915_set_dma_info - set all relevant PCI dma info as configured for the
509 unsigned int mask_size = INTEL_INFO(i915)->dma_mask_size; in i915_set_dma_info()
518 dma_set_max_seg_size(i915->drm.dev, UINT_MAX); in i915_set_dma_info()
520 ret = dma_set_mask(i915->drm.dev, DMA_BIT_MASK(mask_size)); in i915_set_dma_info()
540 ret = dma_set_coherent_mask(i915->drm.dev, DMA_BIT_MASK(mask_size)); in i915_set_dma_info()
547 drm_err(&i915->drm, "Can't set DMA mask/consistent mask (%d)\n", ret); in i915_set_dma_info()
557 ret = intel_pcode_init(gt->uncore); in i915_pcode_init()
559 drm_err(>->i915->drm, "gt%d: intel_pcode_init failed %d\n", id, ret); in i915_pcode_init()
568 * i915_driver_hw_probe - setup state requiring device access
576 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); in i915_driver_hw_probe()
581 return -ENODEV; in i915_driver_hw_probe()
588 return -ENXIO; in i915_driver_hw_probe()
602 return -ENXIO; in i915_driver_hw_probe()
623 ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, dev_priv->drm.driver); in i915_driver_hw_probe()
641 drm_err(&dev_priv->drm, "failed to enable GGTT\n"); in i915_driver_hw_probe()
657 * properly dead afterwards. So we'll just disable them for all in i915_driver_hw_probe()
658 * pre-gen5 chipsets. in i915_driver_hw_probe()
661 * interrupts even when in MSI mode. This results in spurious in i915_driver_hw_probe()
668 drm_dbg(&dev_priv->drm, "can't enable MSI"); in i915_driver_hw_probe()
701 if (pdev->msi_enabled) in i915_driver_hw_probe()
715 * i915_driver_hw_remove - cleanup the setup done in i915_driver_hw_probe()
720 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); in i915_driver_hw_remove()
725 if (pdev->msi_enabled) in i915_driver_hw_remove()
734 * i915_driver_register - register the driver with the rest of the system
742 struct drm_device *dev = &dev_priv->drm; in i915_driver_register()
753 drm_err(&dev_priv->drm, in i915_driver_register()
770 intel_runtime_pm_enable(&dev_priv->runtime_pm); in i915_driver_register()
775 drm_err(&dev_priv->drm, "Failed to register vga switcheroo!\n"); in i915_driver_register()
779 * i915_driver_unregister - cleanup the registration done in i915_driver_regiser()
791 intel_runtime_pm_disable(&dev_priv->runtime_pm); in i915_driver_unregister()
803 drm_dev_unplug(&dev_priv->drm); in i915_driver_unregister()
825 intel_platform_name(INTEL_INFO(dev_priv)->platform), in i915_welcome_messages()
827 INTEL_INFO(dev_priv)->platform), in i915_welcome_messages()
834 intel_gt_info_print(>->info, &p); in i915_welcome_messages()
838 drm_info(&dev_priv->drm, "DRM_I915_DEBUG enabled\n"); in i915_welcome_messages()
840 drm_info(&dev_priv->drm, "DRM_I915_DEBUG_GEM enabled\n"); in i915_welcome_messages()
842 drm_info(&dev_priv->drm, in i915_welcome_messages()
850 (struct intel_device_info *)ent->driver_data; in i915_driver_create()
855 i915 = devm_drm_dev_alloc(&pdev->dev, &i915_drm_driver, in i915_driver_create()
863 i915_params_copy(&i915->params, &i915_modparams); in i915_driver_create()
865 /* Setup the write-once "constant" device info */ in i915_driver_create()
871 memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime)); in i915_driver_create()
872 runtime->device_id = pdev->device; in i915_driver_create()
878 * i915_driver_probe - setup chip and create an initial config
883 * - drive output discovery via intel_modeset_init()
884 * - initialize the memory manager
885 * - allocate initial config memory
886 * - setup the DRM framebuffer with the allocated memory
897 /* Disable nuclear pageflip by default on pre-ILK */ in i915_driver_probe()
898 if (!i915->params.nuclear_pageflip && DISPLAY_VER(i915) < 5) in i915_driver_probe()
899 i915->drm.driver_features &= ~DRIVER_ATOMIC; in i915_driver_probe()
909 disable_rpm_wakeref_asserts(&i915->runtime_pm); in i915_driver_probe()
947 enable_rpm_wakeref_asserts(&i915->runtime_pm); in i915_driver_probe()
951 i915->do_release = true; in i915_driver_probe()
980 enable_rpm_wakeref_asserts(&i915->runtime_pm); in i915_driver_probe()
993 wakeref = intel_runtime_pm_get(&i915->runtime_pm); in i915_driver_remove()
1017 intel_runtime_pm_put(&i915->runtime_pm, wakeref); in i915_driver_remove()
1023 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; in i915_driver_release()
1026 if (!dev_priv->do_release) in i915_driver_release()
1060 * i915_driver_lastclose - clean up after all DRM clients have exited
1064 * mode setting case, we want to restore the kernel's initial mode (just
1067 * Additionally, in the non-mode setting case, we'll tear down the GTT
1083 struct drm_i915_file_private *file_priv = file->driver_priv; in i915_driver_postclose()
1086 i915_drm_client_put(file_priv->client); in i915_driver_postclose()
1096 struct drm_device *dev = &dev_priv->drm; in intel_suspend_encoders()
1104 if (encoder->suspend) in intel_suspend_encoders()
1105 encoder->suspend(encoder); in intel_suspend_encoders()
1111 struct drm_device *dev = &dev_priv->drm; in intel_shutdown_encoders()
1119 if (encoder->shutdown) in intel_shutdown_encoders()
1120 encoder->shutdown(encoder); in intel_shutdown_encoders()
1126 disable_rpm_wakeref_asserts(&i915->runtime_pm); in i915_driver_shutdown()
1127 intel_runtime_pm_disable(&i915->runtime_pm); in i915_driver_shutdown()
1131 drm_kms_helper_poll_disable(&i915->drm); in i915_driver_shutdown()
1133 drm_atomic_helper_shutdown(&i915->drm); in i915_driver_shutdown()
1154 * - unify the pci_driver::shutdown sequence here with the in i915_driver_shutdown()
1156 * - unify the driver remove and system/runtime suspend sequences with in i915_driver_shutdown()
1160 enable_rpm_wakeref_asserts(&i915->runtime_pm); in i915_driver_shutdown()
1162 intel_runtime_pm_driver_release(&i915->runtime_pm); in i915_driver_shutdown()
1180 * ostensibly marked the GPU as ready-to-sleep here. We need to in i915_drm_prepare()
1190 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); in i915_drm_suspend()
1193 disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_suspend()
1216 i915_ggtt_suspend(to_gt(dev_priv)->ggtt); in i915_drm_suspend()
1225 dev_priv->suspend_count++; in i915_drm_suspend()
1229 enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_suspend()
1248 static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation) in i915_drm_suspend_late() argument
1251 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); in i915_drm_suspend_late()
1252 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; in i915_drm_suspend_late()
1261 intel_uncore_suspend(gt->uncore); in i915_drm_suspend_late()
1264 get_suspend_mode(dev_priv, hibernation)); in i915_drm_suspend_late()
1270 drm_err(&dev_priv->drm, "Suspend complete failed: %d\n", ret); in i915_drm_suspend_late()
1278 * During hibernation on some platforms the BIOS may try to access in i915_drm_suspend_late()
1289 if (!(hibernation && GRAPHICS_VER(dev_priv) < 6)) in i915_drm_suspend_late()
1294 if (!dev_priv->uncore.user_forcewake_count) in i915_drm_suspend_late()
1305 if (drm_WARN_ON_ONCE(&i915->drm, state.event != PM_EVENT_SUSPEND && in i915_driver_suspend_switcheroo()
1307 return -EINVAL; in i915_driver_suspend_switcheroo()
1309 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_driver_suspend_switcheroo()
1312 error = i915_drm_suspend(&i915->drm); in i915_driver_suspend_switcheroo()
1316 return i915_drm_suspend_late(&i915->drm, false); in i915_driver_suspend_switcheroo()
1324 disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_resume()
1334 drm_err(&dev_priv->drm, "failed to re-enable GGTT\n"); in i915_drm_resume()
1336 i915_ggtt_resume(to_gt(dev_priv)->ggtt); in i915_drm_resume()
1384 enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_resume()
1392 struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev); in i915_drm_resume_early()
1397 * We have a resume ordering issue with the snd-hda driver also in i915_drm_resume_early()
1418 drm_err(&dev_priv->drm, in i915_drm_resume_early()
1437 return -EIO; in i915_drm_resume_early()
1441 disable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_resume_early()
1445 drm_err(&dev_priv->drm, in i915_drm_resume_early()
1449 intel_uncore_resume_early(gt->uncore); in i915_drm_resume_early()
1457 enable_rpm_wakeref_asserts(&dev_priv->runtime_pm); in i915_drm_resume_early()
1466 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_driver_resume_switcheroo()
1469 ret = i915_drm_resume_early(&i915->drm); in i915_driver_resume_switcheroo()
1473 return i915_drm_resume(&i915->drm); in i915_driver_resume_switcheroo()
1482 return -ENODEV; in i915_pm_prepare()
1485 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_prepare()
1488 return i915_drm_prepare(&i915->drm); in i915_pm_prepare()
1497 return -ENODEV; in i915_pm_suspend()
1502 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_suspend()
1505 return i915_drm_suspend(&i915->drm); in i915_pm_suspend()
1513 * We have a suspend ordering issue with the snd-hda driver also in i915_pm_suspend_late()
1521 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_suspend_late()
1524 return i915_drm_suspend_late(&i915->drm, false); in i915_pm_suspend_late()
1531 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_poweroff_late()
1534 return i915_drm_suspend_late(&i915->drm, true); in i915_pm_poweroff_late()
1541 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_resume_early()
1544 return i915_drm_resume_early(&i915->drm); in i915_pm_resume_early()
1551 if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF) in i915_pm_resume()
1559 if (!IS_ENABLED(CONFIG_ACPI) || acpi_dev_present(irst_name, NULL, -1)) in i915_pm_resume()
1562 return i915_drm_resume(&i915->drm); in i915_pm_resume()
1571 if (i915->drm.switch_power_state != DRM_SWITCH_POWER_OFF) { in i915_pm_freeze()
1572 ret = i915_drm_suspend(&i915->drm); in i915_pm_freeze()
1589 if (i915->drm.switch_power_state != DRM_SWITCH_POWER_OFF) { in i915_pm_freeze_late()
1590 ret = i915_drm_suspend_late(&i915->drm, true); in i915_pm_freeze_late()
1602 /* thaw: called after creating the hibernation image, but before turning off. */
1613 /* restore: called after loading the hibernation image. */
1630 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; in intel_runtime_suspend()
1634 if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv))) in intel_runtime_suspend()
1635 return -ENODEV; in intel_runtime_suspend()
1637 drm_dbg(&dev_priv->drm, "Suspending device\n"); in intel_runtime_suspend()
1642 * We are safe here against re-faults, since the fault handler takes in intel_runtime_suspend()
1653 intel_uncore_suspend(gt->uncore); in intel_runtime_suspend()
1659 drm_err(&dev_priv->drm, in intel_runtime_suspend()
1661 intel_uncore_runtime_resume(&dev_priv->uncore); in intel_runtime_suspend()
1675 if (intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore)) in intel_runtime_suspend()
1676 drm_err(&dev_priv->drm, in intel_runtime_suspend()
1679 rpm->suspended = true; in intel_runtime_suspend()
1704 assert_forcewakes_inactive(&dev_priv->uncore); in intel_runtime_suspend()
1709 drm_dbg(&dev_priv->drm, "Device suspended\n"); in intel_runtime_suspend()
1716 struct intel_runtime_pm *rpm = &dev_priv->runtime_pm; in intel_runtime_resume()
1720 if (drm_WARN_ON_ONCE(&dev_priv->drm, !HAS_RUNTIME_PM(dev_priv))) in intel_runtime_resume()
1721 return -ENODEV; in intel_runtime_resume()
1723 drm_dbg(&dev_priv->drm, "Resuming device\n"); in intel_runtime_resume()
1725 drm_WARN_ON_ONCE(&dev_priv->drm, atomic_read(&rpm->wakeref_count)); in intel_runtime_resume()
1729 rpm->suspended = false; in intel_runtime_resume()
1730 if (intel_uncore_unclaimed_mmio(&dev_priv->uncore)) in intel_runtime_resume()
1731 drm_dbg(&dev_priv->drm, in intel_runtime_resume()
1739 intel_uncore_runtime_resume(gt->uncore); in intel_runtime_resume()
1745 * we can do is to hope that things will still work (and disable RPM). in intel_runtime_resume()
1765 drm_err(&dev_priv->drm, in intel_runtime_resume()
1768 drm_dbg(&dev_priv->drm, "Device resumed\n"); in intel_runtime_resume()
1787 * hibernation image [PMSG_FREEZE] and
1790 * @thaw, @thaw_early : called (1) after creating the hibernation
1794 * @poweroff, @poweroff_late: called after writing the hibernation
1797 * hibernation image [PMSG_RESTORE]
1832 return -ENODEV; in i915_gem_reject_pin_ioctl()
1905 * 1.6: - New ioctl for scheduling buffer swaps on vertical blank
1906 * - Support vertical blank on secondary display pipe