From mboxrd@z Thu Jan 1 00:00:00 1970 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 7D125C5DF81 for ; Mon, 24 Aug 2026 16:23:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17D7B10E571; Mon, 24 Aug 2026 16:23:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="m9vKtV6r"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF87B10E7DC for ; Mon, 24 Aug 2026 16:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1787588618; x=1819124618; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=rD+Y1t48ifLIw+TBZl9hOPk6vbUMvzLDbJ2K8OgIczs=; b=m9vKtV6r5c1w7NhIxyReOI5Ve2JLmYGNpuNu74v+yPgafKypaqCtKWWB osCtteLhUBRTgOBnK01ZoFWSUo0K/GuWG4hdT3O5jZF+wHjubwAAu1grG yE6sWsLzF/EgUOSck/+FqjZ22XdzZTkaP+DANnScyLyVcsnWrP8+1xpYP r6NdL4f5YO8SDaZlsnMI2J7ApwHCCyABG0QEzFOq6YPJjZGgkXed/zUWI QnUaXLDtDMk7WJD8ykuKV4RZQdAWb2n6iYr7I8e1V71FSPIAgX4cbrMD0 5CsjZYboi6wJz3CVqsxrsG9PkKLEmadhuJSMrsi6wQoF15xAgKLmI+puh A==; X-CSE-ConnectionGUID: gKiVxrOmRcqZWC8Sq4Olqw== X-CSE-MsgGUID: TqrosdYhTsmIoYcPxL5yCQ== X-IronPort-AV: E=McAfee;i="6800,10657,11885"; a="91858081" X-IronPort-AV: E=Sophos;i="6.25,240,1779174000"; d="scan'208";a="91858081" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2026 09:23:38 -0700 X-CSE-ConnectionGUID: ltqfpg9gQZmFbcOpLbDxtw== X-CSE-MsgGUID: o4m/bEPrSWSAXSCYFeA15w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,240,1779174000"; d="scan'208";a="267088139" Received: from mjruhl-vm.amr.corp.intel.com ([10.11.186.166]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2026 09:23:39 -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 v3 05/10] drm/xe/vsec: Support possible hotplug exit Date: Mon, 24 Aug 2026 09:23:21 -0700 Message-ID: <20260824162317.2450380-17-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260824162317.2450380-12-michael.j.ruhl@intel.com> References: <20260824162317.2450380-12-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" 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. Signed-off-by: Michael J. Ruhl --- drivers/gpu/drm/xe/xe_vsec.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index 8d99a3770b5a..8abe11e6312f 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" @@ -140,6 +142,11 @@ static int xe_guid_decode(u32 guid, int *index, u32 *offset) return 0; } +/* + * xe_pmt_telem_read is a callback API. I.e this can be accessed external to + * XE driver (PMT driver scope). Because of this, DRM hotplug needs to be + * verified (drm_dev_enter()). + */ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offset, u32 count) { @@ -148,14 +155,20 @@ 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; - if (!xe->soc_remapper.set_telem_region) + if (!drm_dev_enter(&xe->drm, &idx)) return -ENODEV; + if (!xe->soc_remapper.set_telem_region) { + ret = -EINVAL; + goto dev_exit; + } + ret = xe_guid_decode(guid, &mem_region, &offset); if (ret) - return ret; + goto dev_exit; telem_addr += offset + user_offset; @@ -165,11 +178,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; } mutex_lock(&xe->pmt.lock); @@ -183,7 +199,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