mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tony Luck <tony.luck@intel.com>
To: Fenghua Yu <fenghuay@nvidia.com>,
	Reinette Chatre <reinette.chatre@intel.com>,
	Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
	Peter Newman <peternewman@google.com>,
	James Morse <james.morse@arm.com>,
	Babu Moger <babu.moger@amd.com>,
	Drew Fustini <dfustini@baylibre.com>,
	Dave Martin <Dave.Martin@arm.com>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	Tony Luck <tony.luck@intel.com>
Subject: [PATCH v2 01/16] x86/rectrl: Fake OOBMSM interface
Date: Fri, 21 Mar 2025 16:15:51 -0700	[thread overview]
Message-ID: <20250321231609.57418-2-tony.luck@intel.com> (raw)
In-Reply-To: <20250321231609.57418-1-tony.luck@intel.com>

Real version is coming soon ... this is here so the remaining parts
will build (and run ... assuming a 2 socket system that supports RDT
monitoring ... only missing part is that the event counters just
report fixed values).

Real version of this would just add the INTEL_AET_RESCTRL Kconfig
option with dependency checks on
  INTEL_VSEC=y && INTEL_AET_TELEMETRY=y && INTEL_AET_DISCOVERY=y

Just for RFC discussion.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 .../cpu/resctrl/fake_intel_aet_features.h     | 73 +++++++++++++++++++
 .../cpu/resctrl/fake_intel_aet_features.c     | 65 +++++++++++++++++
 arch/x86/Kconfig                              |  1 +
 arch/x86/kernel/cpu/resctrl/Makefile          |  1 +
 drivers/platform/x86/intel/pmt/Kconfig        |  3 +
 5 files changed, 143 insertions(+)
 create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
 create mode 100644 arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c

diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
new file mode 100644
index 000000000000..c835c4108abc
--- /dev/null
+++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.h
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/* Bits stolen from OOBMSM VSEC discovery code */
+
+enum pmt_feature_id {
+	FEATURE_INVALID			= 0x0,
+	FEATURE_PER_CORE_PERF_TELEM	= 0x1,
+	FEATURE_PER_CORE_ENV_TELEM	= 0x2,
+	FEATURE_PER_RMID_PERF_TELEM	= 0x3,
+	FEATURE_ACCEL_TELEM		= 0x4,
+	FEATURE_UNCORE_TELEM		= 0x5,
+	FEATURE_CRASH_LOG		= 0x6,
+	FEATURE_PETE_LOG		= 0x7,
+	FEATURE_TPMI_CTRL		= 0x8,
+	FEATURE_RESERVED		= 0x9,
+	FEATURE_TRACING			= 0xA,
+	FEATURE_PER_RMID_ENERGY_TELEM	= 0xB,
+	FEATURE_MAX			= 0xB,
+};
+
+/**
+ * struct oobmsm_plat_info - Platform information for a device instance
+ * @cdie_mask:       Mask of all compute dies in the partition
+ * @package_id:      CPU Package id
+ * @partition:       Package partition id when multiple VSEC PCI devices per package
+ * @segment:         PCI segment ID
+ * @bus_number:      PCI bus number
+ * @device_number:   PCI device number
+ * @function_number: PCI function number
+ *
+ * Structure to store platform data for a OOBMSM device instance.
+ */
+struct oobmsm_plat_info {
+	u16 cdie_mask;
+	u8 package_id;
+	u8 partition;
+	u8 segment;
+	u8 bus_number;
+	u8 device_number;
+	u8 function_number;
+};
+
+enum oobmsm_supplier_type {
+	OOBMSM_SUP_PLAT_INFO,
+	OOBMSM_SUP_DISC_INFO,
+	OOBMSM_SUP_S3M_SIMICS,
+	OOBMSM_SUP_TYPE_MAX
+};
+
+struct oobmsm_mapping_supplier {
+	struct device *supplier_dev[OOBMSM_SUP_TYPE_MAX];
+	struct oobmsm_plat_info plat_info;
+	unsigned long features;
+};
+
+struct telemetry_region {
+	struct oobmsm_plat_info	plat_info;
+	void __iomem		*addr;
+	size_t			size;
+	u32			guid;
+	u32			num_rmids;
+};
+
+struct pmt_feature_group {
+	enum pmt_feature_id	id;
+	int			count;
+	struct kref		kref;
+	struct telemetry_region	regions[];
+};
+
+struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_feature_id id);
+
+void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group);
diff --git a/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c
new file mode 100644
index 000000000000..b537068d99fb
--- /dev/null
+++ b/arch/x86/kernel/cpu/resctrl/fake_intel_aet_features.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/cleanup.h>
+#include <linux/minmax.h>
+#include <linux/slab.h>
+#include "fake_intel_aet_features.h"
+#include <linux/intel_vsec.h>
+#include <linux/resctrl.h>
+
+#include "internal.h"
+
+#define ENERGY_QWORDS	((576 * 2) + 3)
+#define PERF_QWORDS	((576 * 7) + 3)
+
+static long pg[4 * ENERGY_QWORDS + 2 * PERF_QWORDS];
+
+static int __init fill(void)
+{
+	u64 val = 0;
+
+	for (int i = 0; i < sizeof(pg); i += sizeof(val)) {
+		pg[i / sizeof(val)] = BIT_ULL(63) + val;
+		val++;
+	}
+	return 0;
+}
+device_initcall(fill);
+
+#define PKG_REGION(_entry, _guid, _addr, _pkg)	\
+	[_entry] = { .guid = _guid, .addr = (void __iomem *)_addr, .plat_info = { .package_id = _pkg }}
+
+static struct pmt_feature_group fake_energy = {
+	.count = 4,
+	.regions = {
+		PKG_REGION(0, 0x26696143, &pg[0 * ENERGY_QWORDS], 0),
+		PKG_REGION(1, 0x26696143, &pg[1 * ENERGY_QWORDS], 0),
+		PKG_REGION(2, 0x26696143, &pg[2 * ENERGY_QWORDS], 1),
+		PKG_REGION(3, 0x26696143, &pg[3 * ENERGY_QWORDS], 1)
+	}
+};
+
+static struct pmt_feature_group fake_perf = {
+	.count = 2,
+	.regions = {
+		PKG_REGION(0, 0x26557651, &pg[4 * ENERGY_QWORDS + 0 * PERF_QWORDS], 0),
+		PKG_REGION(1, 0x26557651, &pg[4 * ENERGY_QWORDS + 1 * PERF_QWORDS], 1)
+	}
+};
+
+struct pmt_feature_group *
+intel_pmt_get_regions_by_feature(enum pmt_feature_id id)
+{
+	switch (id) {
+	case FEATURE_PER_RMID_ENERGY_TELEM:
+		return &fake_energy;
+	case FEATURE_PER_RMID_PERF_TELEM:
+		return &fake_perf;
+	default:
+		return ERR_PTR(-ENOENT);
+	}
+	return ERR_PTR(-ENOENT);
+}
+
+void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group)
+{
+}
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ea29d22a621f..6112cb6cad05 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -504,6 +504,7 @@ config X86_CPU_RESCTRL
 	bool "x86 CPU resource control support"
 	depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
 	depends on MISC_FILESYSTEMS
+	select INTEL_AET_RESCTRL	if X86_64
 	select ARCH_HAS_CPU_RESCTRL
 	select RESCTRL_FS
 	select RESCTRL_FS_PSEUDO_LOCK
diff --git a/arch/x86/kernel/cpu/resctrl/Makefile b/arch/x86/kernel/cpu/resctrl/Makefile
index 909be78ec6da..2c3b09f95127 100644
--- a/arch/x86/kernel/cpu/resctrl/Makefile
+++ b/arch/x86/kernel/cpu/resctrl/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_X86_CPU_RESCTRL)		+= core.o rdtgroup.o monitor.o
 obj-$(CONFIG_X86_CPU_RESCTRL)		+= ctrlmondata.o
 obj-$(CONFIG_RESCTRL_FS_PSEUDO_LOCK)	+= pseudo_lock.o
+obj-$(CONFIG_INTEL_AET_RESCTRL)		+= fake_intel_aet_features.o
 
 # To allow define_trace.h's recursive include:
 CFLAGS_pseudo_lock.o = -I$(src)
