From: "Summers, Stuart" <stuart.summers@intel.com>
To: "Vishwanathapura, Niranjana" <niranjana.vishwanathapura@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"Ch, Sai Gowtham" <sai.gowtham.ch@intel.com>,
"Dandamudi, Priyanka" <priyanka.dandamudi@intel.com>,
"kamil.konieczny@linux.intel.com"
<kamil.konieczny@linux.intel.com>
Subject: Re: [PATCH v2 14/19] lib/xe/xe_spin: Add switch point for preemptible spinner
Date: Fri, 5 Dec 2025 18:45:08 +0000 [thread overview]
Message-ID: <eb2c510e27f5facd0f2c86266ecfd53e2f025fde.camel@intel.com> (raw)
In-Reply-To: <aTIAR9boDHPtzkGg@nvishwa1-desk>
On Thu, 2025-12-04 at 13:42 -0800, Niranjana Vishwanathapura wrote:
> On Thu, Dec 04, 2025 at 01:03:25PM -0800, Summers, Stuart wrote:
> > On Thu, 2025-11-20 at 19:57 -0800, Niranjana Vishwanathapura wrote:
> > > When 'preempt' option is specified, insert a MI_SEMAPHORE_WAIT
> > > command in the spinner batch buffer. This provides the switch
> > > point for preemption to happen in multi queue mode.
> > > Allow user to control preempt wait condition.
> > >
> > > Signed-off-by: Niranjana Vishwanathapura
> > > <niranjana.vishwanathapura@intel.com>
> > > ---
> > > include/intel_gpu_commands.h | 1 +
> > > lib/xe/xe_spin.c | 41
> > > ++++++++++++++++++++++++++++++++++++
> > > lib/xe/xe_spin.h | 3 +++
> > > 3 files changed, 45 insertions(+)
> > >
> > > diff --git a/include/intel_gpu_commands.h
> > > b/include/intel_gpu_commands.h
> > > index cd281ba89..5158bb0ea 100644
> > > --- a/include/intel_gpu_commands.h
> > > +++ b/include/intel_gpu_commands.h
> > > @@ -123,6 +123,7 @@
> > > #define MI_SEMAPHORE_WAIT MI_INSTR(0x1c, 2) /* GEN8+ */
> > > #define MI_SEMAPHORE_WAIT_TOKEN MI_INSTR(0x1c, 3) /*
> > > GEN12+
> > > */
> > > #define MI_SEMAPHORE_POLL (1 << 15)
> > > +#define MI_SEMAPHORE_QUEUE_SWITCH_MODE (1 << 11)
> > > #define MI_SEMAPHORE_SAD_GT_SDD (0 << 12)
> > > #define MI_SEMAPHORE_SAD_GTE_SDD (1 << 12)
> > > #define MI_SEMAPHORE_SAD_LT_SDD (2 << 12)
> > > diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c
> > > index 72b13ef42..174c5f7ec 100644
> > > --- a/lib/xe/xe_spin.c
> > > +++ b/lib/xe/xe_spin.c
> > > @@ -57,6 +57,7 @@ void xe_spin_init(struct xe_spin *spin, struct
> > > xe_spin_opts *opts)
> > >
> > > spin->start = 0;
> > > spin->end = 0xffffffff;
> > > + spin->wait_cond = 0;
> > > spin->ticks_delta = 0;
> > >
> > > if (opts->ctx_ticks) {
> > > @@ -167,6 +168,24 @@ void xe_spin_init(struct xe_spin *spin,
> > > struct
> > > xe_spin_opts *opts)
> > > opts->mem_copy->dst-
> > > >mocs_index;
> > > }
> > >
> > > + /*
> > > + * Insert a MI_SEMAPHORE_WAIT_CMD instruction with
> > > condition
> > > controlled
> > > + * by the user. It also acts as a queue switch point in
> > > multi
> > > queue mode.
> > > + */
> > > + if (opts->preempt) {
> > > + uint64_t wait_addr = opts->addr + offsetof(struct
> > > xe_spin, wait_cond);
> > > +
> > > + spin->batch[b++] = MI_SEMAPHORE_WAIT_CMD |
> > > + MI_SEMAPHORE_POLL |
> > > + MI_SEMAPHORE_QUEUE_SWITCH_MODE |
> > > + MI_SEMAPHORE_SAD_EQ_SDD |
> > > + 3;
> > > + spin->batch[b++] = 0;
> >
> > Should this be set to spin->wait_cond in case we ever want to
> > change
> > the default value here?
> >
>
> wait_cond is already part of wait_addr. So, user can control the
> wait using xe_spin_preempt_wait()/nowait() functions below.
Ah right and this is just the value we're using to compare against the
user value. So yeah makes sense what we have.
Reviewed-by: Stuart Summers <stuart.summers@intel.com>
>
> Niranjana
>
> > Otherwise generally this is a great addition to the spinner
> > toolkit:
> > Reviewed-by: Stuart Summers <stuart.summers@intel.com>
> >
> > > + spin->batch[b++] = wait_addr;
> > > + spin->batch[b++] = wait_addr >> 32;
> > > + spin->batch[b++] = 0;
> > > + }
> > > +
> > > spin->batch[b++] = MI_COND_BATCH_BUFFER_END |
> > > MI_DO_COMPARE |
> > > 2;
> > > spin->batch[b++] = 0;
> > > spin->batch[b++] = end_addr;
> > > @@ -207,6 +226,28 @@ void xe_spin_end(struct xe_spin *spin)
> > > WRITE_ONCE(spin->end, 0);
> > > }
> > >
> > > +/**
> > > + * xe_spin_preempt_wait:
> > > + * @spin: pointer to spinner mapped bo
> > > + *
> > > + * Make the spinner wait on the preemption semaphore.
> > > + */
> > > +void xe_spin_preempt_wait(struct xe_spin *spin)
> > > +{
> > > + spin->wait_cond = 1;
> > > +}
> > > +
> > > +/**
> > > + * xe_spin_preempt_nowait:
> > > + * @spin: pointer to spinner mapped bo
> > > + *
> > > + * Make the spinner do not wait on the preemption semaphore.
> > > + */
> > > +void xe_spin_preempt_nowait(struct xe_spin *spin)
> > > +{
> > > + spin->wait_cond = 0;
> > > +}
> > > +
> > > /**
> > > * xe_spin_create:
> > > * @opt: controlling options such as allocator handle,
> > > exec_queue,
> > > vm etc
> > > diff --git a/lib/xe/xe_spin.h b/lib/xe/xe_spin.h
> > > index c2199d0aa..eaf2a409e 100644
> > > --- a/lib/xe/xe_spin.h
> > > +++ b/lib/xe/xe_spin.h
> > > @@ -64,6 +64,7 @@ struct xe_spin {
> > > uint64_t pad;
> > > uint32_t start;
> > > uint32_t end;
> > > + uint32_t wait_cond;
> > > uint32_t ticks_delta;
> > > uint64_t exec_sync;
> > > uint32_t timestamp;
> > > @@ -76,6 +77,8 @@ void xe_spin_init(struct xe_spin *spin, struct
> > > xe_spin_opts *opts);
> > > bool xe_spin_started(struct xe_spin *spin);
> > > void xe_spin_wait_started(struct xe_spin *spin);
> > > void xe_spin_end(struct xe_spin *spin);
> > > +void xe_spin_preempt_wait(struct xe_spin *spin);
> > > +void xe_spin_preempt_nowait(struct xe_spin *spin);
> > >
> > > /*
> > > * xe_cork: higher level API that simplifies exec'ing an xe_spin
> > > by
> > > taking care
> >
next prev parent reply other threads:[~2025-12-05 18:45 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 3:57 [PATCH v2 00/19] Multi Queue feature validation support Niranjana Vishwanathapura
2025-11-21 3:57 ` [PATCH v2 01/19] drm-uapi/xe: Sync with Multi-Queue uapi Niranjana Vishwanathapura
2025-12-04 19:19 ` Summers, Stuart
2025-12-04 20:58 ` Niranjana Vishwanathapura
2025-12-05 18:07 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 02/19] lib/xe: Add multi-queue helper routines Niranjana Vishwanathapura
2025-12-04 19:20 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 03/19] tests/intel/xe_exec_multi_queue: Add xe_exec_multi_queue test Niranjana Vishwanathapura
2025-12-04 20:02 ` Summers, Stuart
2025-12-05 1:34 ` Niranjana Vishwanathapura
2025-12-05 18:09 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 04/19] tests/intel/xe_exec_multi_queue: Validate exec submissions Niranjana Vishwanathapura
2025-12-02 5:27 ` Ch, Sai Gowtham
2025-12-04 20:42 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 05/19] tests/intel/xe_exec_multi_queue: Validate queue priority setting Niranjana Vishwanathapura
2025-12-02 5:29 ` Dandamudi, Priyanka
2025-12-04 20:45 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 06/19] tests/intel/xe_exec_multi_queue: Add close-fd tests Niranjana Vishwanathapura
2025-11-24 8:18 ` Goyal, Nakshtra
2025-12-04 20:46 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 07/19] tests/intel/xe_exec_multi_queue: Add multiple placement test Niranjana Vishwanathapura
2025-12-02 5:32 ` Dandamudi, Priyanka
2025-12-05 18:10 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 08/19] tests/intel/xe_exec_multi_queue: Add preempt mode test Niranjana Vishwanathapura
2025-12-04 20:52 ` Summers, Stuart
2025-12-05 19:12 ` Niranjana Vishwanathapura
2025-12-08 19:40 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 09/19] lib/xe: Add exec_queue set_property ioctl support Niranjana Vishwanathapura
2025-12-04 19:24 ` Summers, Stuart
2025-12-05 1:58 ` Niranjana Vishwanathapura
2025-12-05 18:11 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 10/19] tests/intel/xe_exec_multi_queue: Add dynamic priority test Niranjana Vishwanathapura
2025-12-04 20:53 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 11/19] tests/intel/xe_exec_multi_queue: Add userptr invalidation tests Niranjana Vishwanathapura
2025-12-04 20:56 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 12/19] tests/intel/xe_exec_multi_queue: Add fault mode test Niranjana Vishwanathapura
2025-11-21 5:04 ` Goyal, Nakshtra
2025-12-04 20:59 ` Summers, Stuart
2025-12-04 23:25 ` Niranjana Vishwanathapura
2025-12-05 18:13 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 13/19] tests/intel/xe_exec_multi_queue: Add multi queues with SMEM Niranjana Vishwanathapura
2025-12-04 19:56 ` Goyal, Nakshtra
2025-12-04 20:59 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 14/19] lib/xe/xe_spin: Add switch point for preemptible spinner Niranjana Vishwanathapura
2025-12-04 21:03 ` Summers, Stuart
2025-12-04 21:42 ` Niranjana Vishwanathapura
2025-12-05 18:45 ` Summers, Stuart [this message]
2025-11-21 3:57 ` [PATCH v2 15/19] tests/intel/xe_exec_multi_queue: Add priority test Niranjana Vishwanathapura
2025-12-02 5:28 ` Dandamudi, Priyanka
2025-12-04 21:53 ` Summers, Stuart
2025-12-05 18:23 ` Niranjana Vishwanathapura
2025-12-08 19:38 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 16/19] tests/intel/xe_exec_multi_queue: Add submission sanity test Niranjana Vishwanathapura
2025-12-02 11:46 ` Ch, Sai Gowtham
2025-12-04 21:08 ` Summers, Stuart
2025-12-04 21:28 ` Niranjana Vishwanathapura
2025-11-21 3:57 ` [PATCH v2 17/19] tests/intel/xe_exec_multi_queue: Sanity test KEEP_ACTIVE flag Niranjana Vishwanathapura
2025-12-04 21:10 ` Summers, Stuart
2025-12-04 21:20 ` Niranjana Vishwanathapura
2025-11-21 3:57 ` [PATCH v2 18/19] tests/intel/xe_exec_multi_queue: Keep group active in exec-sanity Niranjana Vishwanathapura
2025-12-02 11:51 ` Ch, Sai Gowtham
2025-12-04 21:12 ` Summers, Stuart
2025-11-21 3:57 ` [PATCH v2 19/19] tests/intel/xe_exec_queue_property: Update invalid-property test Niranjana Vishwanathapura
2025-12-04 19:25 ` Summers, Stuart
2025-12-04 21:11 ` Niranjana Vishwanathapura
2025-11-21 4:32 ` ✓ Xe.CI.BAT: success for Multi Queue feature validation support (rev2) Patchwork
2025-11-21 6:47 ` ✓ i915.CI.BAT: " Patchwork
2025-11-21 7:20 ` ✗ Xe.CI.Full: failure " Patchwork
2025-11-21 9:42 ` ✗ i915.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=eb2c510e27f5facd0f2c86266ecfd53e2f025fde.camel@intel.com \
--to=stuart.summers@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=priyanka.dandamudi@intel.com \
--cc=sai.gowtham.ch@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