Skip to contentSkip to conversation

Add TPMI support

PATCH In review Srinivas Pandruvada 2 participants 14 messages Feb 2, 2023 – Feb 10, 2023

Subsystems (3)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

cover Add TPMI support

The TPMI (Topology Aware Register and PM Capsule Interface) provides a flexible, extendable and PCIe enumerable MMIO interface for PM features.

For example Intel Speed Select Technology (Intel SST) can replace all mailbox commands with direct MMIO access. This reduces latency for SST commands and also defines an architectural interface which will persist for several next generations.

Also Intel RAPL (Running Average Power Limit) provides a MMIO interface using TPMI. This has advantage over traditional MSR (Model Specific Register) interface, where a thread needs to be scheduled on the target CPU to read or write. Also the RAPL features vary between CPU models, and hence lot of model specific code. Here TPMI provides an architectural interface by providing hierarchical tables and fields, which will not need any model specific implementation.

Same value is for Intel Uncore frequency where MSR interface can't be used because of multiple domains.

The TPMI interface uses a PCI VSEC structure to expose the location of MMIO region, which is handled by Intel VSEC driver. Intel VSEC driver is already present in upstream kernel.

This series contains the base driver, which parses TPMI MMIO region and creates device nodes for supported features. The current set of PM feature support includes, Intel Speed Select, RAPL, Uncore frequency scaling.

The first there patches updates Intel VSEC driver to add TPMI VSEC ID and enhance to reuse the code.
The next three patches adds TPMI base driver support.
The last patch adds MAINTAINERS entry.

The TPMI documentation can be downloaded from:
https://github.com/intel/tpmi_power_management

This series cleanly applies on 6.2-rc1.

Srinivas Pandruvada (7):
platform/x86/intel/vsec: Add TPMI ID platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() platform/x86/intel/vsec: Support private data platform/x86/intel: Intel TPMI enumeration driver platform/x86/intel/tpmi: Process CPU package mapping platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature
drivers
MAINTAINERS: Add entry for TPMI driver

 MAINTAINERS                         |   6 +
 drivers/platform/x86/intel/Kconfig  |  13 +
 drivers/platform/x86/intel/Makefile |   4 +
 drivers/platform/x86/intel/tpmi.c   | 415 ++++++++++++++++++++++++++++
 drivers/platform/x86/intel/vsec.c   |  21 +-
 drivers/platform/x86/intel/vsec.h   |   6 +
 include/linux/intel_tpmi.h          |  30 ++
 7 files changed, 490 insertions(+), 5 deletions(-)
 create mode 100644 drivers/platform/x86/intel/tpmi.c
 create mode 100644 include/linux/intel_tpmi.h
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/7 platform/x86/intel/vsec: Add TPMI ID

Add TPMI (Topology Aware Register and PM Capsule Interface) VSEC ID to create an aux device. This will allow TPMI driver to enumerate on this aux device.

---
 drivers/platform/x86/intel/vsec.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/intel/vsec.c +5 -0
index bb81b8b1f7e9..a82b2a5ed99d 100644
@@ -64,6 +64,7 @@ enum intel_vsec_id {
 	VSEC_ID_WATCHER		= 3,
 	VSEC_ID_CRASHLOG	= 4,
 	VSEC_ID_SDSI		= 65,
+	VSEC_ID_TPMI		= 66,
 };
 
 static enum intel_vsec_id intel_vsec_allow_list[] = {
@@ -71,6 +72,7 @@ static enum intel_vsec_id intel_vsec_allow_list[] = {
 	VSEC_ID_WATCHER,
 	VSEC_ID_CRASHLOG,
 	VSEC_ID_SDSI,
+	VSEC_ID_TPMI,
 };
 
 static const char *intel_vsec_name(enum intel_vsec_id id)
@@ -88,6 +90,9 @@ static const char *intel_vsec_name(enum intel_vsec_id id)
 	case VSEC_ID_SDSI:
 		return "sdsi";
 
+	case VSEC_ID_TPMI:
+		return "tpmi";
+
 	default:
 		return NULL;
 	}
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/7 platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux()

