Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Copyright © 2017 Red Hat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * The above copyright notice and this permission notice (including the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * paragraph) shall be included in all copies or substantial portions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #ifndef __DRM_SYNCOBJ_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define __DRM_SYNCOBJ_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/dma-fence.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/dma-fence-chain.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct drm_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * struct drm_syncobj - sync object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * This structure defines a generic sync object which wraps a &dma_fence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) struct drm_syncobj {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	 * @refcount: Reference count of this object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct kref refcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	 * @fence:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 * NULL or a pointer to the fence bound to this object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * This field should not be used directly. Use drm_syncobj_fence_get()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 * and drm_syncobj_replace_fence() instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	struct dma_fence __rcu *fence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 * @cb_list: List of callbacks to call when the &fence gets replaced.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct list_head cb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	 * @lock: Protects &cb_list and write-locks &fence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	 * @file: A file backing for this syncobj.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct file *file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) void drm_syncobj_free(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * drm_syncobj_get - acquire a syncobj reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * @obj: sync object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * This acquires an additional reference to @obj. It is illegal to call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * without already holding a reference. No locks required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) drm_syncobj_get(struct drm_syncobj *obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	kref_get(&obj->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * drm_syncobj_put - release a reference to a sync object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  * @obj: sync object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) drm_syncobj_put(struct drm_syncobj *obj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	kref_put(&obj->refcount, drm_syncobj_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * drm_syncobj_fence_get - get a reference to a fence in a sync object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * @syncobj: sync object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * This acquires additional reference to &drm_syncobj.fence contained in @obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * if not NULL. It is illegal to call this without already holding a reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * No locks required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  * Either the fence of @obj or NULL if there's none.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static inline struct dma_fence *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) drm_syncobj_fence_get(struct drm_syncobj *syncobj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct dma_fence *fence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	fence = dma_fence_get_rcu_safe(&syncobj->fence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	return fence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				     u32 handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) void drm_syncobj_add_point(struct drm_syncobj *syncobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			   struct dma_fence_chain *chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			   struct dma_fence *fence,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			   uint64_t point);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) void drm_syncobj_replace_fence(struct drm_syncobj *syncobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			       struct dma_fence *fence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int drm_syncobj_find_fence(struct drm_file *file_private,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			   u32 handle, u64 point, u64 flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			   struct dma_fence **fence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void drm_syncobj_free(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		       struct dma_fence *fence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int drm_syncobj_get_handle(struct drm_file *file_private,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			   struct drm_syncobj *syncobj, u32 *handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #endif