![]() |
|
|||
0001 /* 0002 * Copyright © 2017 Red Hat 0003 * 0004 * Permission is hereby granted, free of charge, to any person obtaining a 0005 * copy of this software and associated documentation files (the "Software"), 0006 * to deal in the Software without restriction, including without limitation 0007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 0008 * and/or sell copies of the Software, and to permit persons to whom the 0009 * Software is furnished to do so, subject to the following conditions: 0010 * 0011 * The above copyright notice and this permission notice (including the next 0012 * paragraph) shall be included in all copies or substantial portions of the 0013 * Software. 0014 * 0015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 0018 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 0020 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 0021 * IN THE SOFTWARE. 0022 * 0023 * Authors: 0024 * 0025 */ 0026 #ifndef __DRM_SYNCOBJ_H__ 0027 #define __DRM_SYNCOBJ_H__ 0028 0029 #include <linux/dma-fence.h> 0030 #include <linux/dma-fence-chain.h> 0031 0032 struct drm_file; 0033 0034 /** 0035 * struct drm_syncobj - sync object. 0036 * 0037 * This structure defines a generic sync object which wraps a &dma_fence. 0038 */ 0039 struct drm_syncobj { 0040 /** 0041 * @refcount: Reference count of this object. 0042 */ 0043 struct kref refcount; 0044 /** 0045 * @fence: 0046 * NULL or a pointer to the fence bound to this object. 0047 * 0048 * This field should not be used directly. Use drm_syncobj_fence_get() 0049 * and drm_syncobj_replace_fence() instead. 0050 */ 0051 struct dma_fence __rcu *fence; 0052 /** 0053 * @cb_list: List of callbacks to call when the &fence gets replaced. 0054 */ 0055 struct list_head cb_list; 0056 /** 0057 * @lock: Protects &cb_list and write-locks &fence. 0058 */ 0059 spinlock_t lock; 0060 /** 0061 * @file: A file backing for this syncobj. 0062 */ 0063 struct file *file; 0064 }; 0065 0066 void drm_syncobj_free(struct kref *kref); 0067 0068 /** 0069 * drm_syncobj_get - acquire a syncobj reference 0070 * @obj: sync object 0071 * 0072 * This acquires an additional reference to @obj. It is illegal to call this 0073 * without already holding a reference. No locks required. 0074 */ 0075 static inline void 0076 drm_syncobj_get(struct drm_syncobj *obj) 0077 { 0078 kref_get(&obj->refcount); 0079 } 0080 0081 /** 0082 * drm_syncobj_put - release a reference to a sync object. 0083 * @obj: sync object. 0084 */ 0085 static inline void 0086 drm_syncobj_put(struct drm_syncobj *obj) 0087 { 0088 kref_put(&obj->refcount, drm_syncobj_free); 0089 } 0090 0091 /** 0092 * drm_syncobj_fence_get - get a reference to a fence in a sync object 0093 * @syncobj: sync object. 0094 * 0095 * This acquires additional reference to &drm_syncobj.fence contained in @obj, 0096 * if not NULL. It is illegal to call this without already holding a reference. 0097 * No locks required. 0098 * 0099 * Returns: 0100 * Either the fence of @obj or NULL if there's none. 0101 */ 0102 static inline struct dma_fence * 0103 drm_syncobj_fence_get(struct drm_syncobj *syncobj) 0104 { 0105 struct dma_fence *fence; 0106 0107 rcu_read_lock(); 0108 fence = dma_fence_get_rcu_safe(&syncobj->fence); 0109 rcu_read_unlock(); 0110 0111 return fence; 0112 } 0113 0114 struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private, 0115 u32 handle); 0116 void drm_syncobj_add_point(struct drm_syncobj *syncobj, 0117 struct dma_fence_chain *chain, 0118 struct dma_fence *fence, 0119 uint64_t point); 0120 void drm_syncobj_replace_fence(struct drm_syncobj *syncobj, 0121 struct dma_fence *fence); 0122 int drm_syncobj_find_fence(struct drm_file *file_private, 0123 u32 handle, u64 point, u64 flags, 0124 struct dma_fence **fence); 0125 void drm_syncobj_free(struct kref *kref); 0126 int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags, 0127 struct dma_fence *fence); 0128 int drm_syncobj_get_handle(struct drm_file *file_private, 0129 struct drm_syncobj *syncobj, u32 *handle); 0130 int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd); 0131 0132 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |