From: John.C.Harrison@Intel.com
To: Intel-GFX@Lists.FreeDesktop.Org
Cc: DRI-Devel@Lists.FreeDesktop.Org
Subject: [Intel-gfx] [PATCH 2/2] drm/i915/guc: Don't disable a context whose enable is still pending
Date: Thu, 9 Nov 2023 16:54:09 -0800 [thread overview]
Message-ID: <20231110005409.304273-3-John.C.Harrison@Intel.com> (raw)
In-Reply-To: <20231110005409.304273-1-John.C.Harrison@Intel.com>
From: John Harrison <John.C.Harrison@Intel.com>
Various processes involve requesting GuC to disable a given context.
However context enable/disable is an asynchronous process in the GuC.
Thus, it is possible the previous enable request is still being
processed when the disable request is triggered. Having both enable
and disable in flight concurrently is illegal - GuC will return an
error and fail the second operation. The KMD side handler for the
completion message also can't cope with having both pending flags set.
So delay the disable request until it is safe to send.
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
.../gpu/drm/i915/gt/uc/intel_guc_submission.c | 31 +++++++++++++++----
1 file changed, 25 insertions(+), 6 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 d399e4d238c10..8c34b0a5abf9a 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -3150,7 +3150,8 @@ guc_context_revoke(struct intel_context *ce, struct i915_request *rq,
guc_cancel_context_requests(ce);
intel_engine_signal_breadcrumbs(ce->engine);
} else if (!context_pending_disable(ce)) {
- u16 guc_id;
+ u16 guc_id = ~0;
+ bool pending_enable = context_pending_enable(ce);
/*
* We add +2 here as the schedule disable complete CTB handler
@@ -3158,7 +3159,11 @@ guc_context_revoke(struct intel_context *ce, struct i915_request *rq,
*/
atomic_add(2, &ce->pin_count);
- guc_id = prep_context_pending_disable(ce);
+ if (pending_enable)
+ guc_id = ce->guc_id.id;
+ else
+ guc_id = prep_context_pending_disable(ce);
+
spin_unlock_irqrestore(&ce->guc_state.lock, flags);
/*
@@ -3169,7 +3174,15 @@ guc_context_revoke(struct intel_context *ce, struct i915_request *rq,
with_intel_runtime_pm(runtime_pm, wakeref) {
__guc_context_set_preemption_timeout(guc, guc_id,
preempt_timeout_ms);
- __guc_context_sched_disable(guc, ce, guc_id);
+ if (!pending_enable)
+ __guc_context_sched_disable(guc, ce, guc_id);
+ }
+
+ if (pending_enable) {
+ /* Can't have both in flight concurrently, so try again later... */
+ mod_delayed_work(system_unbound_wq,
+ &ce->guc_state.sched_disable_delay_work,
+ msecs_to_jiffies(1));
}
} else {
if (!context_guc_id_invalid(ce))
@@ -3222,7 +3235,13 @@ static void __delay_sched_disable(struct work_struct *wrk)
spin_lock_irqsave(&ce->guc_state.lock, flags);
- if (bypass_sched_disable(guc, ce)) {
+ if (context_pending_enable(ce)) {
+ spin_unlock_irqrestore(&ce->guc_state.lock, flags);
+ /* Can't have both in flight concurrently, so try again later... */
+ mod_delayed_work(system_unbound_wq,
+ &ce->guc_state.sched_disable_delay_work,
+ msecs_to_jiffies(1));
+ } else if (bypass_sched_disable(guc, ce)) {
spin_unlock_irqrestore(&ce->guc_state.lock, flags);
intel_context_sched_disable_unpin(ce);
} else {
@@ -3257,8 +3276,8 @@ static void guc_context_sched_disable(struct intel_context *ce)
if (bypass_sched_disable(guc, ce)) {
spin_unlock_irqrestore(&ce->guc_state.lock, flags);
intel_context_sched_disable_unpin(ce);
- } else if (!intel_context_is_closed(ce) && !guc_id_pressure(guc, ce) &&
- delay) {
+ } else if ((!intel_context_is_closed(ce) && !guc_id_pressure(guc, ce) &&
+ delay) || context_pending_enable(ce)) {
spin_unlock_irqrestore(&ce->guc_state.lock, flags);
mod_delayed_work(system_unbound_wq,
&ce->guc_state.sched_disable_delay_work,
--
2.41.0
next prev parent reply other threads:[~2023-11-10 0:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 0:54 [Intel-gfx] [PATCH 0/2] Don't send double context enable/disable requests John.C.Harrison
2023-11-10 0:54 ` [Intel-gfx] [PATCH 1/2] drm/i915/guc: Don't double enable a context John.C.Harrison
2023-11-15 21:18 ` Daniele Ceraolo Spurio
2023-11-10 0:54 ` John.C.Harrison [this message]
2023-11-10 6:16 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for Don't send double context enable/disable requests 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=20231110005409.304273-3-John.C.Harrison@Intel.com \
--to=john.c.harrison@intel.com \
--cc=DRI-Devel@Lists.FreeDesktop.Org \
--cc=Intel-GFX@Lists.FreeDesktop.Org \
/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