Skip to contentSkip to conversation

drm/xe/pm: Enable WAKE# support

PATCH Superseded Raag Jadav 2 participants 3 messages Oct 30, 2025 – Oct 31, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH v2 1/1 drm/xe/pm: Enable WAKE# support

CRI supports signalling the host through WAKE# pin on smbus alerts while in D3cold. Enable/disable this feature based on device/host configuration.

v2: Make wakeup helper static, drop d3cold argument (Rodrigo)

---
 drivers/gpu/drm/xe/xe_device_types.h |  4 ++
 drivers/gpu/drm/xe/xe_pcode_api.h    |  5 +++
 drivers/gpu/drm/xe/xe_pm.c           | 66 ++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +4 -0
index dc17f63f9353..1249ca50a65c 100644
@@ -517,6 +517,10 @@ struct xe_device {
 		 * Default threshold value is 300mb.
 		 */
 		u32 vram_threshold;
+
+		/** @d3cold.wake: Indicates WAKE# capability of device */
+		u32 wake;
+
 		/** @d3cold.lock: protect vram_threshold */
 		struct mutex lock;
 	} d3cold;
drivers/gpu/drm/xe/xe_pcode_api.h +5 -0
index 92bfcba51e19..3f8d43c1b4fe 100644
@@ -50,6 +50,11 @@
 #define	READ_PL_FROM_FW				0x1
 #define	READ_PL_FROM_PCODE			0x0
 
+#define   PCODE_D3COLD_WAKE			0x5A
+#define     READ_MODE				0x0
+#define     WRITE_MODE				0x1
+#define       I2C_WAKE_ENABLE			REG_BIT(1)
+
 #define   PCODE_LATE_BINDING			0x5C
 #define     GET_CAPABILITY_STATUS		0x0
 #define       V1_FAN_SUPPORTED			REG_BIT(0)
drivers/gpu/drm/xe/xe_pm.c +66 -0

108 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 2 lines · Raag Jadav

CRI supports signalling the host through WAKE# pin on smbus alerts while in D3cold. Enable/disable this feature based on device/host configuration.

Could you please expand this explanation a bit further? The doc you shared has the bit information, but it doesn't explain what that has to do with the device_may_wakeup or device_can_wakeup.

I also don't understand the cases in which the can_wakeup will be set to false and more specifically what does it have to do with the ability of toggle of WAKE uppon host_i2c_alert.

Perhaps I need more coffee here today, but anyway I believe it should be documented here for people like me on similar situation (needing more coffee :))

oh, and more below...

Quoted 93 lines

v2: Make wakeup helper static, drop d3cold argument (Rodrigo)

---
 drivers/gpu/drm/xe/xe_device_types.h |  4 ++
 drivers/gpu/drm/xe/xe_pcode_api.h    |  5 +++
 drivers/gpu/drm/xe/xe_pm.c           | 66 ++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +4 -0
index dc17f63f9353..1249ca50a65c 100644
@@ -517,6 +517,10 @@ struct xe_device {
 		 * Default threshold value is 300mb.
 		 */
 		u32 vram_threshold;
+
+		/** @d3cold.wake: Indicates WAKE# capability of device */
+		u32 wake;
+
 		/** @d3cold.lock: protect vram_threshold */
 		struct mutex lock;
 	} d3cold;
drivers/gpu/drm/xe/xe_pcode_api.h +5 -0
index 92bfcba51e19..3f8d43c1b4fe 100644
@@ -50,6 +50,11 @@
 #define	READ_PL_FROM_FW				0x1
 #define	READ_PL_FROM_PCODE			0x0
 
+#define   PCODE_D3COLD_WAKE			0x5A
+#define     READ_MODE				0x0
+#define     WRITE_MODE				0x1
+#define       I2C_WAKE_ENABLE			REG_BIT(1)
+
 #define   PCODE_LATE_BINDING			0x5C
 #define     GET_CAPABILITY_STATUS		0x0
 #define       V1_FAN_SUPPORTED			REG_BIT(0)
drivers/gpu/drm/xe/xe_pm.c +26 -0
index 7b089e6fb63f..04621bbd0b44 100644
@@ -7,6 +7,8 @@
 
 #include <linux/fault-inject.h>
 #include <linux/pm_runtime.h>
+#include <linux/pm_wakeup.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 
 #include <drm/drm_managed.h>
@@ -22,6 +24,7 @@
 #include "xe_i2c.h"
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
+#include "xe_pcode_api.h"
 #include "xe_pcode.h"
 #include "xe_pxp.h"
 #include "xe_sriov_vf_ccs.h"
@@ -161,6 +164,29 @@ static void xe_rpm_lockmap_release(const struct xe_device *xe)
 			 &xe_pm_runtime_d3cold_map);
 }
 
+static void xe_pm_set_wakeup(struct xe_device *xe)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	struct pci_dev *root_pdev;
+	bool wakeup;
+	int ret;
+
+	/* Currently WAKE# is supported for I2C only */
+	if (!REG_FIELD_GET(I2C_WAKE_ENABLE, xe->d3cold.wake))
+		return;
+
+	root_pdev = pcie_find_root_port(pdev);
+	wakeup = root_pdev && device_may_wakeup(&root_pdev->dev);
+
+	ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, WRITE_MODE, 0),
+			     wakeup ? xe->d3cold.wake : 0);
+	if (ret)
+		return;
+
+	drm_dbg(&xe->drm, "WAKE# %s\n", str_enabled_disabled(wakeup));
+}
+
 /**
  * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle
  * @xe: xe device instance

drivers/gpu/drm/xe/xe_pm.c int xe_pm_suspend(struct xe_device *xe) · line 234

Quoted 4 lines
drivers/gpu/drm/xe/xe_pm.c +1 -0
@@ -205,6 +231,9 @@ int xe_pm_suspend(struct xe_device *xe)
 
 	xe_i2c_pm_suspend(xe);
 
+	/* Should be the last call in suspend path */

I don't believe this kind of comment is needed.
But also please explain why this is needed as the last call in the suspend path, specially if no unset is done anywhere after the init...

Quoted 29 lines
drivers/gpu/drm/xe/xe_pm.c +22 -0
+	xe_pm_set_wakeup(xe);
+
 	drm_dbg(&xe->drm, "Device suspended\n");
 	xe_pm_block_end_signalling();
 
@@ -422,6 +451,38 @@ static int xe_pm_notifier_callback(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
 
+static void xe_pm_wakeup_init(struct xe_device *xe)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	struct pci_dev *root_pdev;
+	u32 val = 0;
+	int err;
+
+	if (xe->info.platform != XE_CRESCENTISLAND)
+		return;
+
+	err = xe_pcode_read(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, READ_MODE, 0), &val, NULL);
+	if (err || !val) {
+		drm_dbg(&xe->drm, "WAKE# not supported by device\n");
+		return;
+	}
+
+	root_pdev = pcie_find_root_port(pdev);
+	if (!root_pdev || !device_can_wakeup(&root_pdev->dev)) {
+		drm_dbg(&xe->drm, "WAKE# not supported by host\n");

drivers/gpu/drm/xe/xe_pm.c static int xe_pm_notifier_callback(struct notifier_block *nb, · line 483

Quoted 10 lines
drivers/gpu/drm/xe/xe_pm.c +10 -0
+		goto out;
+	}
+
+	if (!xe_i2c_present(xe))
+		val &= ~I2C_WAKE_ENABLE;
+
+	xe->d3cold.wake = val;
+	drm_dbg(&xe->drm, "WAKE# configuration 0x%08x\n", xe->d3cold.wake);
+out:
+	xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, WRITE_MODE, 0), xe->d3cold.wake);

Why do we need to initialize this with 0? Why don't we need to reset to zero upon resume?

