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 5277FCCF2C4 for ; Fri, 16 Oct 2026 20:03:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08F481129BE; Fri, 16 Oct 2026 20:03:30 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3C0D91129C1 for ; Fri, 16 Oct 2026 20:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1792181003; x=1823717003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+p6zwcbNNwqVwp9VEyj8MzPQxMAFNKT2WYyfuExwu6U=; b=f1JUJqNuS6/jt31LvL96F9CFRlt08eXHQH2WfjBnCL4GNdErXVWSVtWL cXJkYQMPkcNbM4n4Ib9ZcjYo7Jkcx+DrUvAHBqV2rWijblgrO1YCDOEa3 0EGg99redAMtaetH/oiuQmUIcpOgGz4uN33hCtLWDfk0Eb2a6PHk8IfJQ lMMdvS0qsfew7rBMTqtOthKYPOJpgC9wqlHP9H4LGURIosaiAG0Gyg70m 273tF+xEk92k/1hZc4ICaxRChQWtY3AeaIeY9Em88sc4tdTYbl4POwM9i UZ5JB2j+0ZP8zc7xKo6k+6EdbpvxAzvZXfyauG5IcMjeWYEG8N37zMuNu A==; X-CSE-ConnectionGUID: nLq2FofNQX+srU/5WwgJ2A== X-CSE-MsgGUID: 4A0kDs5FTBG5pbtIrvsXOw== X-IronPort-AV: E=McAfee;i="6800,10657,11937"; a="962865" X-IronPort-AV: E=Sophos;i="6.27,162,1787036400"; d="scan'208";a="962865" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2026 13:03:18 -0700 X-CSE-ConnectionGUID: UlJ0HVAaSUmiyIpyk3oyrQ== X-CSE-MsgGUID: MJE5AdFBTlG6JNZXP028uw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,162,1787036400"; d="scan'208";a="2020085" Received: from danielcm-desk1.jf.intel.com ([10.24.81.120]) by orviesa004.jf.intel.com with ESMTP; 16 Oct 2026 13:03:18 -0700 From: Daniel Charles To: intel-xe@lists.freedesktop.org Cc: x.wang@intel.com, jia.yao@intel.com, jonathan.cavitt@intel.com, matthew.brost@intel.com, stable Subject: [PATCH v4 1/3] drm/xe: Read scheduler message opcode under lock Date: Fri, 16 Oct 2026 12:59:02 -0700 Message-ID: <20261016195904.1377149-2-daniel.charles@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261016195904.1377149-1-daniel.charles@intel.com> References: <20261016195904.1377149-1-daniel.charles@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" From: Matthew Brost For static scheduler messages, the opcode is only guaranteed to remain stable while the message is on the pending message list. Read the opcode under the message lock before removing the message from the pending list, and pass it through the processing pipeline. Fixes: ff796870f5dd ("drm/xe/guc: rework exec queue teardown PM/unplug handling") Cc: stable Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_gpu_scheduler.c | 13 +++++++++---- drivers/gpu/drm/xe/xe_gpu_scheduler_types.h | 2 +- drivers/gpu/drm/xe/xe_guc_submit.c | 7 ++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.c b/drivers/gpu/drm/xe/xe_gpu_scheduler.c index 9c8004d5dd915..d656db758cb3c 100644 --- a/drivers/gpu/drm/xe/xe_gpu_scheduler.c +++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.c @@ -23,15 +23,19 @@ static void xe_sched_process_msg_queue_if_ready(struct xe_gpu_scheduler *sched) } static struct xe_sched_msg * -xe_sched_get_msg(struct xe_gpu_scheduler *sched) +xe_sched_get_msg(struct xe_gpu_scheduler *sched, unsigned int *opcode) { struct xe_sched_msg *msg; xe_sched_msg_lock(sched); msg = list_first_entry_or_null(&sched->msgs, struct xe_sched_msg, link); - if (msg) + if (msg) { + /* The opcode is only stable under lock for static messages */ + *opcode = msg->opcode; + list_del_init(&msg->link); + } xe_sched_msg_unlock(sched); return msg; @@ -42,13 +46,14 @@ static void xe_sched_process_msg_work(struct work_struct *w) struct xe_gpu_scheduler *sched = container_of(w, struct xe_gpu_scheduler, work_process_msg); struct xe_sched_msg *msg; + unsigned int opcode; if (drm_sched_is_stopped(&sched->base)) return; - msg = xe_sched_get_msg(sched); + msg = xe_sched_get_msg(sched, &opcode); if (msg) { - sched->ops->process_msg(msg); + sched->ops->process_msg(msg, opcode); xe_sched_process_msg_queue_if_ready(sched); } diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h b/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h index 78ef2e8ded4f3..163a0d85e3cb9 100644 --- a/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h +++ b/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h @@ -34,7 +34,7 @@ struct xe_sched_backend_ops { * @process_msg: Process a message. Allowed to block, it is this * function's responsibility to free message if dynamically allocated. */ - void (*process_msg)(struct xe_sched_msg *msg); + void (*process_msg)(struct xe_sched_msg *msg, unsigned int opcode); }; /** diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c index 7ce73489c35fc..c4ef3e9bf7a18 100644 --- a/drivers/gpu/drm/xe/xe_guc_submit.c +++ b/drivers/gpu/drm/xe/xe_guc_submit.c @@ -2056,16 +2056,17 @@ static void __guc_exec_queue_process_msg_cgp_sync(struct xe_sched_msg *msg, #define MSG_HEAD BIT(9) #define MSG_PM_REF BIT(10) -static void guc_exec_queue_process_msg(struct xe_sched_msg *msg) +static void guc_exec_queue_process_msg(struct xe_sched_msg *msg, + unsigned int opcode) { struct xe_device *xe = guc_to_xe(exec_queue_to_guc(msg->private_data)); int idx; - bool pm_ref = !!(msg->opcode & MSG_PM_REF); + bool pm_ref = !!(opcode & MSG_PM_REF); bool bound = drm_dev_enter(&xe->drm, &idx); trace_xe_sched_msg_recv(msg); - switch (msg->opcode & OPCODE_MASK) { + switch (opcode & OPCODE_MASK) { case CLEANUP: __guc_exec_queue_process_msg_cleanup(msg, bound); break; -- 2.43.0