Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2748415lqo; Mon, 20 May 2024 15:55:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPbGQ1SDSxap6nJNiiKZRK4z51/GODXFD9E9W7lj6GEqI043UxFO9HyD6SgwmZTYRYw1syUK9aqeAGHCAfmgoiuVVnkZ7h3vascAZIJA== X-Google-Smtp-Source: AGHT+IG75Mhzwy3WJ+2a3NmEV/Kcub9f444HbmNiOgZU90+IK50bj6SCP74mZfrGYy35pL8bkh+C X-Received: by 2002:a17:90b:4d8d:b0:2bd:69ce:1966 with SMTP id 98e67ed59e1d1-2bd69ce2345mr4779918a91.29.1716245713603; Mon, 20 May 2024 15:55:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716245713; cv=pass; d=google.com; s=arc-20160816; b=DC7lCWif+yXoqtGLxxf8vsmHa0IJXZveVHnI/8Tbg9PbEkcjp+0o32Phkyw1JWgKJW G7mWpDCyLsqm1BR4c+qxSO6t8aYCIf1qiBxOK/DpT5oad2VVGUjxqC5ODVcA9k+vu+6a rFFZ2JOPXeSHsVcqt8w+/GatzBBIMBxmPzigEVgE0okJrgrYgmCcPayF7mhVUpaQnwCA ZIngCVyxgcPbGlVF97X7W5RxARSYDEgWjqk5vM+WS1h9F4qPzDQlyiAfpwgWqhq27s9E XkBJ1QpgqAeT9Bzm7La7HKFR/Z6UfV2LOyomzdvStb5erU6Q77iJZQB1dWQcWwdoXiP9 Fa5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AkMwwTbz1ozIs9Icu5m+NUGrp5ipJKhBiPRVK3jbRiI=; fh=T26ksdX6UpceKBTmCjnZX4okm/RnV1G8gmRkfePNArg=; b=eDc4IbXZPrlOWi61deP1lD1mkz6Nx0v6iqDosSkX04dANKQCzlzTCQu+1etFr1RvDa UgPt4wxdDcBbqa9YTXG1BEqkB/upASRvHy61UQjyj28A6YAfna6U3zdDDf9bJeoFKriS KZCCqKzwJkRJekfE1lHqXC/hy/vDYXWQxHa0SowTQeB9OrcReNw0wlI9xC81MXlhA2Go zuKR2d0Lb8yLC1P3wXBAp36sYRsQG0wjAagurCgSD2/bCPRm9MP+97+w0lTMVio6HwuS hJZP7FdvH6RRPTECGn6vZBSLSSC7lQHAcyj/nquBN4lh25ZiOFOGtaBQnzt95VJEAnEO Q9aQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QIxj0FL3; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-184275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b670f58e26si4085350a91.76.2024.05.20.15.55.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 15:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QIxj0FL3; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-184275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 330EE2812D7 for ; Mon, 20 May 2024 22:55:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B86181411FA; Mon, 20 May 2024 22:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QIxj0FL3" 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 393BF13D609 for ; Mon, 20 May 2024 22:46:59 +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=1716245221; cv=none; b=dyo3BzjzNCCFKPAHqUEXxAhHVV9nOV6lVgt/VIxwYE9ue/3M6AR5dubwcDYbT1iRJMsNxCBLgtbzIIfCcY9F+5PQsLJ0ffFbP+LS5Syc5KqJoUpQXBbuXswkBoA6sJ20XYls0lzueNepIVBDT+i6+ihF8VAVqYn6c+3lM9NPM9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716245221; c=relaxed/simple; bh=kewR2uBkcTny6f6IgFHYsgMrVAXGPg5/f1jOQ9w1xDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRHJ1EAE8qzT2rBq6nwQI9/iWcoK4HhWsaxODyEy4KsYn7/WLcUiiUxdMjr1izwsAz4QxY323YoHJd88aGm77+fYmKYbMZcAisGALX0T36kOJet1CXsA5UazECt4FmkqOa1LzxrnzMK/G2lvrcsJwFjxBwFW1v6q8rXGS+Cgdhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QIxj0FL3; arc=none smtp.client-ip=192.198.163.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716245219; x=1747781219; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kewR2uBkcTny6f6IgFHYsgMrVAXGPg5/f1jOQ9w1xDE=; b=QIxj0FL3arBZXSy8aiOslP9NtXtJQEWf5WamobWHd/I6VA3jKc913+94 HSfrv+CwyADcOlQxFSCB0n0lWZW6R6UMrzrpHQTNls+z29pf5cwas8b82 75Sscnpm7SAgtyO5VWMRWGF+3y8nThhgZ6HpYcyFGEgNO2AWE7J+jkb2x tYgrwW7adSvzvjWOjzzXa535nrhLljScNQxXEp63Hp6MLMRnPueTe9DBy 1xwk42WXvkpVWx+jG2vL2skuxAxSExF1EfBv4RNeyNI/GO4AMJa6av7E8 Jdv9X+yTi8vgGHjPlK3HiiU2LlOiaSbgZxeSvQ4JfB0RvkmBKRLy3RZ1q Q==; X-CSE-ConnectionGUID: l5GUuQcYRLSJkzRne4Mtxw== X-CSE-MsgGUID: OuxYXOqLQoaCMN5i+ShpTg== X-IronPort-AV: E=McAfee;i="6600,9927,11078"; a="12200024" X-IronPort-AV: E=Sophos;i="6.08,176,1712646000"; d="scan'208";a="12200024" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 15:46:41 -0700 X-CSE-ConnectionGUID: zq0pFpXWS6ebPr0Zi6x9gw== X-CSE-MsgGUID: 2+NlFfxISxmt/ivpRL0kAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,176,1712646000"; d="scan'208";a="32593528" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2024 15:46:40 -0700 From: Tony Luck To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Uros Bizjak , Rick Edgecombe , Arnd Bergmann , Tony Luck , Mateusz Guzik , Thomas Renninger , Andi Kleen , 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 Message-ID: <20240520224620.9480-48-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240520224620.9480-1-tony.luck@intel.com> References: <20240520224620.9480-1-tony.luck@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Update peci subsystem to use the same vendor-family-model combined definition that core x86 code uses. Signed-off-by: Tony Luck --- 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 +/* 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" #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