From: Dave Hansen <dave.hansen@intel.com>
To: "Luck, Tony" <tony.luck@intel.com>,
"Mehta, Sohil" <sohil.mehta@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
"Liu, Zhao1" <zhao1.liu@intel.com>,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@redhat.com>, "Kohler, Jon" <jon@nutanix.com>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Thomas Gleixner <tglx@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"Winiarska, Iwona" <iwona.winiarska@intel.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/6] x86/cpu: Break Vendor/Family/Model macros into separate header
Date: Wed, 11 Feb 2026 13:12:00 -0800 [thread overview]
Message-ID: <432e4776-5e10-4bf4-9f6a-e884f5820596@intel.com> (raw)
In-Reply-To: <SJ1PR11MB60837EB0A954FDD35AF30B02FC62A@SJ1PR11MB6083.namprd11.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]
On 2/10/26 15:52, Luck, Tony wrote:
>> Is the PECI model list growing all the time? Like will it grow for the
>> next decade?
> Looks like this started in Feb 2022 with HASWELL ... ICELAKE
>
> July 2023 added SAPPHIRE. October 2025 added EMERALD.
>
> Maybe Iwona can future predictions/details when she sees this e-mail thread.
I went and looked at this a bit more. I think we're going to way too
much trouble to share a few constants. It was a valiant effort on the
part of the PECI folks to avoid duplication, but I think it's run its
course.
The x86 code wants and needs to know the logically separate
model/family/stepping. We have oodles of
if (model == INTEL_FOO)
do_foo_thing();
But we basically never care about the format that's in CPUID.01H:EAX.
The PECI code has none of that. It's *just* matching the "id" of the
device to the "id" of the CPU. It just so happens that the "id" that's
chosen matches CPUID.01H:EAX.
So PECI and x86 both want the same data, but they do very different
things with it.
So let's just duplicate the constants. Completely untested patch attached.
Any reason not to do this?
[-- Attachment #2: peci-sanity.patch --]
[-- Type: text/x-patch, Size: 7189 bytes --]
---
b/drivers/hwmon/peci/cputemp.c | 10 +++++-----
b/drivers/peci/core.c | 4 ++--
b/drivers/peci/cpu.c | 16 ++++++++--------
b/drivers/peci/device.c | 34 +++++++---------------------------
b/drivers/peci/internal.h | 4 ++--
b/include/linux/peci-cpu.h | 34 +++++++++-------------------------
b/include/linux/peci.h | 2 +-
7 files changed, 34 insertions(+), 70 deletions(-)
diff -puN drivers/peci/device.c~peci-sanity drivers/peci/device.c
--- a/drivers/peci/device.c~peci-sanity 2026-02-11 12:45:56.914190235 -0800
+++ b/drivers/peci/device.c 2026-02-11 13:06:11.562229733 -0800
@@ -44,6 +44,12 @@ static int peci_get_revision(struct peci
return 0;
}
+/*
+ * Note 'cpu_id' that comes back from the hardware is in the raw
+ * format of x86 CPUID.01H:EAX leaf and includes the CPU Model, Family
+ * and Stepping. But, for the purposes of this driver, it is an opaque
+ * identifier.
+ */
static int peci_get_cpu_id(struct peci_device *device, u32 *cpu_id)
{
struct peci_request *req;
@@ -64,32 +70,6 @@ out_req_free:
return ret;
}
-static unsigned int peci_x86_cpu_family(unsigned int sig)
-{
- unsigned int x86;
-
- x86 = (sig >> 8) & 0xf;
-
- if (x86 == 0xf)
- x86 += (sig >> 20) & 0xff;
-
- return x86;
-}
-
-static unsigned int peci_x86_cpu_model(unsigned int sig)
-{
- unsigned int fam, model;
-
- fam = peci_x86_cpu_family(sig);
-
- model = (sig >> 4) & 0xf;
-
- if (fam >= 0x6)
- model += ((sig >> 16) & 0xf) << 4;
-
- return model;
-}
-
static int peci_device_info_init(struct peci_device *device)
{
u8 revision;
@@ -100,7 +80,7 @@ static int peci_device_info_init(struct
if (ret)
return ret;
- device->info.x86_vfm = IFM(peci_x86_cpu_family(cpu_id), peci_x86_cpu_model(cpu_id));
+ device->info.device_id = cpu_id >> 4;
ret = peci_get_revision(device, &revision);
if (ret)
diff -puN drivers/peci/internal.h~peci-sanity drivers/peci/internal.h
--- a/drivers/peci/internal.h~peci-sanity 2026-02-11 12:47:24.703476027 -0800
+++ b/drivers/peci/internal.h 2026-02-11 12:48:57.278946288 -0800
@@ -66,11 +66,11 @@ struct peci_request *peci_xfer_ep_mmio64
/**
* struct peci_device_id - PECI device data to match
* @data: pointer to driver private data specific to device
- * @x86_vfm: device vendor-family-model
+ * @device_id: device identifier, includes CPU vendor-family-model
*/
struct peci_device_id {
const void *data;
- u32 x86_vfm;
+ u32 device_id;
};
extern const struct device_type peci_device_type;
diff -puN include/linux/peci.h~peci-sanity include/linux/peci.h
--- a/include/linux/peci.h~peci-sanity 2026-02-11 12:47:36.824930119 -0800
+++ b/include/linux/peci.h 2026-02-11 12:50:50.649202205 -0800
@@ -72,7 +72,7 @@ static inline struct peci_controller *to
struct peci_device {
struct device dev;
struct {
- u32 x86_vfm;
+ u32 device_id;
u8 peci_revision;
u8 socket_id;
} info;
diff -puN drivers/hwmon/peci/cputemp.c~peci-sanity drivers/hwmon/peci/cputemp.c
--- a/drivers/hwmon/peci/cputemp.c~peci-sanity 2026-02-11 12:49:00.694074399 -0800
+++ b/drivers/hwmon/peci/cputemp.c 2026-02-11 12:56:12.154297952 -0800
@@ -340,11 +340,11 @@ static int init_core_mask(struct peci_cp
int ret;
/* Get the RESOLVED_CORES register value */
- switch (peci_dev->info.x86_vfm) {
- case INTEL_ICELAKE_X:
- case INTEL_ICELAKE_D:
- case INTEL_SAPPHIRERAPIDS_X:
- case INTEL_EMERALDRAPIDS_X:
+ switch (peci_dev->info.device_id) {
+ case PECI_INTEL_ICELAKE_X:
+ case PECI_INTEL_ICELAKE_D:
+ case PECI_INTEL_SAPPHIRERAPIDS_X:
+ case PECI_INTEL_EMERALDRAPIDS_X:
ret = peci_ep_pci_local_read(peci_dev, 0, reg->bus, reg->dev,
reg->func, reg->offset + 4, &data);
if (ret)
diff -puN drivers/peci/core.c~peci-sanity drivers/peci/core.c
--- a/drivers/peci/core.c~peci-sanity 2026-02-11 12:49:43.989699060 -0800
+++ b/drivers/peci/core.c 2026-02-11 12:49:56.175156483 -0800
@@ -163,8 +163,8 @@ EXPORT_SYMBOL_NS_GPL(devm_peci_controlle
static const struct peci_device_id *
peci_bus_match_device_id(const struct peci_device_id *id, struct peci_device *device)
{
- while (id->x86_vfm != 0) {
- if (id->x86_vfm == device->info.x86_vfm)
+ while (id->device_id != 0) {
+ if (id->device_id == device->info.device_id)
return id;
id++;
}
diff -puN include/linux/peci-cpu.h~peci-sanity include/linux/peci-cpu.h
--- a/include/linux/peci-cpu.h~peci-sanity 2026-02-11 12:51:19.639291420 -0800
+++ b/include/linux/peci-cpu.h 2026-02-11 13:04:24.068100213 -0800
@@ -6,31 +6,15 @@
#include <linux/types.h>
-/* Copied from x86 <asm/processor.h> */
-#define X86_VENDOR_INTEL 0
-
-/* Copied from x86 <asm/cpu_device_id.h> */
-#define VFM_MODEL_BIT 0
-#define VFM_FAMILY_BIT 8
-#define VFM_VENDOR_BIT 16
-#define VFM_RSVD_BIT 24
-
-#define VFM_MODEL_MASK GENMASK(VFM_FAMILY_BIT - 1, VFM_MODEL_BIT)
-#define VFM_FAMILY_MASK GENMASK(VFM_VENDOR_BIT - 1, VFM_FAMILY_BIT)
-#define VFM_VENDOR_MASK GENMASK(VFM_RSVD_BIT - 1, VFM_VENDOR_BIT)
-
-#define VFM_MODEL(vfm) (((vfm) & VFM_MODEL_MASK) >> VFM_MODEL_BIT)
-#define VFM_FAMILY(vfm) (((vfm) & VFM_FAMILY_MASK) >> VFM_FAMILY_BIT)
-#define VFM_VENDOR(vfm) (((vfm) & VFM_VENDOR_MASK) >> VFM_VENDOR_BIT)
-
-#define VFM_MAKE(_vendor, _family, _model) ( \
- ((_model) << VFM_MODEL_BIT) | \
- ((_family) << VFM_FAMILY_BIT) | \
- ((_vendor) << VFM_VENDOR_BIT) \
-)
-/* End of copied code */
-
-#include "../../arch/x86/include/asm/intel-family.h"
+#define PECI_INTEL_HASWELL_X 0x306C0
+#define PECI_INTEL_BROADWELL_X 0x406F0
+#define PECI_INTEL_BROADWELL_D 0x50660
+#define PECI_INTEL_SKYLAKE_X 0x50650
+
+#define PECI_INTEL_ICELAKE_X 0x606A0
+#define PECI_INTEL_ICELAKE_D 0x606C0
+#define PECI_INTEL_SAPPHIRERAPIDS_X 0x806F0
+#define PECI_INTEL_EMERALDRAPIDS_X 0xC06F0
#define PECI_PCS_PKG_ID 0 /* Package Identifier Read */
#define PECI_PKG_ID_CPU_ID 0x0000 /* CPUID Info */
diff -puN drivers/peci/cpu.c~peci-sanity drivers/peci/cpu.c
--- a/drivers/peci/cpu.c~peci-sanity 2026-02-11 12:56:48.724675627 -0800
+++ b/drivers/peci/cpu.c 2026-02-11 12:57:18.663803707 -0800
@@ -294,35 +294,35 @@ peci_cpu_probe(struct peci_device *devic
static const struct peci_device_id peci_cpu_device_ids[] = {
{ /* Haswell Xeon */
- .x86_vfm = INTEL_HASWELL_X,
+ .device_id = PECI_INTEL_HASWELL_X,
.data = "hsx",
},
{ /* Broadwell Xeon */
- .x86_vfm = INTEL_BROADWELL_X,
+ .device_id = PECI_INTEL_BROADWELL_X,
.data = "bdx",
},
{ /* Broadwell Xeon D */
- .x86_vfm = INTEL_BROADWELL_D,
+ .device_id = PECI_INTEL_BROADWELL_D,
.data = "bdxd",
},
{ /* Skylake Xeon */
- .x86_vfm = INTEL_SKYLAKE_X,
+ .device_id = PECI_INTEL_SKYLAKE_X,
.data = "skx",
},
{ /* Icelake Xeon */
- .x86_vfm = INTEL_ICELAKE_X,
+ .device_id = PECI_INTEL_ICELAKE_X,
.data = "icx",
},
{ /* Icelake Xeon D */
- .x86_vfm = INTEL_ICELAKE_D,
+ .device_id = PECI_INTEL_ICELAKE_D,
.data = "icxd",
},
{ /* Sapphire Rapids Xeon */
- .x86_vfm = INTEL_SAPPHIRERAPIDS_X,
+ .device_id = PECI_INTEL_SAPPHIRERAPIDS_X,
.data = "spr",
},
{ /* Emerald Rapids Xeon */
- .x86_vfm = INTEL_EMERALDRAPIDS_X,
+ .device_id = PECI_INTEL_EMERALDRAPIDS_X,
.data = "emr",
},
{ }
_
next prev parent reply other threads:[~2026-02-11 21:12 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-06 23:14 [PATCH 0/6] [v2] x86/cpu: Take Intel platform into account for old microcode checks Dave Hansen
2026-02-06 23:14 ` [PATCH 1/6] x86/cpu: Break Vendor/Family/Model macros into separate header Dave Hansen
2026-02-10 22:13 ` Sohil Mehta
2026-02-10 22:17 ` Dave Hansen
2026-02-10 23:03 ` Sohil Mehta
2026-02-10 23:32 ` Luck, Tony
2026-02-10 23:35 ` Dave Hansen
2026-02-10 23:52 ` Luck, Tony
2026-02-11 21:12 ` Dave Hansen [this message]
2026-02-11 21:54 ` Sohil Mehta
2026-02-11 22:32 ` Luck, Tony
2026-02-11 22:35 ` Sohil Mehta
2026-02-11 23:02 ` Dave Hansen
2026-02-11 22:21 ` Luck, Tony
2026-02-06 23:14 ` [PATCH 2/6] x86/cpu: Add missing #include Dave Hansen
2026-02-06 23:14 ` [PATCH 3/6] x86/microcode: Refactor platform ID enumeration into a helper Dave Hansen
2026-02-10 23:20 ` Sohil Mehta
2026-02-10 23:23 ` Dave Hansen
2026-02-06 23:14 ` [PATCH 4/6] x86/cpu: Add platform ID to CPU info structure Dave Hansen
2026-02-08 21:37 ` Borislav Petkov
2026-02-11 18:40 ` Dave Hansen
2026-02-12 15:22 ` Borislav Petkov
2026-02-10 23:23 ` Sohil Mehta
2026-02-06 23:14 ` [PATCH 5/6] x86/cpu: Add platform ID to CPU matching structure Dave Hansen
2026-02-10 23:27 ` Sohil Mehta
2026-02-06 23:14 ` [PATCH 6/6] x86/microcode: Add platform mask to Intel microcode "old" list Dave Hansen
2026-02-10 23:39 ` Sohil Mehta
2026-02-09 10:20 ` [PATCH 0/6] [v2] x86/cpu: Take Intel platform into account for old microcode checks Maciej Wieczor-Retman
2026-02-09 15:15 ` Dave Hansen
-- strict thread matches above, loose matches on Subject: below --
2026-01-19 19:50 [PATCH 0/6] " Dave Hansen
2026-01-19 19:50 ` [PATCH 1/6] x86/cpu: Break Vendor/Family/Model macros into separate header Dave Hansen
2026-01-20 8:24 ` Andy Shevchenko
2026-01-20 15:03 ` Dave Hansen
2026-01-20 16:22 ` Andy Shevchenko
2026-01-20 16:34 ` Dave Hansen
2026-01-20 20:54 ` Andy Shevchenko
2026-01-20 16:48 ` Luck, Tony
2026-01-20 20:50 ` Shevchenko, Andriy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=432e4776-5e10-4bf4-9f6a-e884f5820596@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=iwona.winiarska@intel.com \
--cc=jon@nutanix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=sohil.mehta@intel.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome