Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v2 4/5] drm/xe/guc: Add suspend refcount to exec queue ops
Date: Thu, 9 Jul 2026 13:41:52 -0700	[thread overview]
Message-ID: <alAHkBxV6KOZtqoE@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20260701050730.1776476-11-niranjana.vishwanathapura@intel.com>

On Tue, Jun 30, 2026 at 10:07:32PM -0700, Niranjana Vishwanathapura wrote:
> From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> 
> With the lr.suspended flag a consumer already pairs its own suspend()
> and resume() correctly, and no current path issues overlapping suspends
> on the same queue.
> 
> Add a reference count to the exec queue suspend operations, as a small
> self-contained building block for callers that can genuinely overlap.
> A queue stays suspended as long as any caller holds a suspend and only
> resumes once the last caller releases it, so each caller pairs its own
> suspend/resume without needing to know about the others. This is what
> the upcoming multi-queue support needs, where queues in a group share
> a primary and may be suspended concurrently.
> 
> Assisted-by: GitHub_Copilot:claude-sonnet-4.6
> Co-authored-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>

With the upper layer fixed in previous patches, this part LGTM.

Reviewed-by: Matthew Brost <matthew.brost@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc_exec_queue_types.h |  7 +++++
>  drivers/gpu/drm/xe/xe_guc_submit.c           | 30 ++++++++++++++------
>  2 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
> index e5e53b421f29..1207d51cf770 100644
> --- a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
> +++ b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
> @@ -49,6 +49,13 @@ struct xe_guc_exec_queue {
>  	wait_queue_head_t suspend_wait;
>  	/** @suspend_pending: a suspend of the exec_queue is pending */
>  	bool suspend_pending;
> +	/**
> +	 * @suspend_count: Reference count of active suspend requests. The
> +	 * exec_queue remains suspended while this is non-zero, allowing
> +	 * multiple concurrent callers to independently hold a suspend without
> +	 * prematurely re-enabling the queue. Protected by @sched.msg_lock.
> +	 */
> +	int suspend_count;
>  	/**
>  	 * @needs_cleanup: Needs a cleanup message during VF post migration
>  	 * recovery.
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 3d9bdc22c89f..f7a3ff0d0b1d 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -2165,15 +2165,21 @@ static int guc_exec_queue_set_multi_queue_priority(struct xe_exec_queue *q,
>  
>  static int guc_exec_queue_suspend(struct xe_exec_queue *q)
>  {
> -	struct xe_gpu_scheduler *sched = &q->guc->sched;
> -	struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_SUSPEND;
> +	struct xe_guc_exec_queue *ge = q->guc;
> +	struct xe_gpu_scheduler *sched = &ge->sched;
> +	struct xe_sched_msg *msg = ge->static_msgs + STATIC_MSG_SUSPEND;
>  
>  	if (exec_queue_killed_or_banned_or_wedged(q))
>  		return -EINVAL;
>  
>  	xe_sched_msg_lock(sched);
> -	if (guc_exec_queue_try_add_msg(q, msg, SUSPEND))
> -		q->guc->suspend_pending = true;
> +	if (++ge->suspend_count == 1) {
> +		bool added = guc_exec_queue_try_add_msg(q, msg, SUSPEND);
> +
> +		/* slot must be free at 0->1 */
> +		xe_gt_assert(guc_to_gt(exec_queue_to_guc(q)), added);
> +		ge->suspend_pending = true;
> +	}
>  	xe_sched_msg_unlock(sched);
>  
>  	return 0;
> @@ -2249,14 +2255,20 @@ static int guc_exec_queue_suspend_wait(struct xe_exec_queue *q)
>  
>  static void guc_exec_queue_resume(struct xe_exec_queue *q)
>  {
> -	struct xe_gpu_scheduler *sched = &q->guc->sched;
> -	struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_RESUME;
> +	struct xe_guc_exec_queue *ge = q->guc;
> +	struct xe_gpu_scheduler *sched = &ge->sched;
> +	struct xe_sched_msg *msg = ge->static_msgs + STATIC_MSG_RESUME;
>  	struct xe_guc *guc = exec_queue_to_guc(q);
>  
> -	xe_gt_assert(guc_to_gt(guc), !q->guc->suspend_pending);
> -
>  	xe_sched_msg_lock(sched);
> -	guc_exec_queue_try_add_msg(q, msg, RESUME);
> +	xe_gt_assert(guc_to_gt(guc), !ge->suspend_pending);
> +	xe_gt_assert(guc_to_gt(guc), ge->suspend_count > 0);
> +	if (--ge->suspend_count == 0) {
> +		bool added = guc_exec_queue_try_add_msg(q, msg, RESUME);
> +
> +		/* slot must be free at 1->0 */
> +		xe_gt_assert(guc_to_gt(guc), added);
> +	}
>  	xe_sched_msg_unlock(sched);
>  }
>  
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-07-09 20:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  5:07 [PATCH v2 0/5] drm/xe: balance exec queue suspend/resume Niranjana Vishwanathapura
2026-07-01  5:07 ` [PATCH v2 1/5] drm/xe: only resume exec queues that were actually suspended Niranjana Vishwanathapura
2026-07-09 20:33   ` Matthew Brost
2026-07-01  5:07 ` [PATCH v2 2/5] drm/xe/hw_engine_group: propagate suspend failures during mode switch Niranjana Vishwanathapura
2026-07-09 20:20   ` Matthew Brost
2026-07-10  4:13     ` Niranjana Vishwanathapura
2026-07-10 18:23       ` Matthew Brost
2026-07-01  5:07 ` [PATCH v2 3/5] drm/xe/guc: wait killably for suspend and ban queue on timeout Niranjana Vishwanathapura
2026-07-09 20:36   ` Matthew Brost
2026-07-09 20:40     ` Matthew Brost
2026-07-10  4:30       ` Niranjana Vishwanathapura
2026-07-10  5:40         ` Matthew Brost
2026-07-01  5:07 ` [PATCH v2 4/5] drm/xe/guc: Add suspend refcount to exec queue ops Niranjana Vishwanathapura
2026-07-09 20:41   ` Matthew Brost [this message]
2026-07-01  5:07 ` [PATCH v2 5/5] drm/xe/multi_queue: preempt primary on queue group suspend Niranjana Vishwanathapura
2026-07-09 20:43   ` Matthew Brost
2026-07-01  5:14 ` ✗ CI.checkpatch: warning for drm/xe: balance exec queue suspend/resume (rev4) Patchwork
2026-07-01  5:15 ` ✓ CI.KUnit: success " Patchwork
2026-07-01  6:06 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-01 21:17 ` ✓ Xe.CI.FULL: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alAHkBxV6KOZtqoE@gsse-cloud1.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=niranjana.vishwanathapura@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox