drm/xe: Inline gt_reset in the worker
Subsystems (2)
PATCH 1/1 drm/xe: Inline gt_reset in the worker
gt_reset() doesn't make sense by itself: it can only be called as part of the worker. Inline it there to avoid it being called from elsewhere and clarify the gt_reset() vs do_gt_reset() paths. Note that the error return from gt_reset() was just being ignored.
Also add a comment to the xe_pm_runtime_put() to make sure the get()/put() pair is clear.
--- drivers/gpu/drm/xe/xe_gt.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +8 -24
@@ -813,36 +813,29 @@ static int do_gt_restart(struct xe_gt *gt)return 0 ; } -static int gt_reset (struct xe_gt *gt) +static void gt_reset_worker (struct work_struct *w) { +struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker);unsigned int fw_ref;int err; -if (xe_device_wedged (gt_to_xe (gt))) { - err = -ECANCELED ; +if (xe_device_wedged (gt_to_xe (gt))) goto err_pm_put; - }/* We only support GT resets with GuC submission */ -if (!xe_device_uc_enabled (gt_to_xe (gt))) { - err = -ENODEV ; +if (!xe_device_uc_enabled (gt_to_xe (gt))) goto err_pm_put; - }xe_gt_info (gt,"reset started\n" ); -if (xe_fault_inject_gt_reset ()) { - err = -ECANCELED ; +if (xe_fault_inject_gt_reset ()) goto err_fail; - }xe_gt_sanitize (gt); fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FORCEWAKE_ALL ); -if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) { - err = -ETIMEDOUT ; +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) goto err_out; - }if (IS_SRIOV_PF (gt_to_xe (gt)))xe_gt_sriov_pf_stop_prepare (gt);
@@ -864,12 +857,12 @@ static int gt_reset(struct xe_gt *gt) goto err_out;xe_force_wake_put (gt_to_fw (gt), fw_ref); + +/* Pair with get while enqueueing the work in xe_gt_reset_async() */ xe_pm_runtime_put (gt_to_xe (gt));xe_gt_info (gt,"reset done\n" ); -return 0 ; - err_out:xe_force_wake_put (gt_to_fw (gt), fw_ref);XE_WARN_ON (xe_uc_start (>->uc));
@@ -879,15 +872,6 @@ static int gt_reset(struct xe_gt *gt)xe_device_declare_wedged (gt_to_xe (gt)); err_pm_put:xe_pm_runtime_put (gt_to_xe (gt)); - -return err; -} - -static void gt_reset_worker (struct work_struct *w) -{ -struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker); - -gt_reset (gt); }void xe_gt_reset_async (struct xe_gt *gt)
Quoted 62 lines · Lucas De Marchi
gt_reset()doesn't make sense by itself: it can only be called as part of the worker. Inline it there to avoid it being called from elsewhere and clarify thegt_reset()vsdo_gt_reset()paths. Note that the error return fromgt_reset()was just being ignored.Also add a comment to the
xe_pm_runtime_put()to make sure the get()/put() pair is clear.Cc Matthew Brost <[email protected]>Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/xe_gt.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-)drivers/gpu/drm/xe/xe_gt.c +6
-13@@ -813,36 +813,29 @@ static int do_gt_restart(struct xe_gt *gt)return 0 ; } -static int gt_reset (struct xe_gt *gt) +static void gt_reset_worker (struct work_struct *w) { +struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker);unsigned int fw_ref;int err; -if (xe_device_wedged (gt_to_xe (gt))) { - err = -ECANCELED ; +if (xe_device_wedged (gt_to_xe (gt))) goto err_pm_put; - }/* We only support GT resets with GuC submission */ -if (!xe_device_uc_enabled (gt_to_xe (gt))) { - err = -ENODEV ; +if (!xe_device_uc_enabled (gt_to_xe (gt))) goto err_pm_put; - }xe_gt_info (gt,"reset started\n" ); -if (xe_fault_inject_gt_reset ()) { - err = -ECANCELED ; +if (xe_fault_inject_gt_reset ()) goto err_fail; - }xe_gt_sanitize (gt); fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FORCEWAKE_ALL ); -if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) { - err = -ETIMEDOUT ; +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) goto err_out; - }if (IS_SRIOV_PF (gt_to_xe (gt)))xe_gt_sriov_pf_stop_prepare (gt);
drivers/gpu/drm/xe/xe_gt.c static int gt_reset(struct xe_gt *gt) · line 861
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt.c +2
-0@@ -864,12 +857,12 @@ static int gt_reset(struct xe_gt *gt) goto err_out;xe_force_wake_put (gt_to_fw (gt), fw_ref); + +/* Pair with get while enqueueing the work in xe_gt_reset_async() */
Nit, I'd add commit on other side of this (i.e., the get) too.
Feell free to add that when merging. Good cleanup.
Quoted 28 lines
drivers/gpu/drm/xe/xe_gt.c +0
-11xe_pm_runtime_put (gt_to_xe (gt));xe_gt_info (gt,"reset done\n" ); -return 0 ; - err_out:xe_force_wake_put (gt_to_fw (gt), fw_ref);XE_WARN_ON (xe_uc_start (>->uc));@@ -879,15 +872,6 @@ static int gt_reset(struct xe_gt *gt)xe_device_declare_wedged (gt_to_xe (gt)); err_pm_put:xe_pm_runtime_put (gt_to_xe (gt)); - -return err; -} - -static void gt_reset_worker (struct work_struct *w) -{ -struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker); - -gt_reset (gt); }void xe_gt_reset_async (struct xe_gt *gt)
Quoted 65 lines · Matthew Brost
Quoted 64 lines · Lucas De Marchi
gt_reset()doesn't make sense by itself: it can only be called as part of the worker. Inline it there to avoid it being called from elsewhere and clarify thegt_reset()vsdo_gt_reset()paths. Note that the error return fromgt_reset()was just being ignored.Also add a comment to the
xe_pm_runtime_put()to make sure the get()/put() pair is clear.Cc Matthew Brost <[email protected]>Signed-off-by Lucas De Marchi <[email protected]>--- drivers/gpu/drm/xe/xe_gt.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-)drivers/gpu/drm/xe/xe_gt.c +6
-13@@ -813,36 +813,29 @@ static int do_gt_restart(struct xe_gt *gt)return 0 ; } -static int gt_reset (struct xe_gt *gt) +static void gt_reset_worker (struct work_struct *w) { +struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker);unsigned int fw_ref;int err; -if (xe_device_wedged (gt_to_xe (gt))) { - err = -ECANCELED ; +if (xe_device_wedged (gt_to_xe (gt))) goto err_pm_put; - }/* We only support GT resets with GuC submission */ -if (!xe_device_uc_enabled (gt_to_xe (gt))) { - err = -ENODEV ; +if (!xe_device_uc_enabled (gt_to_xe (gt))) goto err_pm_put; - }xe_gt_info (gt,"reset started\n" ); -if (xe_fault_inject_gt_reset ()) { - err = -ECANCELED ; +if (xe_fault_inject_gt_reset ()) goto err_fail; - }xe_gt_sanitize (gt); fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FORCEWAKE_ALL ); -if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) { - err = -ETIMEDOUT ; +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FORCEWAKE_ALL )) goto err_out; - }if (IS_SRIOV_PF (gt_to_xe (gt)))xe_gt_sriov_pf_stop_prepare (gt);@@ -864,12 +857,12 @@ static int gt_reset(struct xe_gt *gt) goto err_out;
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt.c static int gt_reset(struct xe_gt *gt) · line 861
Quoted 3 lines
drivers/gpu/drm/xe/xe_gt.c +2
-0xe_force_wake_put (gt_to_fw (gt), fw_ref); + +/* Pair with get while enqueueing the work in xe_gt_reset_async() */ Nit, I'd add commit on other side of this (i.e., the get) too.
will do
Quoted 2 lines
Feell free to add that when merging. Good cleanup.
I will send a [CI] patch, because it seems patchwork was dead when I sent so there's no CI results.
Quoted 2 lines
Reviewed-by Matthew Brost <[email protected]>
thanks
Lucas De Marchi
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/xe/xe_gt.c +0
-11xe_pm_runtime_put (gt_to_xe (gt));xe_gt_info (gt,"reset done\n" ); -return 0 ; - err_out:xe_force_wake_put (gt_to_fw (gt), fw_ref);XE_WARN_ON (xe_uc_start (>->uc));@@ -879,15 +872,6 @@ static int gt_reset(struct xe_gt *gt)xe_device_declare_wedged (gt_to_xe (gt)); err_pm_put:xe_pm_runtime_put (gt_to_xe (gt)); - -return err; -} - -static void gt_reset_worker (struct work_struct *w) -{ -struct xe_gt *gt =container_of (w,typeof (*gt), reset.worker); - -gt_reset (gt); }void xe_gt_reset_async (struct xe_gt *gt)