From: "Ghimiray, Himal Prasad" <himal.prasad.ghimiray@intel.com>
To: "Nilawar, Badal" <badal.nilawar@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: Michal Wajdeczko <michal.wajdeczko@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 03/25] drm/xe: Error handling in xe_force_wake_get()
Date: Mon, 7 Oct 2024 08:44:08 +0530 [thread overview]
Message-ID: <7f08911c-8841-487d-bc91-d9729e46fbd6@intel.com> (raw)
In-Reply-To: <c6094193-0059-44eb-bab7-73d139a0b4a7@intel.com>
On 04-10-2024 13:10, Nilawar, Badal wrote:
>
>
> On 03-10-2024 21:40, Ghimiray, Himal Prasad wrote:
>>
>>
>> On 03-10-2024 17:53, Nilawar, Badal wrote:
>>>
>>>
>>> On 30-09-2024 11:01, Himal Prasad Ghimiray wrote:
>>>> If an acknowledgment timeout occurs for a forcewake domain awake
>>>> request, do not increment the reference count for the domain. This
>>>> ensures that subsequent _get calls do not incorrectly assume the domain
>>>> is awake. The return value is a mask of domains that got refcounted,
>>>> and these domains need to be provided for subsequent xe_force_wake_put
>>>> call.
>>>>
>>>> While at it, add simple kernel-doc for xe_force_wake_get()
>>>>
>>>> v3
>>>> - Use explicit type for mask (Michal/Badal)
>>>> - Improve kernel-doc (Michal)
>>>> - Use unsigned int instead of abusing enum (Michal)
>>>>
>>>> v5
>>>> - Use unsigned int for return (MattB/Badal/Rodrigo)
>>>> - use xe_gt_WARN for domain awake ack failure (Badal/Rodrigo)
>>>>
>>>> v6
>>>> - Change XE_FORCEWAKE_ALL to single bit, this helps accommodate
>>>> actually refcounted domains in return. (Michal)
>>>> - Modify commit message and warn message (Badal)
>>>> - Remove unnecessary information in kernel-doc (Michal)
>>>>
>>>> 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 | 45 +++++++++++++++++
>>>> +------
>>>> drivers/gpu/drm/xe/xe_force_wake.h | 4 +--
>>>> drivers/gpu/drm/xe/xe_force_wake_types.h | 2 +-
>>>> 3 files changed, 38 insertions(+), 13 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/xe/xe_force_wake.c b/drivers/gpu/drm/
>>>> xe/ xe_force_wake.c
>>>> index 5ce9e912818a..7f358e42c5d4 100644
>>>> --- a/drivers/gpu/drm/xe/xe_force_wake.c
>>>> +++ b/drivers/gpu/drm/xe/xe_force_wake.c
>>>> @@ -160,29 +160,54 @@ static int domain_sleep_wait(struct xe_gt *gt,
>>>> (ffs(tmp__) - 1))) && \
>>>> domain__->reg_ctl.addr)
>>>> -int xe_force_wake_get(struct xe_force_wake *fw,
>>>> - enum xe_force_wake_domains domains)
>>>> +/**
>>>> + * xe_force_wake_get() : Increase the domain refcount
>>>> + * @fw: struct xe_force_wake
>>>> + * @domains: forcewake domains to get refcount on
>>>> + *
>>>> + * This function takes references for the input @domains and wakes
>>>> them if
>>>> + * they are asleep.If requested domain is ALL then only
>>>> + * applicable/initialized domains will be considered for refcount
>>>> and it is
>>>> + * a caller responsibilty to check returned ref if it includes any
>>>> specific
>>>> + * domain by using xe_force_wake_ref_has_domain() function. caller
>>>> must call
>>>> + * xe_force_wake_put() function to decrease incremented refcounts.
>>>> + *
>>>> + * Return: opaque reference to woken domains or zero if none of
>>>> requested
>>>> + * domains were awake.
>>>> + */
>>>> +unsigned int xe_force_wake_get(struct xe_force_wake *fw,
>>>> + enum xe_force_wake_domains domains)
>>>> {
>>>> struct xe_gt *gt = fw->gt;
>>>> struct xe_force_wake_domain *domain;
>>>> - enum xe_force_wake_domains tmp, woken = 0;
>>>> + unsigned int ref_incr = 0, awake_rqst = 0, awake_failed = 0;
>>>> + unsigned int tmp, ref_rqst;
>>>> unsigned long flags;
>>>> - int ret = 0;
>>>
>>> As we have fw->initialized_domains lets add check if valid domain is
>>> being passed and assert otherwise.
>>
>> Sounds good check to have. Will add it.
>>
>>
>>>
>>> Regards,
>>> Badal
>>>
>>>> + ref_rqst = (domains == XE_FORCEWAKE_ALL) ? fw-
>>>> >initialized_domains : domains;
>>>> spin_lock_irqsave(&fw->lock, flags);
>>>> - for_each_fw_domain_masked(domain, domains, fw, tmp) {
>>>> + for_each_fw_domain_masked(domain, ref_rqst, fw, tmp) {
>>>> if (!domain->ref++) {
>>>> - woken |= BIT(domain->id);
>>>> + awake_rqst |= BIT(domain->id);
>>>> domain_wake(gt, domain);
>>>> }
>>>> + ref_incr |= BIT(domain->id);
>>>> }
>>>> - for_each_fw_domain_masked(domain, woken, fw, tmp) {
>>>> - ret |= domain_wake_wait(gt, domain);
>>>> + for_each_fw_domain_masked(domain, awake_rqst, fw, tmp) {
>>>> + if (domain_wake_wait(gt, domain) == 0) {
>>>> + fw->awake_domains |= BIT(domain->id);
>>>> + } else {
>>>> + awake_failed |= BIT(domain->id);
>>>> + --domain->ref;
>>>> + }
>>>> }
>>>> - fw->awake_domains |= woken;
>>>> + ref_incr &= ~awake_failed;
>>>> spin_unlock_irqrestore(&fw->lock, flags);
>>>> - return ret;
>>>> + xe_gt_WARN(gt, awake_failed, "Forcewake domain%s %#x failed to
>>>> acknowledge awake request\n",
>>>> + str_plural(hweight_long(awake_failed)), awake_failed);
>>>> +
>>>> + return (ref_incr == fw->initialized_domains) ? ref_incr |
>>>> XE_FORCEWAKE_ALL : ref_incr;
>
> How about we simply return ref_incr at this point? Then, in patch 2,
> given that we have a helper function available, we can validate ref_incr
> against fw->initialized_domains, particularly for XE_FORCEWAKE_ALL,
> within that helper function.
That approach is perfectly fine as well. The reasoning for this method
was to maintain the independence of the API/helper from the fw.
>
> Regards,
> Badal
>
>>>> }
>>>> int xe_force_wake_put(struct xe_force_wake *fw,
>>>> diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/
>>>> xe/ xe_force_wake.h
>>>> index de720881a300..eb638128952d 100644
>>>> --- a/drivers/gpu/drm/xe/xe_force_wake.h
>>>> +++ b/drivers/gpu/drm/xe/xe_force_wake.h
>>>> @@ -15,8 +15,8 @@ void xe_force_wake_init_gt(struct xe_gt *gt,
>>>> struct xe_force_wake *fw);
>>>> void xe_force_wake_init_engines(struct xe_gt *gt,
>>>> struct xe_force_wake *fw);
>>>> -int xe_force_wake_get(struct xe_force_wake *fw,
>>>> - enum xe_force_wake_domains domains);
>>>> +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);
>>>> diff --git a/drivers/gpu/drm/xe/xe_force_wake_types.h b/drivers/gpu/
>>>> drm/xe/xe_force_wake_types.h
>>>> index fde17dc3d01e..899fbbcb3ea9 100644
>>>> --- a/drivers/gpu/drm/xe/xe_force_wake_types.h
>>>> +++ b/drivers/gpu/drm/xe/xe_force_wake_types.h
>>>> @@ -48,7 +48,7 @@ enum xe_force_wake_domains {
>>>> XE_FW_MEDIA_VEBOX2 = BIT(XE_FW_DOMAIN_ID_MEDIA_VEBOX2),
>>>> XE_FW_MEDIA_VEBOX3 = BIT(XE_FW_DOMAIN_ID_MEDIA_VEBOX3),
>>>> XE_FW_GSC = BIT(XE_FW_DOMAIN_ID_GSC),
>>>> - XE_FORCEWAKE_ALL = BIT(XE_FW_DOMAIN_ID_COUNT) - 1
>>>> + XE_FORCEWAKE_ALL = BIT(XE_FW_DOMAIN_ID_COUNT)
>>>> };
>>>> /**
>>>
>>
>
next prev parent reply other threads:[~2024-10-07 3:14 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 [this message]
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
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=7f08911c-8841-487d-bc91-d9729e46fbd6@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=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