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 10041C624DE for ; Thu, 3 Sep 2026 20:10:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB54810E52E; Thu, 3 Sep 2026 20:10:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="naSDtL7p"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0476B10E521 for ; Thu, 3 Sep 2026 20:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1788466237; x=1820002237; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=HEd0LHkEx+g52+4a2PN5/rQN4+0C7GjLIHWe7dYQU30=; b=naSDtL7p0NWTWWh1AvwLKqwPR9O1OYeHBGhuCd8Kx+Cnq2hbU4+1/4MC +y2nQZzJ/4JcdVy0wpj1n0ccp8gwsplQz39laaa+EIk51e9WGJEgBmQaP zehtvijl05vCY5I5FWfUYzy4HZ0arIESSrm9V8Xqi0NHwpM/KiFcJH0mz /w3DsHrbJWSQ2lFt98LIGbCwByIiqOb+6q/vniafg9HSpwSafeLetaEou zat+8YDeCBI7rA3VcBA8uqBg7AdX2ucaHrYC6A9qVGwd29mFRP2P2j/tz GFUeA2ZZGgbb7ci8oEFHHYJyjJIBsLLn07fMMu5KGT5zHsHUKeiGnr7sq A==; X-CSE-ConnectionGUID: QG0ibi1lRpCT2heCk6EERA== X-CSE-MsgGUID: oiPrUithSGy/NXHnMSSbyQ== X-IronPort-AV: E=McAfee;i="6800,10657,11895"; a="88994617" X-IronPort-AV: E=Sophos;i="6.25,260,1779174000"; d="scan'208";a="88994617" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2026 13:10:37 -0700 X-CSE-ConnectionGUID: Dgsp46IXRa6gNVp/fnuoFQ== X-CSE-MsgGUID: JsYU21vORJabhAwykXDMCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,260,1779174000"; d="scan'208";a="273348141" Received: from mjruhl-vm.amr.corp.intel.com ([10.11.186.166]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2026 13:10:29 -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 v5 10/18] drm/xe/vsec: Support possible hotplug exit Date: Thu, 3 Sep 2026 13:10:12 -0700 Message-ID: <20260903201002.1064889-30-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260903201002.1064889-20-michael.j.ruhl@intel.com> References: <20260903201002.1064889-20-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 | 39 +++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index 5223bfe50ede..01df339ff62f 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,8 +161,13 @@ 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 * - * Returns -EINVAL for VF and PMT WATCHER requests - * count number of bytes read on success + * 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()). + * + * Returns -ENODEV device is not available (hotplug) + * -EINVAL for VF and PMT WATCHER requests + * count number of bytes read on success */ int xe_pmt_telem_read(struct device *dev, u32 guid, u64 *data, loff_t user_offset, u32 count) @@ -170,14 +177,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 (IS_SRIOV_VF(xe)) - return -EINVAL; + if (!drm_dev_enter(&xe->drm, &idx)) + return -ENODEV; + + if (IS_SRIOV_VF(xe)) { + 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; @@ -187,11 +200,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); @@ -205,7 +221,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