* [Intel-xe] [PATCH] drm/xe/guc_submit: prevent repeated unregister
@ 2023-08-02 14:03 Matthew Auld
2023-08-02 14:46 ` [Intel-xe] ✗ CI.Patch_applied: failure for " Patchwork
2023-08-02 15:56 ` [Intel-xe] [PATCH] " Matthew Brost
0 siblings, 2 replies; 3+ messages in thread
From: Matthew Auld @ 2023-08-02 14:03 UTC (permalink / raw)
To: intel-xe
It seems that various things can trigger the lr cleanup worker,
including CAT error, engine reset and destroying the actual engine, so
seems plausible to end up triggering the worker more than once in some
cases. If that does happen we can race with an ongoing engine deregister
before it has completed, thus triggering it again and also changing the
state back into pending_disable. Checking if the engine has been marked
as destroyed looks like it should prevent this.
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_guc_submit.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 8d2b50e03ed2..2459e9dd95e8 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -802,8 +802,18 @@ static void xe_guc_engine_lr_cleanup(struct work_struct *w)
/* Kill the run_job / process_msg entry points */
drm_sched_run_wq_stop(sched);
- /* Engine state now stable, disable scheduling / deregister if needed */
- if (engine_registered(e)) {
+ /*
+ * Engine state now mostly stable, disable scheduling / deregister if
+ * needed. This cleanup routine might be called multiple times, where
+ * the actual async engine deregister drops the final engine ref.
+ * Calling disable_scheduling_deregister will mark the engine as
+ * destroyed and fire off the CT requests to disable scheduling /
+ * deregister, which we only want to do once. We also don't want to mark
+ * the engine as pending_disable again as this may race with the
+ * xe_guc_deregister_done_handler() which treats it as an unexpected
+ * state.
+ */
+ if (engine_registered(e) && !engine_destroyed(e)) {
struct xe_guc *guc = engine_to_guc(e);
int ret;
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [Intel-xe] ✗ CI.Patch_applied: failure for drm/xe/guc_submit: prevent repeated unregister
2023-08-02 14:03 [Intel-xe] [PATCH] drm/xe/guc_submit: prevent repeated unregister Matthew Auld
@ 2023-08-02 14:46 ` Patchwork
2023-08-02 15:56 ` [Intel-xe] [PATCH] " Matthew Brost
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2023-08-02 14:46 UTC (permalink / raw)
To: Matthew Auld; +Cc: intel-xe
== Series Details ==
Series: drm/xe/guc_submit: prevent repeated unregister
URL : https://patchwork.freedesktop.org/series/121889/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-xe-next' with base: ===
Base commit: f16c04291 drm/xe: Rename engine to exec_queue
=== git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_guc_submit.c:802
error: drivers/gpu/drm/xe/xe_guc_submit.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe/guc_submit: prevent repeated unregister
Patch failed at 0001 drm/xe/guc_submit: prevent repeated unregister
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Intel-xe] [PATCH] drm/xe/guc_submit: prevent repeated unregister
2023-08-02 14:03 [Intel-xe] [PATCH] drm/xe/guc_submit: prevent repeated unregister Matthew Auld
2023-08-02 14:46 ` [Intel-xe] ✗ CI.Patch_applied: failure for " Patchwork
@ 2023-08-02 15:56 ` Matthew Brost
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Brost @ 2023-08-02 15:56 UTC (permalink / raw)
To: Matthew Auld; +Cc: intel-xe
On Wed, Aug 02, 2023 at 03:03:16PM +0100, Matthew Auld wrote:
> It seems that various things can trigger the lr cleanup worker,
> including CAT error, engine reset and destroying the actual engine, so
> seems plausible to end up triggering the worker more than once in some
> cases. If that does happen we can race with an ongoing engine deregister
> before it has completed, thus triggering it again and also changing the
> state back into pending_disable. Checking if the engine has been marked
> as destroyed looks like it should prevent this.
>
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_submit.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 8d2b50e03ed2..2459e9dd95e8 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -802,8 +802,18 @@ static void xe_guc_engine_lr_cleanup(struct work_struct *w)
> /* Kill the run_job / process_msg entry points */
> drm_sched_run_wq_stop(sched);
>
> - /* Engine state now stable, disable scheduling / deregister if needed */
> - if (engine_registered(e)) {
> + /*
> + * Engine state now mostly stable, disable scheduling / deregister if
> + * needed. This cleanup routine might be called multiple times, where
> + * the actual async engine deregister drops the final engine ref.
> + * Calling disable_scheduling_deregister will mark the engine as
> + * destroyed and fire off the CT requests to disable scheduling /
> + * deregister, which we only want to do once. We also don't want to mark
> + * the engine as pending_disable again as this may race with the
> + * xe_guc_deregister_done_handler() which treats it as an unexpected
> + * state.
> + */
> + if (engine_registered(e) && !engine_destroyed(e)) {
This looks correct but a few things.
This will need to be rebased after the s/engine/exec_queue patch that has landed.
guc_exec_queue_timedout_job I think has the same issue too. Can you post a patch for that too.
Anyways this one LGTM:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> struct xe_guc *guc = engine_to_guc(e);
> int ret;
>
> --
> 2.41.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-02 15:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 14:03 [Intel-xe] [PATCH] drm/xe/guc_submit: prevent repeated unregister Matthew Auld
2023-08-02 14:46 ` [Intel-xe] ✗ CI.Patch_applied: failure for " Patchwork
2023-08-02 15:56 ` [Intel-xe] [PATCH] " Matthew Brost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox