Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>,
	Badal Nilawar <badal.nilawar@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [PATCH v6 04/25] drm/xe: Modify xe_force_wake_put to handle _get returned mask
Date: Tue, 1 Oct 2024 11:01:03 +0530	[thread overview]
Message-ID: <52ed7c31-c4b4-422c-aa6d-c88d2ab6f5ed@intel.com> (raw)
In-Reply-To: <20240930221352.GD5725@mdroper-desk1.amr.corp.intel.com>



On 01-10-2024 03:43, Matt Roper wrote:
> On Mon, Sep 30, 2024 at 11:01:28AM +0530, Himal Prasad Ghimiray wrote:
>> Instead of calling xe_force_wake_put on all domains that were input to
>> xe_force_wake_get, call _put only on the domains whose reference counts
>> were successfully incremented by the _get call. Since the return value
>> of _get can be a mask that does not match any specific value in the enum
>> xe_force_wake_domains, change the input parameter of _put to unsigned int.
>>
>> v3
>> - Move WARN to this patch (Badal)
>> - use xe_gt_WARN instead of XE_WARN (Michal)
>> - Stop using xe_force_wake_domains for non enum values.
>> - Remove kernel-doc from this patch (Badal)
>>
>> -v5
>> - Fix global awake_domain
>>
>> -v6
>> - put all initialized domains in case of FORCEWAKE_ALL.
>> - Modify ret variable name (Michal)
>> - Modify input var name (Michal)
>> - Modify commit message and warn (Badal)
>>
>> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Cc: Badal Nilawar <badal.nilawar@intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> Cc: Nirmoy Das <nirmoy.das@intel.com>
>> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com>
>> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
>> ---
>>   drivers/gpu/drm/xe/xe_force_wake.c | 28 +++++++++++++++++++++-------
>>   drivers/gpu/drm/xe/xe_force_wake.h |  2 +-
>>   2 files changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_force_wake.c b/drivers/gpu/drm/xe/xe_force_wake.c
>> index 7f358e42c5d4..372ea43b0d06 100644
>> --- a/drivers/gpu/drm/xe/xe_force_wake.c
>> +++ b/drivers/gpu/drm/xe/xe_force_wake.c
>> @@ -211,26 +211,40 @@ unsigned int xe_force_wake_get(struct xe_force_wake *fw,
>>   }
>>   
>>   int xe_force_wake_put(struct xe_force_wake *fw,
>> -		      enum xe_force_wake_domains domains)
>> +		      unsigned int fw_ref)
>>   {
>>   	struct xe_gt *gt = fw->gt;
>>   	struct xe_force_wake_domain *domain;
>> -	enum xe_force_wake_domains tmp, sleep = 0;
>> +	unsigned int tmp, sleep = 0;
>>   	unsigned long flags;
>> -	int ret = 0;
>> +	int ack_fail = 0;
>> +
>> +	/*
>> +	 * Avoid unnecessary lock and unlock when the function is called
>> +	 * in error path of individual domains.
>> +	 */
>> +	if (!fw_ref)
>> +		return 0;
>> +
>> +	if (fw_ref == XE_FORCEWAKE_ALL)
>> +		fw_ref = fw->initialized_domains;
>>   
>>   	spin_lock_irqsave(&fw->lock, flags);
>> -	for_each_fw_domain_masked(domain, domains, fw, tmp) {
>> +	for_each_fw_domain_masked(domain, fw_ref, fw, tmp) {
>>   		if (!--domain->ref) {
>>   			sleep |= BIT(domain->id);
>>   			domain_sleep(gt, domain);
>>   		}
>>   	}
>>   	for_each_fw_domain_masked(domain, sleep, fw, tmp) {
>> -		ret |= domain_sleep_wait(gt, domain);
>> +		if (domain_sleep_wait(gt, domain) == 0)
> 
> One of the long-standing bugs with Xe's forcewake implementation is that
> we shouldn't be waiting in the 'put' function at all.  The idea is that
> the driver is supposed to just submit a request to sleep and then move
> on; the hardware will actually go to sleep asynchronously and it's
> perfectly expected for that to not happen immediately when we request
> it.  Waiting here adds an unnecessary delay and slows down the whole
> system.  We probably/hopefully don't wake/sleep forcewake often enough
> in the Xe driver for this to cause a major user-noticeable performance
> impact, but the current synchronous sleep is definitely not the intended
> design or what we want going forward.
> 
> What we actually need to do is drop the wait here and add a check+wait
> at the beginning of the 'get' function to ensure that any previously
> submitted sleeps have actually completed before we start the next wake.
> Usually they will have already completed while the driver was doing
> other work, so there will be no extra artificial delays added as we have
> today.

I don't have any objections on my end. The only downside I see is that 
we won't have a definitive time for sleep acknowledgment with this approach.

I'd prefer to keep the current changes separate from this, and we can 
address it in future patches.

BR
Himal
> 
> 
> Matt
> 
>> +			fw->awake_domains &= ~BIT(domain->id);
>> +		else
>> +			ack_fail |= BIT(domain->id);
>>   	}
>> -	fw->awake_domains &= ~sleep;
>>   	spin_unlock_irqrestore(&fw->lock, flags);
>>   
>> -	return ret;
>> +	xe_gt_WARN(gt, ack_fail, "Forcewake domain%s %#x failed to acknowledge sleep request\n",
>> +		   str_plural(hweight_long(ack_fail)), ack_fail);
>> +	return ack_fail;
>>   }
>> diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/xe/xe_force_wake.h
>> index eb638128952d..b5a75544d86a 100644
>> --- a/drivers/gpu/drm/xe/xe_force_wake.h
>> +++ b/drivers/gpu/drm/xe/xe_force_wake.h
>> @@ -18,7 +18,7 @@ void xe_force_wake_init_engines(struct xe_gt *gt,
>>   unsigned int xe_force_wake_get(struct xe_force_wake *fw,
>>   			       enum xe_force_wake_domains domains);
>>   int xe_force_wake_put(struct xe_force_wake *fw,
>> -		      enum xe_force_wake_domains domains);
>> +		      unsigned int fw_ref);
>>   
>>   static inline int
>>   xe_force_wake_ref(struct xe_force_wake *fw,
>> -- 
>> 2.34.1
>>
> 


  reply	other threads:[~2024-10-01  5:31 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30  5:31 [PATCH v6 00/25] Fix xe_force_wake_get() failure handling Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 01/25] drm/xe: Add member initialized_domains to xe_force_wake() Himal Prasad Ghimiray
2024-09-30 19:51   ` Michal Wajdeczko
2024-10-01  5:03     ` Ghimiray, Himal Prasad
2024-09-30  5:31 ` [PATCH v6 02/25] drm/xe/forcewake: Add a helper xe_force_wake_ref_has_domain() Himal Prasad Ghimiray
2024-09-30 20:04   ` Michal Wajdeczko
2024-10-01  5:06     ` Ghimiray, Himal Prasad
2024-09-30  5:31 ` [PATCH v6 03/25] drm/xe: Error handling in xe_force_wake_get() Himal Prasad Ghimiray
2024-10-03 12:23   ` Nilawar, Badal
2024-10-03 16:10     ` Ghimiray, Himal Prasad
2024-10-04  7:40       ` Nilawar, Badal
2024-10-07  3:14         ` Ghimiray, Himal Prasad
2024-09-30  5:31 ` [PATCH v6 04/25] drm/xe: Modify xe_force_wake_put to handle _get returned mask Himal Prasad Ghimiray
2024-09-30 20:13   ` Michal Wajdeczko
2024-09-30 20:15     ` Michal Wajdeczko
2024-10-01  5:11       ` Ghimiray, Himal Prasad
2024-10-04  3:21         ` Nilawar, Badal
2024-09-30 22:13   ` Matt Roper
2024-10-01  5:31     ` Ghimiray, Himal Prasad [this message]
2024-09-30  5:31 ` [PATCH v6 05/25] drm/xe/device: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-10-04  7:18   ` Nilawar, Badal
2024-10-07  3:40     ` Ghimiray, Himal Prasad
2024-09-30  5:31 ` [PATCH v6 06/25] drm/xe/hdcp: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 07/25] drm/xe/gsc: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 08/25] drm/xe/gt: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 09/25] drm/xe/xe_gt_idle: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 10/25] drm/xe/devcoredump: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 11/25] drm/xe/tests/mocs: Update xe_force_wake_get() return handling Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 12/25] drm/xe/mocs: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 13/25] drm/xe/xe_drm_client: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 14/25] drm/xe/xe_gt_debugfs: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 15/25] drm/xe/guc: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 16/25] drm/xe/huc: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 17/25] drm/xe/oa: Handle force_wake_get failure in xe_oa_stream_init() Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 18/25] drm/xe/pat: Update handling of xe_force_wake_get return Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 19/25] drm/xe/gt_tlb_invalidation_ggtt: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 20/25] drm/xe/xe_reg_sr: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 21/25] drm/xe/query: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 22/25] drm/xe/vram: " Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 23/25] drm/xe: forcewake debugfs open fails on xe_forcewake_get failure Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 24/25] drm/xe: Ensure __must_check for xe_force_wake_get() return Himal Prasad Ghimiray
2024-09-30  5:31 ` [PATCH v6 25/25] drm/xe: Change return type to void for xe_force_wake_put Himal Prasad Ghimiray
2024-09-30  6:02 ` ✓ CI.Patch_applied: success for Fix xe_force_wake_get() failure handling (rev6) Patchwork
2024-09-30  6:03 ` ✓ CI.checkpatch: " Patchwork
2024-09-30  6:03 ` ✗ CI.KUnit: failure " Patchwork
2024-09-30  7:35   ` Ghimiray, Himal Prasad
2024-09-30 20:55 ` ✓ CI.Patch_applied: success for Fix xe_force_wake_get() failure handling (rev7) Patchwork
2024-09-30 20:55 ` ✓ CI.checkpatch: " Patchwork
2024-09-30 20:57 ` ✓ CI.KUnit: " Patchwork
2024-09-30 21:08 ` ✓ CI.Build: " Patchwork
2024-09-30 21:10 ` ✗ CI.Hooks: failure " Patchwork
2024-09-30 21:12 ` ✓ CI.checksparse: success " Patchwork
2024-09-30 21:39 ` ✗ CI.BAT: failure " Patchwork
2024-10-01  6:20 ` ✗ 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=52ed7c31-c4b4-422c-aa6d-c88d2ab6f5ed@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=nirmoy.das@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