goto err_pci_disable;
xe_pm_runtime_init(xe);
+ xe_pm_init(xe);
return 0;
struct pci_dev *pdev = to_pci_dev(dev);
struct xe_device *xe = pdev_to_xe_device(pdev);
- /*
- * TODO: d3cold should be allowed (true) if
- * (IS_DGFX(xe) && !xe_device_mem_access_ongoing(xe))
- * but maybe include some other conditions. So, before
- * we can re-enable the D3cold, we need to:
- * 1. rewrite the VRAM save / restore to avoid buffer object locks
- * 2. block D3cold if we have a big amount of device memory in use
- * in order to reduce the latency.
- * 3. at resume, detect if we really lost power and avoid memory
- * restoration if we were only up to d3cold
- */
- xe->d3cold_allowed = false;
+ if (!xe->d3cold_capable) {
+ xe->d3cold_allowed = false;
+ } else {
+ /*
+ * TODO: d3cold should be allowed (true) if
+ * (IS_DGFX(xe) && !xe_device_mem_access_ongoing(xe))
+ * but maybe include some other conditions. So, before
+ * we can re-enable the D3cold, we need to:
+ * 1. rewrite the VRAM save / restore to avoid buffer object locks
+ * 2. block D3cold if we have a big amount of device memory in use
+ * in order to reduce the latency.
+ * 3. at resume, detect if we really lost power and avoid memory
+ * restoration if we were only up to d3cold
+ */
+ xe->d3cold_allowed = false;
+ }
return 0;
}
return 0;
}
+static bool xe_pm_pci_d3cold_capable(struct pci_dev *pdev)
+{
+ struct pci_dev *root_pdev;
+
+ root_pdev = pcie_find_root_port(pdev);
+ if (!root_pdev)
+ return false;
+
+ /* D3Cold requires PME capability and _PR3 power resource */
+ if (!pci_pme_capable(root_pdev, PCI_D3cold) || !pci_pr3_present(root_pdev))
+ return false;
+
+ return true;
+}
+
void xe_pm_runtime_init(struct xe_device *xe)
{
struct device *dev = xe->drm.dev;
pm_runtime_put_autosuspend(dev);
}
+void xe_pm_init(struct xe_device *xe)
+{
+ struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+
+ xe->d3cold_capable = xe_pm_pci_d3cold_capable(pdev);
+}
+
void xe_pm_runtime_fini(struct xe_device *xe)
{
struct device *dev = xe->drm.dev;
int xe_pm_resume(struct xe_device *xe);
void xe_pm_runtime_init(struct xe_device *xe);
+void xe_pm_init(struct xe_device *xe);
void xe_pm_runtime_fini(struct xe_device *xe);
int xe_pm_runtime_suspend(struct xe_device *xe);
int xe_pm_runtime_resume(struct xe_device *xe);