]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe/pm: Don't access device in init_early()
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 26 May 2026 19:54:51 +0000 (21:54 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 27 May 2026 10:51:28 +0000 (12:51 +0200)
We should separate software-only state initialization from anything
else that requires access to the device's hardware. Extract d3cold
capability detection into a new function. Add simple kernel-doc for
updated functions here.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20260526195452.20545-7-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_pci.c
drivers/gpu/drm/xe/xe_pm.c
drivers/gpu/drm/xe/xe_pm.h

index 7ba407f73a02f136f5e3d4204b8e561e64118f8d..d224861b6f6fd954d506ad6e82c7943666688bbf 100644 (file)
@@ -594,6 +594,10 @@ int xe_device_init_early(struct xe_device *xe)
        if (err)
                return err;
 
+       err = xe_pm_init_early(xe);
+       if (err)
+               return err;
+
        return 0;
 }
 
index c05cd2ba35098d1cd2bb491b30b91d77448fb8b5..3165686e3e04bc455c0a98f3c95c265de83d8c69 100644 (file)
@@ -1167,7 +1167,7 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                str_yes_no(xe_device_has_sriov(xe)),
                xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
 
-       err = xe_pm_init_early(xe);
+       err = xe_pm_probe(xe);
        if (err)
                return err;
 
@@ -1179,9 +1179,6 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (err)
                goto err_driver_cleanup;
 
-       drm_dbg(&xe->drm, "d3cold: capable=%s\n",
-               str_yes_no(xe->d3cold.capable));
-
        return 0;
 
 err_driver_cleanup:
index d4672eb0747621a8bbf852a7474189650014fa68..5d1a3a26cb6e596d202005ea2316b243fac36afe 100644 (file)
@@ -24,6 +24,7 @@
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
 #include "xe_pcode.h"
+#include "xe_printk.h"
 #include "xe_pxp.h"
 #include "xe_sriov_vf_ccs.h"
 #include "xe_sysctrl.h"
@@ -349,6 +350,15 @@ static void xe_pm_runtime_init(struct xe_device *xe)
        pm_runtime_put(dev);
 }
 
+/**
+ * xe_pm_init_early() - Initialize Xe Power Management
+ * @xe: the &xe_device instance
+ *
+ * Initialize everything that is a "software-only" state that does not
+ * require access to any of the device's hardware data.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
 int xe_pm_init_early(struct xe_device *xe)
 {
        int err;
@@ -363,11 +373,26 @@ int xe_pm_init_early(struct xe_device *xe)
        if (err)
                return err;
 
-       xe->d3cold.capable = xe_pm_pci_d3cold_capable(xe);
        return 0;
 }
 ALLOW_ERROR_INJECTION(xe_pm_init_early, ERRNO); /* See xe_pci_probe() */
 
+/**
+ * xe_pm_probe() - Initialize Xe Power Management
+ * @xe: the &xe_device instance
+ *
+ * Check d3cold capability.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int xe_pm_probe(struct xe_device *xe)
+{
+       xe->d3cold.capable = xe_pm_pci_d3cold_capable(xe);
+       xe_dbg(xe, "d3cold: capable=%s\n", str_yes_no(xe->d3cold.capable));
+
+       return 0;
+}
+
 static u32 vram_threshold_value(struct xe_device *xe)
 {
        if (xe->info.platform == XE_BATTLEMAGE) {
index 6b27039e7b2d7cf4f355d086412c0484b5d05920..6d5ab09cb7696fa2410ec6193e936f1f93de3659 100644 (file)
@@ -17,6 +17,7 @@ int xe_pm_suspend(struct xe_device *xe);
 int xe_pm_resume(struct xe_device *xe);
 
 int xe_pm_init_early(struct xe_device *xe);
+int xe_pm_probe(struct xe_device *xe);
 int xe_pm_init(struct xe_device *xe);
 void xe_pm_fini(struct xe_device *xe);
 bool xe_pm_runtime_suspended(struct xe_device *xe);