Skip to contentSkip to conversation

TPMI feature major/minor version check

PATCH In review Srinivas Pandruvada 3 participants 8 messages Oct 3, 2023 – Oct 4, 2023

Subsystems (4)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

v2 cover TPMI feature major/minor version check

Changes for core and feature drivers to check major minor version.

v2
- commit description changes
- Log level change

Srinivas Pandruvada (3):
platform/x86/intel/tpmi: Add defines to get version information platform/x86: ISST: Ignore minor version change platform/x86/intel-uncore-freq: Process hardware version

 .../x86/intel/speed_select_if/isst_tpmi_core.c | 16 ++++++++++++----
 .../uncore-frequency/uncore-frequency-tpmi.c   | 18 ++++++++++++++----
 include/linux/intel_tpmi.h                     |  6 ++++++
 3 files changed, 32 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH v2 1/3 platform/x86/intel/tpmi: Add defines to get version information

Add defines to get major and minor version from a TPMI version field value. This will avoid code duplication to convert in every feature driver. Also add define for invalid version field.

---
v2:
No change

 include/linux/intel_tpmi.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/intel_tpmi.h +6 -0
index 04d937ad4dc4..ee07393445f9 100644
@@ -6,6 +6,12 @@
 #ifndef _INTEL_TPMI_H_
 #define _INTEL_TPMI_H_
 
+#include <linux/bitfield.h>
+
+#define TPMI_VERSION_INVALID	0xff
+#define TPMI_MINOR_VERSION(val)	FIELD_GET(GENMASK(4, 0), val)
+#define TPMI_MAJOR_VERSION(val)	FIELD_GET(GENMASK(7, 5), val)
+
 /**
  * struct intel_tpmi_plat_info - Platform information for a TPMI device instance
  * @package_id:	CPU Package id
Signature · 1 line
2.41.0
#2 lore raw

Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information

Quoted 3 lines · Srinivas Pandruvada

Add defines to get major and minor version from a TPMI version field value. This will avoid code duplication to convert in every feature driver. Also add define for invalid version field.

...

Quoted 1 line

+#define TPMI_VERSION_INVALID 0xff

I would make it clearer with (GENMASK(7, 5) | GENMASK(4, 0)) or even with specific masks defined and used in both cases:
#def

#define TPMI_MINVER_MASK GENMASK(4, 0)
#define TPMI_MAJVER_MASK GENMASK(7, 5)

#define TPMI_VERSION_INVALID (TPMI_MINVER_MASK | TPMI_MAJVER_MASK)

#define TPMI_MINOR_VERSION(val) FIELD_GET(TPMI_MINVER_MASK, val)
#define TPMI_MAJOR_VERSION(val) FIELD_GET(TPMI_MAJVER_MASK, val)

Quoted 2 lines
include/linux/intel_tpmi.h +2 -0
+#define TPMI_MINOR_VERSION(val)	FIELD_GET(GENMASK(4, 0), val)
+#define TPMI_MAJOR_VERSION(val)	FIELD_GET(GENMASK(7, 5), val)
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw

Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information

Quoted 16 lines · Andy Shevchenko
Quoted 3 lines · Srinivas Pandruvada

Add defines to get major and minor version from a TPMI version field value. This will avoid code duplication to convert in every feature driver. Also add define for invalid version field.

...

Quoted 1 line

+#define TPMI_VERSION_INVALID 0xff

I would make it clearer with (GENMASK(7, 5) | GENMASK(4, 0)) or even with specific masks defined and used in both cases:
#def

#define TPMI_MINVER_MASK GENMASK(4, 0)
#define TPMI_MAJVER_MASK GENMASK(7, 5)

Quoted 7 lines

#define TPMI_VERSION_INVALID (TPMI_MINVER_MASK | TPMI_MAJVER_MASK)

#define TPMI_MINOR_VERSION(val) FIELD_GET(TPMI_MINVER_MASK, val)
#define TPMI_MAJOR_VERSION(val) FIELD_GET(TPMI_MAJVER_MASK, val)

include/linux/intel_tpmi.h line 13

Quoted 2 lines
include/linux/intel_tpmi.h +2 -0
+#define TPMI_MINOR_VERSION(val)	FIELD_GET(GENMASK(4, 0), val)
+#define TPMI_MAJOR_VERSION(val)	FIELD_GET(GENMASK(7, 5), val)

In case somebody does, please do it on top of the existing changes as I already applied the series.

Signature · 1 line
 i.
author maintainer
#4 lore raw

Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information

In reply to Andy Shevchenko
Quoted 19 lines · Andy Shevchenko
Quoted 4 lines · Srinivas Pandruvada

Add defines to get major and minor version from a TPMI version field
value. This will avoid code duplication to convert in every feature driver. Also add define for invalid version field.

...

Quoted 1 line

+#define TPMI_VERSION_INVALID   0xff

I would make it clearer with (GENMASK(7, 5) | GENMASK(4, 0)) or even with specific masks defined and used in both cases:
#def

#define TPMI_MINVER_MASK        GENMASK(4, 0)
#define TPMI_MAJVER_MASK        GENMASK(7, 5)

#define TPMI_VERSION_INVALID    (TPMI_MINVER_MASK | TPMI_MAJVER_MASK)

Quoted 7 lines

#define TPMI_MINOR_VERSION(val) FIELD_GET(TPMI_MINVER_MASK, val) #define TPMI_MAJOR_VERSION(val) FIELD_GET(TPMI_MAJVER_MASK, val)

Quoted 4 lines

+#define TPMI_MINOR_VERSION(val)        FIELD_GET(GENMASK(4, 0), val)
+#define TPMI_MAJOR_VERSION(val)        FIELD_GET(GENMASK(7, 5), val)

OK. Will add another patch on top.

Thanks,
Srinivas

Quoted 1 line
author maintainer
#5 lore raw

PATCH v2 2/3 platform/x86: ISST: Ignore minor version change

In reply to Srinivas Pandruvada

The hardware definition of every TPMI feature contains a major and minor version. When there is a change in the MMIO offset or change in the definition of a field, hardware will change major version. For addition of new fields without modifying existing MMIO offsets or fields, only the minor version is changed.

Driver is developed to support SST functionality for a major and minor version. If the hardware changes major version, since offsets and definitions are changed, driver cannot continue to provide SST interface to users. Driver can still function with a minor version change as it will just miss the new functionality added by the hardware. The current implementation doesn't ignore any version change.

If there is mismatch with the minor version, continue with an information log message. If there is mismatch with the major version, log error and exit.

---
v2
- Commit description and header change as suggested by llpo
- Change log level for minor version mismatch

 .../x86/intel/speed_select_if/isst_tpmi_core.c   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +12 -4
index ac5c6a812592..0b6d2c864437 100644
@@ -30,7 +30,8 @@
 #include "isst_if_common.h"
 
 /* Supported SST hardware version by this driver */
