From nobody Fri Apr 3 08:09:58 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB8829B78F; Fri, 20 Feb 2026 17:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771609884; cv=none; b=Y7leHZKjREOzUsUCF9pdxiTlm2VE5FLz9I2DXX30pQUnO3Pgchhu+4BFn2OEZ1jwRY0gb/tYlDsCoxRO4Yk6U1qHQixWW6qxiheNWPnoOJOtZohtYLLFGibnML7EMMI/XyzXbvJZegXCC9XJOnOJCu6ZvxTs5U4yHbUZW+RuJDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771609884; c=relaxed/simple; bh=ETXxAKA8nDrQemqxEr3m5Ayv/YK4R/0cCs0w8n/jtjI=; h=Subject:To:Cc:From:Date:Message-Id; b=FE/5zov4H0N4sAKi7DnHZuahLOlvGx+Ycd5Wlh7h7s04IIl5wA7vkpidqh7ka2CwfCfeGF+cZx7NLUy6jDtdUurnoR0JtvN2b25jnYGQnhupc5rcXNPhYULoJnRxRZE+MmT1dgZKWzLTY0oMf2fNKNFxcPgP0XZjvJmmGy5qCJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=aRIdboLe; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aRIdboLe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771609883; x=1803145883; h=subject:to:cc:from:date:message-id; bh=ETXxAKA8nDrQemqxEr3m5Ayv/YK4R/0cCs0w8n/jtjI=; b=aRIdboLet2y9TrCNyHU4sa0PuQGOSx5zA9IXEU/Qs9EA9pV2jLA/cTMm jiqtxYKl2n88givDl2XozU88BgaJeezEgtiwJlFXwlBXCXJa1wZzo+CMt P1mqFP6hT/hTCq3zEq3xhdplsOLALERnInra2b2DeSUODbZphmiC/tebB +R2F4O1hdENVGTdSVXbMmR2/plKiTVouOwW2sKDS6KSm+3zIheYxzWgVV cmYwvApREuddbXkYZEycb6TtSEbp4obXjLEHrL0Yd9m8QKu8jAvMWJ8RP kz09LFLw9wBmbgaRsPsn4sJp9sWf90Z7flMTpe/NUUs275Jpvtdkk2Vhl w==; X-CSE-ConnectionGUID: 0VCdDL7OSzeVy4R9apxd6g== X-CSE-MsgGUID: EmTJ9p0nSK+2ktf5znoivg== X-IronPort-AV: E=McAfee;i="6800,10657,11707"; a="71911942" X-IronPort-AV: E=Sophos;i="6.21,302,1763452800"; d="scan'208";a="71911942" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2026 09:51:22 -0800 X-CSE-ConnectionGUID: dC49z/qkTJ6W8U8ORXyiFg== X-CSE-MsgGUID: aslatxuuT+yMjRVBGfgKHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,302,1763452800"; d="scan'208";a="218615445" Received: from davehans-spike.ostc.intel.com (HELO localhost.localdomain) ([10.165.164.11]) by fmviesa004.fm.intel.com with ESMTP; 20 Feb 2026 09:51:21 -0800 Subject: [PATCH] [v2] peci: Remove dependency on x86 CPU variables To: linux-kernel@vger.kernel.org Cc: sohil.mehta@intel.com, Dave Hansen , Borislav Petkov , Guenter Roeck , "H. Peter Anvin" , Ingo Molnar , Iwona Winiarska , linux-hwmon@vger.kernel.org, openbmc@lists.ozlabs.org, Thomas Gleixner , Tony Luck , x86@kernel.org From: Dave Hansen Date: Fri, 20 Feb 2026 09:51:21 -0800 Message-Id: <20260220175121.C16ADAAA@davehans-spike.ostc.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Dave Hansen tl;dr: The non-x86 PECI driver #includes an arch/x86 header. This is ostensibly to avoid duplicating CPU model number constants, but the result is complexity and duplicated *code* which is a far worse fate than duplicated constants. Remove the PECI dependency on arch/x86 by adding a list of supported "target" CPU models in the driver. This is only compile tested. Long version: =3D=3D Background =3D=3D The "PECI" driver runs on non-x86 hardware inside an x86 system. It talks to the x86 CPU. The PECI hardware has different features based on platform generations and uses the CPU model to control feature detections. Basically, instead of a PCI or USB device ID that a USB or PCI driver would use, the PECI driver uses the CPU model (and family). The arch/x86 code unsurprisingly has a list of CPU model numbers and the PECI code currently reuses that list. But the arch/x86 list is maintained in the "Display" format which is different than the binary format that CPUID (and PECI hardware) uses. =3D=3D Problem =3D=3D The end result is that the PECI code #includes the arch/x86 constants header and then duplicates some code that transforms the CPUID to the "Display" format. This is fragile because it's easy for us x86 folks to break the PECI driver when assuming that arch/x86 is x86-only. =3D=3D Solution =3D=3D Remove the arch/x86 dependency. Instead of duplicating the CPUID=3D>Display functionality, just duplicate the constants. Also rename the formerly "x86_vfm" variables. They are not in the VFM format any longer. They are purely device IDs. Name them appropriately. The result is a net code removal. The only downside is that the PECI folks need to add a #define whenever there is a new CPU model. But, they need to go add new CPU model to the driver explicitly *anyway*. =3D=3D Notes =3D=3D One little wrinkle in this is that the CPU identifier that comes back from the PECI hardware contains the CPU stepping just like CPUID.01H:EAX. But the stepping is ignored by the PECI driver. So, the PECI_INTEL_* identifiers are just defined with the stepping shifted off the beginning. They could have been defined with a 0 there and then have the stepping masked somewhere. Signed-off-by: Dave Hansen Reviewed-by: Sohil Mehta Cc: Iwona Winiarska Cc: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Cc: openbmc@lists.ozlabs.org Cc: Tony Luck Cc: x86@kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" -- Changes from v1: * Fix wrong Haswell model/family * Fix peci_device kernel doc Acked-by: Guenter Roeck Reviewed-by: Iwona Winiarska --- b/drivers/hwmon/peci/cputemp.c | 10 ++++----- b/drivers/peci/core.c | 4 +-- b/drivers/peci/cpu.c | 16 +++++++------- b/drivers/peci/device.c | 40 +++++++++++------------------------- b/drivers/peci/internal.h | 4 +-- b/include/linux/peci-cpu.h | 45 ++++++++++++++++++------------------= ----- b/include/linux/peci.h | 4 +-- 7 files changed, 52 insertions(+), 71 deletions(-) diff -puN drivers/peci/device.c~peci-sanity drivers/peci/device.c --- a/drivers/peci/device.c~peci-sanity 2026-02-19 15:30:50.446519294 -0800 +++ b/drivers/peci/device.c 2026-02-19 15:30:50.481521176 -0800 @@ -57,39 +57,25 @@ static int peci_get_cpu_id(struct peci_d if (ret) goto out_req_free; =20 + /* + * The 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. + */ *cpu_id =3D peci_request_data_readl(req); + + /* + * Remove the stepping (CPUID.01H:EAX[3:0]) to match the + * PECI_INTEL_* identifiers: + */ + *cpu_id >>=3D 4; + out_req_free: peci_request_free(req); =20 return ret; } =20 -static unsigned int peci_x86_cpu_family(unsigned int sig) -{ - unsigned int x86; - - x86 =3D (sig >> 8) & 0xf; - - if (x86 =3D=3D 0xf) - x86 +=3D (sig >> 20) & 0xff; - - return x86; -} - -static unsigned int peci_x86_cpu_model(unsigned int sig) -{ - unsigned int fam, model; - - fam =3D peci_x86_cpu_family(sig); - - model =3D (sig >> 4) & 0xf; - - if (fam >=3D 0x6) - model +=3D ((sig >> 16) & 0xf) << 4; - - return model; -} - static int peci_device_info_init(struct peci_device *device) { u8 revision; @@ -100,7 +86,7 @@ static int peci_device_info_init(struct if (ret) return ret; =20 - device->info.x86_vfm =3D IFM(peci_x86_cpu_family(cpu_id), peci_x86_cpu_mo= del(cpu_id)); + device->info.device_id =3D cpu_id; =20 ret =3D 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-19 15:30:50.449519456 -08= 00 +++ b/drivers/peci/internal.h 2026-02-19 15:30:50.482521229 -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; }; =20 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-19 15:30:50.452519617 -0800 +++ b/include/linux/peci.h 2026-02-19 15:30:50.482521229 -0800 @@ -59,7 +59,7 @@ static inline struct peci_controller *to * struct peci_device - PECI device * @dev: device object to register PECI device to the device model * @info: PECI device characteristics - * @info.x86_vfm: device vendor-family-model + * @info.device_id: device identifier (CPU 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 @@ -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/cpute= mp.c --- a/drivers/hwmon/peci/cputemp.c~peci-sanity 2026-02-19 15:30:50.45551977= 8 -0800 +++ b/drivers/hwmon/peci/cputemp.c 2026-02-19 15:30:50.482521229 -0800 @@ -340,11 +340,11 @@ static int init_core_mask(struct peci_cp int ret; =20 /* 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 =3D 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-19 15:30:50.459519993 -0800 +++ b/drivers/peci/core.c 2026-02-19 15:30:50.482521229 -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_devi= ce *device) { - while (id->x86_vfm !=3D 0) { - if (id->x86_vfm =3D=3D device->info.x86_vfm) + while (id->device_id !=3D 0) { + if (id->device_id =3D=3D 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-19 15:30:50.462520154 -0= 800 +++ b/include/linux/peci-cpu.h 2026-02-19 15:30:50.482521229 -0800 @@ -6,31 +6,26 @@ =20 #include =20 -/* Copied from x86 */ -#define X86_VENDOR_INTEL 0 - -/* Copied from x86 */ -#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" +/* + * These are in the format of and match the values of the x86 + * CPUID.01H:EAX[19:4]. They encode the model and family of + * the CPU with which the driver is interfacing. + * + * All driver functionality is common across all CPU steppings + * of a given model. Exclude the lower 4 stepping bits from + * these IDs. + * + * Always mirror the naming from the x86 intel-family.h file. + */ + +#define PECI_INTEL_HASWELL_X 0x306F +#define PECI_INTEL_BROADWELL_X 0x406F +#define PECI_INTEL_BROADWELL_D 0x5066 +#define PECI_INTEL_SKYLAKE_X 0x5065 +#define PECI_INTEL_ICELAKE_X 0x606A +#define PECI_INTEL_ICELAKE_D 0x606C +#define PECI_INTEL_SAPPHIRERAPIDS_X 0x806F +#define PECI_INTEL_EMERALDRAPIDS_X 0xC06F =20 #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-19 15:30:50.474520799 -0800 +++ b/drivers/peci/cpu.c 2026-02-19 15:30:50.482521229 -0800 @@ -294,35 +294,35 @@ peci_cpu_probe(struct peci_device *devic =20 static const struct peci_device_id peci_cpu_device_ids[] =3D { { /* Haswell Xeon */ - .x86_vfm =3D INTEL_HASWELL_X, + .device_id =3D PECI_INTEL_HASWELL_X, .data =3D "hsx", }, { /* Broadwell Xeon */ - .x86_vfm =3D INTEL_BROADWELL_X, + .device_id =3D PECI_INTEL_BROADWELL_X, .data =3D "bdx", }, { /* Broadwell Xeon D */ - .x86_vfm =3D INTEL_BROADWELL_D, + .device_id =3D PECI_INTEL_BROADWELL_D, .data =3D "bdxd", }, { /* Skylake Xeon */ - .x86_vfm =3D INTEL_SKYLAKE_X, + .device_id =3D PECI_INTEL_SKYLAKE_X, .data =3D "skx", }, { /* Icelake Xeon */ - .x86_vfm =3D INTEL_ICELAKE_X, + .device_id =3D PECI_INTEL_ICELAKE_X, .data =3D "icx", }, { /* Icelake Xeon D */ - .x86_vfm =3D INTEL_ICELAKE_D, + .device_id =3D PECI_INTEL_ICELAKE_D, .data =3D "icxd", }, { /* Sapphire Rapids Xeon */ - .x86_vfm =3D INTEL_SAPPHIRERAPIDS_X, + .device_id =3D PECI_INTEL_SAPPHIRERAPIDS_X, .data =3D "spr", }, { /* Emerald Rapids Xeon */ - .x86_vfm =3D INTEL_EMERALDRAPIDS_X, + .device_id =3D PECI_INTEL_EMERALDRAPIDS_X, .data =3D "emr", }, { } _