Subversion Repositories Kolibri OS

Rev

Rev 6125 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6125 Rev 6936
Line 33... Line 33...
33
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34
 * OTHER DEALINGS IN THE SOFTWARE.
34
 * OTHER DEALINGS IN THE SOFTWARE.
35
 */
35
 */
Line 36... Line 36...
36
 
36
 
-
 
37
/**
-
 
38
 * struct drm_gem_object - GEM buffer object
37
/**
39
 *
-
 
40
 * This structure defines the generic parts for GEM buffer objects, which are
-
 
41
 * mostly around handling mmap and userspace handles.
38
 * This structure defines the drm_mm memory object, which will be used by the
42
 *
39
 * DRM for its buffer objects.
43
 * Buffer objects are often abbreviated to BO.
40
 */
44
 */
-
 
45
struct drm_gem_object {
-
 
46
	/**
-
 
47
	 * @refcount:
41
struct drm_gem_object {
48
	 *
-
 
49
	 * Reference count of this object
-
 
50
	 *
-
 
51
	 * Please use drm_gem_object_reference() to acquire and
-
 
52
	 * drm_gem_object_unreference() or drm_gem_object_unreference_unlocked()
-
 
53
	 * to release a reference to a GEM buffer object.
42
	/** Reference count of this object */
54
	 */
Line 43... Line 55...
43
	struct kref refcount;
55
	struct kref refcount;
-
 
56
 
-
 
57
	/**
44
 
58
	 * @handle_count:
45
	/**
59
	 *
46
	 * handle_count - gem file_priv handle count of this object
60
	 * This is the GEM file_priv handle count of this object.
47
	 *
61
	 *
48
	 * Each handle also holds a reference. Note that when the handle_count
62
	 * Each handle also holds a reference. Note that when the handle_count
49
	 * drops to 0 any global names (e.g. the id in the flink namespace) will
63
	 * drops to 0 any global names (e.g. the id in the flink namespace) will
50
	 * be cleared.
64
	 * be cleared.
51
	 *
65
	 *
52
	 * Protected by dev->object_name_lock.
66
	 * Protected by dev->object_name_lock.
Line -... Line 67...
-
 
67
	 */
53
	 * */
68
	unsigned handle_count;
-
 
69
 
54
	unsigned handle_count;
70
	/**
Line -... Line 71...
-
 
71
	 * @dev: DRM dev this object belongs to.
-
 
72
	 */
-
 
73
	struct drm_device *dev;
55
 
74
 
-
 
75
	/**
-
 
76
	 * @filp:
-
 
77
	 *
-
 
78
	 * SHMEM file node used as backing storage for swappable buffer objects.
56
	/** Related drm device */
79
	 * GEM also supports driver private objects with driver-specific backing
Line -... Line 80...
-
 
80
	 * storage (contiguous CMA memory, special reserved blocks). In this
-
 
81
	 * case @filp is NULL.
-
 
82
	 */
57
	struct drm_device *dev;
83
	struct file *filp;
-
 
84
 
-
 
85
	/**
-
 
86
	 * @vma_node:
-
 
87
	 *
-
 
88
	 * Mapping info for this object to support mmap. Drivers are supposed to
-
 
89
	 * allocate the mmap offset using drm_gem_create_mmap_offset(). The
58
 
90
	 * offset itself can be retrieved using drm_vma_node_offset_addr().
Line 59... Line 91...
59
	/** File representing the shmem storage */
91
	 *
-
 
92
	 * Memory mapping itself is handled by drm_gem_mmap(), which also checks
-
 
93
	 * that userspace is allowed to access the object.
60
	struct file *filp;
94
	 */
61
 
95
	struct drm_vma_offset_node vma_node;
62
	/* Mapping info for this object */
96
 
63
	struct drm_vma_offset_node vma_node;
97
	/**
Line 64... Line 98...
64
 
98
	 * @size:
-
 
99
	 *
-
 
100
	 * Size of the object, in bytes.  Immutable over the object's
65
	/**
101
	 * lifetime.
66
	 * Size of the object, in bytes.  Immutable over the object's
102
	 */
-
 
103
	size_t size;
67
	 * lifetime.
104
 
68
	 */
105
	/**
Line 69... Line 106...
69
	size_t size;
106
	 * @name:
-
 
107
	 *
-
 
108
	 * Global name for this object, starts at 1. 0 means unnamed.
70
 
109
	 * Access is covered by dev->object_name_lock. This is used by the GEM_FLINK
71
	/**
110
	 * and GEM_OPEN ioctls.
72
	 * Global name for this object, starts at 1. 0 means unnamed.
111
	 */
73
	 * Access is covered by the object_name_lock in the related drm_device
112
	int name;
74
	 */
113
 
75
	int name;
114
	/**
-
 
115
	 * @read_domains:
-
 
116
	 *
-
 
117
	 * Read memory domains. These monitor which caches contain read/write data
-
 
118
	 * related to the object. When transitioning from one set of domains
76
 
119
	 * to another, the driver is called to ensure that caches are suitably
Line 77... Line 120...
77
	/**
120
	 * flushed and invalidated.
-
 
121
	 */
-
 
122
	uint32_t read_domains;
78
	 * Memory domains. These monitor which caches contain read/write data
123
 
79
	 * related to the object. When transitioning from one set of domains
124
	/**
80
	 * to another, the driver is called to ensure that caches are suitably
125
	 * @write_domain: Corresponding unique write memory domain.
81
	 * flushed and invalidated
126
	 */
82
	 */
127
	uint32_t write_domain;
83
	uint32_t read_domains;
128
 
-
 
129
	/**
-
 
130
	 * @pending_read_domains:
-
 
131
	 *
-
 
132
	 * While validating an exec operation, the
84
	uint32_t write_domain;
133
	 * new read/write domain values are computed here.
Line 85... Line 134...
85
 
134
	 * They will be transferred to the above values
-
 
135
	 * at the point that any cache flushing occurs
-
 
136
	 */
86
	/**
137
	uint32_t pending_read_domains;
87
	 * While validating an exec operation, the
138
 
88
	 * new read/write domain values are computed here.
139
	/**
89
	 * They will be transferred to the above values
140
	 * @pending_write_domain: Write domain similar to @pending_read_domains.
90
	 * at the point that any cache flushing occurs
141
	 */
91
	 */
142
	uint32_t pending_write_domain;
92
	uint32_t pending_read_domains;
143
 
93
	uint32_t pending_write_domain;
144
	/**
94
 
145
	 * @dma_buf:
Line 95... Line 146...
95
	/**
146
	 *
-
 
147
	 * dma-buf associated with this GEM object.
-
 
148
	 *
96
	 * dma_buf - dma buf associated with this GEM object
149
	 * Pointer to the dma-buf associated with this gem object (either
97
	 *
150
	 * through importing or exporting). We break the resulting reference
98
	 * Pointer to the dma-buf associated with this gem object (either
151
	 * loop when the last gem handle for this object is released.
99
	 * through importing or exporting). We break the resulting reference
152
	 *
100
	 * loop when the last gem handle for this object is released.
153
	 * Protected by obj->object_name_lock.
101
	 *
154
	 */
Line 131... Line 184...
131
void drm_gem_vm_close(struct vm_area_struct *vma);
184
void drm_gem_vm_close(struct vm_area_struct *vma);
132
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
185
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
133
		     struct vm_area_struct *vma);
