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 53753C88E5A for ; Fri, 11 Sep 2026 20:12:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F0C3610F6EB; Fri, 11 Sep 2026 20:12:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="gT873ju8"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1DE410E1F5 for ; Fri, 11 Sep 2026 20:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789157521; x=1820693521; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Y05JvbiBoc6hnW2yndM8nHg4xST78/jI1JnLeTfb6qQ=; b=gT873ju8yb7MBO0lMQ7c8gipsGDRGhalKu1KMvSPZD8mKHZ+DTgpC3RO 6Yn1JbNT8rMCN9noNP/44YneUejXhVgGO4LkyK8kQaedj7OXvdrNR9HDH NTfxEsl5as4cjPYj2w7R0QV+vDWc5DD2PtE2KJOxS6iuAIi4SfYj4IpWX mcX2zrksJ5Kg1LLYaTIu41Y1qQldqvS62jN/09ISr+mk/OAwyqTRKEOn6 cSV4goN5jkFBLC4jwL5ckbq6F2kwWWo3OILePZ2f6NBu9zB+lKuj6y8xO olr0Hy9iFQle9mPfOZWACdvtNIw2LhyFv0mLApQ3P6dhF0W0rK+N3uo7s Q==; X-CSE-ConnectionGUID: maYSTxxXRMOas5ToQNr3pA== X-CSE-MsgGUID: bkWbCQojQiaAEXBPu9D4Ng== X-IronPort-AV: E=McAfee;i="6800,10657,11902"; a="115162401" X-IronPort-AV: E=Sophos;i="6.27,97,1787036400"; d="scan'208";a="115162401" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2026 13:11:59 -0700 X-CSE-ConnectionGUID: MWDOYoHcRuW0X85DZr1JiQ== X-CSE-MsgGUID: yLjiKK0yQ16azWasc1bRSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,97,1787036400"; d="scan'208";a="277272097" Received: from mjruhl-vm.amr.corp.intel.com ([10.11.186.166]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2026 13:11:59 -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 v8 10/20] drm/xe/vsec: Support possible hotplug exit Date: Fri, 11 Sep 2026 13:11:58 -0700 Message-ID: <20260911201148.1610547-32-michael.j.ruhl@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260911201148.1610547-22-michael.j.ruhl@intel.com> References: <20260911201148.1610547-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" 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 | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c index c0252f5b508f..3bea89f2a5c5 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) * * -EINVAL for VF and PMT WATCHER requests * * count number of bytes read on success */ @@ -171,14 +178,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; @@ -188,11 +201,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); @@ -206,7 +222,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