In reply to Srinivas Pandruvada

Remove static for intel_vsec_add_aux() and export this interface so that it can be used by other vsec related modules.

This driver creates aux devices by parsing PCI-VSEC, which allows individual drivers to load on those devices. Those driver may further create more devices on aux bus by parsing the PCI MMIO region.

For example, TPMI (Topology Aware Register and PM Capsule Interface) creates device nodes for power management features by parsing MMIO region.

When TPMI driver creates devices, it can reuse existing function intel_vsec_add_aux() to create aux devices with TPMI device as the parent.

---
 drivers/platform/x86/intel/vsec.c | 16 +++++++++++-----
 drivers/platform/x86/intel/vsec.h |  4 ++++
 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/platform/x86/intel/vsec.c +11 -5
index a82b2a5ed99d..b936fc5776d7 100644
@@ -138,8 +138,9 @@ static void intel_vsec_dev_release(struct device *dev)
 	kfree(intel_vsec_dev);
 }
 
-static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *intel_vsec_dev,
-			      const char *name)
+int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
+		       struct intel_vsec_device *intel_vsec_dev,
+		       const char *name)
 {
 	struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev;
 	int ret, id;
@@ -150,9 +151,12 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
 		return ret;
 	}
 
+	if (!parent)
+		parent = &pdev->dev;
+
 	auxdev->id = ret;
 	auxdev->name = name;
-	auxdev->dev.parent = &pdev->dev;
+	auxdev->dev.parent = parent;
 	auxdev->dev.release = intel_vsec_dev_release;
 
 	ret = auxiliary_device_init(auxdev);
@@ -169,7 +173,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
 		return ret;
 	}
 
-	ret = devm_add_action_or_reset(&pdev->dev, intel_vsec_remove_aux,
+	ret = devm_add_action_or_reset(parent, intel_vsec_remove_aux,
 				       auxdev);
 	if (ret < 0)
 		return ret;
@@ -182,6 +186,7 @@ static int intel_vsec_add_aux(struct pci_dev *pdev, struct intel_vsec_device *in
 
 	return 0;
 }
+EXPORT_SYMBOL_NS_GPL(intel_vsec_add_aux, INTEL_VSEC);
 
 static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *header,
 			      struct intel_vsec_platform_info *info)