186
		     struct vm_area_struct *vma);
134
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
187
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
Line -... Line 188...
-
 
188
 
-
 
189
/**
-
 
190
 * drm_gem_object_reference - acquire a GEM BO reference
-
 
191
 * @obj: GEM buffer object
-
 
192
 *
-
 
193
 * This acquires additional reference to @obj. It is illegal to call this
-
 
194
 * without already holding a reference. No locks required.
135
 
195
 */
136
static inline void
196
static inline void
137
drm_gem_object_reference(struct drm_gem_object *obj)
197
drm_gem_object_reference(struct drm_gem_object *obj)
138
{
198
{
139
	kref_get(&obj->refcount);
199
	kref_get(&obj->refcount);
Line -... Line 200...
-
 
200
}
-
 
201
 
-
 
202
/**
-
 
203
 * drm_gem_object_unreference - release a GEM BO reference
-
 
204
 * @obj: GEM buffer object
-
 
205
 *
-
 
206
 * This releases a reference to @obj. Callers must hold the dev->struct_mutex
-
 
207
 * lock when calling this function, even when the driver doesn't use
-
 
208
 * dev->struct_mutex for anything.
-
 
209
 *
-
 
210
 * For drivers not encumbered with legacy locking use
140
}
211
 * drm_gem_object_unreference_unlocked() instead.
141
 
212
 */
142
static inline void
213
static inline void
143
drm_gem_object_unreference(struct drm_gem_object *obj)
214
drm_gem_object_unreference(struct drm_gem_object *obj)
144
{
215
{
Line 145... Line 216...
145
	if (obj != NULL) {
216
	if (obj != NULL) {
146
		WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
217
		WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
147
 
218
 
Line -... Line 219...
-
 
219
		kref_put(&obj->refcount, drm_gem_object_free);
-
 
220
	}
-
 
221
}
-
 
222
 
-
 
223
/**
-
 
224
 * drm_gem_object_unreference_unlocked - release a GEM BO reference
-
 
225
 * @obj: GEM buffer object
148
		kref_put(&obj->refcount, drm_gem_object_free);
226
 *
149
	}
227
 * This releases a reference to @obj. Callers must not hold the
150
}
228
 * dev->struct_mutex lock when calling this function.
151
 
229
 */