From: Tony Luck <tony.luck@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Uros Bizjak <ubizjak@gmail.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Arnd Bergmann <arnd@arndb.de>, Tony Luck <tony.luck@intel.com>,
Mateusz Guzik <mjguzik@gmail.com>,
Thomas Renninger <trenn@suse.de>, Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, patches@lists.linux.dev
Subject: [PATCH v6 47/49] peci, hwmon: Switch to new Intel CPU model defines
Date: Mon, 20 May 2024 15:46:18 -0700 [thread overview]
Message-ID: <20240520224620.9480-48-tony.luck@intel.com> (raw)
In-Reply-To: <20240520224620.9480-1-tony.luck@intel.com>
Update peci subsystem to use the same vendor-family-model
combined definition that core x86 code uses.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
include/linux/peci-cpu.h | 24 ++++++++++++++++++++++++
include/linux/peci.h | 6 ++----
drivers/peci/internal.h | 6 ++----
drivers/hwmon/peci/cputemp.c | 8 ++++----
drivers/peci/core.c | 5 ++---
drivers/peci/cpu.c | 21 +++++++--------------
drivers/peci/device.c | 3 +--
7 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/include/linux/peci-cpu.h b/include/linux/peci-cpu.h
index ff8ae9c26c80..601cdd086bf6 100644
--- a/include/linux/peci-cpu.h
+++ b/include/linux/peci-cpu.h
@@ -6,6 +6,30 @@
#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_PCS_PKG_ID 0 /* Package Identifier Read */
diff --git a/include/linux/peci.h b/include/linux/peci.h
index 90e241458ef6..3e0bc37591d6 100644
--- a/include/linux/peci.h
+++ b/include/linux/peci.h
@@ -59,8 +59,7 @@ static inline struct peci_controller *to_peci_controller(void *d)
* struct peci_device - PECI device
* @dev: device object to register PECI device to the device model
* @info: PECI device characteristics
- * @info.family: device family
- * @info.model: device model
+ * @info.x86_vfm: device vendor-family-model
* @info.peci_revision: PECI revision supported by the PECI device
* @info.socket_id: the socket ID represented by the PECI device
* @addr: address used on the PECI bus connected to the parent controller
@@ -73,8 +72,7 @@ static inline struct peci_controller *to_peci_controller(void *d)
struct peci_device {
struct device dev;
struct {
- u16 family;
- u8 model;
+ u32 x86_vfm;
u8 peci_revision;
u8 socket_id;
} info;
diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h
index 9d75ea54504c..b9d45483cabe 100644
--- a/drivers/peci/internal.h
+++ b/drivers/peci/internal.h
@@ -66,13 +66,11 @@ struct peci_request *peci_xfer_ep_mmio64_readl(struct peci_device *device, u8 ba
/**
* struct peci_device_id - PECI device data to match
* @data: pointer to driver private data specific to device
- * @family: device family
- * @model: device model
+ * @x86_vfm: device vendor-family-model
*/
struct peci_device_id {
const void *data;
- u16 family;
- u8 model;
+ u32 x86_vfm;
};
extern struct device_type peci_device_type;
diff --git a/drivers/hwmon/peci/cputemp.c b/drivers/hwmon/peci/cputemp.c
index a812c15948d9..5a682195b98f 100644
--- a/drivers/hwmon/peci/cputemp.c
+++ b/drivers/hwmon/peci/cputemp.c
@@ -360,10 +360,10 @@ static int init_core_mask(struct peci_cputemp *priv)
int ret;
/* Get the RESOLVED_CORES register value */
- switch (peci_dev->info.model) {
- case INTEL_FAM6_ICELAKE_X:
- case INTEL_FAM6_ICELAKE_D:
- case INTEL_FAM6_SAPPHIRERAPIDS_X:
+ switch (peci_dev->info.x86_vfm) {
+ case INTEL_ICELAKE_X:
+ case INTEL_ICELAKE_D:
+ case INTEL_SAPPHIRERAPIDS_X:
ret = peci_ep_pci_local_read(peci_dev, 0, reg->bus, reg->dev,
reg->func, reg->offset + 4, &data);
if (ret)
diff --git a/drivers/peci/core.c b/drivers/peci/core.c
index 0f83a9c6093b..b2d7adf05ba0 100644
--- a/drivers/peci/core.c
+++ b/drivers/peci/core.c
@@ -163,9 +163,8 @@ EXPORT_SYMBOL_NS_GPL(devm_peci_controller_add, PECI);
static const struct peci_device_id *
peci_bus_match_device_id(const struct peci_device_id *id, struct peci_device *device)
{
- while (id->family != 0) {
- if (id->family == device->info.family &&
- id->model == device->info.model)
+ while (id->x86_vfm != 0) {
+ if (id->x86_vfm == device->info.x86_vfm)
return id;
id++;
}
diff --git a/drivers/peci/cpu.c b/drivers/peci/cpu.c
index bd990acd92b8..152bbd8e717a 100644
--- a/drivers/peci/cpu.c
+++ b/drivers/peci/cpu.c
@@ -294,38 +294,31 @@ peci_cpu_probe(struct peci_device *device, const struct peci_device_id *id)
static const struct peci_device_id peci_cpu_device_ids[] = {
{ /* Haswell Xeon */
- .family = 6,
- .model = INTEL_FAM6_HASWELL_X,
+ .x86_vfm = INTEL_HASWELL_X,
.data = "hsx",
},
{ /* Broadwell Xeon */
- .family = 6,
- .model = INTEL_FAM6_BROADWELL_X,
+ .x86_vfm = INTEL_BROADWELL_X,
.data = "bdx",
},
{ /* Broadwell Xeon D */
- .family = 6,
- .model = INTEL_FAM6_BROADWELL_D,
+ .x86_vfm = INTEL_BROADWELL_D,
.data = "bdxd",
},
{ /* Skylake Xeon */
- .family = 6,
- .model = INTEL_FAM6_SKYLAKE_X,
+ .x86_vfm = INTEL_SKYLAKE_X,
.data = "skx",
},
{ /* Icelake Xeon */
- .family = 6,
- .model = INTEL_FAM6_ICELAKE_X,
+ .x86_vfm = INTEL_ICELAKE_X,
.data = "icx",
},
{ /* Icelake Xeon D */
- .family = 6,
- .model = INTEL_FAM6_ICELAKE_D,
+ .x86_vfm = INTEL_ICELAKE_D,
.data = "icxd",
},
{ /* Sapphire Rapids Xeon */
- .family = 6,
- .model = INTEL_FAM6_SAPPHIRERAPIDS_X,
+ .x86_vfm = INTEL_SAPPHIRERAPIDS_X,
.data = "spr",
},
{ }
diff --git a/drivers/peci/device.c b/drivers/peci/device.c
index e6b0bffb14f4..5eb57b503c81 100644
--- a/drivers/peci/device.c
+++ b/drivers/peci/device.c
@@ -100,8 +100,7 @@ static int peci_device_info_init(struct peci_device *device)
if (ret)
return ret;
- device->info.family = peci_x86_cpu_family(cpu_id);
- device->info.model = peci_x86_cpu_model(cpu_id);
+ device->info.x86_vfm = IFM(peci_x86_cpu_family(cpu_id), peci_x86_cpu_model(cpu_id));
ret = peci_get_revision(device, &revision);
if (ret)
--
2.45.0
next prev parent reply other threads:[~2024-05-20 22:46 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 22:45 [PATCH v6 00/49] New Intel CPUID families Tony Luck
2024-05-20 22:45 ` [PATCH v6 01/49] crypto: x86/aes-xts - Switch to new Intel CPU model defines Tony Luck
2024-05-21 17:22 ` Borislav Petkov
2024-05-21 17:36 ` Eric Biggers
2024-05-22 3:32 ` Herbert Xu
2024-05-22 9:47 ` [tip: x86/urgent] crypto: x86/aes-xts - switch " tip-bot2 for Tony Luck
2024-05-20 22:45 ` [PATCH v6 02/49] x86/cpu: Fix x86_match_cpu() to match just X86_VENDOR_INTEL Tony Luck
2024-05-21 7:49 ` Borislav Petkov
2024-05-21 15:48 ` Tony Luck
2024-05-21 17:18 ` Borislav Petkov
2024-05-20 22:45 ` [PATCH v6 03/49] tpm: Switch to new Intel CPU model defines Tony Luck
2024-05-20 22:45 ` [PATCH v6 04/49] platform/x86/intel/ifs: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 05/49] media: atomisp: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 06/49] ASoC: Intel: avs: es8336: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 07/49] platform/x86: intel_scu_wdt: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 08/49] KVM: x86/pmu: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 09/49] KVM: VMX: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 10/49] cpufreq: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 11/49] intel_idle: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 12/49] PCI: PM: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 13/49] powercap: intel_rapl: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 14/49] ASoC: Intel: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 15/49] thermal: intel: intel_tcc_cooling: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 16/49] x86/platform/intel-mid: " Tony Luck
2024-05-21 14:12 ` Andy Shevchenko
2024-05-21 16:10 ` [PATCH v6.1 " Tony Luck
2024-05-21 16:17 ` Andy Shevchenko
2024-05-20 22:45 ` [PATCH v6 17/49] platform/x86: intel_speed_select_if: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 18/49] platform/x86: intel-uncore-freq: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 19/49] platform/x86: intel_ips: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 20/49] platform/x86: intel_telemetry: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 21/49] platform/x86: intel: telemetry: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 22/49] platform/x86: intel_turbo_max_3: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 23/49] platform/x86: p2sb: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 24/49] platform/x86/intel: pmc: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 25/49] platform/x86/intel/pmc: " Tony Luck
2024-05-20 22:45 ` [PATCH v6 26/49] crypto: x86/poly1305 - " Tony Luck
2024-05-20 22:45 ` [PATCH v6 27/49] crypto: x86/twofish " Tony Luck
2024-05-20 22:45 ` [PATCH v6 28/49] x86/cpu/intel: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 29/49] x86/PCI: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 30/49] x86/virt/tdx: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 31/49] perf/x86/intel: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 32/49] x86/platform/atom: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 33/49] x86/cpu: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 34/49] x86/boot: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 35/49] EDAC/i10nm: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 36/49] EDAC, pnd2: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 37/49] EDAC/sb_edac: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 38/49] EDAC/skx: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 39/49] extcon: axp288: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 40/49] ACPI: LPSS: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 41/49] ACPI: x86: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 42/49] cpufreq: intel_pstate: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 43/49] perf/x86/rapl: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 44/49] platform/x86: ISST: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 45/49] powercap: intel_rapl: " Tony Luck
2024-05-20 22:46 ` [PATCH v6 46/49] tools/power/turbostat: " Tony Luck
2024-05-20 22:46 ` Tony Luck [this message]
2024-05-20 22:46 ` [PATCH v6 48/49] x86/cpu/vfm: Delete X86_MATCH_INTEL_FAM6_MODEL[_STEPPING]() macros Tony Luck
2024-05-20 22:46 ` [PATCH v6 49/49] x86/cpu/vfm: Delete all the *_FAM6_ CPU #defines Tony Luck
2024-05-21 8:32 ` [PATCH v6 00/49] New Intel CPUID families Borislav Petkov
2024-05-21 15:21 ` Luck, Tony
2024-05-28 17:34 ` Tony Luck
2024-06-04 23:29 ` Sean Christopherson
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=20240520224620.9480-48-tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=ak@linux.intel.com \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mjguzik@gmail.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--cc=trenn@suse.de \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.org \
/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