From 7cc3dc9258648a9fdbe8b00e74e6f62a47dc577a Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 1 Sep 2023 12:45:52 +0300 Subject: [PATCH] Revert "[NOT FOR UPSTREAM] Revert "platform/x86/intel/pmc/mtl: Put GNA/IPU/VPU devices in D3"" This reverts commit 743c0c9b590899b78edcd24bf1999f948141d8ca. Signed-off-by: Kai Vehmanen --- drivers/platform/x86/intel/pmc/mtl.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/mtl.c b/drivers/platform/x86/intel/pmc/mtl.c index 3bb59d097c4025..2204bc666980ed 100644 --- a/drivers/platform/x86/intel/pmc/mtl.c +++ b/drivers/platform/x86/intel/pmc/mtl.c @@ -8,6 +8,7 @@ * */ +#include #include "core.h" /* @@ -942,8 +943,37 @@ static struct pmc_info mtl_pmc_info_list[] = { {} }; +#define MTL_GNA_PCI_DEV 0x7e4c +#define MTL_IPU_PCI_DEV 0x7d19 +#define MTL_VPU_PCI_DEV 0x7d1d +static void mtl_set_device_d3(unsigned int device) +{ + struct pci_dev *pcidev; + + pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); + if (pcidev) { + if (!device_trylock(&pcidev->dev)) { + pci_dev_put(pcidev); + return; + } + if (!pcidev->dev.driver) { + dev_info(&pcidev->dev, "Setting to D3hot\n"); + pci_set_power_state(pcidev, PCI_D3hot); + } + device_unlock(&pcidev->dev); + pci_dev_put(pcidev); + } +} + +/* + * Set power state of select devices that do not have drivers to D3 + * so that they do not block Package C entry. + */ static void mtl_d3_fixup(void) { + mtl_set_device_d3(MTL_GNA_PCI_DEV); + mtl_set_device_d3(MTL_IPU_PCI_DEV); + mtl_set_device_d3(MTL_VPU_PCI_DEV); } static int mtl_resume(struct pmc_dev *pmcdev)