[PATCH v3 3/3] drm/xe: Fix xe_force_wake_assert_held for enum XE_FORCEWAKE_ALL

Himal Prasad Ghimiray himal.prasad.ghimiray at intel.com
Wed Jun 5 09:50:05 UTC 2024


xe_force_wake_assert_held is designed to trigger an assertion if the
provided domain is not awake, which works correctly for individual
domains. However, the assertion condition becomes incorrect for
XE_FORCEWAKE_ALL.

For instance, if we assume all domains are in sleep mode, invoking
xe_force_wake_get(fw, XE_FORCEWAKE_GT) will only awaken the "gt" domain.
Subsequently, another function needs that all domains are awake and
utilizes xe_force_wake_assert_held(fw, XE_FORCEWAKE_ALL).
In this scenario, the condition will inaccurately return success because
fw->awake_domains (0x1) & XE_FORCEWAKE_ALL (0xFF) will still be 0x1 and
Ideally it should have asserted.

Make sure that the assertion condition covers the wakefulness of all
initialized domains for XE_FORCEWAKE_ALL.

v2:
- %s/supported/initialized/
- update commit message (Rodrigo)

Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
Cc: Badal Nilawar <badal.nilawar at intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
Reviewed-by: Badal Nilawar <badal.nilawar at intel.com>
---
 drivers/gpu/drm/xe/xe_force_wake.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/xe/xe_force_wake.h
index 83cb157da7cc..a9b01d7ede44 100644
--- a/drivers/gpu/drm/xe/xe_force_wake.h
+++ b/drivers/gpu/drm/xe/xe_force_wake.h
@@ -32,7 +32,12 @@ static inline void
 xe_force_wake_assert_held(struct xe_force_wake *fw,
 			  enum xe_force_wake_domains domain)
 {
-	xe_gt_assert(fw->gt, fw->awake_domains & domain);
+	enum xe_force_wake_domains is_awake;
+
+	is_awake = (domain == XE_FORCEWAKE_ALL) ?
+		    fw->initialized_domains : domain;
+
+	xe_gt_assert(fw->gt, (fw->awake_domains & is_awake) == is_awake);
 }
 
 #endif
-- 
2.25.1



More information about the Intel-xe mailing list