* [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information
2023-10-03 18:49 [PATCH v2 0/3] TPMI feature major/minor version check Srinivas Pandruvada
@ 2023-10-03 18:49 ` Srinivas Pandruvada
2023-10-04 12:59 ` Andy Shevchenko
2023-10-03 18:49 ` [PATCH v2 2/3] platform/x86: ISST: Ignore minor version change Srinivas Pandruvada
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Srinivas Pandruvada @ 2023-10-03 18:49 UTC (permalink / raw)
To: hdegoede, markgross, ilpo.jarvinen, andriy.shevchenko
Cc: platform-driver-x86, linux-kernel, 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.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
v2:
No change
include/linux/intel_tpmi.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/intel_tpmi.h b/include/linux/intel_tpmi.h
index 04d937ad4dc4..ee07393445f9 100644
--- a/include/linux/intel_tpmi.h
+++ b/include/linux/intel_tpmi.h
@@ -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
--
2.41.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information
2023-10-03 18:49 ` [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information Srinivas Pandruvada
@ 2023-10-04 12:59 ` Andy Shevchenko
2023-10-04 13:03 ` Ilpo Järvinen
2023-10-04 18:37 ` srinivas pandruvada
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-10-04 12:59 UTC (permalink / raw)
To: Srinivas Pandruvada
Cc: hdegoede, markgross, ilpo.jarvinen, platform-driver-x86,
linux-kernel
On Tue, Oct 03, 2023 at 11:49:14AM -0700, Srinivas Pandruvada wrote:
> 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.
...
> +#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)
> +#define TPMI_MINOR_VERSION(val) FIELD_GET(GENMASK(4, 0), val)
> +#define TPMI_MAJOR_VERSION(val) FIELD_GET(GENMASK(7, 5), val)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information
2023-10-04 12:59 ` Andy Shevchenko
@ 2023-10-04 13:03 ` Ilpo Järvinen
2023-10-04 18:37 ` srinivas pandruvada
1 sibling, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2023-10-04 13:03 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Srinivas Pandruvada, Hans de Goede, markgross,
platform-driver-x86, LKML
On Wed, 4 Oct 2023, Andy Shevchenko wrote:
> On Tue, Oct 03, 2023 at 11:49:14AM -0700, Srinivas Pandruvada wrote:
> > 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.
>
> ...
>
> > +#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)
>
> > +#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.
--
i.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information
2023-10-04 12:59 ` Andy Shevchenko
2023-10-04 13:03 ` Ilpo Järvinen
@ 2023-10-04 18:37 ` srinivas pandruvada
1 sibling, 0 replies; 8+ messages in thread
From: srinivas pandruvada @ 2023-10-04 18:37 UTC (permalink / raw)
To: Andy Shevchenko
Cc: hdegoede, markgross, ilpo.jarvinen, platform-driver-x86,
linux-kernel
On Wed, 2023-10-04 at 15:59 +0300, Andy Shevchenko wrote:
> On Tue, Oct 03, 2023 at 11:49:14AM -0700, Srinivas Pandruvada wrote:
> > 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.
>
> ...
>
> > +#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)
>
> > +#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
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] platform/x86: ISST: Ignore minor version change
2023-10-03 18:49 [PATCH v2 0/3] TPMI feature major/minor version check Srinivas Pandruvada
2023-10-03 18:49 ` [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information Srinivas Pandruvada
@ 2023-10-03 18:49 ` Srinivas Pandruvada
2023-10-03 18:49 ` [PATCH v2 3/3] platform/x86/intel-uncore-freq: " Srinivas Pandruvada
2023-10-04 9:08 ` [PATCH v2 0/3] TPMI feature major/minor version check Ilpo Järvinen
3 siblings, 0 replies; 8+ messages in thread
From: Srinivas Pandruvada @ 2023-10-03 18:49 UTC (permalink / raw)
To: hdegoede, markgross, ilpo.jarvinen, andriy.shevchenko
Cc: platform-driver-x86, linux-kernel, 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.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
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(-)
diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
index ac5c6a812592..0b6d2c864437 100644
--- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
+++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
@@ -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);
--
2.41.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 3/3] platform/x86/intel-uncore-freq: Ignore minor version change
2023-10-03 18:49 [PATCH v2 0/3] TPMI feature major/minor version check Srinivas Pandruvada
2023-10-03 18:49 ` [PATCH v2 1/3] platform/x86/intel/tpmi: Add defines to get version information Srinivas Pandruvada
2023-10-03 18:49 ` [PATCH v2 2/3] platform/x86: ISST: Ignore minor version change Srinivas Pandruvada
@ 2023-10-03 18:49 ` Srinivas Pandruvada
2023-10-04 9:08 ` [PATCH v2 0/3] TPMI feature major/minor version check Ilpo Järvinen
3 siblings, 0 replies; 8+ messages in thread
From: Srinivas Pandruvada @ 2023-10-03 18:49 UTC (permalink / raw)
To: hdegoede, markgross, ilpo.jarvinen, andriy.shevchenko
Cc: platform-driver-x86, linux-kernel, 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.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
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(-)
diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
index 7d0a67f8b517..4fb790552c47 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c
@@ -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) {
--
2.41.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 0/3] TPMI feature major/minor version check
2023-10-03 18:49 [PATCH v2 0/3] TPMI feature major/minor version check Srinivas Pandruvada
` (2 preceding siblings ...)
2023-10-03 18:49 ` [PATCH v2 3/3] platform/x86/intel-uncore-freq: " Srinivas Pandruvada
@ 2023-10-04 9:08 ` Ilpo Järvinen
3 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2023-10-04 9:08 UTC (permalink / raw)
To: hdegoede, markgross, andriy.shevchenko, Srinivas Pandruvada
Cc: platform-driver-x86, linux-kernel
On Tue, 03 Oct 2023 11:49:13 -0700, Srinivas Pandruvada wrote:
> 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
>
> [...]
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.
^ permalink raw reply [flat|nested] 8+ messages in thread