public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Lis, Tomasz" <tomasz.lis@intel.com>
To: Lionel Landwerlin <lionel.g.landwerlin@intel.com>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: Oscar Mateo <oscar.mateo@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH 08/21] drm/i915/guc: Make use of the SW counter field in the context descriptor
Date: Thu, 30 Aug 2018 16:15:05 +0200	[thread overview]
Message-ID: <fb73b1ae-cf96-eeff-83d1-26be33c7d3de@intel.com> (raw)
In-Reply-To: <7686aaf1-1307-1777-2246-f9bcd59cefc6@intel.com>



On 2018-08-30 02:08, Lionel Landwerlin wrote:
> On 29/08/2018 20:16, Michal Wajdeczko wrote:
>> The new context descriptor format contains two assignable fields:
>> the SW Context ID (technically 11 bits, but practically limited to 2032
>> entries due to some being reserved for future use by the GuC) and the
>> SW Counter (6 bits).
>>
>> We don't want to limit ourselves too much in the maximum number of
>> concurrent contexts we want to allow, so ideally we want to employ
>> every possible bit available. Unfortunately, a further limitation in
>> the interface with the GuC means the combination of SW Context ID +
>> SW Counter has to be unique within the same engine class (as we use
>> the SW Context ID to index in the GuC stage descriptor pool, and the
>> Engine Class + SW Counter to index in the 2-dimensional lrc array).
>> This essentially means we need to somehow encode the engine instance.
>>
>> Since the BSpec allows 6 bits for engine instance, we use the whole
>> SW counter for this task. If the limitation of 2032 maximum simultaneous
>> contexts is too restrictive, we can always squeeze things a bit more
>> (3 extras bits for hw_id, 3 bits for instance) and things will still
>> work (Gen11 does not instance more than 8 engines of any class).
>>
>> Another alternative would be to generate the hw_id per HW context
>> instead of per GEM context, but that has other problems (e.g. maximum
>> number of user-created contexts would be variable, no relationship
>> between a GuC principal descriptor and the proxy descriptor it uses, 
>> ...)
>>
>> Bspec: 12254
>>
>> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
>> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>> Cc: Michel Thierry <michel.thierry@intel.com>
Tested-by: Tomasz Lis <tomasz.lis@intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_drv.h         | 15 +++++++++++----
>>   drivers/gpu/drm/i915/i915_gem_context.c |  5 ++++-
>>   drivers/gpu/drm/i915/i915_gem_context.h |  2 ++
>>   drivers/gpu/drm/i915/i915_reg.h         |  2 ++
>>   drivers/gpu/drm/i915/intel_lrc.c        | 12 +++++++++---
>>   5 files changed, 28 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_drv.h 
>> b/drivers/gpu/drm/i915/i915_drv.h
>> index e5b9d3c..34f5495 100644
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -1866,14 +1866,21 @@ struct drm_i915_private {
>>           struct llist_head free_list;
>>           struct work_struct free_work;
>>   -        /* The hw wants to have a stable context identifier for the
>> +        /*
>> +         * The HW wants to have a stable context identifier for the
>>            * lifetime of the context (for OA, PASID, faults, etc).
>>            * This is limited in execlists to 21 bits.
>> +         * In enhanced execlist (GEN11+) this is limited to 11 bits
>> +         * (the SW Context ID field) but GuC limits it a bit further
>> +         * (11 bits - 16) due to some entries being reserved for future
>> +         * use (so the firmware only supports a GuC stage descriptor
>> +         * pool of 2032 entries).
>>            */
>>           struct ida hw_ida;
>> -#define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
>> -#define MAX_GUC_CONTEXT_HW_ID (1 << 20) /* exclusive */
>> -#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
>> +#define MAX_CONTEXT_HW_ID            (1 << 21) /* exclusive */
>> +#define MAX_GUC_CONTEXT_HW_ID            (1 << 20) /* exclusive */
>> +#define GEN11_MAX_CONTEXT_HW_ID            (1 << 11) /* exclusive */
>> +#define GEN11_MAX_CONTEXT_HW_ID_WITH_GUC (GEN11_MAX_CONTEXT_HW_ID - 16)
>>       } contexts;
>>         u32 fdi_rx_config;
>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
>> b/drivers/gpu/drm/i915/i915_gem_context.c
>> index f15a039..e3b500c 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_context.c
>> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
>> @@ -209,7 +209,10 @@ static int assign_hw_id(struct drm_i915_private 
>> *dev_priv, unsigned *out)
>>       unsigned int max;
>>         if (INTEL_GEN(dev_priv) >= 11) {
>> -        max = GEN11_MAX_CONTEXT_HW_ID;
>> +        if (USES_GUC_SUBMISSION(dev_priv))
>> +            max = GEN11_MAX_CONTEXT_HW_ID_WITH_GUC;
>> +        else
>> +            max = GEN11_MAX_CONTEXT_HW_ID;
>>       } else {
>>           /*
>>            * When using GuC in proxy submission, GuC consumes the
>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h 
>> b/drivers/gpu/drm/i915/i915_gem_context.h
>> index 851dad6..4b87f5d 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_context.h
>> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
>> @@ -154,6 +154,8 @@ struct i915_gem_context {
>>           struct intel_ring *ring;
>>           u32 *lrc_reg_state;
>>           u64 lrc_desc;
>> +        u32 sw_context_id;
>> +        u32 sw_counter;
>>           int pin_count;
>>             const struct intel_context_ops *ops;
>> diff --git a/drivers/gpu/drm/i915/i915_reg.h 
>> b/drivers/gpu/drm/i915/i915_reg.h
>> index f232178..ea65d7b 100644
>> --- a/drivers/gpu/drm/i915/i915_reg.h
>> +++ b/drivers/gpu/drm/i915/i915_reg.h
>> @@ -3900,6 +3900,8 @@ enum {
>>   #define GEN8_CTX_ID_WIDTH 21
>>   #define GEN11_SW_CTX_ID_SHIFT 37
>>   #define GEN11_SW_CTX_ID_WIDTH 11
>> +#define GEN11_SW_COUNTER_SHIFT 55
>> +#define GEN11_SW_COUNTER_WIDTH 6
>>   #define GEN11_ENGINE_CLASS_SHIFT 61
>>   #define GEN11_ENGINE_CLASS_WIDTH 3
>>   #define GEN11_ENGINE_INSTANCE_SHIFT 48
>> diff --git a/drivers/gpu/drm/i915/intel_lrc.c 
>> b/drivers/gpu/drm/i915/intel_lrc.c
>> index f4b9972..3001a14 100644
>> --- a/drivers/gpu/drm/i915/intel_lrc.c
>> +++ b/drivers/gpu/drm/i915/intel_lrc.c
>> @@ -240,14 +240,15 @@ static inline bool need_preempt(const struct 
>> intel_engine_cs *engine,
>>        * anything below.
>>        */
>>       if (INTEL_GEN(ctx->i915) >= 11) {
>
>
> Hey Michal,
>
> There is a comment just above the if () about updating the i915_perf.c 
> (oa_get_render_ctx_id) when descriptor is updated.
> Otherwise this will break some part of the observability feature.
> You can verify this with the IGT tests/perf 
> --run-subtest=gen8-unprivileged-single-ctx-counters
>
> Thanks a lot,
>
> -
> Lionel
Tested on KBL; works fine for both enable_guc=2 and enable_guc=3.

./tests/perf --run-subtest=gen8-unprivileged-single-ctx-counters
IGT-Version: 1.22-g11db680 (x86_64) (Linux: 4.19.0-rc1tli+ x86_64)
Subtest gen8-unprivileged-single-ctx-counters: SUCCESS (0,058s)

-Tomasz
>> -        GEM_BUG_ON(ctx->hw_id >= BIT(GEN11_SW_CTX_ID_WIDTH));
>> -        desc |= (u64)ctx->hw_id << GEN11_SW_CTX_ID_SHIFT;
>> +        GEM_BUG_ON(ce->sw_context_id >= BIT(GEN11_SW_CTX_ID_WIDTH));
>> +        desc |= (u64)ce->sw_context_id << GEN11_SW_CTX_ID_SHIFT;
>>                                   /* bits 37-47 */
>>             desc |= (u64)engine->instance << 
>> GEN11_ENGINE_INSTANCE_SHIFT;
>>                                   /* bits 48-53 */
>>   -        /* TODO: decide what to do with SW counter (bits 55-60) */
>> +        desc |= (u64)ce->sw_counter << GEN11_SW_COUNTER_SHIFT;
>> +                                /* bits 55-60 */
>>             /*
>>            * Although GuC will never see this upper part as it fills
>> @@ -2771,6 +2772,11 @@ static int 
>> execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>>       ce->ring = ring;
>>       ce->state = vma;
>>   +    if (INTEL_GEN(ctx->i915) >= 11) {
>> +        ce->sw_context_id = ctx->hw_id;
>> +        ce->sw_counter = engine->instance;
>> +    }
>> +
>>       return 0;
>>     error_ring_free:
>
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-08-30 14:18 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29 19:10 [PATCH 00/21] New GuC ABI Michal Wajdeczko
2018-08-29 19:10 ` [PATCH 01/21] drm/i915/guc: Update GuC power domain states Michal Wajdeczko
2018-08-29 20:57   ` Daniele Ceraolo Spurio
2018-08-29 22:43     ` Michal Wajdeczko
2018-08-29 19:10 ` [PATCH 02/21] drm/i915/guc: Don't allow GuC submission on pre-Gen11 Michal Wajdeczko
2018-08-29 19:16   ` Srivatsa, Anusha
2018-08-30 22:58   ` John Spotswood
2018-09-06  8:28   ` Joonas Lahtinen
2018-09-06  8:29   ` Joonas Lahtinen
2018-08-29 19:10 ` [PATCH 03/21] drm/i915/guc: Simplify preparation of GuC parameter block Michal Wajdeczko
2018-08-30 22:58   ` John Spotswood
2018-09-06  8:32   ` Joonas Lahtinen
2018-08-29 19:10 ` [PATCH 04/21] drm/i915/guc: Support dual Gen9/Gen11 parameters block Michal Wajdeczko
2018-08-30 22:58   ` John Spotswood
2018-09-06  8:39   ` Joonas Lahtinen
2018-08-29 19:10 ` [PATCH 05/21] drm/i915/guc: Update sample-forcewake command Michal Wajdeczko
2018-08-29 21:52   ` Daniele Ceraolo Spurio
2018-08-29 22:31     ` Michal Wajdeczko
2018-08-29 19:10 ` [PATCH 06/21] drm/i915/guc: Use guc_class instead of engine_class in fw interface Michal Wajdeczko
2018-08-29 19:58   ` Michel Thierry
2018-08-30  0:16     ` Lionel Landwerlin
2018-08-30 13:29       ` Lis, Tomasz
2018-08-30 14:16         ` Lis, Tomasz
2018-08-30 14:56         ` Lionel Landwerlin
2018-08-30 22:34       ` Daniele Ceraolo Spurio
2018-09-06  8:55   ` Joonas Lahtinen
2018-08-29 19:15 ` [PATCH 07/21] drm/i915/guc: New GuC ADS object definition Michal Wajdeczko
2018-08-29 19:16 ` [PATCH 08/21] drm/i915/guc: Make use of the SW counter field in the context descriptor Michal Wajdeczko
2018-08-30  0:08   ` Lionel Landwerlin
2018-08-30 14:15     ` Lis, Tomasz [this message]
2018-08-31 15:31       ` Lis, Tomasz
2018-08-29 19:17 ` [PATCH 09/21] drm/i915/guc: New GuC IDs based on engine class and instance Michal Wajdeczko
2018-08-29 19:18 ` [PATCH 10/21] drm/i915: Add hooks for (per-engine) context allocation/update/free Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 11/21] drm/i915/guc: New GuC stage descriptors Michal Wajdeczko
2018-08-29 23:14     ` Daniele Ceraolo Spurio
2018-10-12 18:25     ` [RFC] " Daniele Ceraolo Spurio
2018-10-17 18:42       ` Lis, Tomasz
2018-10-18 21:07         ` Daniele Ceraolo Spurio
2018-08-29 19:18   ` [PATCH 12/21] drm/i915/guc: New GuC workqueue item submission mechanism Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 13/21] drm/i915/guc: Add support for resume-parsing wq item Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 14/21] drm/i915/guc: New reset-engine command Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 15/21] drm/i915/guc: Support for extended GuC notification messages Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 16/21] drm/i915/guc: New engine-reset-complete message Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 17/21] drm/i915/guc: New GuC interrupt register for Gen11 Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 18/21] drm/i915/guc: New GuC scratch registers " Michal Wajdeczko
2018-08-29 19:18   ` [PATCH 19/21] drm/i915/huc: New HuC status register " Michal Wajdeczko
2018-08-30 22:59     ` John Spotswood
2018-08-29 19:19 ` [PATCH 20/21] drm/i915/guc: Enable command transport buffers " Michal Wajdeczko
2018-08-29 19:19   ` [PATCH 21/21] HAX Don't enable GuC submission on pre-Gen11 even if forced Michal Wajdeczko

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=fb73b1ae-cf96-eeff-83d1-26be33c7d3de@intel.com \
    --to=tomasz.lis@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lionel.g.landwerlin@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=oscar.mateo@intel.com \
    --cc=rodrigo.vivi@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