[PATCH v5 02/23] drm/xe: Modify xe_force_wake_put to handle _get returned mask
Michal Wajdeczko
michal.wajdeczko at intel.com
Wed Sep 25 14:03:12 UTC 2024
On 24.09.2024 14:16, 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 xe_wakeref_t.
>
> 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
>
> Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Badal Nilawar <badal.nilawar at intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> Cc: Lucas De Marchi <lucas.demarchi at intel.com>
> Cc: Nirmoy Das <nirmoy.das at intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
> ---
> drivers/gpu/drm/xe/xe_force_wake.c | 21 ++++++++++++++++-----
> drivers/gpu/drm/xe/xe_force_wake.h | 2 +-
> 2 files changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_force_wake.c b/drivers/gpu/drm/xe/xe_force_wake.c
> index d190aa93be90..c805214bc348 100644
> --- a/drivers/gpu/drm/xe/xe_force_wake.c
> +++ b/drivers/gpu/drm/xe/xe_force_wake.c
> @@ -197,26 +197,37 @@ 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 domains_mask)
it seems that in whole series you're using "fw_ref" as var name to hold
return value from the xe_force_wake_get() so maybe the same name should
be used here for the parameter instead "domain_mask" ?
> {
> 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;
in patch 23/23 (which personally I would squash into this one) you're
changing return type to void, so keeping the local var named "ret" is
questionable
>
> + /*
> + * Avoid unnecessary lock and unlock when the function is called
> + * in error path of individual domains.
> + */
> + if (!domains_mask)
> + return 0;
> +
> spin_lock_irqsave(&fw->lock, flags);
> - for_each_fw_domain_masked(domain, domains, fw, tmp) {
> + for_each_fw_domain_masked(domain, domains_mask, 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)
> + fw->awake_domains &= ~BIT(domain->id);
> + else
> + ret |= BIT(domain->id);
> }
> - fw->awake_domains &= ~sleep;
> spin_unlock_irqrestore(&fw->lock, flags);
>
> + xe_gt_WARN(gt, ret, "domain%s %#x failed to acknowledgment sleep\n",
> + str_plural(hweight_long(ret)), ret);
> return ret;
> }
> diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/xe/xe_force_wake.h
> index 6c1ade39139b..731a9a5a29a4 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 domains_mask);
>
> static inline int
> xe_force_wake_ref(struct xe_force_wake *fw,
More information about the Intel-xe
mailing list