]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/intel/pmc: Use PCI DID for PMC SSRAM device discovery
authorXi Pardee <xi.pardee@linux.intel.com>
Tue, 5 May 2026 04:33:35 +0000 (21:33 -0700)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Fri, 8 May 2026 18:38:48 +0000 (21:38 +0300)
Update the PMC SSRAM discovery process to identify the device using its
PCI Device ID rather than relying on a fixed PCI bus location. The
enumeration of integrated devices on the PCI bus is no longer guaranteed
to be consistent across CPUs.

On earlier platforms, the IOE and PCH SSRAM devices were hidden from the
BIOS, and the SOC SSRAM device is associated to telemetry regions from all
available SSRAM devices. Starting with Nova Lake, the IOE and PCH SSRAM
devices register their telemetry regions independently, meaning each
telemetry region is now linked to its corresponding SSRAM device. A new
ssram_hidden attribute has been added to the pmc_dev_info structure to
reflect this distinction.

Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Signed-off-by: Xi Pardee <xi.pardee@linux.intel.com>
Link: https://patch.msgid.link/20260505043342.2573556-5-xi.pardee@linux.intel.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/intel/pmc/arl.c
drivers/platform/x86/intel/pmc/core.c
drivers/platform/x86/intel/pmc/core.h
drivers/platform/x86/intel/pmc/lnl.c
drivers/platform/x86/intel/pmc/mtl.c
drivers/platform/x86/intel/pmc/ptl.c
drivers/platform/x86/intel/pmc/wcl.c

index eb23bc68340ab8727556661e34e60258fa498fb6..95372a0807acff5e0df3c16c9c87d69c862ddedd 100644 (file)
@@ -720,7 +720,6 @@ static int arl_h_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_
 
 static u32 ARL_PMT_DMU_GUIDS[] = {ARL_PMT_DMU_GUID, 0x0};
 struct pmc_dev_info arl_pmc_dev = {
-       .pci_func = 0,
        .dmu_guids = ARL_PMT_DMU_GUIDS,
        .regmap_list = arl_pmc_info_list,
        .map = &arl_socs_reg_map,
@@ -729,11 +728,11 @@ struct pmc_dev_info arl_pmc_dev = {
        .resume = arl_resume,
        .init = arl_core_init,
        .sub_req = pmc_core_pmt_get_lpm_req,
+       .ssram_hidden = true,
 };
 
 static u32 ARL_H_PMT_DMU_GUIDS[] = {ARL_PMT_DMU_GUID, ARL_H_PMT_DMU_GUID, 0x0};
 struct pmc_dev_info arl_h_pmc_dev = {
-       .pci_func = 2,
        .dmu_guids = ARL_H_PMT_DMU_GUIDS,
        .regmap_list = arl_pmc_info_list,
        .map = &mtl_socm_reg_map,
@@ -742,4 +741,5 @@ struct pmc_dev_info arl_h_pmc_dev = {
        .resume = arl_h_resume,
        .init = arl_h_core_init,
        .sub_req = pmc_core_pmt_get_lpm_req,
+       .ssram_hidden = true,
 };
index 94ae098a155a692e448ba06bcd3c766989062989..e0ac329e6723a1be0a107f873e4cf5c994ecc1b3 100644 (file)
@@ -1646,17 +1646,13 @@ int pmc_core_pmt_get_blk_sub_req(struct pmc_dev *pmcdev, struct pmc *pmc,
 
 static int pmc_core_get_telem_info(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_info)
 {
-       struct pci_dev *pcidev __free(pci_dev_put) = NULL;
        struct telem_endpoint *ep;
        unsigned int pmc_idx;
        int ret;
 
-       pcidev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(20, pmc_dev_info->pci_func));
-       if (!pcidev)
-               return -ENODEV;
-
        for (pmc_idx = 0; pmc_idx < ARRAY_SIZE(pmcdev->pmcs); ++pmc_idx) {
                struct pmc *pmc;
+               u16 devid;
 
                pmc = pmcdev->pmcs[pmc_idx];
                if (!pmc)
@@ -1665,6 +1661,16 @@ static int pmc_core_get_telem_info(struct pmc_dev *pmcdev, struct pmc_dev_info *
                if (!pmc->map->lpm_req_guid)
                        return -ENXIO;
 
+               if (pmc_dev_info->ssram_hidden)
+                       devid = pmcdev->pmcs[PMC_IDX_MAIN]->devid;
+               else
+                       devid = pmc->devid;
+
+               struct pci_dev *pcidev __free(pci_dev_put) =
+                       pci_get_device(PCI_VENDOR_ID_INTEL, devid, NULL);
+               if (!pcidev)
+                       return -ENODEV;
+
                ep = pmt_telem_find_and_register_endpoint(&pcidev->dev, pmc->map->lpm_req_guid, 0);
                if (IS_ERR(ep)) {
                        dev_dbg(&pmcdev->pdev->dev, "couldn't get telem endpoint %pe", ep);
@@ -1715,6 +1721,7 @@ static int pmc_core_pmc_add(struct pmc_dev *pmcdev, unsigned int pmc_idx)
 
        pmc->map = map;
        pmc->base_addr = pmc_ssram_telemetry.base_addr;
+       pmc->devid = pmc_ssram_telemetry.devid;
        pmc->regbase = ioremap(pmc->base_addr, pmc->map->regmap_length);
 
        if (!pmc->regbase) {
index 829b1dee3f63693f9b87ab2b0bd61a51c1535ede..f385a0eccd2c2d1e9e767de13a3f4e3a9eec6baf 100644 (file)
@@ -425,6 +425,7 @@ struct pmc_info {
  * @ltr_ign:           Holds LTR ignore data while suspended
  * @num_lpm_modes:     Count of enabled modes
  * @lpm_en_modes:      Array of enabled modes from lowest to highest priority
+ * @devid:             Device ID of the SSRAM device
  *
  * pmc contains info about one power management controller device.
  */
@@ -436,6 +437,7 @@ struct pmc {
        u32 ltr_ign;
        u8 num_lpm_modes;
        u8 lpm_en_modes[LPM_MAX_NUM_MODES];
+       u16 devid;
 };
 
 /**
@@ -495,7 +497,6 @@ enum pmc_index {
 
 /**
  * struct pmc_dev_info - Structure to keep PMC device info
- * @pci_func:          Function number of the primary PMC
  * @dmu_guids:         List of Die Management Unit GUID
  * @pc_guid:           GUID for telemetry region to read PKGC blocker info
  * @pkgc_ltr_blocker_offset: Offset to PKGC LTR blockers in telemetry region
@@ -512,9 +513,9 @@ enum pmc_index {
  * @resume:            Function to perform platform specific resume
  * @init:              Function to perform platform specific init action
  * @sub_req:           Function to achieve low power mode substate requirements
+ * @ssram_hidden:      Some SSRAM devices are hidden on this platform
  */
 struct pmc_dev_info {
-       u8 pci_func;
        u32 *dmu_guids;
        u32 pc_guid;
        u32 pkgc_ltr_blocker_offset;
@@ -528,6 +529,7 @@ struct pmc_dev_info {
        int (*resume)(struct pmc_dev *pmcdev);
        int (*init)(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_info);
        int (*sub_req)(struct pmc_dev *pmcdev, struct pmc *pmc, struct telem_endpoint *ep);
+       bool ssram_hidden;
 };
 
 extern const struct pmc_bit_map msr_map[];
index 1cd81ee54dcf8e5bddda19150c8922fa8f8ab99e..18f303af328e3175800e9a13b6f17ac42080d414 100644 (file)
@@ -571,7 +571,6 @@ static int lnl_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_in
 }
 
 struct pmc_dev_info lnl_pmc_dev = {
-       .pci_func = 2,
        .regmap_list = lnl_pmc_info_list,
        .map = &lnl_socm_reg_map,
        .sub_req_show = &pmc_core_substate_req_regs_fops,
@@ -579,4 +578,5 @@ struct pmc_dev_info lnl_pmc_dev = {
        .resume = lnl_resume,
        .init = lnl_core_init,
        .sub_req = pmc_core_pmt_get_lpm_req,
+       .ssram_hidden = true,
 };
index 57508cbf9cd429f4821be3c58f7062f38c7e364d..193ebbe584023f3970fa4d68bcd2ada8a3b192b2 100644 (file)
@@ -994,7 +994,6 @@ static int mtl_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_in
 
 static u32 MTL_PMT_DMU_GUIDS[] = {MTL_PMT_DMU_GUID, 0x0};
 struct pmc_dev_info mtl_pmc_dev = {
-       .pci_func = 2,
        .dmu_guids = MTL_PMT_DMU_GUIDS,
        .regmap_list = mtl_pmc_info_list,
        .map = &mtl_socm_reg_map,
@@ -1003,4 +1002,5 @@ struct pmc_dev_info mtl_pmc_dev = {
        .resume = mtl_resume,
        .init = mtl_core_init,
        .sub_req = pmc_core_pmt_get_lpm_req,
+       .ssram_hidden = true,
 };
index 1f48e2bbc699f587a54d4cca9683136e5e631334..6c68772e738c8a53646773b9680c3ed43795805e 100644 (file)
@@ -569,7 +569,6 @@ static int ptl_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_in
 }
 
 struct pmc_dev_info ptl_pmc_dev = {
-       .pci_func = 2,
        .regmap_list = ptl_pmc_info_list,
        .map = &ptl_pcdp_reg_map,
        .sub_req_show = &pmc_core_substate_blk_req_fops,
@@ -577,4 +576,5 @@ struct pmc_dev_info ptl_pmc_dev = {
        .resume = ptl_resume,
        .init = ptl_core_init,
        .sub_req = pmc_core_pmt_get_blk_sub_req,
+       .ssram_hidden = true,
 };
index a45707e6364f2b0f6cd68d16dc9495566578fd8f..b55069945e9e7aa741c68e107db9de820d618e80 100644 (file)
@@ -493,7 +493,6 @@ static int wcl_core_init(struct pmc_dev *pmcdev, struct pmc_dev_info *pmc_dev_in
 }
 
 struct pmc_dev_info wcl_pmc_dev = {
-       .pci_func = 2,
        .regmap_list = wcl_pmc_info_list,
        .map = &wcl_pcdn_reg_map,
        .sub_req_show = &pmc_core_substate_blk_req_fops,
@@ -501,4 +500,5 @@ struct pmc_dev_info wcl_pmc_dev = {
        .resume = wcl_resume,
        .init = wcl_core_init,
        .sub_req = pmc_core_pmt_get_blk_sub_req,
+       .ssram_hidden = true,
 };