@@ -239,7 +244,8 @@ static int intel_vsec_add_dev(struct pci_dev *pdev, struct intel_vsec_header *he
 	else
 		intel_vsec_dev->ida = &intel_vsec_ida;
 
-	return intel_vsec_add_aux(pdev, intel_vsec_dev, intel_vsec_name(header->id));
+	return intel_vsec_add_aux(pdev, NULL, intel_vsec_dev,
+				  intel_vsec_name(header->id));
 }
 
 static bool intel_vsec_walk_header(struct pci_dev *pdev,
drivers/platform/x86/intel/vsec.h +4 -0
index 3deeb05cf394..d02c340fd458 100644
@@ -40,6 +40,10 @@ struct intel_vsec_device {
 	int num_resources;
 };
 
+int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
+		       struct intel_vsec_device *intel_vsec_dev,
+		       const char *name);
+
 static inline struct intel_vsec_device *dev_to_ivdev(struct device *dev)
 {
 	return container_of(dev, struct intel_vsec_device, auxdev.dev);
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 3/7 platform/x86/intel/vsec: Support private data

In reply to Srinivas Pandruvada

Add fields to struct intel_vsec_device, so that core module (which creates aux bus devices) can pass private data to the client drivers.

For example there is one vsec device instance per CPU package. On a multi package system, this private data can be used to pass the package ID. This package id can be used by client drivers to change power settings for a specific CPU package by targeting MMIO space of the correct PCI device.

---
 drivers/platform/x86/intel/vsec.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/platform/x86/intel/vsec.h +2 -0
index d02c340fd458..ae8fe92c5595 100644
@@ -38,6 +38,8 @@ struct intel_vsec_device {
 	struct ida *ida;
 	struct intel_vsec_platform_info *info;
 	int num_resources;
+	void *priv_data;
+	size_t priv_data_size;
 };
 
 int intel_vsec_add_aux(struct pci_dev *pdev, struct device *parent,
Signature · 1 line
2.31.1
author maintainer
#4 lore raw

PATCH 4/7 platform/x86/intel: Intel TPMI enumeration driver

In reply to Srinivas Pandruvada

The TPMI (Topology Aware Register and PM Capsule Interface) provides a flexible, extendable and PCIe enumerable MMIO interface for PM features.

For example Intel RAPL (Running Average Power Limit) provides a MMIO interface using TPMI. This has advantage over traditional MSR (Model Specific Register) interface, where a thread needs to be scheduled on the target CPU to read or write. Also the RAPL features vary between CPU models, and hence lot of model specific code. Here TPMI provides an architectural interface by providing hierarchical tables and fields, which will not need any model specific implementation.

The TPMI interface uses a PCI VSEC structure to expose the location of MMIO region.

This VSEC structure is present in the PCI configuration space of the Intel Out-of-Band (OOB) device, which is handled by the Intel VSEC driver. The Intel VSEC driver parses VSEC structures present in the PCI configuration space of the given device and creates an auxiliary device object for each of them. In particular, it creates an auxiliary device object representing TPMI that can be bound by an auxiliary driver.

Introduce a TPMI driver that will bind to the TPMI auxiliary device object created by the Intel VSEC driver.

The TPMI specification defines a PFS (PM Feature Structure) table. This table is present in the TPMI MMIO region. The starting address of PFS is derived from the tBIR (Bar Indicator Register) and "Address" field from the VSEC header.

Each TPMI PM feature has one entry in the PFS with a unique TPMI ID and its access details. The TPMI driver creates device nodes for the supported PM features.

The names of the devices created by the TPMI driver start with the "intel_vsec.tpmi-" prefix which is followed by a specific name of the given PM feature (for example, "intel_vsec.tpmi-rapl.0").

The device nodes are create by using interface "intel_vsec_add_aux()" provided by the Intel VSEC driver.

---
 drivers/platform/x86/intel/Kconfig  |  13 ++
 drivers/platform/x86/intel/Makefile |   4 +
 drivers/platform/x86/intel/tpmi.c   | 321 ++++++++++++++++++++++++++++
 3 files changed, 338 insertions(+)
 create mode 100644 drivers/platform/x86/intel/tpmi.c
drivers/platform/x86/intel/Kconfig +13 -0
index d5a33473e838..bbbd9e54e9ee 100644
@@ -182,6 +182,19 @@ config INTEL_SMARTCONNECT
 	  This driver checks to determine whether the device has Intel Smart
 	  Connect enabled, and if so disables it.
 
+config INTEL_TPMI
+	tristate "Intel Topology Aware Register and PM Capsule Interface (TPMI)"
+	depends on INTEL_VSEC
+	depends on X86_64
+	help
+	  The Intel Topology Aware Register and PM Capsule Interface (TPMI),
+	  provides enumerable MMIO interface for power management features.
+	  This driver creates devices, so that other PM feature driver can
+	  be loaded for PM specific feature operation.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called intel_vsec_tpmi.
+
 config INTEL_TURBO_MAX_3
 	bool "Intel Turbo Boost Max Technology 3.0 enumeration driver"
 	depends on X86_64 && SCHED_MC_PRIO
drivers/platform/x86/intel/Makefile +4 -0
index 717933dd0cfd..411df4040427 100644
@@ -47,6 +47,10 @@ obj-$(CONFIG_INTEL_MRFLD_PWRBTN)	+= intel_mrfld_pwrbtn.o
 intel_punit_ipc-y			:= punit_ipc.o
 obj-$(CONFIG_INTEL_PUNIT_IPC)		+= intel_punit_ipc.o
 
+# TPMI drivers
+intel_vsec_tpmi-y			:= tpmi.o
+obj-$(CONFIG_INTEL_TPMI)		+= intel_vsec_tpmi.o
+
 # Intel Uncore drivers
 intel-rst-y				:= rst.o
 obj-$(CONFIG_INTEL_RST)			+= intel-rst.o
drivers/platform/x86/intel/tpmi.c new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.31.1
author maintainer
#5 lore raw

PATCH 5/7 platform/x86/intel/tpmi: Process CPU package mapping

In reply to Srinivas Pandruvada

There is one Intel Out-of-Band (OOB) PCI device per CPU package. Since TPMI feature is exposed via OOB PCI device, there will be multiple TPMI device instances on a multi CPU package system.

There are several PM features, which needs to associate APIC based CPU package ID information to a TPMI instance. For example if Intel Speed Select feature requires control of a CPU package, it needs to identify right TPMI device instance.

There is one special TPMI ID (ID = 0x81) in the PFS. The MMIO region of this TPMI ID points to a mapping table:
- PCI Bus ID
- PCI Device ID
- APIC based Package ID

This mapping information can be used by any PM feature driver which requires mapping from a CPU package to a TPMI device instance.

Unlike other TPMI features, device node is not created for this feature ID (0x81). Instead store the mapping information as platform data, which is part of the per PCI device TPMI instance (struct intel_tpmi_info). Later the TPMI feature drivers can get the mapping information using an interface "tpmi_get_platform_data()"

---
 drivers/platform/x86/intel/tpmi.c | 72 +++++++++++++++++++++++++++++++
 include/linux/intel_tpmi.h        | 28 ++++++++++++
 2 files changed, 100 insertions(+)
 create mode 100644 include/linux/intel_tpmi.h
drivers/platform/x86/intel/tpmi.c +72 -0
index 1b87b46ba8a9..e612da579b29 100644
@@ -47,6 +47,7 @@
  */
 
 #include <linux/auxiliary_bus.h>
+#include <linux/intel_tpmi.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -96,6 +97,7 @@ struct intel_tpmi_pm_feature {
  * @vsec_dev:		Pointer to intel_vsec_device structure for this TPMI device
  * @feature_count:	Number of TPMI of TPMI instances pointed by tpmi_features
  * @pfs_start:		Start of PFS offset for the TPMI instances in this device
+ * @plat_info:		Stores platform info which can be used by the client drivers
  *
  * Stores the information for all TPMI devices enumerated from a single PCI device.
  */
@@ -104,8 +106,30 @@ struct intel_tpmi_info {
 	struct intel_vsec_device *vsec_dev;
 	int feature_count;
 	u64 pfs_start;
+	struct intel_tpmi_plat_info plat_info;
 };
 
+/**
+ * struct tpmi_info_header - CPU package ID to PCI device mapping information
+ * @fn:		PCI function number
+ * @dev:	PCI device number
+ * @bus:	PCI bus number
+ * @pkg:	CPU Package id
+ * @reserved:	Reserved for future use
+ * @lock:	When set to 1 the register is locked and becomes read-only
+ *		until next reset. Not for use by the OS driver.
+ *
+ * The structure to read hardware provided mapping information.
+ */
+struct tpmi_info_header {
+	u64 fn:3;
+	u64 dev:5;
+	u64 bus:8;
+	u64 pkg:8;
+	u64 reserved:39;
+	u64 lock:1;
+} __packed;
+
 /*
  * List of supported TMPI IDs.
  * Some TMPI IDs are not used by Linux, so the numbers are not consecutive.
@@ -115,11 +139,20 @@ enum intel_tpmi_id {
 	TPMI_ID_PEM = 1, /* Power and Perf excursion Monitor */
 	TPMI_ID_UNCORE = 2, /* Uncore Frequency Scaling */
 	TPMI_ID_SST = 5, /* Speed Select Technology */
+	TPMI_INFO_ID = 0x81, /* Special ID for PCI BDF and Package ID information */
 };
 
 /* Used during auxbus device creation */
 static DEFINE_IDA(intel_vsec_tpmi_ida);
 
+struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev)
+{
+	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+
+	return vsec_dev->priv_data;
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_platform_data, INTEL_TPMI);
+
 static const char *intel_tpmi_name(enum intel_tpmi_id id)
 {
 	switch (id) {
@@ -177,6 +210,8 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
 	feature_vsec_dev->pcidev = vsec_dev->pcidev;
 	feature_vsec_dev->resource = res;
 	feature_vsec_dev->num_resources = pfs->pfs_header.num_entries;
+	feature_vsec_dev->priv_data = &tpmi_info->plat_info;
+	feature_vsec_dev->priv_data_size = sizeof(tpmi_info->plat_info);
 	feature_vsec_dev->ida = &intel_vsec_tpmi_ida;
 
 	/*
@@ -220,6 +255,31 @@ static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
 	return 0;
 }
 
+#define TPMI_INFO_BUS_INFO_OFFSET	0x08
+
+static int tpmi_process_info(struct intel_tpmi_info *tpmi_info,
+			     struct intel_tpmi_pm_feature *pfs)
+{
+	struct tpmi_info_header header;
+	void __iomem *info_mem;
+
+	info_mem = ioremap(pfs->vsec_offset + TPMI_INFO_BUS_INFO_OFFSET,
+			   pfs->pfs_header.entry_size * 4 - TPMI_INFO_BUS_INFO_OFFSET);
+	if (!info_mem)
+		return -ENOMEM;
+
+	memcpy_fromio(&header, info_mem, sizeof(header));
+
+	tpmi_info->plat_info.package_id = header.pkg;
+	tpmi_info->plat_info.bus_number = header.bus;
+	tpmi_info->plat_info.device_number = header.dev;
+	tpmi_info->plat_info.function_number = header.fn;
+
+	iounmap(info_mem);
+
+	return 0;
+}
+
 static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, int size)
 {
 	void __iomem *pfs_mem;
@@ -238,6 +298,7 @@ static int tpmi_fetch_pfs_header(struct intel_tpmi_pm_feature *pfs, u64 start, i
 static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
 {
 	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+	struct pci_dev *pci_dev = vsec_dev->pcidev;
 	struct intel_tpmi_info *tpmi_info;
 	u64 pfs_start = 0;
 	int i;
@@ -248,6 +309,7 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
 
 	tpmi_info->vsec_dev = vsec_dev;
 	tpmi_info->feature_count = vsec_dev->num_resources;
+	tpmi_info->plat_info.bus_number = pci_dev->bus->number;
 
 	tpmi_info->tpmi_features = devm_kcalloc(&auxdev->dev, vsec_dev->num_resources,
 						sizeof(*tpmi_info->tpmi_features),
@@ -282,6 +344,16 @@ static int intel_vsec_tpmi_init(struct auxiliary_device *auxdev)
 		pfs->pfs_header.cap_offset *= 1024;
 
 		pfs->vsec_offset = pfs_start + pfs->pfs_header.cap_offset;
+
+		/*
+		 * Process TPMI_INFO to get PCI device to CPU package ID.
+		 * Device nodes for TPMI features are not created in this
+		 * for loop. So, the mapping information will be available
+		 * when actual device nodes created outside this
+		 * loop via tpmi_create_devices().
+		 */
+		if (pfs->pfs_header.tpmi_id == TPMI_INFO_ID)
+			tpmi_process_info(tpmi_info, pfs);
 	}
 
 	tpmi_info->pfs_start = pfs_start;
include/linux/intel_tpmi.h new file +28 -0
new file mode 100644
index 000000000000..5b665320ecb4
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * intel_tpmi.h: Intel TPMI core external interface
+ */
+
+#ifndef _INTEL_TPMI_H_
+#define _INTEL_TPMI_H_
+
+/**
+ * struct intel_tpmi_plat_info - Platform information for a TPMI device instance
+ * @package_id:	CPU Package id
+ * @bus_number:	PCI bus number
+ * @device_number: PCI device number
+ * @function_number: PCI function number
+ *
+ * Structure to store platform data for a TPMI device instance. This
+ * struct is used to return data via tpmi_get_platform_data().
+ */
+struct intel_tpmi_plat_info {
+	u8 package_id;
+	u8 bus_number;
+	u8 device_number;
+	u8 function_number;
+};
+
+struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev);
+
+#endif
Signature · 1 line
2.31.1
author maintainer
#6 lore raw

