All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: "Lis, Tomasz" <tomasz.lis@intel.com>, intel-gfx@lists.freedesktop.org
Cc: mika.kuoppala@intel.com
Subject: Re: [PATCH v1] drm/i915/gen11: Preempt-to-idle support in execlists.
Date: Wed, 28 Mar 2018 23:28:11 +0100	[thread overview]
Message-ID: <152227609116.10679.12481725029029254564@mail.alporthouse.com> (raw)
In-Reply-To: <9a0aefb3-12cb-2614-d8fb-1d069719b9aa@intel.com>

Quoting Lis, Tomasz (2018-03-28 17:06:58)
> 
> 
> On 2018-03-28 01:27, Chris Wilson wrote:
> > Quoting Tomasz Lis (2018-03-27 16:17:59)
> >> The patch adds support of preempt-to-idle requesting by setting a proper
> >> bit within Execlist Control Register, and receiving preemption result from
> >> Context Status Buffer.
> >>
> >> Preemption in previous gens required a special batch buffer to be executed,
> >> so the Command Streamer never preempted to idle directly. In Icelake it is
> >> possible, as there is a hardware mechanism to inform the kernel about
> >> status of the preemption request.
> >>
> >> This patch does not cover using the new preemption mechanism when GuC is
> >> active.
> >>
> >> Bspec: 18922
> >> Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
> >> ---
> >>   drivers/gpu/drm/i915/i915_drv.h          |  2 ++
> >>   drivers/gpu/drm/i915/i915_pci.c          |  3 ++-
> >>   drivers/gpu/drm/i915/intel_device_info.h |  1 +
> >>   drivers/gpu/drm/i915/intel_lrc.c         | 45 +++++++++++++++++++++++++++-----
> >>   drivers/gpu/drm/i915/intel_lrc.h         |  1 +
> >>   5 files changed, 45 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> >> index 800230b..c32580b 100644
> >> --- a/drivers/gpu/drm/i915/i915_drv.h
> >> +++ b/drivers/gpu/drm/i915/i915_drv.h
> >> @@ -2514,6 +2514,8 @@ intel_info(const struct drm_i915_private *dev_priv)
> >>                  ((dev_priv)->info.has_logical_ring_elsq)
> >>   #define HAS_LOGICAL_RING_PREEMPTION(dev_priv) \
> >>                  ((dev_priv)->info.has_logical_ring_preemption)
> >> +#define HAS_HW_PREEMPT_TO_IDLE(dev_priv) \
> >> +               ((dev_priv)->info.has_hw_preempt_to_idle)
> >>   
> >>   #define HAS_EXECLISTS(dev_priv) HAS_LOGICAL_RING_CONTEXTS(dev_priv)
> >>   
> >> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> >> index 4364922..66b6700 100644
> >> --- a/drivers/gpu/drm/i915/i915_pci.c
> >> +++ b/drivers/gpu/drm/i915/i915_pci.c
> >> @@ -595,7 +595,8 @@ static const struct intel_device_info intel_cannonlake_info = {
> >>          GEN(11), \
> >>          .ddb_size = 2048, \
> >>          .has_csr = 0, \
> >> -       .has_logical_ring_elsq = 1
> >> +       .has_logical_ring_elsq = 1, \
> >> +       .has_hw_preempt_to_idle = 1
> >>   
> >>   static const struct intel_device_info intel_icelake_11_info = {
> >>          GEN11_FEATURES,
> >> diff --git a/drivers/gpu/drm/i915/intel_device_info.h b/drivers/gpu/drm/i915/intel_device_info.h
> >> index 933e316..4eb97b5 100644
> >> --- a/drivers/gpu/drm/i915/intel_device_info.h
> >> +++ b/drivers/gpu/drm/i915/intel_device_info.h
> >> @@ -98,6 +98,7 @@ enum intel_platform {
> >>          func(has_logical_ring_contexts); \
> >>          func(has_logical_ring_elsq); \
> >>          func(has_logical_ring_preemption); \
> >> +       func(has_hw_preempt_to_idle); \
> >>          func(has_overlay); \
> >>          func(has_pooled_eu); \
> >>          func(has_psr); \
> >> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> >> index ba7f783..1a22de4 100644
> >> --- a/drivers/gpu/drm/i915/intel_lrc.c
> >> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> >> @@ -153,6 +153,7 @@
> >>   #define GEN8_CTX_STATUS_ACTIVE_IDLE    (1 << 3)
> >>   #define GEN8_CTX_STATUS_COMPLETE       (1 << 4)
> >>   #define GEN8_CTX_STATUS_LITE_RESTORE   (1 << 15)
> >> +#define GEN11_CTX_STATUS_PREEMPT_IDLE  (1 << 29)
> >>   
> >>   #define GEN8_CTX_STATUS_COMPLETED_MASK \
> >>           (GEN8_CTX_STATUS_COMPLETE | GEN8_CTX_STATUS_PREEMPTED)
> >> @@ -183,7 +184,9 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,
> >>                                  const struct i915_request *last,
> >>                                  int prio)
> >>   {
> >> -       return engine->i915->preempt_context && prio > max(rq_prio(last), 0);
> >> +       return (engine->i915->preempt_context ||
> >> +               HAS_HW_PREEMPT_TO_IDLE(engine->i915)) &&
> > Well, you haven't actually disabled allocating the preempt_context so...
> Yes.. I had mixed feelings about changing needs_preempt_context() now, 
> as that would mean adding a temporary condition on GuC until the GuC 
> preemption is merged.
> I will add the conditions and disable the allocation in v2 of the patch.
> > But at any rate, making this an engine->flag would eliminate one pointer
> > dance.
> Could be an interesting idea for a separate patch.

To land first ;)

> >> +                prio > max(rq_prio(last), 0);
> >>   }
> >>   
> >>   /**
> >> @@ -535,6 +538,25 @@ static void inject_preempt_context(struct intel_engine_cs *engine)
> >>          execlists_set_active(&engine->execlists, EXECLISTS_ACTIVE_PREEMPT);
> >>   }
> >>   
> >> +static void gen11_preempt_to_idle(struct intel_engine_cs *engine)
> >> +{
> >> +       struct intel_engine_execlists *execlists = &engine->execlists;
> >> +
> >> +       GEM_TRACE("%s\n", engine->name);
> >> +
> >> +       /*
> >> +        * hardware which HAS_HW_PREEMPT_TO_IDLE(), always also
> >> +        * HAS_LOGICAL_RING_ELSQ(), so we can assume ctrl_reg is set
> >> +        */
> >> +       GEM_BUG_ON(execlists->ctrl_reg != NULL);
> >> +
> >> +       /* trigger preemption to idle */
> >> +       writel(EL_CTRL_PREEMPT_TO_IDLE, execlists->ctrl_reg);
> > Future plans? Because just inserting the branch into the setter of
> > inject_preempt_context() resolves a lot of conflicts with other work.
> My arguments for separate function are:
> - better code readability
> - keeping the symmetry between execlist and GuC flow - GuC preemption 
> patches will introduce separate function as well
> - only 4 lines of the function would be common
> - the name inject_preempt_context() wouldn't match the new purpose, so 
> renaming would be needed
> - reduced self-documenting code due to two separate preempt methods not 
> having distinct names
> 
> That's all, I don't have any future plans for it. If you want me to 
> merge the two, let me know.

The problem that I am worrying about is that we will duplicate bunch of
other code, the actual ELS[PQ] write is the smaller portion. Plus we
already have the branch on something much more pleasant.

> >> @@ -962,10 +987,13 @@ static void execlists_submission_tasklet(unsigned long data)
> >>                                    status, buf[2*head + 1],
> >>                                    execlists->active);
> >>   
> >> -                       if (status & (GEN8_CTX_STATUS_IDLE_ACTIVE |
> >> -                                     GEN8_CTX_STATUS_PREEMPTED))
> >> +                       /* Check if switched to active or preempted to active */
> >> +                       if ((status & (GEN8_CTX_STATUS_IDLE_ACTIVE |
> >> +                                       GEN8_CTX_STATUS_PREEMPTED)) &&
> >> +                           !(status & GEN11_CTX_STATUS_PREEMPT_IDLE))
> > Setting HWACK here is harmless as it gets cleared again. Unless, there
> > is some oddity in the code flow.
> I will check if lack of the change affects test results.
> Personally, I would keep this change, even if only for allowing simple 
> definition of what HWACK flag means.

