From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 6495B4218B6 for ; Thu, 4 Jun 2026 16:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780590057; cv=none; b=Vvsae+XSH40MTgYtuon3GB3/kr4ubKQf/Ro27mMvNaCde3REWV4kx5uoMsas3iHMpPRAJ3aaXYCRYygKRiULGyVArXvUcEtM4oXLfmPwnjGq9SZCMZ5hXnw2w6t91dUo7fxRRt8PTQdPeaU9+kukB2iSDwRsFyH1ionRVcBcIhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780590057; c=relaxed/simple; bh=97Ofr0/iYSVM3FarcKBttj0IGxp3ung4oviHHPrxz+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dBIO8HmfP+R6Csm5KpZmH4xCdiwrnTCHy1AdwozxJUku+S6/yqrmjmd6PvbDQMoB6OoTkvkVIS50XUVeL1eWmlbXW2ce11Jnny64EA2TCEXGZBLhui+WyRcsMVCHWeT4qWCnw5HmWqpYgrxTkhZjPeZ5OjIzvMSWc+07F+gJKvo= 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=hKJF6xMz; arc=none smtp.client-ip=192.198.163.12 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="hKJF6xMz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780590056; x=1812126056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=97Ofr0/iYSVM3FarcKBttj0IGxp3ung4oviHHPrxz+I=; b=hKJF6xMzsJ3Q454mm2C2TNOe5rRwZR7znLqMBcEQ0aK1TZ6YLxEdHfbu pLdUisokPtc2hGICHUsT2NGPC8v+CLWGxv5IAU3ZBROC8zNKwpZwcvpFC 2KRWx5lbn5yWu2V5leXFrbdBqOD8YOVQjqZlGYUlnAM/p0jiEbtbLEPh3 RKlPx0eBN/tpYTJC0n8nQwXHH/9ONzHEJtkcpvq9oVAYqDtSVCS6GanuA Lg6wcp08fjPWeJu/81UNx/4bMnTq590AmfgB1p5OZ2wONj4Uoq+ka8DCL 7DMlKEzu3mYmkldUbL4PP3UAXQ0UbC17U+KpcmG5Lrem1uMh5/hYX0VtS g==; X-CSE-ConnectionGUID: 00gbbQrARsSsOasz2AFF5A== X-CSE-MsgGUID: cWb6fU+VRX2H+5w2LqzVtQ== X-IronPort-AV: E=McAfee;i="6800,10657,11807"; a="85274954" X-IronPort-AV: E=Sophos;i="6.24,187,1774335600"; d="scan'208";a="85274954" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2026 09:20:56 -0700 X-CSE-ConnectionGUID: Evom9GxpQYGI4NbtZLcYtQ== X-CSE-MsgGUID: RjmNHz01RLq/+1c41TMDFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,187,1774335600"; d="scan'208";a="244699483" Received: from chenyu-dev.sh.intel.com ([10.239.62.107]) by orviesa007.jf.intel.com with ESMTP; 04 Jun 2026 09:20:53 -0700 From: Chen Yu To: tony.luck@intel.com, reinette.chatre@intel.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de, tglx@kernel.org, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, dave.martin@arm.com, james.morse@arm.com, fenghuay@nvidia.com, babu.moger@amd.com, anil.keshavamurthy@broadcom.com Subject: [PATCH v2 2/6] x86/resctrl: Parse ACPI CMRC table Date: Fri, 5 Jun 2026 00:11:04 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The CMRC (Cache Monitoring Registers for CPU Agents Description) sub-table of ERDT describes the MMIO registers used to read cache monitoring counters (e.g. LLC occupancy) for an RMD. Parse each CMRC sub-table, ioremap its register window, and save the CMRC pointer in the corresponding ERDT domain entry so that later monitoring code can read the counters via MMIO. Suggested-by: Tony Luck Signed-off-by: Chen Yu --- arch/x86/kernel/cpu/resctrl/erdt.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/erdt.c b/arch/x86/kernel/cpu/resctrl/erdt.c index 3f309a4b15c8..d1eca4594f09 100644 --- a/arch/x86/kernel/cpu/resctrl/erdt.c +++ b/arch/x86/kernel/cpu/resctrl/erdt.c @@ -38,6 +38,7 @@ static bool erdt_available; static DEFINE_XARRAY(erdt_domain_xa); /* Indexed by L3 cache ID */ #define ERDT_VALID_VERSION 1 +#define CMRC_VALID_INDEX_FUNC_VERSION 1 static u32 valid_subtbl_mask; @@ -159,6 +160,7 @@ static void erdt_iounmap_domain(struct erdt_domain_info *domain) static void cleanup_one_domain(struct erdt_domain_info *d) { erdt_iounmap_domain(d); + kfree(d->cmrc); kfree(d); } @@ -171,6 +173,40 @@ static __init bool cacd_init(struct erdt_domain_info *d, return *l3_cache_id != -1; } +static __init bool cmrc_init(struct erdt_domain_info *d, struct acpi_subtbl_hdr_16 *subtbl) +{ + struct acpi_erdt_cmrc *cmrc = (struct acpi_erdt_cmrc *)subtbl; + + if (subtbl->length < sizeof(*cmrc)) { + pr_warn(FW_BUG "Truncated CMRC subtable\n"); + return false; + } + + if (cmrc->index_fn != CMRC_VALID_INDEX_FUNC_VERSION) { + pr_info("Unknown CMRC index function %d\n", cmrc->index_fn); + return false; + } + + if (!cmrc->clump_size) { + pr_warn(FW_BUG "CMRC clump_size is zero\n"); + return false; + } + + d->base[ERDT_MMIO_CMRC_BASE] = erdt_ioremap_checked(cmrc->cmt_reg_base, + cmrc->cmt_reg_size, "CMRC base"); + if (!d->base[ERDT_MMIO_CMRC_BASE]) + return false; + + d->cmrc = kmemdup(cmrc, subtbl->length, GFP_KERNEL); + if (!d->cmrc) { + iounmap(d->base[ERDT_MMIO_CMRC_BASE]); + d->base[ERDT_MMIO_CMRC_BASE] = NULL; + return false; + } + + return true; +} + static __init bool parse_rmdd_entry(struct acpi_subtbl_hdr_16 *rmdd_hdr) { struct acpi_erdt_rmdd *rmdd; @@ -219,6 +255,10 @@ static __init bool parse_rmdd_entry(struct acpi_subtbl_hdr_16 *rmdd_hdr) if (cacd_init(domain_info, subtbl, &l3_cache_id)) subtbl_mask |= BIT(ACPI_ERDT_TYPE_CACD); break; + case ACPI_ERDT_TYPE_CMRC: + if (cmrc_init(domain_info, subtbl)) + subtbl_mask |= BIT(ACPI_ERDT_TYPE_CMRC); + break; default: break; } -- 2.25.1