Create Intel PMC SSRAM Telemetry driver
Subsystems (3)
Xi Pardee
maintainercover Create Intel PMC SSRAM Telemetry driver
This patch series removes the SSRAM support from Intel PMC Core driver and creates a separate PCI driver for SSRAM device. The new Intel PMC SSRAM driver provides the following functionalities:
1. Search and store the PMC information in a structure, including PWRMBASE address and devid for each available PMC. Then Intel PMC Core driver achieves the PMC information using the API provided by the new driver.
2. Search and register Intel Platform Monitoring Techology telemetry regions so they would by available for read through sysfs and Intel PMT API. Intel PMC Core driver can achieve Low Power Mode requirement information from a telemetry region registered by the new driver. The above functionalities was previously handled by Intel PMC Core driver. Intel PMC Core driver returns -EPROBE_DEFER when trying to read data from a telem region that is not available yet. This setup may result in an infinite loop of .probe() calls as Intel PMC Core driver creates child devices. Creating a separate PCI driver avoids the infinite loop possibility.
Xi Pardee (7):
platform/x86:intel/pmc: Remove SSRAM support from PMC Core platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver platform/x86:intel/pmc: Add support to get PMC information from SSRAM platform/x86:intel/pmt: Get PMC from SSRAM for available platforms platform/x86:intel/pmt: Create inline version for telemetry functions platform/x86:intel/pmc: Add support to Retrieve LPM information platform/x86:intel/pmc: Get LPM information for available platforms
drivers/platform/x86/intel/pmc/Kconfig | 13 +- drivers/platform/x86/intel/pmc/Makefile | 8 +- drivers/platform/x86/intel/pmc/arl.c | 36 +- drivers/platform/x86/intel/pmc/core.c | 216 +++++++++++- drivers/platform/x86/intel/pmc/core.h | 25 +- drivers/platform/x86/intel/pmc/core_ssram.c | 326 ------------------ drivers/platform/x86/intel/pmc/lnl.c | 36 +- drivers/platform/x86/intel/pmc/mtl.c | 34 +- .../platform/x86/intel/pmc/ssram_telemetry.c | 184 ++++++++++ .../platform/x86/intel/pmc/ssram_telemetry.h | 45 +++ drivers/platform/x86/intel/pmt/telemetry.h | 19 +- 11 files changed, 550 insertions(+), 392 deletions(-) delete mode 100644 drivers/platform/x86/intel/pmc/core_ssram.c create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.c create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.h
Signature · 1 line
2.43.0
Xi Pardee
maintainerPATCH 1/7 platform/x86:intel/pmc: Remove SSRAM support from PMC Core
From: Xi Pardee <[email protected]>
Remove SSRAM support code from PMC Core driver. That includes removing support to discover PMCs through SSRAM device and achieve LPM requirement data from telemetry endpoints. A separate Intel SSRAM Telemetry driver will be added later in this series to be responsible for the SSRAM device.
Currently PMC Core driver gets PWRMBASE address and devid for each PMC from the SSRAM device and also registers telemetry endpoints through intel_vsec driver. PMC Core probe function returns -EPROBE_DEFER when getting LPM requirement data from a telem endpoint that is not available yet. This setup may result in an infinite loop of .probe() calls as -EPROBE_DEFER is returned after a child device has been registered. Creating a new Intel SSRAM Telemetry driver prevents the infinite loop possibility.
--- drivers/platform/x86/intel/pmc/Makefile | 4 +- drivers/platform/x86/intel/pmc/arl.c | 58 +--- drivers/platform/x86/intel/pmc/core.c | 6 +- drivers/platform/x86/intel/pmc/core.h | 5 - drivers/platform/x86/intel/pmc/core_ssram.c | 326 -------------------- drivers/platform/x86/intel/pmc/mtl.c | 59 +--- 6 files changed, 12 insertions(+), 446 deletions(-) delete mode 100644 drivers/platform/x86/intel/pmc/core_ssram.c
drivers/platform/x86/intel/pmc/Makefile +2 -2
@@ -3,8 +3,8 @@ # Intel x86 Platform-Specific Drivers # -intel_pmc_core-y := core.o core_ssram.o spt.o cnp.o \ - icl.o tgl.o adl.o mtl.o arl.o lnl.o +intel_pmc_core-y := core.o spt.o cnp.o icl.o \ + tgl.o adl.o mtl.o arl.o lnl.o obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o intel_pmc_core_pltdrv-y := pltdrv.o obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core_pltdrv.o
drivers/platform/x86/intel/pmc/arl.c +4 -54
93 lines not on this page · raw message
drivers/platform/x86/intel/pmc/core.c +1 -5
@@ -1386,11 +1386,6 @@ static void pmc_core_clean_structure(struct platform_device *pdev)iounmap (pmc->regbase); } -if (pmcdev->ssram_pcidev) { -pci_dev_put (pmcdev->ssram_pcidev); -pci_disable_device (pmcdev->ssram_pcidev); - } -if (pmcdev->punit_ep)pmt_telem_unregister_endpoint (pmcdev->punit_ep);
@@ -1623,5 +1618,6 @@ static struct platform_driver pmc_core_driver = {module_platform_driver (pmc_core_driver); +MODULE_IMPORT_NS (INTEL_PMT_TELEMETRY );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("Intel PMC Core Driver" );
drivers/platform/x86/intel/pmc/core.h +0 -5
@@ -386,7 +386,6 @@ struct pmc {* struct pmc_dev - pmc device structure * @devs: pointer to an array of pmc pointers * @pdev: pointer to platform_device struct -* @ssram_pcidev: pointer to pci device struct for the PMC SSRAM * @crystal_freq: crystal frequency from cpuid * @dbgfs_dir: path to debugfs interface * @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers
@@ -406,7 +405,6 @@ struct pmc_dev {struct pmc *pmcs[MAX_NUM_PMC ];struct dentry *dbgfs_dir;struct platform_device *pdev; -struct pci_dev *ssram_pcidev;unsigned int crystal_freq;int pmc_xram_read_bit;struct mutex lock;/* generic mutex lock for PMC Core */
@@ -579,7 +577,6 @@ extern const struct pmc_bit_map *arl_pchs_lpm_maps[];extern const struct pmc_reg_map arl_pchs_reg_map;extern void pmc_core_get_tgl_lpm_reqs (struct platform_device *pdev); -extern int pmc_core_ssram_get_lpm_reqs (struct pmc_dev *pmcdev);int pmc_core_send_ltr_ignore (struct pmc_dev *pmcdev,u32 value,int ignore);int pmc_core_resume_common (struct pmc_dev *pmcdev);
@@ -588,8 +585,6 @@ extern void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev);extern void pmc_core_punit_pmt_init (struct pmc_dev *pmcdev,u32 guid);extern void pmc_core_set_device_d3 (unsigned int device); -extern int pmc_core_ssram_init (struct pmc_dev *pmcdev,int func); -int spt_core_init (struct pmc_dev *pmcdev);int cnp_core_init (struct pmc_dev *pmcdev);int icl_core_init (struct pmc_dev *pmcdev);
drivers/platform/x86/intel/pmc/core_ssram.c deleted +0 -326
326 lines not on this page · raw message
drivers/platform/x86/intel/pmc/mtl.c +5 -54
97 lines not on this page · raw message
Signature · 1 line
2.43.0
Xi Pardee
maintainerPATCH 2/7 platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver
In reply to Xi PardeeFrom: Xi Pardee <[email protected]>
Create Intel PMC SSRAM Telemetry driver for SSRAM device. The driver binds to SSRAM device and provides the following functionalities:
1. Look for and register telemetry regions available in SSRAM device.
2. Provide devid and PWRMBASE address information for the corresponding PMCs.
--- drivers/platform/x86/intel/pmc/Kconfig | 10 + drivers/platform/x86/intel/pmc/Makefile | 4 + drivers/platform/x86/intel/pmc/core.h | 10 + .../platform/x86/intel/pmc/ssram_telemetry.c | 184 ++++++++++++++++++ .../platform/x86/intel/pmc/ssram_telemetry.h | 45 +++++ 5 files changed, 253 insertions(+) create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.c create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.h
drivers/platform/x86/intel/pmc/Kconfig +10 -0
@@ -24,3 +24,13 @@ config INTEL_PMC_CORE - SLPS0 Debug registers (Cannonlake/Icelake PCH) - Low Power Mode registers (Tigerlake and beyond) - PMC quirks as needed to enable SLPS0/S0ix + +config INTEL_PMC_SSRAM_TELEMETRY + tristate "Intel PMC SSRAM Telemetry driver" + depends on INTEL_VSEC + help + The PMC SSRAM device contains counters structured in Intel Platform + Monitoring Techology (PMT) telemetry regions. This driver looks for + and register these telemetry regions so they would be available for + read through sysfs and Intel PMT API. The driver also provides API to + expose information of PMCs available in the platform.
drivers/platform/x86/intel/pmc/Makefile +4 -0
@@ -8,3 +8,7 @@ intel_pmc_core-y := core.o spt.o cnp.o icl.o \ obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o intel_pmc_core_pltdrv-y := pltdrv.o obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core_pltdrv.o + +# Intel PMC SSRAM driver +intel_pmc_ssram_telemetry-y += ssram_telemetry.o +obj-$(CONFIG_INTEL_PMC_SSRAM_TELEMETRY) += intel_pmc_ssram_telemetry.o
drivers/platform/x86/intel/pmc/core.h +10 -0
@@ -285,6 +285,16 @@ enum ppfear_regs {#define LNL_PPFEAR_NUM_ENTRIES 12#define LNL_S0IX_BLOCKER_OFFSET 0x2004 +/* SSRAM PMC Device ID*/ +/* ARL */ +#define PMC_DEVID_ARL_SOCS 0xae7f + +/* MTL */ +#define PMC_DEVID_MTL_SOCM 0x7e7f + +/* LNL */ +#define PMC_DEVID_LNL_SOCM 0xa87f +extern const char *pmc_lpm_modes[];struct pmc_bit_map {
drivers/platform/x86/intel/pmc/ssram_telemetry.c new file +184 -0
184 lines not on this page · raw message
drivers/platform/x86/intel/pmc/ssram_telemetry.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 2/7] platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver
kernel test robot noticed the following build warnings:
Hi Xi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.11-rc3 next-20240812]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Xi-Pardee/platform-x86-intel-pmc-Remove-SSRAM-support-from-PMC-Core/20240810-114100 base: linus/master patch link: https://lore.kernel.org/r/20240809204648.1124545-3-xi.pardee%40linux.intel.com patch subject: [PATCH 2/7] platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver config: x86_64-randconfig-123-20240812 (https://download.01.org/0day-ci/archive/20240812/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240812/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/platform/x86/intel/pmc/ssram_telemetry.c:97:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile *val @@ got void [noderef] __iomem *__val @@
drivers/platform/x86/intel/pmc/ssram_telemetry.c:97:25: sparse: expected void const volatile *val
drivers/platform/x86/intel/pmc/ssram_telemetry.c:97:25: sparse: got void [noderef] __iomem *__val
drivers/platform/x86/intel/pmc/ssram_telemetry.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h, include/linux/xarray.h, ...):
include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false
include/linux/page-flags.h:235:46: sparse: sparse: self-comparison always evaluates to false
vim +97 drivers/platform/x86/intel/pmc/ssram_telemetry.c
70
71 static int pmc_ssram_telemetry_get_pmc(struct pci_dev *pdev, unsigned int pmc_idx, u32 offset)
72 {
73 void __iomem __free(pmc_ssram_telemetry_iounmap) * tmp_ssram = NULL;
74 void __iomem __free(pmc_ssram_telemetry_iounmap) * ssram = NULL;
75 u64 ssram_base, pwrm_base;
76 u16 devid;
77
78 ssram_base = pdev->resource[0].start;
79 tmp_ssram = ioremap(ssram_base, SSRAM_HDR_SIZE);
80
81 if (!tmp_ssram)
82 return -ENOMEM;
83
84 if (pmc_idx != PMC_IDX_MAIN) {
85 /*
86 * The secondary PMC BARS (which are behind hidden PCI devices)
87 * are read from fixed offsets in MMIO of the primary PMC BAR.
88 */
89 ssram_base = get_base(tmp_ssram, offset);
90 if (!ssram_base)
91 return -ENODEV;
92
93 ssram = ioremap(ssram_base, SSRAM_HDR_SIZE);
94 if (!ssram)
95 return -ENOMEM;
96 } else
> 97 ssram = no_free_ptr(tmp_ssram); 98
99 /* Find and register and PMC telemetry entries */
100 pmc_ssram_telemetry_add_pmt(pdev, ssram_base, ssram);
101
102 pwrm_base = get_base(ssram, SSRAM_PWRM_OFFSET);
103 if (!pwrm_base)
104 return -ENODEV;
105 devid = readw(ssram + SSRAM_DEVID_OFFSET);
106
107 pmc_ssram_telems[pmc_idx].devid = devid;
108 pmc_ssram_telems[pmc_idx].base_addr = pwrm_base;
109
110 return 0;
111 }
112
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Xi Pardee
maintainerPATCH 3/7 platform/x86:intel/pmc: Add support to get PMC information from SSRAM
In reply to Xi PardeePWRMBASE address and devid for PMCs are available through API of Intel PMC SSRAM Telemetry driver. Add support to discover and achieve the information for each available PMC. Use PMC devid to find and assign the corresponding register map.
--- drivers/platform/x86/intel/pmc/Kconfig | 1 + drivers/platform/x86/intel/pmc/core.c | 64 ++++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 1 + 3 files changed, 66 insertions(+)
drivers/platform/x86/intel/pmc/Kconfig +1 -0
@@ -7,6 +7,7 @@ config INTEL_PMC_CORE tristate "Intel PMC Core driver" depends on PCI depends on ACPI + depends on INTEL_PMC_SSRAM_TELEMETRY || !INTEL_PMC_SSRAM_TELEMETRY depends on INTEL_PMT_TELEMETRY help The Intel Platform Controller Hub for Intel Core SoCs provides access
drivers/platform/x86/intel/pmc/core.c +64 -0
76 lines not on this page · raw message
drivers/platform/x86/intel/pmc/core.h +1 -0
@@ -591,6 +591,7 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value, int ignore);int pmc_core_resume_common (struct pmc_dev *pmcdev);int get_primary_reg_base (struct pmc *pmc); +extern int pmc_core_ssram_get_reg_base (struct pmc_dev *pmcdev);extern void pmc_core_get_low_power_modes (struct pmc_dev *pmcdev);extern void pmc_core_punit_pmt_init (struct pmc_dev *pmcdev,u32 guid);extern void pmc_core_set_device_d3 (unsigned int device);
Signature · 1 line
2.43.0
Xi Pardee
maintainerPATCH 4/7 platform/x86:intel/pmt: Get PMC from SSRAM for available platforms
In reply to Xi PardeeAdd support to discover and achieve PMC information from Intel SSRAM Telemetry driver for Meteor Lake, Lunar Lake and Arror Lake platforms.
--- drivers/platform/x86/intel/pmc/arl.c | 34 +++++++++++++++++++++++---- drivers/platform/x86/intel/pmc/core.h | 3 +++ drivers/platform/x86/intel/pmc/lnl.c | 26 ++++++++++++++++---- drivers/platform/x86/intel/pmc/mtl.c | 34 +++++++++++++++++++++++---- 4 files changed, 85 insertions(+), 12 deletions(-)
drivers/platform/x86/intel/pmc/arl.c +30 -4
@@ -640,6 +640,22 @@ const struct pmc_reg_map arl_pchs_reg_map = { .etr3_offset = ETR3_OFFSET, }; +static struct pmc_info arl_pmc_info_list[] = { + { + .devid =PMC_DEVID_MTL_IOEP , + .map = &mtl_ioep_reg_map, + }, + { + .devid =PMC_DEVID_ARL_SOCS , + .map = &arl_socs_reg_map, + }, + { + .devid =PMC_DEVID_ARL_PCHS , + .map = &arl_pchs_reg_map, + }, + {} +}; +#define ARL_NPU_PCI_DEV 0xad1d#define ARL_GNA_PCI_DEV 0xae4c/*
@@ -669,10 +685,20 @@ int arl_core_init(struct pmc_dev *pmcdev) pmcdev->suspend = cnl_suspend; pmcdev->resume = arl_resume; - pmc->map = &arl_socs_reg_map; - ret =get_primary_reg_base (pmc); -if (ret) -return ret; + pmcdev->regmap_list = arl_pmc_info_list; + ret =pmc_core_ssram_get_reg_base (pmcdev); + +/* Try again later after Intel PMC SSRAM Telemetry driver finishes probe */ +if (ret == -EAGAIN ) +return -EPROBE_DEFER ; + +/* If regbase not assigned, set map and discover using legacy method */ +if (ret) { + pmc->map = &arl_socs_reg_map; + ret =get_primary_reg_base (pmc); +if (ret) +return ret; + }pmc_core_get_low_power_modes (pmcdev);pmc_core_punit_pmt_init (pmcdev,ARL_PMT_DMU_GUID );
drivers/platform/x86/intel/pmc/core.h +3 -0
@@ -288,9 +288,12 @@ enum ppfear_regs {/* SSRAM PMC Device ID*/ /* ARL */ #define PMC_DEVID_ARL_SOCS 0xae7f +#define PMC_DEVID_ARL_PCHS 0x7f27/* MTL */ #define PMC_DEVID_MTL_SOCM 0x7e7f +#define PMC_DEVID_MTL_IOEP 0x7ecf +#define PMC_DEVID_MTL_IOEM 0x7ebf/* LNL */ #define PMC_DEVID_LNL_SOCM 0xa87f
drivers/platform/x86/intel/pmc/lnl.c +22 -4
@@ -13,6 +13,14 @@#include "core.h" +static struct pmc_info lnl_pmc_info_list[] = { + { + .devid =PMC_DEVID_LNL_SOCM , + .map = &lnl_socm_reg_map, + }, + {} +}; +const struct pmc_bit_map lnl_ltr_show_map[] = { {"SOUTHPORT_A" ,CNP_PMC_LTR_SPA }, {"SOUTHPORT_B" ,CNP_PMC_LTR_SPB },
@@ -561,10 +569,20 @@ int lnl_core_init(struct pmc_dev *pmcdev) pmcdev->suspend = cnl_suspend; pmcdev->resume = lnl_resume; - pmc->map = &lnl_socm_reg_map; - ret =get_primary_reg_base (pmc); -if (ret) -return ret; + pmcdev->regmap_list = lnl_pmc_info_list; + ret =pmc_core_ssram_get_reg_base (pmcdev); + +/* Try again later after Intel PMC SSRAM Telemetry driver finishes probe */ +if (ret == -EAGAIN ) +return -EPROBE_DEFER ; + +/* If regbase not assigned, set map and discover using legacy method */ +if (ret) { + pmc->map = &lnl_socm_reg_map; + ret =get_primary_reg_base (pmc); +if (ret) +return ret; + }pmc_core_get_low_power_modes (pmcdev);
drivers/platform/x86/intel/pmc/mtl.c +30 -4
@@ -936,6 +936,22 @@ const struct pmc_reg_map mtl_ioem_reg_map = { .lpm_residency_offset = MTL_LPM_RESIDENCY_OFFSET, }; +static struct pmc_info mtl_pmc_info_list[] = { + { + .devid =PMC_DEVID_MTL_SOCM , + .map = &mtl_socm_reg_map, + }, + { + .devid =PMC_DEVID_MTL_IOEP , + .map = &mtl_ioep_reg_map, + }, + { + .devid =PMC_DEVID_MTL_IOEM , + .map = &mtl_ioem_reg_map + }, + {} +}; +#define MTL_GNA_PCI_DEV 0x7e4c#define MTL_IPU_PCI_DEV 0x7d19#define MTL_VPU_PCI_DEV 0x7d1d
@@ -968,10 +984,20 @@ int mtl_core_init(struct pmc_dev *pmcdev) pmcdev->suspend = cnl_suspend; pmcdev->resume = mtl_resume; - pmc->map = &mtl_socm_reg_map; - ret =get_primary_reg_base (pmc); -if (ret) -return ret; + pmcdev->regmap_list = mtl_pmc_info_list; + ret =pmc_core_ssram_get_reg_base (pmcdev); + +/* Try again later after Intel PMC SSRAM Telemetry driver finishes probe */ +if (ret == -EAGAIN ) +return -EPROBE_DEFER ; + +/* If regbase not assigned, set map and discover using legacy method */ +if (ret) { + pmc->map = &mtl_socm_reg_map; + ret =get_primary_reg_base (pmc); +if (ret) +return ret; + }pmc_core_get_low_power_modes (pmcdev);pmc_core_punit_pmt_init (pmcdev,MTL_PMT_DMU_GUID );
Signature · 1 line
2.43.0
Xi Pardee
maintainerPATCH 5/7 platform/x86:intel/pmt: Create inline version for telemetry functions
In reply to Xi PardeeCreate inline versions of functions in Intel PMT Telemetry driver when config option is not set. Drivers that imports the INTEL_PMT_TELEMETRY namespace could compile when CONFIG_INTEL_PMT_TELEMETRY option is not set.
--- drivers/platform/x86/intel/pmt/telemetry.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmt/telemetry.h +18 -1
@@ -21,6 +21,7 @@ struct telem_endpoint_info {struct telem_header header; }; +#if IS_REACHABLE (CONFIG_INTEL_PMT_TELEMETRY )/** * pmt_telem_get_next_endpoint() - Get next device id for a telemetry endpoint * @start: starting devid to look from
@@ -123,4 +124,20 @@ int pmt_telem_read(struct telem_endpoint *ep, u32 id, u64 *data, u32 count);*/ int pmt_telem_read32 (struct telem_endpoint *ep,u32 id,u32 *data,u32 count); -#endif +#else /* !CONFIG_INTEL_PMT_TELEMETRY */ +static inline unsigned long pmt_telem_get_next_endpoint (unsigned long start) {return 0 ; } +static inline struct telem_endpoint *pmt_telem_register_endpoint (int devid) +{return ERR_PTR (-ENODEV ); } +static inline void pmt_telem_unregister_endpoint (struct telem_endpoint *ep) {} +static inline int pmt_telem_get_endpoint_info (int devid,struct telem_endpoint_info *info) +{return -ENODEV ; } +static inline struct telem_endpoint *pmt_telem_find_and_register_endpoint (struct pci_dev *pcidev, +u32 guid,u16 pos) +{return ERR_PTR (-ENODEV ); } +static inline int pmt_telem_read (struct telem_endpoint *ep,u32 id,u64 *data,u32 count) +{return -ENODEV ; } +static inline int pmt_telem_read32 (struct telem_endpoint *ep,u32 id,u32 *data,u32 count) +{return -ENODEV ; } +#endif /* CONFIG_INTEL_PMT_TELEMETRY */ + +#endif /* _TELEMETRY_H */
Signature · 1 line
2.43.0
Xi Pardee
maintainerPATCH 6/7 platform/x86:intel/pmc: Add support to Retrieve LPM information
In reply to Xi PardeeOn supported platforms, the low power mode (LPM) requirements for entering each idle substate are described in Platform Monitoring Technology (PMT) telemetry entries. Add support to find and read the requirements from the telemetry entries.
--- drivers/platform/x86/intel/pmc/Kconfig | 2 +- drivers/platform/x86/intel/pmc/core.c | 146 +++++++++++++++++++++++++ drivers/platform/x86/intel/pmc/core.h | 6 + 3 files changed, 153 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/Kconfig +1 -1
@@ -8,7 +8,7 @@ config INTEL_PMC_CORE depends on PCI depends on ACPI depends on INTEL_PMC_SSRAM_TELEMETRY || !INTEL_PMC_SSRAM_TELEMETRY - depends on INTEL_PMT_TELEMETRY + depends on INTEL_PMT_TELEMETRY || !INTEL_PMT_TELEMETRY help The Intel Platform Controller Hub for Intel Core SoCs provides access to Power Management Controller registers via various interfaces. This
drivers/platform/x86/intel/pmc/core.c +146 -0
152 lines not on this page · raw message
drivers/platform/x86/intel/pmc/core.h +6 -0
@@ -24,6 +24,11 @@ struct telem_endpoint;#define MAX_NUM_PMC 3#define S0IX_BLK_SIZE 4 +/* PCH query */ +#define LPM_HEADER_OFFSET 1 +#define LPM_REG_COUNT 28 +#define LPM_MODE_OFFSET 1 +/* Sunrise Point Power Management Controller PCI Device ID */ #define SPT_PMC_PCI_DEVICE_ID 0x9d21#define SPT_PMC_BASE_ADDR_OFFSET 0x48
@@ -590,6 +595,7 @@ extern const struct pmc_bit_map *arl_pchs_lpm_maps[];extern const struct pmc_reg_map arl_pchs_reg_map;extern void pmc_core_get_tgl_lpm_reqs (struct platform_device *pdev); +extern int pmc_core_get_lpm_reqs (struct pmc_dev *pmcdev,int func);int pmc_core_send_ltr_ignore (struct pmc_dev *pmcdev,u32 value,int ignore);int pmc_core_resume_common (struct pmc_dev *pmcdev);
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 6/7] platform/x86:intel/pmc: Add support to Retrieve LPM information
kernel test robot noticed the following build errors:
Hi Xi,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.11-rc3 next-20240816]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Xi-Pardee/platform-x86-intel-pmc-Remove-SSRAM-support-from-PMC-Core/20240810-114100 base: linus/master patch link: https://lore.kernel.org/r/20240809204648.1124545-7-xi.pardee%40linux.intel.com patch subject: [PATCH 6/7] platform/x86:intel/pmc: Add support to Retrieve LPM information config: x86_64-randconfig-104-20240817 (https://download.01.org/0day-ci/archive/20240818/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240818/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/usb/serial/ch341.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/usb/serial/usb_debug.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_powersave.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/fsi/fsi-master-gpio.o
>> ERROR: modpost: "pmc_ssram_telemetry_get_pmc_info" [drivers/platform/x86/intel/pmc/intel_pmc_core.ko] undefined!
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for FB_IOMEM_HELPERS
Depends on [n]: HAS_IOMEM [=y] && FB_CORE [=n]
Selected by [m]:
- DRM_XE_DISPLAY [=y] && HAS_IOMEM [=y] && DRM [=m] && DRM_XE [=m] && DRM_XE [=m]=m [=m]
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Xi Pardee
maintainerPATCH 7/7 platform/x86:intel/pmc: Get LPM information for available platforms
In reply to Xi PardeeAdd support to find and read the requirements from the telemetry entries for Meteor Lake, Lunar Lake and Arror Lake platforms.
--- drivers/platform/x86/intel/pmc/arl.c | 16 ++++++++++++++-- drivers/platform/x86/intel/pmc/lnl.c | 10 ++++++++-- drivers/platform/x86/intel/pmc/mtl.c | 17 +++++++++++++++-- 3 files changed, 37 insertions(+), 6 deletions(-)
drivers/platform/x86/intel/pmc/arl.c +14 -2
@@ -11,6 +11,13 @@#include <linux/pci.h> #include "core.h" +/* PMC SSRAM PMT Telemetry GUID */ +#define IOEP_LPM_REQ_GUID 0x5077612 +#define SOCS_LPM_REQ_GUID 0x8478657 +#define PCHS_LPM_REQ_GUID 0x9684572 + +static const u8 ARL_LPM_REG_INDEX [] = {0 ,4 ,5 ,6 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,20 }; +const struct pmc_bit_map arl_socs_ltr_show_map[] = { {"SOUTHPORT_A" ,CNP_PMC_LTR_SPA }, {"SOUTHPORT_B" ,CNP_PMC_LTR_SPB },
@@ -269,6 +276,7 @@ const struct pmc_reg_map arl_socs_reg_map = { .lpm_sts_latch_en_offset = MTL_LPM_STATUS_LATCH_EN_OFFSET, .lpm_live_status_offset = MTL_LPM_LIVE_STATUS_OFFSET, .lpm_num_maps = ADL_LPM_NUM_MAPS, + .lpm_reg_index = ARL_LPM_REG_INDEX, .etr3_offset = ETR3_OFFSET, .pson_residency_offset = TGL_PSON_RESIDENCY_OFFSET, .pson_residency_counter_step = TGL_PSON_RES_COUNTER_STEP,
@@ -637,19 +645,23 @@ const struct pmc_reg_map arl_pchs_reg_map = { .lpm_sts_latch_en_offset = MTL_LPM_STATUS_LATCH_EN_OFFSET, .lpm_live_status_offset = MTL_LPM_LIVE_STATUS_OFFSET, .lpm_num_maps = ADL_LPM_NUM_MAPS, + .lpm_reg_index = ARL_LPM_REG_INDEX, .etr3_offset = ETR3_OFFSET, };static struct pmc_info arl_pmc_info_list[] = { { + .guid =IOEP_LPM_REQ_GUID , .devid =PMC_DEVID_MTL_IOEP , .map = &mtl_ioep_reg_map, }, { + .guid =SOCS_LPM_REQ_GUID , .devid =PMC_DEVID_ARL_SOCS , .map = &arl_socs_reg_map, }, { + .guid =PCHS_LPM_REQ_GUID , .devid =PMC_DEVID_ARL_PCHS , .map = &arl_pchs_reg_map, },
@@ -679,7 +691,7 @@ static int arl_resume(struct pmc_dev *pmcdev)int arl_core_init (struct pmc_dev *pmcdev) {struct pmc *pmc = pmcdev->pmcs[PMC_IDX_SOC ]; -int ret; +int ret, func =0 ;arl_d3_fixup (); pmcdev->suspend = cnl_suspend;
@@ -703,5 +715,5 @@ int arl_core_init(struct pmc_dev *pmcdev)pmc_core_get_low_power_modes (pmcdev);pmc_core_punit_pmt_init (pmcdev,ARL_PMT_DMU_GUID ); -return 0 ; +return pmc_core_get_lpm_reqs (pmcdev, func); }
drivers/platform/x86/intel/pmc/lnl.c +8 -2
@@ -13,8 +13,13 @@#include "core.h" +#define SOCM_LPM_REQ_GUID 0x15099748 + +static const u8 LNL_LPM_REG_INDEX [] = {0 ,4 ,5 ,6 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,20 }; +static struct pmc_info lnl_pmc_info_list[] = { { + .guid =SOCM_LPM_REQ_GUID , .devid =PMC_DEVID_LNL_SOCM , .map = &lnl_socm_reg_map, },
@@ -536,6 +541,7 @@ const struct pmc_reg_map lnl_socm_reg_map = { .lpm_live_status_offset = MTL_LPM_LIVE_STATUS_OFFSET, .s0ix_blocker_maps = lnl_blk_maps, .s0ix_blocker_offset = LNL_S0IX_BLOCKER_OFFSET, + .lpm_reg_index = LNL_LPM_REG_INDEX, };#define LNL_NPU_PCI_DEV 0x643e
@@ -561,7 +567,7 @@ static int lnl_resume(struct pmc_dev *pmcdev)int lnl_core_init (struct pmc_dev *pmcdev) { -int ret; +int ret, func =2 ;struct pmc *pmc = pmcdev->pmcs[PMC_IDX_SOC ];lnl_d3_fixup ();
@@ -586,5 +592,5 @@ int lnl_core_init(struct pmc_dev *pmcdev)pmc_core_get_low_power_modes (pmcdev); -return 0 ; +return pmc_core_get_lpm_reqs (pmcdev, func); }
drivers/platform/x86/intel/pmc/mtl.c +15 -2
@@ -11,6 +11,13 @@#include <linux/pci.h> #include "core.h" +/* PMC SSRAM PMT Telemetry GUIDS */ +#define SOCP_LPM_REQ_GUID 0x2625030 +#define IOEM_LPM_REQ_GUID 0x4357464 +#define IOEP_LPM_REQ_GUID 0x5077612 + +static const u8 MTL_LPM_REG_INDEX [] = {0 ,4 ,5 ,6 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,20 }; +/* * Die Mapping to Product. * Product SOCDie IOEDie PCHDie
@@ -465,6 +472,7 @@ const struct pmc_reg_map mtl_socm_reg_map = { .lpm_sts = mtl_socm_lpm_maps, .lpm_status_offset = MTL_LPM_STATUS_OFFSET, .lpm_live_status_offset = MTL_LPM_LIVE_STATUS_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, };const struct pmc_bit_map mtl_ioep_pfear_map[] = {
@@ -788,6 +796,7 @@ const struct pmc_reg_map mtl_ioep_reg_map = { .lpm_priority_offset = MTL_LPM_PRI_OFFSET, .lpm_en_offset = MTL_LPM_EN_OFFSET, .lpm_sts_latch_en_offset = MTL_LPM_STATUS_LATCH_EN_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, };const struct pmc_bit_map mtl_ioem_pfear_map[] = {
@@ -934,18 +943,22 @@ const struct pmc_reg_map mtl_ioem_reg_map = { .lpm_en_offset = MTL_LPM_EN_OFFSET, .lpm_res_counter_step_x2 = TGL_PMC_LPM_RES_COUNTER_STEP_X2, .lpm_residency_offset = MTL_LPM_RESIDENCY_OFFSET, + .lpm_reg_index = MTL_LPM_REG_INDEX, };static struct pmc_info mtl_pmc_info_list[] = { { + .guid =SOCP_LPM_REQ_GUID , .devid =PMC_DEVID_MTL_SOCM , .map = &mtl_socm_reg_map, }, { + .guid =IOEP_LPM_REQ_GUID , .devid =PMC_DEVID_MTL_IOEP , .map = &mtl_ioep_reg_map, }, { + .guid =IOEM_LPM_REQ_GUID , .devid =PMC_DEVID_MTL_IOEM , .map = &mtl_ioem_reg_map },
@@ -977,7 +990,7 @@ static int mtl_resume(struct pmc_dev *pmcdev)int mtl_core_init (struct pmc_dev *pmcdev) {struct pmc *pmc = pmcdev->pmcs[PMC_IDX_SOC ]; -int ret; +int ret, func =2 ;mtl_d3_fixup ();
@@ -1002,5 +1015,5 @@ int mtl_core_init(struct pmc_dev *pmcdev)pmc_core_get_low_power_modes (pmcdev);pmc_core_punit_pmt_init (pmcdev,MTL_PMT_DMU_GUID ); -return 0 ; +return pmc_core_get_lpm_reqs (pmcdev, func); }
Signature · 1 line
2.43.0
Ilpo Järvinen
maintainerQuoted 19 lines · Xi Pardee
This patch series removes the SSRAM support from Intel PMC Core driver and creates a separate PCI driver for SSRAM device. The new Intel PMC SSRAM driver provides the following functionalities:
1. Search and store the PMC information in a structure, including PWRMBASE address and devid for each available PMC. Then Intel PMC Core driver achieves the PMC information using the API provided by the new driver.
2. Search and register Intel Platform Monitoring Techology telemetry regions so they would by available for read through sysfs and Intel PMT API. Intel PMC Core driver can achieve Low Power Mode requirement information from a telemetry region registered by the new driver. The above functionalities was previously handled by Intel PMC Core driver. Intel PMC Core driver returns -EPROBE_DEFER when trying to read data from a telem region that is not available yet. This setup may result in an infinite loop of .probe() calls as Intel PMC Core driver creates child devices. Creating a separate PCI driver avoids the infinite loop possibility.
Quoted 8 lines
Xi Pardee (7):
platform/x86:intel/pmc: Remove SSRAM support from PMC Core platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver platform/x86:intel/pmc: Add support to get PMC information from SSRAM platform/x86:intel/pmt: Get PMC from SSRAM for available platforms platform/x86:intel/pmt: Create inline version for telemetry functions platform/x86:intel/pmc: Add support to Retrieve LPM information platform/x86:intel/pmc: Get LPM information for available platforms
Hi,
I don't see why the removal first, then re-add approach would be justified here. You're basically adding the same code back later in many cases with only very minimal changes, and some changes are entirely pointless such as pmc_idx -> pmc_index parameter rename. This is just a big pain to review.
I'd suggest you move functions in first patch into core.c. Try to avoid logic/code changes other than making making the necessary functions non-static and adding the prototypes for them into a header (temporarily).
Then rename the ssram file to its new name in the second change.
Then do the rework on top of that (and make things back static again).
Try to split the rework into sensible chunks, anything that can be taken away from the main rework change is less lines to review in that patch. If you e.g. want to do pcidev -> pdev renames, put them into own separate change (and do it consistently then, not just for some of the cases like currently :-/).
The move patches are nearly trivial to review and take large chunk of diff away from the actual rework itself which doesn't seem that complicated to review once the 1:1 move bits and trivial rename churn is eliminated from the diff.
Quoted 17 lines
drivers/platform/x86/intel/pmc/Kconfig | 13 +- drivers/platform/x86/intel/pmc/Makefile | 8 +- drivers/platform/x86/intel/pmc/arl.c | 36 +- drivers/platform/x86/intel/pmc/core.c | 216 +++++++++++- drivers/platform/x86/intel/pmc/core.h | 25 +- drivers/platform/x86/intel/pmc/core_ssram.c | 326 ------------------ drivers/platform/x86/intel/pmc/lnl.c | 36 +- drivers/platform/x86/intel/pmc/mtl.c | 34 +- .../platform/x86/intel/pmc/ssram_telemetry.c | 184 ++++++++++ .../platform/x86/intel/pmc/ssram_telemetry.h | 45 +++ drivers/platform/x86/intel/pmt/telemetry.h | 19 +- 11 files changed, 550 insertions(+), 392 deletions(-) delete mode 100644 drivers/platform/x86/intel/pmc/core_ssram.c create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.c create mode 100644 drivers/platform/x86/intel/pmc/ssram_telemetry.h
Signature · 1 line
i.
Xi Pardee
maintainerQuoted 50 lines · Ilpo Järvinen
Quoted 19 lines · Xi Pardee
This patch series removes the SSRAM support from Intel PMC Core driver and creates a separate PCI driver for SSRAM device. The new Intel PMC SSRAM driver provides the following functionalities:
1. Search and store the PMC information in a structure, including PWRMBASE address and devid for each available PMC. Then Intel PMC Core driver achieves the PMC information using the API provided by the new driver.
2. Search and register Intel Platform Monitoring Techology telemetry regions so they would by available for read through sysfs and Intel PMT API. Intel PMC Core driver can achieve Low Power Mode requirement information from a telemetry region registered by the new driver. The above functionalities was previously handled by Intel PMC Core driver. Intel PMC Core driver returns -EPROBE_DEFER when trying to read data from a telem region that is not available yet. This setup may result in an infinite loop of .probe() calls as Intel PMC Core driver creates child devices. Creating a separate PCI driver avoids the infinite loop possibility.
Quoted 8 lines
Xi Pardee (7):
platform/x86:intel/pmc: Remove SSRAM support from PMC Core platform/x86:intel/pmc: Create Intel PMC SSRAM Telemetry driver platform/x86:intel/pmc: Add support to get PMC information from SSRAM platform/x86:intel/pmt: Get PMC from SSRAM for available platforms platform/x86:intel/pmt: Create inline version for telemetry functions platform/x86:intel/pmc: Add support to Retrieve LPM information platform/x86:intel/pmc: Get LPM information for available platformsHi,
I don't see why the removal first, then re-add approach would be justified here. You're basically adding the same code back later in many cases with only very minimal changes, and some changes are entirely pointless such as
pmc_idx->pmc_indexparameter rename. This is just a big pain to review.I'd suggest you move functions in first patch into
core.c. Try to avoid logic/code changes other than making making the necessary functions non-static and adding the prototypes for them into a header (temporarily).Then rename the ssram file to its new name in the second change.
Then do the rework on top of that (and make things back static again).
Try to split the rework into sensible chunks, anything that can be taken away from the main rework change is less lines to review in that patch. If you e.g. want to do pcidev -> pdev renames, put them into own separate change (and do it consistently then, not just for some of the cases like currently :-/).
Quoted 4 lines
The move patches are nearly trivial to review and take large chunk of diff away from the actual rework itself which doesn't seem that complicated to review once the 1:1 move bits and trivial rename churn is eliminated from the diff.
Hi,
Thanks for reviewing the patches. I will rearrange the code in next version.
Xi
Quoted 17 lines
Quoted 17 lines
drivers/platform/x86/intel/pmc/Kconfig | 13 +- drivers/platform/x86/intel/pmc/Makefile | 8 +- drivers/platform/x86/intel/pmc/arl.c | 36 +- drivers/platform/x86/intel/pmc/core.c | 216 +++++++++++- drivers/platform/x86/intel/pmc/core.h | 25 +- drivers/platform/x86/intel/pmc/core_ssram.c | 326 ------------------ drivers/platform/x86/intel/pmc/lnl.c | 36 +- drivers/platform/x86/intel/pmc/mtl.c | 34 +- .../platform/x86/intel/pmc/ssram_telemetry.c | 184 ++++++++++ .../platform/x86/intel/pmc/ssram_telemetry.h | 45 +++ drivers/platform/x86/intel/pmt/telemetry.h | 19 +- 11 files changed, 550 insertions(+), 392 deletions(-)delete mode 100644
drivers/platform/x86/intel/pmc/core_ssram.ccreate mode 100644drivers/platform/x86/intel/pmc/ssram_telemetry.ccreate mode 100644drivers/platform/x86/intel/pmc/ssram_telemetry.h