-#define ISST_HEADER_VERSION		1
+#define ISST_MAJOR_VERSION	0
+#define ISST_MINOR_VERSION	1
 
 /*
  * Used to indicate if value read from MMIO needs to get multiplied
@@ -352,12 +353,19 @@ static int sst_main(struct auxiliary_device *auxdev, struct tpmi_per_power_domai
 	pd_info->sst_header.cp_offset *= 8;
 	pd_info->sst_header.pp_offset *= 8;
 
-	if (pd_info->sst_header.interface_version != ISST_HEADER_VERSION) {
-		dev_err(&auxdev->dev, "SST: Unsupported version:%x\n",
-			pd_info->sst_header.interface_version);
+	if (pd_info->sst_header.interface_version == TPMI_VERSION_INVALID)
+		return -ENODEV;
+
+	if (TPMI_MAJOR_VERSION(pd_info->sst_header.interface_version) != ISST_MAJOR_VERSION) {
+		dev_err(&auxdev->dev, "SST: Unsupported major version:%lx\n",
+			TPMI_MAJOR_VERSION(pd_info->sst_header.interface_version));
 		return -ENODEV;
 	}
 
+	if (TPMI_MINOR_VERSION(pd_info->sst_header.interface_version) != ISST_MINOR_VERSION)
+		dev_info(&auxdev->dev, "SST: Ignore: Unsupported minor version:%lx\n",
+			 TPMI_MINOR_VERSION(pd_info->sst_header.interface_version));
+
 	/* Read SST CP Header */
 	*((u64 *)&pd_info->cp_header) = readq(pd_info->sst_base + pd_info->sst_header.cp_offset);
 