PATCH 6/7 platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature drivers

In reply to Srinivas Pandruvada

Add interface to get resources and platform data. This will avoid code duplication. These interfaces includes:
- Get resource count
- Get resource at an index

---
 drivers/platform/x86/intel/tpmi.c | 22 ++++++++++++++++++++++
 include/linux/intel_tpmi.h        |  2 ++
 2 files changed, 24 insertions(+)
drivers/platform/x86/intel/tpmi.c +22 -0
index e612da579b29..c60733261c89 100644
@@ -153,6 +153,28 @@ struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *aux
 }
 EXPORT_SYMBOL_NS_GPL(tpmi_get_platform_data, INTEL_TPMI);
 
+int tpmi_get_resource_count(struct auxiliary_device *auxdev)
+{
+	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+
+	if (vsec_dev)
+		return vsec_dev->num_resources;
+
+	return 0;
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_count, INTEL_TPMI);
+
+struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index)
+{
+	struct intel_vsec_device *vsec_dev = auxdev_to_ivdev(auxdev);
+
+	if (vsec_dev && index < vsec_dev->num_resources)
+		return &vsec_dev->resource[index];
+
+	return NULL;
+}
+EXPORT_SYMBOL_NS_GPL(tpmi_get_resource_at_index, INTEL_TPMI);
+
 static const char *intel_tpmi_name(enum intel_tpmi_id id)
 {
 	switch (id) {
include/linux/intel_tpmi.h +2 -0
index 5b665320ecb4..f505788c05da 100644
@@ -24,5 +24,7 @@ struct intel_tpmi_plat_info {
 };
 
 struct intel_tpmi_plat_info *tpmi_get_platform_data(struct auxiliary_device *auxdev);
+struct resource *tpmi_get_resource_at_index(struct auxiliary_device *auxdev, int index);
+int tpmi_get_resource_count(struct auxiliary_device *auxdev);
 
 #endif
Signature · 1 line
2.31.1
author maintainer
#7 lore raw

PATCH 7/7 MAINTAINERS: Add entry for TPMI driver

In reply to Srinivas Pandruvada

Add entry for TPMI (Topology Aware Register and PM Capsule Interface) driver.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index f61eb221415b..6f3aaa7161d6 100644
@@ -10683,6 +10683,12 @@ S:	Maintained
 F:	arch/x86/include/asm/intel_telemetry.h
 F:	drivers/platform/x86/intel/telemetry/
 
+INTEL TPMI DRIVER
+M:	Srinivas Pandruvada <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/intel/tpmi.c
+
 INTEL UNCORE FREQUENCY CONTROL
 M:	Srinivas Pandruvada <[email protected]>
 L:	[email protected]
Signature · 1 line
2.31.1
#8 lore raw

Re: [PATCH 7/7] MAINTAINERS: Add entry for TPMI driver

Hi,

Quoted 13 lines · Srinivas Pandruvada

Add entry for TPMI (Topology Aware Register and PM Capsule Interface) driver.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +0 -0
index f61eb221415b..6f3aaa7161d6 100644

MAINTAINERS S: Maintained · line 10690

Quoted 8 lines
MAINTAINERS +5 -0
@@ -10683,6 +10683,12 @@ S:	Maintained
 F:	arch/x86/include/asm/intel_telemetry.h
 F:	drivers/platform/x86/intel/telemetry/
 
+INTEL TPMI DRIVER
+M:	Srinivas Pandruvada <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/intel/tpmi.c

Note this is missing:

F: include/linux/intel_tpmi.h

I have fixed this up while merging this.

Regards,

Hans

Quoted 4 lines
MAINTAINERS +1 -0
+
 INTEL UNCORE FREQUENCY CONTROL
 M:	Srinivas Pandruvada <[email protected]>
 L:	[email protected]
#9 lore raw
In reply to Srinivas Pandruvada

Hi,

Quoted 33 lines · Srinivas Pandruvada

The TPMI (Topology Aware Register and PM Capsule Interface) provides a flexible, extendable and PCIe enumerable MMIO interface for PM features.

For example Intel Speed Select Technology (Intel SST) can replace all mailbox commands with direct MMIO access. This reduces latency for SST commands and also defines an architectural interface which will persist for several next generations.

Also Intel RAPL (Running Average Power Limit) provides a MMIO interface using TPMI. This has advantage over traditional MSR (Model Specific Register) interface, where a thread needs to be scheduled on the target CPU to read or write. Also the RAPL features vary between CPU models, and hence lot of model specific code. Here TPMI provides an architectural interface by providing hierarchical tables and fields, which will not need any model specific implementation.

Same value is for Intel Uncore frequency where MSR interface can't be used because of multiple domains.

The TPMI interface uses a PCI VSEC structure to expose the location of MMIO region, which is handled by Intel VSEC driver. Intel VSEC driver is already present in upstream kernel.

This series contains the base driver, which parses TPMI MMIO region and creates device nodes for supported features. The current set of PM feature support includes, Intel Speed Select, RAPL, Uncore frequency scaling.

The first there patches updates Intel VSEC driver to add TPMI VSEC ID and enhance to reuse the code.
The next three patches adds TPMI base driver support.
The last patch adds MAINTAINERS entry.

Quoted 4 lines

The TPMI documentation can be downloaded from:
https://github.com/intel/tpmi_power_management

This series cleanly applies on 6.2-rc1.

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 21 lines

Srinivas Pandruvada (7):
platform/x86/intel/vsec: Add TPMI ID platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() platform/x86/intel/vsec: Support private data platform/x86/intel: Intel TPMI enumeration driver platform/x86/intel/tpmi: Process CPU package mapping platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature
drivers
MAINTAINERS: Add entry for TPMI driver

 MAINTAINERS                         |   6 +
 drivers/platform/x86/intel/Kconfig  |  13 +
 drivers/platform/x86/intel/Makefile |   4 +
 drivers/platform/x86/intel/tpmi.c   | 415 ++++++++++++++++++++++++++++
 drivers/platform/x86/intel/vsec.c   |  21 +-
 drivers/platform/x86/intel/vsec.h   |   6 +
 include/linux/intel_tpmi.h          |  30 ++
 7 files changed, 490 insertions(+), 5 deletions(-)
 create mode 100644 drivers/platform/x86/intel/tpmi.c
 create mode 100644 include/linux/intel_tpmi.h
#10 lore raw

Hi,

Quoted 11 lines · Hans de Goede

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

One thing which I did notice, which is a pre-existing problem is that the IDA accesses in drivers/platform/x86/intel/vsec.c are not protected by any locking.

This is likely ok for now because there is only 1 PCI device per type of ida and the enumeration of the vsec devices under the PCI device is done in a single loop, so all IDA accesses are single threaded atm.

But still IMHO it would be good to protect the IDA accesses (ida_alloc() / ida_free()) with a mutex to protect against any future races.

I think that a single global static mutex inside
drivers/platform/x86/intel/vsec.c to protect the
ida calls there should suffice for this.

Regards,

Hans

author maintainer
#11 lore raw

Hi Hans,

Quoted 25 lines · Hans de Goede

Hi,

Quoted 11 lines · Hans de Goede

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

One thing which I did notice, which is a pre-existing problem is that the IDA accesses in drivers/platform/x86/intel/vsec.c are not protected by any locking.

This is likely ok for now because there is only 1 PCI device per type of ida and the enumeration of the vsec devices under the PCI device is done in a single loop, so all IDA accesses are single threaded atm.

Quoted 7 lines

But still IMHO it would be good to protect the IDA accesses (ida_alloc() / ida_free()) with a mutex to protect against any future races.

I think that a single global static mutex inside
drivers/platform/x86/intel/vsec.c to protect the
ida calls there should suffice for this.

Let me look into this and get back.

Thanks,
Srinivas

Quoted 7 lines

Regards,

Hans

author maintainer
#12 lore raw
In reply to Hans de Goede

Hi Hans,

Quoted 5 lines · Hans de Goede

Hi,

On 2/2/23 02:07, Srinivas Pandruvada wrote:

[...]

Quoted 5 lines

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Thanks for the help here.

Quoted 7 lines

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

I guess this will appear in 6.3 merge window.

Can I post next set of patches (targeted for 6.4)?

Thanks,
Srinivas

Quoted 32 lines

Regards,

Hans

Quoted 23 lines

Srinivas Pandruvada (7):
  platform/x86/intel/vsec: Add TPMI ID platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() platform/x86/intel/vsec: Support private data platform/x86/intel: Intel TPMI enumeration driver platform/x86/intel/tpmi: Process CPU package mapping platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature
    drivers
  MAINTAINERS: Add entry for TPMI driver

 MAINTAINERS                         |   6 +
 drivers/platform/x86/intel/Kconfig  |  13 +
 drivers/platform/x86/intel/Makefile |   4 +
 drivers/platform/x86/intel/tpmi.c   | 415
++++++++++++++++++++++++++++
 drivers/platform/x86/intel/vsec.c   |  21 +-
 drivers/platform/x86/intel/vsec.h   |   6 +
 include/linux/intel_tpmi.h          |  30 ++

 7 files changed, 490 insertions(+), 5 deletions(-)

 create mode 100644 drivers/platform/x86/intel/tpmi.c create mode 100644 include/linux/intel_tpmi.h

#13 lore raw

Hi,

Quoted 8 lines · srinivas pandruvada

Hi Hans,

Quoted 5 lines · Hans de Goede

Hi,

On 2/2/23 02:07, Srinivas Pandruvada wrote:

Quoted 8 lines

[...]

Quoted 5 lines

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Thanks for the help here.

You're welcome.

Quoted 8 lines
Quoted 7 lines

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

I guess this will appear in 6.3 merge window.

Yes I plan to push my review-hans branch to for-next shortly.

Quoted 1 line

Can I post next set of patches (targeted for 6.4)?

Yes please, I'm not sure if I can review them next week, but that will also give other people a chance to take a look and comment so getting them out there would be good.

Regards,

Hans

Quoted 25 lines
Quoted 24 lines
Quoted 23 lines

Srinivas Pandruvada (7):
  platform/x86/intel/vsec: Add TPMI ID platform/x86/intel/vsec: Enhance and Export intel_vsec_add_aux() platform/x86/intel/vsec: Support private data platform/x86/intel: Intel TPMI enumeration driver platform/x86/intel/tpmi: Process CPU package mapping platform/x86/intel/tpmi: ADD tpmi external interface for tpmi feature
    drivers
  MAINTAINERS: Add entry for TPMI driver

 MAINTAINERS                         |   6 +
 drivers/platform/x86/intel/Kconfig  |  13 +
 drivers/platform/x86/intel/Makefile |   4 +
 drivers/platform/x86/intel/tpmi.c   | 415
++++++++++++++++++++++++++++
 drivers/platform/x86/intel/vsec.c   |  21 +-
 drivers/platform/x86/intel/vsec.h   |   6 +
 include/linux/intel_tpmi.h          |  30 ++

 7 files changed, 490 insertions(+), 5 deletions(-)

 create mode 100644 drivers/platform/x86/intel/tpmi.c create mode 100644 include/linux/intel_tpmi.h