xref: /linux/drivers/gpu/drm/xe/xe_preempt_fence.h (revision 119ff04864a24470b1e531bb53e5c141aa8fefb0)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_PREEMPT_FENCE_H_
7 #define _XE_PREEMPT_FENCE_H_
8 
9 #include "xe_preempt_fence_types.h"
10 
11 struct list_head;
12 
13 struct dma_fence *
14 xe_preempt_fence_create(struct xe_exec_queue *q,
15 			u64 context, u32 seqno);
16 
17 struct xe_preempt_fence *xe_preempt_fence_alloc(void);
18 
19 void xe_preempt_fence_free(struct xe_preempt_fence *pfence);
20 
21 struct dma_fence *
22 xe_preempt_fence_arm(struct xe_preempt_fence *pfence, struct xe_exec_queue *q,
23 		     u64 context, u32 seqno);
24 
25 static inline struct xe_preempt_fence *
26 to_preempt_fence(struct dma_fence *fence)
27 {
28 	return container_of(fence, struct xe_preempt_fence, base);
29 }
30 
31 /**
32  * xe_preempt_fence_link() - Return a link used to keep unarmed preempt
33  * fences on a list.
34  * @pfence: Pointer to the preempt fence.
35  *
36  * The link is embedded in the struct xe_preempt_fence. Use
37  * link_to_preempt_fence() to convert back to the preempt fence.
38  *
39  * Return: A pointer to an embedded struct list_head.
40  */
41 static inline struct list_head *
42 xe_preempt_fence_link(struct xe_preempt_fence *pfence)
43 {
44 	return &pfence->link;
45 }
46 
47 /**
48  * to_preempt_fence_from_link() - Convert back to a preempt fence pointer
49  * from a link obtained with xe_preempt_fence_link().
50  * @link: The struct list_head obtained from xe_preempt_fence_link().
51  *
52  * Return: A pointer to the embedding struct xe_preempt_fence.
53  */
54 static inline struct xe_preempt_fence *
55 to_preempt_fence_from_link(struct list_head *link)
56 {
57 	return container_of(link, struct xe_preempt_fence, link);
58 }
59 
60 bool xe_fence_is_xe_preempt(const struct dma_fence *fence);
61 #endif
62