Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3272EC982D6 for ; Wed, 16 Sep 2026 20:12:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C974A10E548; Wed, 16 Sep 2026 20:12:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="f8PHpUAR"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF8ED10E3C2 for ; Wed, 16 Sep 2026 20:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789589522; x=1821125522; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=SrJP7AW1S4q1Ezbf7jNnltk8lpIEsdm0flPJUiY4394=; b=f8PHpUARZUAxHL3Cb8J2QIjykRplWJbxwWehcqrqNcS0YiN9KcXoMAIl 5wBgZ8MxBAjIA7ZmrhgkE5jEzdfBe27l34R2wgpBBNvN3oXpJ4n/GqIoH bFN43lUmWQP2kwdJmijSui47EuEdFE3rch5AeFoBpx11itje6Z9JU2Gdy vDAlzHPHqDKibg4B3WsrwWZ45gZLfOVuyr2LYIZfNnmcs+uqZUbcLT6dO bjntbagLHwRzAAq/+zeojxcZojoJVlGU3iLyEvqN8uKioH1sbAbHCYBnC fKdD4J4D2NNVxovXLfGV4SwplUpsT0j5TdkpETVy5ph1nEvr4sVqLUNxh w==; X-CSE-ConnectionGUID: m7Poid6AR3SzzIAfkKX5yg== X-CSE-MsgGUID: psD25ZtTSYuDTKuI9WHZrw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="100296212" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="100296212" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 13:12:02 -0700 X-CSE-ConnectionGUID: CkvfGguFTq6irP8jsA9nyQ== X-CSE-MsgGUID: KlNHJ4pHSWqHcrnMZA4JHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="277574044" Received: from mjruhl-vm.amr.corp.intel.com ([10.11.186.166]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2026 13:12:02 -0700 From: "Michael J. Ruhl" To: platform-driver-x86@vger.kernel.org, intel-xe@lists.freedesktop.org, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, matthew.brost@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com, airlied@gmail.com, simona@ffwll.ch, david.e.box@linux.intel.com, anoop.c.vijay@intel.com, badal.nilawar@intel.com, matthew.d.roper@intel.com, james.ausmus@intel.com, karthik.poosa@intel.com Subject: [PATCH v9 16/20] drm/xe/vsec: Crescent Island PMT callbacks Date: Wed, 16 Sep 2026 13:11:54 -0700 Message-ID: <20260916201139.2374531-38-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260916201139.2374531-22-michael.j.ruhl@intel.com> References: <20260916201139.2374531-22-michael.j.ruhl@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" CRI PMT support requires callbacks to access the discovery status and control areas. Access is a common MMIO area that requires an index to be set before access is allowed. Introduce the necessary callbacks to get the status and control information for CRI PMT usage. Add the glue logic to register the CRI PMT functionality. Signed-off-by: Michael J. Ruhl --- drivers/gpu/drm/xe/xe_vsec.c | 115 +++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index 95d3150f701a..d1427ec50728 100644 --- a/drivers/gpu/drm/xe/xe_vsec.c +++ b/drivers/gpu/drm/xe/xe_vsec.c @@ -357,20 +357,120 @@ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offse return ret == 0 ? count : ret; } -static struct pmt_callbacks xe_pmt_cb = { +/** + * xe_pmt_read_reg() - read a crashlog register + * @dev: the xe device that registered the callback + * @guid: PMT guid of the crashlog instance + * @reg: data read from the PMT data structure + * @offset: which data to read from the PMT data structure + * + * Read the requested PMT register based on the pcie device and guid. The + * supported struct is the Crashlog Type1 Version2. + * + * Currently this is for CRI only. + * + * Return: + * * -ENODEV device is not available (hotplug) + * * -EINVAL invalid guid + * * 0 success + */ +static int xe_pmt_read_reg(struct device *dev, u32 guid, u32 *reg, u32 offset) +{ + struct xe_device *xe = kdev_to_xe_device(dev); + void __iomem *disc_addr = xe->mmio.regs + xe->pmt.base_offset; + int ret = 0; + u32 inst; + int idx; + + if (!drm_dev_enter(&xe->drm, &idx)) + return -ENODEV; + + if (FIELD_GET(GUID_DEVICE_ID, guid) != CRI_DEVICE_ID || + FIELD_GET(GUID_CAP_TYPE, guid) != CRASHLOG) { + ret = -EINVAL; + goto dev_exit; + } + + inst = FIELD_GET(GUID_RECORD_ID, guid) == PUNIT ? + CRI_CRASHLOG_PUNIT_DISC_OFFSET : CRI_CRASHLOG_OOBMSM_DISC_OFFSET; + disc_addr += inst + offset; + + xe_pm_runtime_get(xe); + + scoped_guard(mutex, &xe->pmt.lock) { + xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY); + + *reg = readl(disc_addr); + } + + xe_pm_runtime_put(xe); + +dev_exit: + drm_dev_exit(idx); + + return ret; +} + +static int xe_pmt_write_reg(struct device *dev, u32 guid, u32 reg, u32 offset) +{ + struct xe_device *xe = kdev_to_xe_device(dev); + void __iomem *disc_addr = xe->mmio.regs + xe->pmt.base_offset; + int ret = 0; + u32 inst; + int idx; + + if (!drm_dev_enter(&xe->drm, &idx)) + return -ENODEV; + + if (FIELD_GET(GUID_DEVICE_ID, guid) != CRI_DEVICE_ID || + FIELD_GET(GUID_CAP_TYPE, guid) != CRASHLOG) { + ret = -EINVAL; + goto dev_exit; + } + + inst = FIELD_GET(GUID_RECORD_ID, guid) == PUNIT ? + CRI_CRASHLOG_PUNIT_DISC_OFFSET : CRI_CRASHLOG_OOBMSM_DISC_OFFSET; + disc_addr += inst + offset; + + xe_pm_runtime_get(xe); + + scoped_guard(mutex, &xe->pmt.lock) { + xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY); + + writel(reg, disc_addr); + } + + xe_pm_runtime_put(xe); + +dev_exit: + drm_dev_exit(idx); + + return ret; +} + +static struct pmt_callbacks xe_bmg_pmt_cb = { + .read_telem = xe_pmt_telem_read, +}; + +static struct pmt_callbacks xe_cri_pmt_cb = { .read_telem = xe_pmt_telem_read, + .read_reg = xe_pmt_read_reg, + .write_reg = xe_pmt_write_reg, }; static const int vsec_platforms[] = { [XE_BATTLEMAGE] = XE_VSEC_BMG, + [XE_CRESCENTISLAND] = XE_VSEC_CRI, }; static enum xe_vsec get_platform_info(struct xe_device *xe) { - if (xe->info.platform > XE_BATTLEMAGE) + if (xe->info.platform > XE_CRESCENTISLAND) return XE_VSEC_UNKNOWN; - if (IS_SRIOV_VF(xe) && (xe->info.platform == XE_BATTLEMAGE)) + if (IS_SRIOV_VF(xe) && + (xe->info.platform == XE_BATTLEMAGE || + xe->info.platform == XE_CRESCENTISLAND)) return XE_VSEC_UNKNOWN; return vsec_platforms[xe->info.platform]; @@ -398,8 +498,15 @@ void xe_vsec_init(struct xe_device *xe) switch (platform) { case XE_VSEC_BMG: xe->pmt.base_offset = BMG_TELEMETRY_OFFSET; - info->priv_data = &xe_pmt_cb; + info->priv_data = &xe_bmg_pmt_cb; break; + + case XE_VSEC_CRI: + xe->pmt.base_offset = CRI_PMT_OFFSET; + info->priv_data = &xe_cri_pmt_cb; + xe->soc_remapper.set_telem_region(xe, CRI_IDX_TELEM_DISCOVERY); + break; + default: break; } -- 2.43.0