Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nilawar, Badal" <badal.nilawar@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: Matthew Brost <matthew.brost@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v8 09/26] drm/xe/gt: Update handling of xe_force_wake_get return
Date: Wed, 9 Oct 2024 18:16:02 +0530	[thread overview]
Message-ID: <876cb906-f6c5-42e1-8f80-340adafff1ab@intel.com> (raw)
In-Reply-To: <20241008071115.1862704-10-himal.prasad.ghimiray@intel.com>



On 08-10-2024 12:40, Himal Prasad Ghimiray wrote:
> xe_force_wake_get() now returns the reference count-incremented domain
> mask. If it fails for individual domains, the return value will always
> be 0. However, for XE_FORCEWAKE_ALL, it may return a non-zero value even
> in the event of failure. Use helper xe_force_wake_ref_has_domain to verify
> all domains are initialized or not. Update the return handling of
> xe_force_wake_get() to reflect this behavior, and ensure that the return
> value is passed as input to xe_force_wake_put().
> 
> v3
> - return xe_wakeref_t instead of int in xe_force_wake_get()
> - xe_force_wake_put() error doesn't need to be checked. It internally
> WARNS on domain ack failure.
> 
> v4
> - Rebase fix
> 
> v5
> - return unsigned int for xe_force_wake_get()
> - remove redundant XE_WARN_ON()
> 
> v6
> - use helper for checking all initialized domains are awake or not.
> 
> v7
> - Fix commit message
> 
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
>   drivers/gpu/drm/xe/xe_gt.c | 105 ++++++++++++++++++++-----------------
>   1 file changed, 58 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index 2d5e78311b76..409f1ab6ea37 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -97,14 +97,14 @@ void xe_gt_sanitize(struct xe_gt *gt)
>   
>   static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	u32 reg;
> -	int err;
>   
>   	if (!XE_WA(gt, 16023588340))
>   		return;
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> -	if (WARN_ON(err))
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> +	if (!fw_ref)
>   		return;
>   
>   	if (!xe_gt_is_media_type(gt)) {
> @@ -115,13 +115,13 @@ static void xe_gt_enable_host_l2_vram(struct xe_gt *gt)
>   	}
>   
>   	xe_gt_mcr_multicast_write(gt, XEHPC_L3CLOS_MASK(3), 0x3);
> -	xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   }
>   
>   static void xe_gt_disable_host_l2_vram(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	u32 reg;
> -	int err;
>   
>   	if (!XE_WA(gt, 16023588340))
>   		return;
> @@ -129,15 +129,15 @@ static void xe_gt_disable_host_l2_vram(struct xe_gt *gt)
>   	if (xe_gt_is_media_type(gt))
>   		return;
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> -	if (WARN_ON(err))
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> +	if (WARN_ON(!fw_ref))

Is seems you forgot to remove this WARN_ON.

Regards,
Badal

>   		return;
>   
>   	reg = xe_gt_mcr_unicast_read_any(gt, XE2_GAMREQSTRM_CTRL);
>   	reg &= ~CG_DIS_CNTLBUS;
>   	xe_gt_mcr_multicast_write(gt, XE2_GAMREQSTRM_CTRL, reg);
>   
> -	xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   }
>   
>   /**
> @@ -403,11 +403,14 @@ static void dump_pat_on_error(struct xe_gt *gt)
>   
>   static int gt_fw_domain_init(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err, i;
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> -	if (err)
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> +	if (!fw_ref) {
> +		err = -ETIMEDOUT;
>   		goto err_hw_fence_irq;
> +	}
>   
>   	if (!xe_gt_is_media_type(gt)) {
>   		err = xe_ggtt_init(gt_to_tile(gt)->mem.ggtt);
> @@ -442,14 +445,12 @@ static int gt_fw_domain_init(struct xe_gt *gt)
>   	 */
>   	gt->info.gmdid = xe_mmio_read32(&gt->mmio, GMD_ID);
>   
> -	err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> -	XE_WARN_ON(err);
> -
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	return 0;
>   
>   err_force_wake:
>   	dump_pat_on_error(gt);
> -	xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   err_hw_fence_irq:
>   	for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
>   		xe_hw_fence_irq_finish(&gt->fence_irq[i]);
> @@ -459,11 +460,14 @@ static int gt_fw_domain_init(struct xe_gt *gt)
>   
>   static int all_fw_domain_init(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err, i;
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	if (err)
> -		goto err_hw_fence_irq;
> +	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;
> +		goto err_force_wake;
> +	}
>   
>   	xe_gt_mcr_set_implicit_defaults(gt);
>   	xe_reg_sr_apply_mmio(&gt->reg_sr, gt);
> @@ -527,14 +531,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
>   	if (IS_SRIOV_PF(gt_to_xe(gt)))
>   		xe_gt_sriov_pf_init_hw(gt);
>   
> -	err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	XE_WARN_ON(err);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   
>   	return 0;
>   
>   err_force_wake:
> -	xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -err_hw_fence_irq:
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
>   		xe_hw_fence_irq_finish(&gt->fence_irq[i]);
>   
> @@ -547,11 +549,12 @@ static int all_fw_domain_init(struct xe_gt *gt)
>    */
>   int xe_gt_init_hwconfig(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err;
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> -	if (err)
> -		goto out;
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> +	if (!fw_ref)
> +		return -ETIMEDOUT;
>   
>   	xe_gt_mcr_init_early(gt);
>   	xe_pat_init(gt);
> @@ -569,8 +572,7 @@ int xe_gt_init_hwconfig(struct xe_gt *gt)
>   	xe_gt_enable_host_l2_vram(gt);
>   
>   out_fw:
> -	xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> -out:
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	return err;
>   }
>   
> @@ -765,6 +767,7 @@ static int do_gt_restart(struct xe_gt *gt)
>   
>   static int gt_reset(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err;
>   
>   	if (xe_device_wedged(gt_to_xe(gt)))
> @@ -785,9 +788,11 @@ static int gt_reset(struct xe_gt *gt)
>   
>   	xe_gt_sanitize(gt);
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	if (err)
> -		goto err_msg;
> +	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;
> +		goto err_out;
> +	}
>   
>   	xe_uc_gucrc_disable(&gt->uc);
>   	xe_uc_stop_prepare(&gt->uc);
> @@ -805,8 +810,7 @@ static int gt_reset(struct xe_gt *gt)
>   	if (err)
>   		goto err_out;
>   
> -	err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	XE_WARN_ON(err);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	xe_pm_runtime_put(gt_to_xe(gt));
>   
>   	xe_gt_info(gt, "reset done\n");
> @@ -814,8 +818,7 @@ static int gt_reset(struct xe_gt *gt)
>   	return 0;
>   
>   err_out:
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> -err_msg:
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	XE_WARN_ON(xe_uc_start(&gt->uc));
>   err_fail:
>   	xe_gt_err(gt, "reset failed (%pe)\n", ERR_PTR(err));
> @@ -847,22 +850,25 @@ void xe_gt_reset_async(struct xe_gt *gt)
>   
>   void xe_gt_suspend_prepare(struct xe_gt *gt)
>   {
> -	XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> +	unsigned int fw_ref;
> +
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
>   
>   	xe_uc_stop_prepare(&gt->uc);
>   
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   }
>   
>   int xe_gt_suspend(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err;
>   
>   	xe_gt_dbg(gt, "suspending\n");
>   	xe_gt_sanitize(gt);
>   
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	if (err)
> +	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))
>   		goto err_msg;
>   
>   	err = xe_uc_suspend(&gt->uc);
> @@ -873,14 +879,15 @@ int xe_gt_suspend(struct xe_gt *gt)
>   
>   	xe_gt_disable_host_l2_vram(gt);
>   
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	xe_gt_dbg(gt, "suspended\n");
>   
>   	return 0;
>   
> -err_force_wake:
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
>   err_msg:
> +	err = -ETIMEDOUT;
> +err_force_wake:
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	xe_gt_err(gt, "suspend failed (%pe)\n", ERR_PTR(err));
>   
>   	return err;
> @@ -888,9 +895,11 @@ int xe_gt_suspend(struct xe_gt *gt)
>   
>   void xe_gt_shutdown(struct xe_gt *gt)
>   {
> -	xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> +	unsigned int fw_ref;
> +
> +	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
>   	do_gt_reset(gt);
> -	xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   }
>   
>   /**
> @@ -915,11 +924,12 @@ int xe_gt_sanitize_freq(struct xe_gt *gt)
>   
>   int xe_gt_resume(struct xe_gt *gt)
>   {
> +	unsigned int fw_ref;
>   	int err;
>   
>   	xe_gt_dbg(gt, "resuming\n");
> -	err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
> -	if (err)
> +	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))
>   		goto err_msg;
>   
>   	err = do_gt_restart(gt);
> @@ -928,14 +938,15 @@ int xe_gt_resume(struct xe_gt *gt)
>   
>   	xe_gt_idle_enable_pg(gt);
>   
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	xe_gt_dbg(gt, "resumed\n");
>   
>   	return 0;
>   
> -err_force_wake:
> -	XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
>   err_msg:
> +	err = -ETIMEDOUT;
> +err_force_wake:
> +	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>   	xe_gt_err(gt, "resume failed (%pe)\n", ERR_PTR(err));
>   
>   	return err;


  reply	other threads:[~2024-10-09 12:46 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  7:10 [PATCH v8 00/26] Fix xe_force_wake_get() failure handling Himal Prasad Ghimiray
2024-10-08  6:58 ` ✓ CI.Patch_applied: success for Fix xe_force_wake_get() failure handling (rev9) Patchwork
2024-10-08  6:59 ` ✓ CI.checkpatch: " Patchwork
2024-10-08  7:00 ` ✓ CI.KUnit: " Patchwork
2024-10-08  7:10 ` [PATCH v8 01/26] drm/xe: Add member initialized_domains to xe_force_wake() Himal Prasad Ghimiray
2024-10-08 14:55   ` Nilawar, Badal
2024-10-08 17:03   ` Michal Wajdeczko
2024-10-08  7:10 ` [PATCH v8 02/26] drm/xe/forcewake: Change awake_domain datatype Himal Prasad Ghimiray
2024-10-08 14:56   ` Nilawar, Badal
2024-10-08 17:04   ` Michal Wajdeczko
2024-10-08  7:10 ` [PATCH v8 03/26] drm/xe/forcewake: Add a helper xe_force_wake_ref_has_domain() Himal Prasad Ghimiray
2024-10-08 14:58   ` Nilawar, Badal
2024-10-08 17:07   ` Michal Wajdeczko
2024-10-08  7:10 ` [PATCH v8 04/26] drm/xe: Error handling in xe_force_wake_get() Himal Prasad Ghimiray
2024-10-08 15:13   ` Nilawar, Badal
2024-10-08 18:05   ` Michal Wajdeczko
2024-10-08  7:10 ` [PATCH v8 05/26] drm/xe: Modify xe_force_wake_put to handle _get returned mask Himal Prasad Ghimiray
2024-10-08 18:18   ` Michal Wajdeczko
2024-10-08  7:10 ` [PATCH v8 06/26] drm/xe/device: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-10-09 11:30   ` Jani Nikula
2024-10-08  7:10 ` [PATCH v8 07/26] drm/xe/hdcp: " Himal Prasad Ghimiray
2024-10-08  7:10 ` [PATCH v8 08/26] drm/xe/gsc: " Himal Prasad Ghimiray
2024-10-09 12:42   ` Nilawar, Badal
2024-10-08  7:10 ` [PATCH v8 09/26] drm/xe/gt: " Himal Prasad Ghimiray
2024-10-09 12:46   ` Nilawar, Badal [this message]
2024-10-08  7:10 ` [PATCH v8 10/26] drm/xe/xe_gt_idle: " Himal Prasad Ghimiray
2024-10-09 12:49   ` Nilawar, Badal
2024-10-08  7:11 ` [PATCH v8 11/26] drm/xe/devcoredump: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 12/26] drm/xe/tests/mocs: Update xe_force_wake_get() return handling Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 13/26] drm/xe/mocs: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 14/26] drm/xe/xe_drm_client: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 15/26] drm/xe/xe_gt_debugfs: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 16/26] drm/xe/guc: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 17/26] drm/xe/huc: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 18/26] drm/xe/oa: Handle force_wake_get failure in xe_oa_stream_init() Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 19/26] drm/xe/pat: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 20/26] drm/xe/gt_tlb_invalidation_ggtt: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 21/26] drm/xe/xe_reg_sr: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 22/26] drm/xe/query: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 23/26] drm/xe/vram: " Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 24/26] drm/xe: forcewake debugfs open fails on xe_forcewake_get failure Himal Prasad Ghimiray
2024-10-08  7:11 ` [PATCH v8 25/26] drm/xe: Ensure __must_check for xe_force_wake_get() return Himal Prasad Ghimiray
2024-10-08 17:17   ` Nilawar, Badal
2024-10-08  7:11 ` [PATCH v8 26/26] drm/xe: Change return type to void for xe_force_wake_put Himal Prasad Ghimiray
2024-10-08 17:22   ` Nilawar, Badal
2024-10-08 18:24   ` Michal Wajdeczko
2024-10-08  7:30 ` ✓ CI.Hooks: success for Fix xe_force_wake_get() failure handling (rev9) Patchwork
2024-10-08  7:32 ` ✓ CI.checksparse: " Patchwork
2024-10-08  8:12 ` ✗ CI.BAT: failure " Patchwork
2024-10-08 10:44 ` ✗ CI.FULL: " 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=876cb906-f6c5-42e1-8f80-340adafff1ab@intel.com \
    --to=badal.nilawar@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.brost@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