Quoted 27 lines
drivers/gpu/drm/xe/xe_pm.c +7 -0
+}
+
 /**
  * xe_pm_init - Initialize Xe Power Management
  * @xe: xe device instance
@@ -459,6 +520,7 @@ int xe_pm_init(struct xe_device *xe)
 			goto err_unregister;
 	}
 
+	xe_pm_wakeup_init(xe);
 	xe_pm_runtime_init(xe);
 	return 0;
 
@@ -602,6 +664,10 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	xe_i2c_pm_suspend(xe);
 
+	/* Should be the last call in suspend path */
+	if (xe->d3cold.allowed)
+		xe_pm_set_wakeup(xe);
+
 	xe_rpm_lockmap_release(xe);
 	xe_pm_write_callback_task(xe, NULL);
 	return 0;
Signature · 1 line
2.34.1
author
#2 lore raw
Quoted 7 lines · Rodrigo Vivi
Quoted 2 lines · Raag Jadav

CRI supports signalling the host through WAKE# pin on smbus alerts while in D3cold. Enable/disable this feature based on device/host configuration.

Could you please expand this explanation a bit further? The doc you shared has the bit information, but it doesn't explain what that has to do with the device_may_wakeup or device_can_wakeup.

There's a requirement to enable/disable it for debug cases so we also take user input into account. Will add this.

Quoted 3 lines

I also don't understand the cases in which the can_wakeup will be set to false and more specifically what does it have to do with the ability of toggle of WAKE uppon host_i2c_alert.

We defeature it if not supported by host but I see your point.

Quoted 3 lines

Perhaps I need more coffee here today, but anyway I believe it should be documented here for people like me on similar situation (needing more coffee :))

Yeah, we already brought it back so now we can have as much as we want ;)

Quoted 97 lines

oh, and more below...

Quoted 94 lines

v2: Make wakeup helper static, drop d3cold argument (Rodrigo)

---
 drivers/gpu/drm/xe/xe_device_types.h |  4 ++
 drivers/gpu/drm/xe/xe_pcode_api.h    |  5 +++
 drivers/gpu/drm/xe/xe_pm.c           | 66 ++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/xe/xe_device_types.h +4 -0
index dc17f63f9353..1249ca50a65c 100644
@@ -517,6 +517,10 @@ struct xe_device {
 		 * Default threshold value is 300mb.
 		 */
 		u32 vram_threshold;
+
+		/** @d3cold.wake: Indicates WAKE# capability of device */
+		u32 wake;
+
 		/** @d3cold.lock: protect vram_threshold */
 		struct mutex lock;
 	} d3cold;
drivers/gpu/drm/xe/xe_pcode_api.h +5 -0
index 92bfcba51e19..3f8d43c1b4fe 100644
@@ -50,6 +50,11 @@
 #define	READ_PL_FROM_FW				0x1
 #define	READ_PL_FROM_PCODE			0x0
 
+#define   PCODE_D3COLD_WAKE			0x5A
+#define     READ_MODE				0x0
+#define     WRITE_MODE				0x1
+#define       I2C_WAKE_ENABLE			REG_BIT(1)
+
 #define   PCODE_LATE_BINDING			0x5C
 #define     GET_CAPABILITY_STATUS		0x0
 #define       V1_FAN_SUPPORTED			REG_BIT(0)
drivers/gpu/drm/xe/xe_pm.c +26 -0
index 7b089e6fb63f..04621bbd0b44 100644
@@ -7,6 +7,8 @@
 
 #include <linux/fault-inject.h>
 #include <linux/pm_runtime.h>
+#include <linux/pm_wakeup.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 
 #include <drm/drm_managed.h>
@@ -22,6 +24,7 @@
 #include "xe_i2c.h"
 #include "xe_irq.h"
 #include "xe_late_bind_fw.h"
+#include "xe_pcode_api.h"
 #include "xe_pcode.h"
 #include "xe_pxp.h"
 #include "xe_sriov_vf_ccs.h"
@@ -161,6 +164,29 @@ static void xe_rpm_lockmap_release(const struct xe_device *xe)
 			 &xe_pm_runtime_d3cold_map);
 }
 
+static void xe_pm_set_wakeup(struct xe_device *xe)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	struct pci_dev *root_pdev;
+	bool wakeup;
+	int ret;
+
+	/* Currently WAKE# is supported for I2C only */
+	if (!REG_FIELD_GET(I2C_WAKE_ENABLE, xe->d3cold.wake))
+		return;
+
+	root_pdev = pcie_find_root_port(pdev);
+	wakeup = root_pdev && device_may_wakeup(&root_pdev->dev);
+
+	ret = xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, WRITE_MODE, 0),
+			     wakeup ? xe->d3cold.wake : 0);
+	if (ret)
+		return;
+
+	drm_dbg(&xe->drm, "WAKE# %s\n", str_enabled_disabled(wakeup));
+}
+
 /**
  * xe_pm_suspend - Helper for System suspend, i.e. S0->S3 / S0->S2idle
  * @xe: xe device instance
@@ -205,6 +231,9 @@ int xe_pm_suspend(struct xe_device *xe)
 
Quoted 7 lines

drivers/gpu/drm/xe/xe_pm.c int xe_pm_suspend(struct xe_device *xe) · line 234

Quoted 3 lines
drivers/gpu/drm/xe/xe_pm.c +1 -0
 	xe_i2c_pm_suspend(xe);
 
+	/* Should be the last call in suspend path */

I don't believe this kind of comment is needed.
But also please explain why this is needed as the last call in the suspend path, specially if no unset is done anywhere after the init...

Why bother setting wakeup if we're not suspended yet?

Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/xe/xe_pm.c +27 -0
+	xe_pm_set_wakeup(xe);
+
 	drm_dbg(&xe->drm, "Device suspended\n");
 	xe_pm_block_end_signalling();
 
@@ -422,6 +451,38 @@ static int xe_pm_notifier_callback(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
 
+static void xe_pm_wakeup_init(struct xe_device *xe)
+{
+	struct xe_tile *root_tile = xe_device_get_root_tile(xe);
+	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
+	struct pci_dev *root_pdev;
+	u32 val = 0;
+	int err;
+
+	if (xe->info.platform != XE_CRESCENTISLAND)
+		return;
+
+	err = xe_pcode_read(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, READ_MODE, 0), &val, NULL);
+	if (err || !val) {
+		drm_dbg(&xe->drm, "WAKE# not supported by device\n");
+		return;
+	}
+
+	root_pdev = pcie_find_root_port(pdev);
+	if (!root_pdev || !device_can_wakeup(&root_pdev->dev)) {
+		drm_dbg(&xe->drm, "WAKE# not supported by host\n");
+		goto out;
+	}
+
+	if (!xe_i2c_present(xe))
+		val &= ~I2C_WAKE_ENABLE;
Quoted 8 lines

drivers/gpu/drm/xe/xe_pm.c static int xe_pm_notifier_callback(struct notifier_block *nb, · line 483

Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5 -0
+
+	xe->d3cold.wake = val;
+	drm_dbg(&xe->drm, "WAKE# configuration 0x%08x\n", xe->d3cold.wake);
+out:
+	xe_pcode_write(root_tile, PCODE_MBOX(PCODE_D3COLD_WAKE, WRITE_MODE, 0), xe->d3cold.wake);

Why do we need to initialize this with 0? Why don't we need to reset to zero upon resume?

Good point. Will drop it.

Raag

Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/xe/xe_pm.c +7 -0
+}
+
 /**
  * xe_pm_init - Initialize Xe Power Management
  * @xe: xe device instance
@@ -459,6 +520,7 @@ int xe_pm_init(struct xe_device *xe)
 			goto err_unregister;
 	}
 
+	xe_pm_wakeup_init(xe);
 	xe_pm_runtime_init(xe);
 	return 0;
 
@@ -602,6 +664,10 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	xe_i2c_pm_suspend(xe);
 
+	/* Should be the last call in suspend path */
+	if (xe->d3cold.allowed)
+		xe_pm_set_wakeup(xe);
+
 	xe_rpm_lockmap_release(xe);
 	xe_pm_write_callback_task(xe, NULL);
 	return 0;
Signature · 1 line
2.34.1