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 6835CC43458 for ; Tue, 7 Jul 2026 13:06:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DB3710ECF8; Tue, 7 Jul 2026 13:06:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="L7wFaRwT"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id A636A10ECF8 for ; Tue, 7 Jul 2026 13:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783429617; x=1814965617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W7gY4MoZj0DQ9QP7aANlBAvsu6VytlfGurZldVk3D3M=; b=L7wFaRwT+YT2d1JeCnDx6Wi/zM1Qi33KvUTV88MscEZRUHEPtGRiN02d pCySU9BtqHH8GV58EKXsmFHVyjQ6DZaWzUezg3B1OSrbfFDHA01QhiP0f 1KmVnUTyp5lvZAsBr/e+tYY4+k4/8cXfLxpjhoSw2DKa+M3n6D8iggE6Q iagdpotj6SK7QWwCKdYzScg22IYDN/XubDeTgGAkcrP+SXPzkl3+1p13I zq0oJ2cqh47FWBDG4Wa73XtPFNsbHi0k3D5aK4MH71OqwI4TyU3AC5ud+ IbNPH1fNAo8ql+b+NXJgFzX2tzWZiMNbUJyVJ40SyWVQEvNNgq+R85eBs A==; X-CSE-ConnectionGUID: +TvKpuxSQKGo1cyU3Cty6Q== X-CSE-MsgGUID: ee5Z9q/CRk67c3mRwcvA4g== X-IronPort-AV: E=McAfee;i="6800,10657,11840"; a="84050150" X-IronPort-AV: E=Sophos;i="6.25,153,1779174000"; d="scan'208";a="84050150" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2026 06:06:57 -0700 X-CSE-ConnectionGUID: Xvo8NHEoSIaQj/NV78GYaA== X-CSE-MsgGUID: NbGfroVyQBmGLfJZNL20HA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,153,1779174000"; d="scan'208";a="250006220" Received: from tejasupa-desk.iind.intel.com (HELO tejasupa-desk) ([10.190.239.37]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2026 06:06:54 -0700 From: Tejas Upadhyay To: intel-xe@lists.freedesktop.org Cc: Tejas Upadhyay , "Mrozek, Michal" , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , "Vivi, Rodrigo" Subject: [PATCH V11 10/11] drm/xe/uapi: Expose ban reason in EXEC_QUEUE_GET_PROPERTY_BAN Date: Tue, 7 Jul 2026 18:36:23 +0530 Message-ID: <20260707130617.970638-23-tejas.upadhyay@intel.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260707130617.970638-13-tejas.upadhyay@intel.com> References: <20260707130617.970638-13-tejas.upadhyay@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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" Extend DRM_XE_EXEC_QUEUE_GET_PROPERTY_BAN to return a bitmask indicating the reason for the ban, rather than a simple boolean. This allows userspace to distinguish between different ban causes: - DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG (bit 0): exec queue was banned due to a GPU hang or job timeout detected by the TDR. - DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE (bit 1): exec queue was banned because a VRAM page backing its resources was taken offline. The ban_reason field is added to struct xe_exec_queue and set at the point where the ban is triggered: - In guc_exec_queue_timedout_job() for GPU hang. - In xe_ttm_vram_purge_page() for memory page offline, before calling xe_exec_queue_kill() or xe_vm_kill(). The reset_status op is updated to return u64 with the reason bitmask. When a queue is banned but no explicit reason was recorded (e.g., from a generic CAT error), it defaults to GPU_HANG for backward compatibility. A value of 0 means the exec queue is not banned. Assisted-by: Copilot:claude-opus-4.6 Signed-off-by: Tejas Upadhyay cc: Mrozek, Michal cc: José Roberto de Souza cc: Vivi, Rodrigo Acked-by: José Roberto de Souza Acked-by: Michal Mrozek --- drivers/gpu/drm/xe/xe_exec_queue_types.h | 7 +++++-- drivers/gpu/drm/xe/xe_execlist.c | 4 ++-- drivers/gpu/drm/xe/xe_guc_submit.c | 24 +++++++++++++++++++----- drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 7 +++++++ include/uapi/drm/xe_drm.h | 12 +++++++++++- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h b/drivers/gpu/drm/xe/xe_exec_queue_types.h index d27ce24daae5..4242c3eb09f7 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue_types.h +++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h @@ -143,6 +143,9 @@ struct xe_exec_queue { */ unsigned long flags; + /** @ban_reason: Bitmask of ban reasons (DRM_XE_EXEC_QUEUE_BAN_REASON_*) */ + u32 ban_reason; + union { /** @multi_gt_list: list head for VM bind engines if multi-GT */ struct list_head multi_gt_list; @@ -316,8 +319,8 @@ struct xe_exec_queue_ops { * signalled when this function is called. */ void (*resume)(struct xe_exec_queue *q); - /** @reset_status: check exec queue reset status */ - bool (*reset_status)(struct xe_exec_queue *q); + /** @reset_status: check exec queue ban status, returns ban reason bitmask */ + u64 (*reset_status)(struct xe_exec_queue *q); }; #endif diff --git a/drivers/gpu/drm/xe/xe_execlist.c b/drivers/gpu/drm/xe/xe_execlist.c index 6b86b4f9cc1c..0695767ab071 100644 --- a/drivers/gpu/drm/xe/xe_execlist.c +++ b/drivers/gpu/drm/xe/xe_execlist.c @@ -452,10 +452,10 @@ static void execlist_exec_queue_resume(struct xe_exec_queue *q) /* NIY */ } -static bool execlist_exec_queue_reset_status(struct xe_exec_queue *q) +static u64 execlist_exec_queue_reset_status(struct xe_exec_queue *q) { /* NIY */ - return false; + return 0; } static const struct xe_exec_queue_ops execlist_exec_queue_ops = { diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c index 12416bfa3255..0187bb59e594 100644 --- a/drivers/gpu/drm/xe/xe_guc_submit.c +++ b/drivers/gpu/drm/xe/xe_guc_submit.c @@ -6,6 +6,7 @@ #include "xe_guc_submit.h" #include +#include #include #include #include @@ -1551,6 +1552,7 @@ guc_exec_queue_timedout_job(struct drm_sched_job *drm_job) if (!exec_queue_killed(q)) wedged = guc_submit_hint_wedged(exec_queue_to_guc(q)); + q->ban_reason |= DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG; set_exec_queue_banned(q); /* Kick job / queue off hardware */ @@ -2236,13 +2238,25 @@ static void guc_exec_queue_resume(struct xe_exec_queue *q) xe_sched_msg_unlock(sched); } -static bool guc_exec_queue_reset_status(struct xe_exec_queue *q) +static u64 guc_exec_queue_reset_status(struct xe_exec_queue *q) { - if (xe_exec_queue_is_multi_queue_secondary(q) && - guc_exec_queue_reset_status(xe_exec_queue_multi_queue_primary(q))) - return true; + if (xe_exec_queue_is_multi_queue_secondary(q)) { + u64 status = guc_exec_queue_reset_status( + xe_exec_queue_multi_queue_primary(q)); + if (status) + return status; + } + + if (exec_queue_reset(q) || exec_queue_killed_or_banned_or_wedged(q)) { + u64 reason = q->ban_reason; - return exec_queue_reset(q) || exec_queue_killed_or_banned_or_wedged(q); + /* If no specific reason was recorded, default to GPU hang */ + if (!reason) + reason = DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG; + return reason; + } + + return 0; } /* diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c index 35b5eaf590fa..3765e8fcdcec 100644 --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -537,10 +538,15 @@ static int xe_ttm_vram_purge_page(struct xe_device *xe, struct xe_bo *bo) xe_bo_unlock(bo); /* Ban VM if BO is PPGTT */ if (vm && (flags & XE_BO_FLAG_PAGETABLE)) { + struct xe_exec_queue *eq; + down_write(&vm->lock); + list_for_each_entry(eq, &vm->preempt.exec_queues, lr.link) + eq->ban_reason |= DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE; xe_vm_kill(vm, true); up_write(&vm->lock); } + if (vm) xe_vm_put(vm); @@ -548,6 +554,7 @@ static int xe_ttm_vram_purge_page(struct xe_device *xe, struct xe_bo *bo) /* Ban exec queue if BO is lrc */ if (bo->q && xe_exec_queue_get_unless_zero(bo->q)) { /* ban queue */ + bo->q->ban_reason |= DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE; xe_exec_queue_kill(bo->q); xe_exec_queue_put(bo->q); } diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h index 509202a7b13e..1600e8f0885a 100644 --- a/include/uapi/drm/xe_drm.h +++ b/include/uapi/drm/xe_drm.h @@ -1503,7 +1503,17 @@ struct drm_xe_exec_queue_get_property { /** @property: property to get */ __u32 property; - /** @value: property value */ + /** + * @value: property value + * + * For %DRM_XE_EXEC_QUEUE_GET_PROPERTY_BAN, this is a bitmask of: + * - %DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG - banned due to GPU hang/timeout + * - %DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE - banned due to memory page offline + * + * Value of 0 means the exec queue is not banned. + */ +#define DRM_XE_EXEC_QUEUE_BAN_REASON_GPU_HANG (1 << 0) +#define DRM_XE_EXEC_QUEUE_BAN_REASON_PAGE_OFFLINE (1 << 1) __u64 value; /** @reserved: Reserved */ -- 2.52.0