The simple definition is the opposite one, imo. We set the flag after we
get the corresponding response from HW; any preemption or activate event
must follow the most recent ELSP write. So that will include the
preemption event following the preempt-idle write.

Then on deciding that the HW is idle, we apply the complication such
that execlists->active == 0. (That rule is what breaks the pattern.)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-03-28 22:28 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 15:17 [PATCH v1] drm/i915/gen11: Preempt-to-idle support in execlists Tomasz Lis
2018-03-27 15:40 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2018-03-27 15:56 ` ✓ Fi.CI.BAT: success " Patchwork
2018-03-27 20:50 ` ✓ Fi.CI.IGT: " Patchwork
2018-03-27 23:27 ` [PATCH v1] " Chris Wilson
2018-03-28 16:06   ` Lis, Tomasz
2018-03-28 22:28     ` Chris Wilson [this message]
2018-03-30 15:42       ` Lis, Tomasz
2018-03-30 19:45         ` Daniele Ceraolo Spurio
2018-04-26 14:02           ` Lis, Tomasz
2018-03-30 18:23   ` Daniele Ceraolo Spurio
2018-04-12 17:15     ` Lis, Tomasz
2018-04-19 11:44 ` [PATCH v2] " Tomasz Lis
2018-04-19 12:00   ` Chris Wilson
2018-04-19 22:23     ` Daniele Ceraolo Spurio
2018-04-19 11:58 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev2) Patchwork
2018-04-19 11:59 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-04-19 12:13 ` ✓ Fi.CI.BAT: success " Patchwork
2018-04-19 16:08 ` ✓ Fi.CI.IGT: " Patchwork
2018-05-11 15:45 ` [PATCH v3] drm/i915/gen11: Preempt-to-idle support in execlists - v3 notes Tomasz Lis
2018-05-11 15:45   ` [PATCH v3] drm/i915/gen11: Preempt-to-idle support in execlists Tomasz Lis
2018-05-18 21:08     ` Daniele Ceraolo Spurio
2018-05-21 10:16       ` Lis, Tomasz
2018-05-22 14:39         ` Ceraolo Spurio, Daniele
2018-05-22 14:54           ` Lis, Tomasz
2018-05-11 16:15 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev3) Patchwork
2018-05-11 16:16 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-11 16:33 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-11 17:46 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-05-25 18:26 ` [PATCH v4] drm/i915/gen11: Preempt-to-idle support in execlists Tomasz Lis
2018-06-11 16:37   ` Daniele Ceraolo Spurio
2018-06-29 16:50     ` Lis, Tomasz
2018-07-02 17:36       ` Daniele Ceraolo Spurio
2018-05-25 18:51 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev4) Patchwork
2018-05-25 18:52 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-25 19:08 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-26  5:18 ` ✓ Fi.CI.IGT: " Patchwork
2018-07-06 15:52 ` [PATCH v5] drm/i915/gen11: Preempt-to-idle support in execlists Tomasz Lis
2018-07-06 16:08 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev5) Patchwork
2018-07-06 16:08 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-07-06 16:25 ` ✓ Fi.CI.BAT: success " Patchwork
2018-07-07 14:09 ` ✓ Fi.CI.IGT: " Patchwork
2018-07-16 13:07 ` [PATCH v6] drm/i915: Add IOCTL Param to control data port coherency Tomasz Lis
2018-07-16 13:35   ` Tvrtko Ursulin
2018-07-18 13:24   ` Joonas Lahtinen
2018-07-18 14:42     ` Tvrtko Ursulin
2018-07-18 15:28       ` Lis, Tomasz
2018-07-19  7:12         ` Joonas Lahtinen
2018-07-19 15:10           ` Lis, Tomasz
2018-07-16 14:36 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev6) Patchwork
2018-07-16 14:37 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-07-16 14:58 ` ✓ Fi.CI.BAT: success " Patchwork
2018-07-16 19:26 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-10-15 17:29 ` [PATCH v5] drm/i915/icl: Preempt-to-idle support in execlists Tomasz Lis
2018-10-16 10:53   ` Joonas Lahtinen
2018-10-19 16:00     ` Lis, Tomasz
2018-10-23  9:13       ` Joonas Lahtinen
2018-10-23  9:24         ` Lis, Tomasz
2018-10-15 17:44 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev7) Patchwork
2018-10-15 17:45 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-10-15 18:07 ` ✓ Fi.CI.BAT: success " Patchwork
2018-10-15 23:55 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-11-09 17:18 ` [PATCH v6] drm/i915/icl: Preempt-to-idle support in execlists Tomasz Lis
2018-12-10 15:40   ` Tvrtko Ursulin
2018-12-14 11:10     ` Joonas Lahtinen
2018-12-17 15:21       ` Lis, Tomasz
2018-11-09 18:17 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gen11: Preempt-to-idle support in execlists. (rev8) Patchwork
2018-11-09 18:18 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-11-09 18:33 ` ✓ Fi.CI.BAT: success " Patchwork
2018-11-10  3:29 ` ✓ Fi.CI.IGT: " 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=152227609116.10679.12481725029029254564@mail.alporthouse.com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mika.kuoppala@intel.com \
    --cc=tomasz.lis@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.