Skip to content

Commit 79f716b

Browse files
hghimirarodrigovivi
authored andcommitted
drm/xe: Modify xe_force_wake_put to handle _get returned mask
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) -v9 - Add assert condition. Cc: Michal Wajdeczko <[email protected]> Cc: Badal Nilawar <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: Nirmoy Das <[email protected]> Reviewed-by: Badal Nilawar <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Reviewed-by: Michal Wajdeczko <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent a7ddcea commit 79f716b

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

drivers/gpu/drm/xe/xe_force_wake.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,42 @@ unsigned int xe_force_wake_get(struct xe_force_wake *fw,
212212
}
213213

214214
int xe_force_wake_put(struct xe_force_wake *fw,
215-
enum xe_force_wake_domains domains)
215+
unsigned int fw_ref)
216216
{
217217
struct xe_gt *gt = fw->gt;
218218
struct xe_force_wake_domain *domain;
219-
enum xe_force_wake_domains tmp, sleep = 0;
219+
unsigned int tmp, sleep = 0;
220220
unsigned long flags;
221-
int ret = 0;
221+
int ack_fail = 0;
222+
223+
/*
224+
* Avoid unnecessary lock and unlock when the function is called
225+
* in error path of individual domains.
226+
*/
227+
if (!fw_ref)
228+
return 0;
229+
230+
if (xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL))
231+
fw_ref = fw->initialized_domains;
222232

223233
spin_lock_irqsave(&fw->lock, flags);
224-
for_each_fw_domain_masked(domain, domains, fw, tmp) {
234+
for_each_fw_domain_masked(domain, fw_ref, fw, tmp) {
235+
xe_gt_assert(gt, domain->ref);
236+
225237
if (!--domain->ref) {
226238
sleep |= BIT(domain->id);
227239
domain_sleep(gt, domain);
228240
}
229241
}
230242
for_each_fw_domain_masked(domain, sleep, fw, tmp) {
231-
ret |= domain_sleep_wait(gt, domain);
243+
if (domain_sleep_wait(gt, domain) == 0)
244+
fw->awake_domains &= ~BIT(domain->id);
245+
else
246+
ack_fail |= BIT(domain->id);
232247
}
233-
fw->awake_domains &= ~sleep;
234248
spin_unlock_irqrestore(&fw->lock, flags);
235249

236-
return ret;
250+
xe_gt_WARN(gt, ack_fail, "Forcewake domain%s %#x failed to acknowledge sleep request\n",
251+
str_plural(hweight_long(ack_fail)), ack_fail);
252+
return ack_fail;
237253
}

drivers/gpu/drm/xe/xe_force_wake.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void xe_force_wake_init_engines(struct xe_gt *gt,
1818
unsigned int xe_force_wake_get(struct xe_force_wake *fw,
1919
enum xe_force_wake_domains domains);
2020
int xe_force_wake_put(struct xe_force_wake *fw,
21-
enum xe_force_wake_domains domains);
21+
unsigned int fw_ref);
2222

2323
static inline int
2424
xe_force_wake_ref(struct xe_force_wake *fw,

0 commit comments

Comments
 (0)