xref: /linux/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.h (revision db5d28c0bfe566908719bec8e25443aabecbb802)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _XE_ENGINE_CLASS_SYSFS_H_
7 #define _XE_ENGINE_CLASS_SYSFS_H_
8 
9 #include <linux/kobject.h>
10 
11 struct xe_gt;
12 struct xe_hw_engine_class_intf;
13 
14 int xe_hw_engine_class_sysfs_init(struct xe_gt *gt);
15 bool xe_hw_engine_timeout_in_range(u64 timeout, u64 min, u64 max);
16 
17 /**
18  * struct kobj_eclass - A eclass's kobject struct that connects the kobject and the
19  * eclass.
20  *
21  * When dealing with multiple eclass, this struct helps to understand which eclass
22  * needs to be addressed on a given sysfs call.
23  */
24 struct kobj_eclass {
25 	/** @base: The actual kobject */
26 	struct kobject base;
27 	/** @eclass: A pointer to the hw engine class interface */
28 	struct xe_hw_engine_class_intf *eclass;
29 	/** @xe: A pointer to the xe device */
30 	struct xe_device *xe;
31 };
32 
kobj_to_eclass(struct kobject * kobj)33 static inline struct xe_hw_engine_class_intf *kobj_to_eclass(struct kobject *kobj)
34 {
35 	return container_of(kobj, struct kobj_eclass, base)->eclass;
36 }
37 
kobj_to_xe(struct kobject * kobj)38 static inline struct xe_device *kobj_to_xe(struct kobject *kobj)
39 {
40 	return container_of(kobj, struct kobj_eclass, base)->xe;
41 }
42 
43 #endif
44