Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08EDE606BCA9 for ; Fri, 13 Nov 2026 16:52:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bcuMHoQZ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9192710E176; Fri, 13 Nov 2026 16:51:57 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC60610E5A8 for ; Fri, 13 Nov 2026 16:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794588707; x=1826124707; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=aSExY6XUYC0oEPjDcj/taKCl3VRcUT5EAxgzrFJNEf4=; b=bcuMHoQZK5fE9sabQR+AKS0gc2qlSshRpfZFUcqob5HXaJMqufCw2TBH xlzW5nj2fvoYC1+LpqZVGNAuFdKx5Pk/IDegc4tzwGNEiqR7YJoRjWKMC TKy9pv7TSjXpO7DsZWcUYvdoGw8dL9psSwg0GH8hvvyTxroXlQbWEXFh5 7Fj7UVv23ltcBlr9xWDwtaUmAX11iopC+Z/esGUBy+DHZ577xf2f/r921 85UOcUmGYM2PtL4DrMQYkpDtOl/KBZipJG3GkYtLSQkdBX9prRGcfz+hv FkqAtMGmY12Bn2MHEQ3FHzMTzJHj1wRSn1fkap9JcSMRy1DPmAdso2dNR Q==; X-CSE-ConnectionGUID: oVpPPxdURMqX63ChIhvGbQ== X-CSE-MsgGUID: R6h5w5ICQ2akDmwQUMFdJw== X-IronPort-AV: E=McAfee;i="6800,10657,11965"; a="3392135" X-IronPort-AV: E=Sophos;i="6.27,212,1787036400"; d="scan'208";a="3392135" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2026 08:51:37 -0800 X-CSE-ConnectionGUID: oefJ4r0LTFGia2AUSUx1mQ== X-CSE-MsgGUID: F29SnSRuSYiPB/a8K/BUCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,212,1787036400"; d="scan'208";a="9230799" Received: from mjruhl-vm.amr.corp.intel.com ([10.11.186.166]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2026 08:51:36 -0800 From: "Michael J. Ruhl" To: intel-xe@lists.freedesktop.org, 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 Subject: [PATCH v15 06/17] drm/xe/vsec: Support possible hotplug exit Date: Fri, 13 Nov 2026 08:51:32 -0800 Message-ID: <20261113165127.1989471-25-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261113165127.1989471-19-michael.j.ruhl@intel.com> References: <20261113165127.1989471-19-michael.j.ruhl@intel.com> X-Archived-By: 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-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 DRM has an API that will verify that a device is valid in the hotplug context. Verify device is valid before access in the VSEC callback API. Reviewed-by: Rodrigo Vivi Signed-off-by: Michael J. Ruhl --- drivers/gpu/drm/xe/xe_vsec.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index 082b25b017db..c0e06b2aeca6 100644 --- a/drivers/gpu/drm/xe/xe_vsec.c +++ b/drivers/gpu/drm/xe/xe_vsec.c @@ -10,6 +10,8 @@ #include #include +#include + #include "xe_device.h" #include "xe_device_types.h" #include "xe_mmio.h" @@ -159,7 +161,12 @@ static int xe_guid_decode(u32 guid, int *index, u32 *offset) * @user_offset: a user offset relative to the beginning of the data to read * @count: bytes to read * + * This is a callback API. I.e this can be accessed external to the XE driver + * (PMT driver scope). Because of this, DRM hotplug needs to be verified + * (drm_dev_enter()). + * * Return: + * * -ENODEV device is not available (hotplug) * * -ENODATA for incorrect power state * * -EINVAL for unsupported PMT feature * * count number of bytes read on success @@ -172,13 +179,17 @@ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offse u32 cap_type = FIELD_GET(GUID_CAP_TYPE, guid); u32 mem_region; u32 offset; - int ret; + int ret = 0; + int idx; xe_assert(xe, !IS_SRIOV_VF(xe)); + if (!drm_dev_enter(&xe->drm, &idx)) + return -ENODEV; + ret = xe_guid_decode(guid, &mem_region, &offset); if (ret) - return ret; + goto dev_exit; telem_addr += offset + user_offset; @@ -188,11 +199,14 @@ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offse xe_pm_runtime_get(xe); break; case TELEMETRY: - if (!xe_pm_runtime_get_if_active(xe)) - return -ENODATA; + if (!xe_pm_runtime_get_if_active(xe)) { + ret = -ENODATA; + goto dev_exit; + } break; case WATCHER: - return -EINVAL; + ret = -EINVAL; + goto dev_exit; } scoped_guard(mutex, &xe->pmt.lock) { @@ -204,7 +218,10 @@ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offse xe_pm_runtime_put(xe); - return count; +dev_exit: + drm_dev_exit(idx); + + return ret == 0 ? count : ret; } static struct pmt_callbacks xe_pmt_cb = { -- 2.43.0