xref: /linux/drivers/gpu/drm/xe/xe_force_wake.h (revision c745b15c1f9cea5680c2906ae868302108f8daf0)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_FORCE_WAKE_H_
7 #define _XE_FORCE_WAKE_H_
8 
9 #include "xe_assert.h"
10 #include "xe_force_wake_types.h"
11 
12 struct xe_gt;
13 
14 void xe_force_wake_init_gt(struct xe_gt *gt,
15 			   struct xe_force_wake *fw);
16 void xe_force_wake_init_engines(struct xe_gt *gt,
17 				struct xe_force_wake *fw);
18 int xe_force_wake_get(struct xe_force_wake *fw,
19 		      enum xe_force_wake_domains domains);
20 int xe_force_wake_put(struct xe_force_wake *fw,
21 		      enum xe_force_wake_domains domains);
22 
23 static inline int
24 xe_force_wake_ref(struct xe_force_wake *fw,
25 		  enum xe_force_wake_domains domain)
26 {
27 	xe_gt_assert(fw->gt, domain);
28 	return fw->domains[ffs(domain) - 1].ref;
29 }
30 
31 static inline void
32 xe_force_wake_assert_held(struct xe_force_wake *fw,
33 			  enum xe_force_wake_domains domain)
34 {
35 	xe_gt_assert(fw->gt, fw->awake_domains & domain);
36 }
37 
38 #endif
39