[PATCH 2/3] drm/xe: Check valid domain is passed in xe_force_wake_ref

Himal Prasad Ghimiray himal.prasad.ghimiray at intel.com
Thu Jun 6 10:08:03 UTC 2024


Assert in case of multiple or invalid domains are passed.

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

diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/xe/xe_force_wake.h
index cee8ff039f83..067afcdde429 100644
--- a/drivers/gpu/drm/xe/xe_force_wake.h
+++ b/drivers/gpu/drm/xe/xe_force_wake.h
@@ -24,7 +24,9 @@ static inline int
 xe_force_wake_ref(struct xe_force_wake *fw,
 		  enum xe_force_wake_domains domain)
 {
-	xe_gt_assert(fw->gt, domain);
+	xe_gt_assert(fw->gt, domain && (domain < XE_FORCEWAKE_ALL));
+	xe_gt_assert(fw->gt, !(domain & (domain - 1)));
+
 	return fw->domains[ffs(domain) - 1].ref;
 }
 
-- 
2.25.1



More information about the Intel-xe mailing list