drm/xe/pm: Don't access device in init_early()

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
This commit is contained in:
Michal Wajdeczko 2026-05-26 21:54:51 +02:00
parent 2841cea001
commit 6c766f8d22
4 changed files with 32 additions and 5 deletions

View 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;
}

View 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:

View 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) {

View 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);