Home | History | Annotate | Line # | Download | only in i915
      1 /*	$NetBSD: i915_active_types.h,v 1.3 2021/12/19 11:52:07 riastradh Exp $	*/
      2 
      3 /*
      4  * SPDX-License-Identifier: MIT
      5  *
      6  * Copyright  2019 Intel Corporation
      7  */
      8 
      9 #ifndef _I915_ACTIVE_TYPES_H_
     10 #define _I915_ACTIVE_TYPES_H_
     11 
     12 #include <linux/atomic.h>
     13 #include <linux/dma-fence.h>
     14 #include <linux/llist.h>
     15 #include <linux/mutex.h>
     16 #include <linux/rbtree.h>
     17 #include <linux/rcupdate.h>
     18 #include <linux/workqueue.h>
     19 
     20 #include <drm/drm_wait_netbsd.h> /* XXX */
     21 
     22 #include "i915_utils.h"
     23 
     24 struct i915_active_fence {
     25 	struct dma_fence __rcu *fence;
     26 	struct dma_fence_cb cb;
     27 	struct llist_node llist;
     28 };
     29 
     30 struct active_node;
     31 
     32 #define I915_ACTIVE_MAY_SLEEP BIT(0)
     33 
     34 #define __i915_active_call __aligned(4)
     35 #define i915_active_may_sleep(fn) ptr_pack_bits(&(fn), I915_ACTIVE_MAY_SLEEP, 2)
     36 
     37 struct i915_active {
     38 	atomic_t count;
     39 	struct mutex mutex;
     40 
     41 	spinlock_t tree_lock;
     42 	drm_waitqueue_t tree_wq;
     43 	struct active_node *cache;
     44 	struct rb_root tree;
     45 
     46 	/* Preallocated "exclusive" node */
     47 	struct i915_active_fence excl;
     48 
     49 	unsigned long flags;
     50 #define I915_ACTIVE_RETIRE_SLEEPS BIT(0)
     51 
     52 	int (*active)(struct i915_active *ref);
     53 	void (*retire)(struct i915_active *ref);
     54 
     55 	struct work_struct work;
     56 
     57 	struct llist_head preallocated_barriers;
     58 };
     59 
     60 #endif /* _I915_ACTIVE_TYPES_H_ */
     61