From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 2C5F833F5B4 for ; Fri, 10 Apr 2026 20:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; cv=none; b=eU4NX8/bPluV+uGiS5EL/vrvTmNEw0iIU8z3lxUErdMghMm+lwxqXNYv1esXzEI7mkccGwaGK86UZxCnX8VuTI2jsJUhGBVTx7kH1/NT7xw3wQFhxweKyWhNgUnVmt/3BikymxGRuCM1jrgBy0xxvZz5UxSPIpXd52JvIPJxces= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775851543; c=relaxed/simple; bh=iV4S5j2BrthBeOJkRN+K1btg+O2lMEcy08RQXWT+Hj0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pxNbVTOKoCZ59eXh9SeUisFSugdvsIQHPn7m2z/nPkxn810/4bHlsijNCc6tzaHDCzEOAwsdXx5HxM2KwTF/7dKHmC0pCtVZtVPaFq+XZdJCP7YujskLFVMRKF7F4KV+WyqmhqRw38ywY2plLB8vJl7KNxS2YDZnO+BHT2wIhc8= 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=nXV/eBDI; arc=none smtp.client-ip=198.175.65.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nXV/eBDI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1775851542; x=1807387542; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iV4S5j2BrthBeOJkRN+K1btg+O2lMEcy08RQXWT+Hj0=; b=nXV/eBDIZy1a6i73Z1qQ+mY6J2S58kJ7zn6riwftNzlWNiSwVnWxmy5S AyZHZxWG5+BqnRgFHKDB9RegnbEjY4Mi+DKsXhDSxJPkmfnzXshWIMBCy rwGxfUiaYKzJSuulbbZ6zeHYhXNZBh0SKmfaCi+qGD31FJuNvr4/0XAlP Y4SsA1v4Ki78VeD4OL8WqEm6TAvKcky6KIHgTULRBi2JmFl004aNqfT5V F4wSlfGYAnAAFhsJYRvZZwF2SLRKg4+jk9FqfAzm6Mu4gZ+Xo/kLFEPkS tX4T1IAQHXwHnwXB7QQln9Z2eOaRPavI/i4jZl1EywHiFwRAXgq10yl9R g==; X-CSE-ConnectionGUID: 4lxxSq3BR/q/zoAt0aSMCw== X-CSE-MsgGUID: YteNvb9cR+SD5iGGRKBkWQ== X-IronPort-AV: E=McAfee;i="6800,10657,11755"; a="76898088" X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="76898088" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:41 -0700 X-CSE-ConnectionGUID: ibWS4kWOSPiuRpWr1/m+vQ== X-CSE-MsgGUID: z3Dcjo0sRvK8lFRSOni/Aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,172,1770624000"; d="scan'208";a="228155017" Received: from khuang2-desk.gar.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.106]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2026 13:05:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu , David E Box , x86@kernel.org Cc: Christoph Hellwig , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [RFC PATCH v5 4/7] platform/x86/intel/pmt: Register enumeration functions with resctrl Date: Fri, 10 Apr 2026 13:05:29 -0700 Message-ID: <20260410200532.58602-5-tony.luck@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260410200532.58602-1-tony.luck@intel.com> References: <20260410200532.58602-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 INTEL_PMT_TELEMETRY is a loadable module, but resctrl is built-in and cannot call PMT functions directly. Register the telemetry enumeration function pointers at resctrl module init, and unregister them at module exit. Add module_{get,put} calls to the PMT get/put functions to ensure that INTEL_PMT_TELEMETRY cannot be unloaded while resctrl is mounted and referencing the MMIO register space mapped by INTEL_PMT_TELEMETRY. Note that checkpatch complains about the #include of . This is needed rather than to get the function stub definitions when CONFIG_X86_CPU_RESCTRL=n. Suggested-by: Christoph Hellwig Signed-off-by: Tony Luck --- drivers/platform/x86/intel/pmt/telemetry.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/x86/intel/pmt/telemetry.c b/drivers/platform/x86/intel/pmt/telemetry.c index a52803bfe124..e76927cabc97 100644 --- a/drivers/platform/x86/intel/pmt/telemetry.c +++ b/drivers/platform/x86/intel/pmt/telemetry.c @@ -25,6 +25,8 @@ #include #include +#include + #include "class.h" #define TELEM_SIZE_OFFSET 0x0 @@ -283,6 +285,9 @@ struct pmt_feature_group *intel_pmt_get_regions_by_feature(enum pmt_feature_id i region++; } + if (!try_module_get(THIS_MODULE)) + return ERR_PTR(-EINVAL); + kref_init(&feature_group->kref); return no_free_ptr(feature_group); @@ -292,6 +297,7 @@ EXPORT_SYMBOL(intel_pmt_get_regions_by_feature); void intel_pmt_put_feature_group(struct pmt_feature_group *feature_group) { kref_put(&feature_group->kref, pmt_feature_group_release); + module_put(THIS_MODULE); } EXPORT_SYMBOL(intel_pmt_put_feature_group); @@ -404,6 +410,9 @@ static int pmt_telem_probe(struct auxiliary_device *auxdev, const struct auxilia intel_pmt_get_features(entry); } + intel_aet_register_enumeration(intel_pmt_get_regions_by_feature, + intel_pmt_put_feature_group); + return 0; abort_probe: pmt_telem_remove(auxdev); @@ -432,6 +441,7 @@ static void __exit pmt_telem_exit(void) { auxiliary_driver_unregister(&pmt_telem_aux_driver); xa_destroy(&telem_array); + intel_aet_unregister_enumeration(); } module_exit(pmt_telem_exit); -- 2.53.0