Re: [PATCH 1/6] x86/cpu: Break Vendor/Family/Model macros into separate header

From: Dave Hansen

Date: Wed Feb 11 2026 - 16:12:11 EST


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?

---

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",
},
{ }
_