Created
May 10, 2024 00:31
-
-
Save superm1/ac47f764e32422bbe71de9b172f23f68 to your computer and use it in GitHub Desktop.
Possible patch for putting NPU into right state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 911645703dddcf2c0911d73f1791927cfd4d888e Mon Sep 17 00:00:00 2001 | |
From: Mario Limonciello <mario.limonciello@amd.com> | |
Date: Thu, 9 May 2024 19:29:20 -0500 | |
Subject: [PATCH] x86/pci: Put NPU into D3 after resume if it's not bound to a | |
driver | |
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> | |
--- | |
arch/x86/pci/fixup.c | 26 ++++++++++++++++++++++++++ | |
1 file changed, 26 insertions(+) | |
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c | |
index ff1fbc39086d..bd6a8d213a46 100644 | |
--- a/arch/x86/pci/fixup.c | |
+++ b/arch/x86/pci/fixup.c | |
@@ -988,6 +988,25 @@ static void amd_rp_pme_suspend(struct pci_dev *dev) | |
dev_info_once(&rp->dev, "quirk: disabling D3cold for suspend\n"); | |
} | |
+static void amd_rp_put_child_d3(int device) | |
+{ | |
+ struct pci_dev *child; | |
+ | |
+ child = pci_get_device(PCI_VENDOR_ID_AMD, device, NULL); | |
+ if (child) { | |
+ if (!device_trylock(&child->dev)) { | |
+ pci_dev_put(child); | |
+ return; | |
+ } | |
+ if (!child->dev.driver) { | |
+ dev_info(&child->dev, "Setting to D3hot\n"); | |
+ pci_set_power_state(child, PCI_D3hot); | |
+ } | |
+ device_unlock(&child->dev); | |
+ pci_dev_put(child); | |
+ } | |
+} | |
+ | |
static void amd_rp_pme_resume(struct pci_dev *dev) | |
{ | |
struct pci_dev *rp; | |
@@ -999,6 +1018,13 @@ static void amd_rp_pme_resume(struct pci_dev *dev) | |
pci_read_config_word(rp, rp->pm_cap + PCI_PM_PMC, &pmc); | |
rp->pme_support = FIELD_GET(PCI_PM_CAP_PME_MASK, pmc); | |
+ | |
+ /* | |
+ * Make sure that any if NPU doesn't have a driver it is put back into D3 | |
+ * after the quirk is done | |
+ */ | |
+ amd_rp_put_child_d3(0x1502); | |
+ amd_rp_put_child_d3(0x14ec); | |
} | |
/* Rembrandt (yellow_carp) */ | |
DECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_AMD, 0x162e, amd_rp_pme_suspend); | |
-- | |
2.43.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment