1 /* 2 * SPDX-License-Identifier: MIT 3 * 4 * Copyright © 2019 Intel Corporation 5 */ 6 7 #ifndef _I915_ACTIVE_TYPES_H_ 8 #define _I915_ACTIVE_TYPES_H_ 9 10 #include <linux/atomic.h> 11 #include <linux/llist.h> 12 #include <linux/mutex.h> 13 #include <linux/rbtree.h> 14 #include <linux/rcupdate.h> 15 16 struct drm_i915_private; 17 struct i915_active_request; 18 struct i915_request; 19 20 typedef void (*i915_active_retire_fn)(struct i915_active_request *, 21 struct i915_request *); 22 23 struct i915_active_request { 24 struct i915_request __rcu *request; 25 struct list_head link; 26 i915_active_retire_fn retire; 27 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) 28 /* 29 * Incorporeal! 30 * 31 * Updates to the i915_active_request must be serialised under a lock 32 * to ensure that the timeline is ordered. Normally, this is the 33 * timeline->mutex, but another mutex may be used so long as it is 34 * done so consistently. 35 * 36 * For lockdep tracking of the above, we store the lock we intend 37 * to always use for updates of this i915_active_request during 38 * construction and assert that is held on every update. 39 */ 40 struct mutex *lock; 41 #endif 42 }; 43 44 struct active_node; 45 46 struct i915_active { 47 struct drm_i915_private *i915; 48 49 struct active_node *cache; 50 struct rb_root tree; 51 struct mutex mutex; 52 atomic_t count; 53 54 unsigned long flags; 55 #define I915_ACTIVE_GRAB_BIT 0 56 57 int (*active)(struct i915_active *ref); 58 void (*retire)(struct i915_active *ref); 59 60 struct llist_head preallocated_barriers; 61 }; 62 63 #endif /* _I915_ACTIVE_TYPES_H_ */ 64