Signature · 1 line
2.41.0
author maintainer
#6 lore raw

PATCH v2 3/3 platform/x86/intel-uncore-freq: Ignore minor version change

In reply to Srinivas Pandruvada

The hardware definition of every TPMI feature contains a major and minor version. When there is a change in the MMIO offset or change in the definition of a field, hardware will change major version. For addition of new fields without modifying existing MMIO offsets or fields, only the minor version is changed.

Driver is developed to support uncore frequency control (UFS) for a major and minor version. If the hardware changes major version, since offsets and definitions are changed, driver cannot continue to provide UFS interface to users. Driver can still function with minor version change as it will just miss the new functionality added by the hardware.

The current implementation logs information message and skips adding uncore sysfs entry for a resource for any version mismatch. Check major and minor version mismatch for every valid resource and fail on any major version mismatch by logging an error message. A valid resource has a version which is not 0xFF.

If there is mismatch with the minor version, continue with a log message.

---
v2
- Commit description and header change
- Change log levels exit on any major version mismatch

 .../uncore-frequency/uncore-frequency-tpmi.c   | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c +14 -4
index 7d0a67f8b517..4fb790552c47 100644
@@ -28,7 +28,8 @@
 
 #include "uncore-frequency-common.h"
 
-#define	UNCORE_HEADER_VERSION		1
+#define	UNCORE_MAJOR_VERSION		0
+#define	UNCORE_MINOR_VERSION		1
 #define UNCORE_HEADER_INDEX		0
 #define UNCORE_FABRIC_CLUSTER_OFFSET	8
 
@@ -302,12 +303,21 @@ static int uncore_probe(struct auxiliary_device *auxdev, const struct auxiliary_
 		/* Check for version and skip this resource if there is mismatch */
 		header = readq(pd_info->uncore_base);
 		pd_info->ufs_header_ver = header & UNCORE_VERSION_MASK;
-		if (pd_info->ufs_header_ver != UNCORE_HEADER_VERSION) {
-			dev_info(&auxdev->dev, "Uncore: Unsupported version:%d\n",
-				pd_info->ufs_header_ver);
+
+		if (pd_info->ufs_header_ver == TPMI_VERSION_INVALID)
 			continue;
+
+		if (TPMI_MAJOR_VERSION(pd_info->ufs_header_ver) != UNCORE_MAJOR_VERSION) {
+			dev_err(&auxdev->dev, "Uncore: Unsupported major version:%lx\n",
+				TPMI_MAJOR_VERSION(pd_info->ufs_header_ver));
+			ret = -ENODEV;
+			goto remove_clusters;
 		}
 
+		if (TPMI_MINOR_VERSION(pd_info->ufs_header_ver) != UNCORE_MINOR_VERSION)
+			dev_info(&auxdev->dev, "Uncore: Ignore: Unsupported minor version:%lx\n",
+				 TPMI_MINOR_VERSION(pd_info->ufs_header_ver));
+
 		/* Get Cluster ID Mask */
 		cluster_mask = FIELD_GET(UNCORE_LOCAL_FABRIC_CLUSTER_ID_MASK, header);
 		if (!cluster_mask) {
Signature · 1 line
2.41.0
maintainer
#7 lore raw
In reply to Srinivas Pandruvada
Quoted 6 lines · Srinivas Pandruvada

Changes for core and feature drivers to check major minor version.

v2
- commit description changes
- Log level change

Quoted 6 lines

Srinivas Pandruvada (3):
platform/x86/intel/tpmi: Add defines to get version information platform/x86: ISST: Ignore minor version change platform/x86/intel-uncore-freq: Process hardware version

[...]

Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.

Once I've run some tests on the review-ilpo 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.

The list of commits applied:
[1/3] platform/x86/intel/tpmi: Add defines to get version information

      commit: 8874e414fe78718d0f2861fe511cecbd1cd73f4d
[2/3] platform/x86: ISST: Ignore minor version change
      commit: 07510a59b316445311775ee53adf10448140607a
[3/3] platform/x86/intel-uncore-freq: Ignore minor version change
      commit: 4b0d9c8f8f55562ed5346723e66eec64f22887f4

--
i.