From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>
To: <John.C.Harrison@Intel.com>, <Intel-GFX@Lists.FreeDesktop.Org>
Cc: DRI-Devel@Lists.FreeDesktop.Org
Subject: Re: [Intel-gfx] [PATCH 4/8] drm/i915/guc: Split guc_lrc_desc_pin apart
Date: Tue, 22 Feb 2022 17:04:16 -0800 [thread overview]
Message-ID: <2286d56c-577f-7c28-1398-7c1e9d96cb5b@intel.com> (raw)
In-Reply-To: <20220217235207.930153-5-John.C.Harrison@Intel.com>
On 2/17/2022 3:52 PM, John.C.Harrison@Intel.com wrote:
> From: John Harrison <John.C.Harrison@Intel.com>
>
> The LRC descriptor pool is going away. Further, the function that was
> populating it was also doing a bunch of logic about the context
> registration sequence. So, split that code apart into separate state
> setup and try to register functions. Note that some of those 'try to
> register' code paths actually undo the state setup and leave it to be
> redone again later (with potentially different values). This is
> inefficient. The next patch will correct this.
>
> Also, move a comment about ignoring return values to the place where
> the return values are actually ignored.
>
> Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Daniele
> ---
> .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 45 ++++++++++++-------
> 1 file changed, 28 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index ad784e8068c7..0ab2d1a24bf6 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -634,7 +634,7 @@ int intel_guc_wait_for_idle(struct intel_guc *guc, long timeout)
> true, timeout);
> }
>
> -static int guc_lrc_desc_pin(struct intel_context *ce, bool loop);
> +static int try_context_registration(struct intel_context *ce, bool loop);
>
> static int __guc_add_request(struct intel_guc *guc, struct i915_request *rq)
> {
> @@ -932,7 +932,7 @@ static int guc_dequeue_one_context(struct intel_guc *guc)
>
> if (unlikely(!ctx_id_mapped(guc, ce->guc_id.id) &&
> !intel_context_is_banned(ce))) {
> - ret = guc_lrc_desc_pin(ce, false);
> + ret = try_context_registration(ce, false);
> if (unlikely(ret == -EPIPE)) {
> goto deadlk;
> } else if (ret == -EBUSY) {
> @@ -2237,17 +2237,13 @@ static void guc_context_policy_init(struct intel_engine_cs *engine,
> desc->preemption_timeout = engine->props.preempt_timeout_ms * 1000;
> }
>
> -static int guc_lrc_desc_pin(struct intel_context *ce, bool loop)
> +static void prepare_context_registration_info(struct intel_context *ce)
> {
> struct intel_engine_cs *engine = ce->engine;
> - struct intel_runtime_pm *runtime_pm = engine->uncore->rpm;
> struct intel_guc *guc = &engine->gt->uc.guc;
> u32 desc_idx = ce->guc_id.id;
> struct guc_lrc_desc *desc;
> - bool context_registered;
> - intel_wakeref_t wakeref;
> struct intel_context *child;
> - int ret = 0;
>
> GEM_BUG_ON(!engine->mask);
> GEM_BUG_ON(!sched_state_is_init(ce));
> @@ -2259,8 +2255,6 @@ static int guc_lrc_desc_pin(struct intel_context *ce, bool loop)
> GEM_BUG_ON(i915_gem_object_is_lmem(guc->ct.vma->obj) !=
> i915_gem_object_is_lmem(ce->ring->vma->obj));
>
> - context_registered = ctx_id_mapped(guc, desc_idx);
> -
> clr_ctx_id_mapping(guc, desc_idx);
> set_ctx_id_mapping(guc, desc_idx, ce);
>
> @@ -2308,6 +2302,21 @@ static int guc_lrc_desc_pin(struct intel_context *ce, bool loop)
>
> clear_children_join_go_memory(ce);
> }
> +}
> +
> +static int try_context_registration(struct intel_context *ce, bool loop)
> +{
> + struct intel_engine_cs *engine = ce->engine;
> + struct intel_runtime_pm *runtime_pm = engine->uncore->rpm;
> + struct intel_guc *guc = &engine->gt->uc.guc;
> + intel_wakeref_t wakeref;
> + u32 desc_idx = ce->guc_id.id;
> + bool context_registered;
> + int ret = 0;
> +
> + context_registered = ctx_id_mapped(guc, desc_idx);
> +
> + prepare_context_registration_info(ce);
>
> /*
> * The context_lookup xarray is used to determine if the hardware
> @@ -3145,7 +3154,7 @@ static int guc_request_alloc(struct i915_request *rq)
> if (unlikely(ret < 0))
> return ret;
> if (context_needs_register(ce, !!ret)) {
> - ret = guc_lrc_desc_pin(ce, true);
> + ret = try_context_registration(ce, true);
> if (unlikely(ret)) { /* unwind */
> if (ret == -EPIPE) {
> disable_submission(guc);
> @@ -3633,9 +3642,17 @@ static void guc_set_default_submission(struct intel_engine_cs *engine)
> static inline void guc_kernel_context_pin(struct intel_guc *guc,
> struct intel_context *ce)
> {
> + /*
> + * Note: we purposefully do not check the returns below because
> + * the registration can only fail if a reset is just starting.
> + * This is called at the end of reset so presumably another reset
> + * isn't happening and even it did this code would be run again.
> + */
> +
> if (context_guc_id_invalid(ce))
> pin_guc_id(guc, ce);
> - guc_lrc_desc_pin(ce, true);
> +
> + try_context_registration(ce, true);
> }
>
> static inline void guc_init_lrc_mapping(struct intel_guc *guc)
> @@ -3653,13 +3670,7 @@ static inline void guc_init_lrc_mapping(struct intel_guc *guc)
> * Also, after a reset the of the GuC we want to make sure that the
> * information shared with GuC is properly reset. The kernel LRCs are
> * not attached to the gem_context, so they need to be added separately.
> - *
> - * Note: we purposefully do not check the return of guc_lrc_desc_pin,
> - * because that function can only fail if a reset is just starting. This
> - * is at the end of reset so presumably another reset isn't happening
> - * and even it did this code would be run again.
> */
> -
> for_each_engine(engine, gt, id) {
> struct intel_context *ce;
>
next prev parent reply other threads:[~2022-02-23 1:04 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 23:51 [Intel-gfx] [PATCH 0/8] Prep work for next GuC release John.C.Harrison
2022-02-17 23:52 ` [Intel-gfx] [PATCH 1/8] drm/i915/guc: Do not conflate lrc_desc with GuC id for registration John.C.Harrison
2022-02-18 21:13 ` Ceraolo Spurio, Daniele
2022-02-17 23:52 ` [Intel-gfx] [PATCH 2/8] drm/i915/guc: Add an explicit 'submission_initialized' flag John.C.Harrison
2022-02-18 21:18 ` Ceraolo Spurio, Daniele
2022-02-17 23:52 ` [Intel-gfx] [PATCH 3/8] drm/i915/guc: Better name for context id limit John.C.Harrison
2022-02-23 1:00 ` Ceraolo Spurio, Daniele
2022-02-17 23:52 ` [Intel-gfx] [PATCH 4/8] drm/i915/guc: Split guc_lrc_desc_pin apart John.C.Harrison
2022-02-23 1:04 ` Ceraolo Spurio, Daniele [this message]
2022-02-17 23:52 ` [Intel-gfx] [PATCH 5/8] drm/i915/guc: Move lrc desc setup to where it is needed John.C.Harrison
2022-02-23 1:12 ` Ceraolo Spurio, Daniele
2022-02-23 20:23 ` John Harrison
2022-02-24 2:03 ` Ceraolo Spurio, Daniele
2022-02-24 21:13 ` John Harrison
2022-02-17 23:52 ` [Intel-gfx] [PATCH 6/8] drm/i915/guc: Rename desc_idx to ctx_id John.C.Harrison
2022-02-23 1:14 ` Ceraolo Spurio, Daniele
2022-02-17 23:52 ` [Intel-gfx] [PATCH 7/8] drm/i915/guc: Drop obsolete H2G definitions John.C.Harrison
2022-02-23 1:19 ` Ceraolo Spurio, Daniele
2022-02-17 23:52 ` [Intel-gfx] [PATCH 8/8] drm/i915/guc: Fix potential invalid pointer dereferences when decoding G2Hs John.C.Harrison
2022-02-23 1:28 ` Ceraolo Spurio, Daniele
2022-02-18 5:29 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Prep work for next GuC release (rev2) Patchwork
2022-02-18 5:56 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-02-18 16:58 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2022-02-08 2:20 [Intel-gfx] [PATCH 0/8] Prep work for next GuC release John.C.Harrison
2022-02-08 2:20 ` [Intel-gfx] [PATCH 4/8] drm/i915/guc: Split guc_lrc_desc_pin apart John.C.Harrison
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=2286d56c-577f-7c28-1398-7c1e9d96cb5b@intel.com \
--to=daniele.ceraolospurio@intel.com \
--cc=DRI-Devel@Lists.FreeDesktop.Org \
--cc=Intel-GFX@Lists.FreeDesktop.Org \
--cc=John.C.Harrison@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