From nobody Wed Oct 8 16:43:48 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 6650E2EF9DF for ; Thu, 26 Jun 2025 16:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750956606; cv=none; b=FsXrVdAgZcD+uSsM7pY0x0kTxowr+ueGsbVftITC8/41PJGTW6PXIzP7vKnWigfq6a/QFzCWeGTU8mbmAoohi43ay9wqcQv3JuzEnk8TycWBnnhQrJ8BPDmpbu0mdFMhBMvDgbyoE79CaI8gxgc8BMgkzr+rb1jGcfFMERs6Nm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750956606; c=relaxed/simple; bh=/dVildZ2z+SGctJJUuboEilq0TwsoT2gkP4IyXcUnjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pI/AMaInWqVIZNppXunEdd91B0xspbRd8Vaa37zKNQ4NPsZw6MEQe29M0Th4wnSTR1FVVXg+8aNJ/CUS1oskKtUyK0mi+c8OHv8tancwPoA4HkeRJufg8Z4jvrpW3iHIrCgLNILCBSiRpCWIeSA3C0IoOI/EOuHz9ydiwCAkn5Q= 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=XVDL/Wv4; arc=none smtp.client-ip=198.175.65.19 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XVDL/Wv4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1750956605; x=1782492605; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/dVildZ2z+SGctJJUuboEilq0TwsoT2gkP4IyXcUnjg=; b=XVDL/Wv4hn9MX92WnVeHnnqnQ56A8mFfcFBF9rvFusqHE/WMdU9sd3Pn wQBdXMm/C0rlxW4pgHungKsn0X7dHfTxWekdLHF1iffTyGltb+whE0o4T A5trt5N5Z0tRLRf3gwmc1mIIvnTJnT2S5KbGml5JXpR1qjkd95FurYPfQ ZwHmO/iMB7cJAsCSd+xsdfbVlWnvH+YiSBj0DOb6g946SQR0Xs9s2GPKw gL8IzWfNwhzBmDYy3qkXN/A+eT8CkCAhmeMWKvTYpav5zdF6LbIPF0WaO L3ogyH3bt7cKKYzQcKmFuNujMayI36CySyJYkHhPuitRbS+thO5t424mj w==; X-CSE-ConnectionGUID: qbIBq3sOROqcV9Lt1crQ+Q== X-CSE-MsgGUID: /KGK+3LnQouEqyhJqTINEQ== X-IronPort-AV: E=McAfee;i="6800,10657,11476"; a="53136461" X-IronPort-AV: E=Sophos;i="6.16,268,1744095600"; d="scan'208";a="53136461" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2025 09:49:59 -0700 X-CSE-ConnectionGUID: 1zdv6IPmRQmEqCKZMysuqg== X-CSE-MsgGUID: 7SUT49TNR4+fP5T0smFqVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,268,1744095600"; d="scan'208";a="153069258" Received: from agluck-desk3.sc.intel.com ([172.25.103.51]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2025 09:49:58 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Anil Keshavamurthy , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v6 18/30] x86/resctrl: Count valid telemetry aggregators per package Date: Thu, 26 Jun 2025 09:49:27 -0700 Message-ID: <20250626164941.106341-19-tony.luck@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250626164941.106341-1-tony.luck@intel.com> References: <20250626164941.106341-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: quoted-printable Content-Type: text/plain; charset="utf-8" There may be multiple telemetry aggregators per package, each enumerated by a telemetry region structure in the feature group. Scan the array of telemetry region structures and count how many are in each package in preparation to allocate structures to save the MMIO addresses for each in a convenient format for use when reading event counters. Sanity check that the telemetry region structures have a valid package_id and that the size they report for the MMIO space is as large as expected from the XML description of the registers in the region. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/intel_aet.c | 55 ++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/= resctrl/intel_aet.c index b09044b093dd..8d67ed709a74 100644 --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include "internal.h" =20 @@ -24,6 +25,7 @@ * within the OOBMSM driver that contains data for all * telemetry regions. * @guid: Unique number per XML description file. + * @mmio_size: Number of bytes of MMIO registers for this group. */ struct event_group { /* Data fields for additional structures to manage this group. */ @@ -31,14 +33,19 @@ struct event_group { =20 /* Remaining fields initialized from XML file. */ u32 guid; + size_t mmio_size; }; =20 +#define XML_MMIO_SIZE(num_rmids, num_events, num_extra_status) \ + (((num_rmids) * (num_events) + (num_extra_status)) * sizeof(u64)) + /* * Link: https://github.com/intel/Intel-PMT * File: xml/CWF/OOBMSM/RMID-ENERGY/cwf_aggregator.xml */ static struct event_group energy_0x26696143 =3D { .guid =3D 0x26696143, + .mmio_size =3D XML_MMIO_SIZE(576, 2, 3), }; =20 /* @@ -47,6 +54,7 @@ static struct event_group energy_0x26696143 =3D { */ static struct event_group perf_0x26557651 =3D { .guid =3D 0x26557651, + .mmio_size =3D XML_MMIO_SIZE(576, 7, 3), }; =20 static struct event_group *known_event_groups[] =3D { @@ -56,10 +64,53 @@ static struct event_group *known_event_groups[] =3D { =20 #define NUM_KNOWN_GROUPS ARRAY_SIZE(known_event_groups) =20 -/* Stub for now */ +static bool skip_this_region(struct telemetry_region *tr, struct event_gro= up *e) +{ + if (tr->guid !=3D e->guid) + return true; + if (tr->plat_info.package_id >=3D topology_max_packages()) { + pr_warn_once("Bad package %d in guid 0x%x\n", tr->plat_info.package_id, + tr->guid); + return true; + } + if (tr->size < e->mmio_size) { + pr_warn_once("MMIO space %zu too small for guid 0x%x\n", tr->size, e->gu= id); + return true; + } + + return false; +} + +/* + * Configure events from one pmt_feature_group. + * 1) Count how many per package. + * 2...) To be continued. + */ static int configure_events(struct event_group *e, struct pmt_feature_grou= p *p) { - return -EINVAL; + int *pkgcounts __free(kfree) =3D NULL; + struct telemetry_region *tr; + int num_pkgs; + + num_pkgs =3D topology_max_packages(); + + /* Get per-package counts of telemetry_regions for this event group */ + for (int i =3D 0; i < p->count; i++) { + tr =3D &p->regions[i]; + if (skip_this_region(tr, e)) + continue; + if (!pkgcounts) { + pkgcounts =3D kcalloc(num_pkgs, sizeof(*pkgcounts), GFP_KERNEL); + if (!pkgcounts) + return -ENOMEM; + } + pkgcounts[tr->plat_info.package_id]++; + } + + if (!pkgcounts) + return -ENODEV; + + return 0; } =20 DEFINE_FREE(intel_pmt_put_feature_group, struct pmt_feature_group *, --=20 2.49.0