diff --git a/drivers/platform/x86/intel/pmt/Kconfig b/drivers/platform/x86/intel/pmt/Kconfig
index e916fc966221..6d3b1f64efe9 100644
--- a/drivers/platform/x86/intel/pmt/Kconfig
+++ b/drivers/platform/x86/intel/pmt/Kconfig
@@ -38,3 +38,6 @@ config INTEL_PMT_CRASHLOG
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called intel_pmt_crashlog.
+
+config INTEL_AET_RESCTRL
+	bool
-- 
2.48.1


  reply	other threads:[~2025-03-21 23:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21 23:15 [PATCH v2 00/16] x86/resctrl telemetry monitoring Tony Luck
2025-03-21 23:15 ` Tony Luck [this message]
2025-03-31 16:14   ` [PATCH v2 01/16] x86/rectrl: Fake OOBMSM interface Reinette Chatre
2025-03-31 21:09     ` Luck, Tony
2025-03-21 23:15 ` [PATCH v2 02/16] x86/resctrl: Move L3 initialization out of domain_add_cpu_mon() Tony Luck
2025-03-21 23:15 ` [PATCH v2 03/16] x86/resctrl: Refactor domain_remove_cpu_mon() ready for new domain types Tony Luck
2025-03-21 23:15 ` [PATCH v2 04/16] x86/resctrl: Change generic monitor functions to use struct rdt_domain_hdr Tony Luck
2025-03-31 16:15   ` Reinette Chatre
2025-03-31 21:14     ` Luck, Tony
2025-03-21 23:15 ` [PATCH v2 05/16] x86/resctrl: Add and initialize rdt_resource for package scope core monitor Tony Luck
2025-03-31 16:18   ` Reinette Chatre
2025-03-31 21:22     ` Luck, Tony
2025-03-31 23:49       ` Reinette Chatre
2025-03-21 23:15 ` [PATCH v2 06/16] x86/resctrl: Prepare for resource specific event ids Tony Luck
2025-03-21 23:15 ` [PATCH v2 07/16] x86/resctrl: Add initialization hook for Intel PMT events Tony Luck
2025-03-31 16:20   ` Reinette Chatre
2025-03-31 21:53     ` Luck, Tony
2025-04-01  0:07       ` Reinette Chatre
2025-03-21 23:15 ` [PATCH v2 08/16] x86/resctrl: Add Intel PMT domain specific code Tony Luck
2025-03-21 23:15 ` [PATCH v2 09/16] x86/resctrl: Add detailed descriptions for Clearwater Forest events Tony Luck
2025-03-31 16:21   ` Reinette Chatre
2025-03-31 22:07     ` Luck, Tony
2025-04-01  0:13       ` Reinette Chatre
2025-03-21 23:16 ` [PATCH v2 10/16] x86/resctrl: Allocate per-package structures for known events Tony Luck
2025-03-31 16:21   ` Reinette Chatre
2025-03-31 22:23     ` Luck, Tony
2025-04-01  0:22       ` Luck, Tony
2025-03-21 23:16 ` [PATCH v2 11/16] x86/resctrl: Link known events onto RDT_RESOURCE_INTEL_AET.evt_list Tony Luck
2025-03-31 16:23   ` Reinette Chatre
2025-03-31 22:29     ` Luck, Tony
2025-03-21 23:16 ` [PATCH v2 12/16] x86/resctrl: Build lookup table for package events Tony Luck
2025-03-21 23:16 ` [PATCH v2 13/16] x86/resctrl: Add code to display core telemetry events Tony Luck
2025-03-31 16:23   ` Reinette Chatre
2025-03-31 22:42     ` Luck, Tony
2025-03-21 23:16 ` [PATCH v2 14/16] x86/resctrl: Add status files to info/PKG_MON Tony Luck
2025-03-21 23:16 ` [PATCH v2 15/16] x86/resctrl: Enable package event monitoring Tony Luck
2025-03-21 23:16 ` [PATCH v2 16/16] x86/resctrl: Update Documentation for package events Tony Luck

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=20250321231609.57418-2-tony.luck@intel.com \
    --to=tony.luck@intel.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=patches@lists.linux.dev \
    --cc=peternewman@google.com \
    --cc=reinette.chatre@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

all inboxes | Powered by JetHome®