Skip to content

Commit 924fe8d

Browse files
committed
drm/syncobj: some kerneldoc polish
Complete a few missing bits, fix up the existing xcross-references and add a bunch more. v2: Fix typos (Alex). Cc: Dave Airlie <airlied@gmail.com> via lists.freedesktop.org Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20171214203054.20141-4-daniel.vetter@ffwll.ch
1 parent 42f1b31 commit 924fe8d

2 files changed

Lines changed: 61 additions & 18 deletions

File tree

‎drivers/gpu/drm/drm_syncobj.c‎

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
/**
3030
* DOC: Overview
3131
*
32-
* DRM synchronisation objects (syncobj) are a persistent objects,
33-
* that contain an optional fence. The fence can be updated with a new
34-
* fence, or be NULL.
32+
* DRM synchronisation objects (syncobj, see struct &drm_syncobj) are
33+
* persistent objects that contain an optional fence. The fence can be updated
34+
* with a new fence, or be NULL.
3535
*
3636
* syncobj's can be waited upon, where it will wait for the underlying
3737
* fence.
@@ -61,7 +61,8 @@
6161
* @file_private: drm file private pointer
6262
* @handle: sync object handle to lookup.
6363
*
64-
* Returns a reference to the syncobj pointed to by handle or NULL.
64+
* Returns a reference to the syncobj pointed to by handle or NULL. The
65+
* reference must be released by calling drm_syncobj_put().
6566
*/
6667
struct drm_syncobj *drm_syncobj_find(struct drm_file *file_private,
6768
u32 handle)
@@ -229,6 +230,19 @@ static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj)
229230
return 0;
230231
}
231232

233+
/**
234+
* drm_syncobj_find_fence - lookup and reference the fence in a sync object
235+
* @file_private: drm file private pointer
236+
* @handle: sync object handle to lookup.
237+
* @fence: out parameter for the fence
238+
*
239+
* This is just a convenience function that combines drm_syncobj_find() and
240+
* drm_syncobj_fence_get().
241+
*
242+
* Returns 0 on success or a negative error value on failure. On success @fence
243+
* contains a reference to the fence, which must be released by calling
244+
* dma_fence_put().
245+
*/
232246
int drm_syncobj_find_fence(struct drm_file *file_private,
233247
u32 handle,
234248
struct dma_fence **fence)
@@ -269,6 +283,12 @@ EXPORT_SYMBOL(drm_syncobj_free);
269283
* @out_syncobj: returned syncobj
270284
* @flags: DRM_SYNCOBJ_* flags
271285
* @fence: if non-NULL, the syncobj will represent this fence
286+
*
287+
* This is the first function to create a sync object. After creating, drivers
288+
* probably want to make it available to userspace, either through
289+
* drm_syncobj_get_handle() or drm_syncobj_get_fd().
290+
*
291+
* Returns 0 on success or a negative error value on failure.
272292
*/
273293
int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
274294
struct dma_fence *fence)
@@ -302,6 +322,14 @@ EXPORT_SYMBOL(drm_syncobj_create);
302322

303323
/**
304324
* drm_syncobj_get_handle - get a handle from a syncobj
325+
* @file_private: drm file private pointer
326+
* @syncobj: Sync object to export
327+
* @handle: out parameter with the new handle
328+
*
329+
* Exports a sync object created with drm_syncobj_create() as a handle on
330+
* @file_private to userspace.
331+
*
332+
* Returns 0 on success or a negative error value on failure.
305333
*/
306334
int drm_syncobj_get_handle(struct drm_file *file_private,
307335
struct drm_syncobj *syncobj, u32 *handle)
@@ -388,6 +416,15 @@ static int drm_syncobj_alloc_file(struct drm_syncobj *syncobj)
388416
return 0;
389417
}
390418

419+
/**
420+
* drm_syncobj_get_fd - get a file descriptor from a syncobj
421+
* @syncobj: Sync object to export
422+
* @p_fd: out parameter with the new file descriptor
423+
*
424+
* Exports a sync object created with drm_syncobj_create() as a file descriptor.
425+
*
426+
* Returns 0 on success or a negative error value on failure.
427+
*/
391428
int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
392429
{
393430
int ret;

‎include/drm/drm_syncobj.h‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,31 @@ struct drm_syncobj_cb;
3333
/**
3434
* struct drm_syncobj - sync object.
3535
*
36-
* This structure defines a generic sync object which wraps a dma fence.
36+
* This structure defines a generic sync object which wraps a &dma_fence.
3737
*/
3838
struct drm_syncobj {
3939
/**
40-
* @refcount:
41-
*
42-
* Reference count of this object.
40+
* @refcount: Reference count of this object.
4341
*/
4442
struct kref refcount;
4543
/**
4644
* @fence:
4745
* NULL or a pointer to the fence bound to this object.
4846
*
49-
* This field should not be used directly. Use drm_syncobj_fence_get
50-
* and drm_syncobj_replace_fence instead.
47+
* This field should not be used directly. Use drm_syncobj_fence_get()
48+
* and drm_syncobj_replace_fence() instead.
5149
*/
5250
struct dma_fence __rcu *fence;
5351
/**
54-
* @cb_list:
55-
* List of callbacks to call when the fence gets replaced
52+
* @cb_list: List of callbacks to call when the &fence gets replaced.
5653
*/
5754
struct list_head cb_list;
5855
/**
59-
* @lock:
60-
* locks cb_list and write-locks fence.
56+
* @lock: Protects &cb_list and write-locks &fence.
6157
*/
6258
spinlock_t lock;
6359
/**
64-
* @file:
65-
* a file backing for this syncobj.
60+
* @file: A file backing for this syncobj.
6661
*/
6762
struct file *file;
6863
};
@@ -73,7 +68,7 @@ typedef void (*drm_syncobj_func_t)(struct drm_syncobj *syncobj,
7368
/**
7469
* struct drm_syncobj_cb - callback for drm_syncobj_add_callback
7570
* @node: used by drm_syncob_add_callback to append this struct to
76-
* syncobj::cb_list
71+
* &drm_syncobj.cb_list
7772
* @func: drm_syncobj_func_t to call
7873
*
7974
* This struct will be initialized by drm_syncobj_add_callback, additional
@@ -92,7 +87,7 @@ void drm_syncobj_free(struct kref *kref);
9287
* drm_syncobj_get - acquire a syncobj reference
9388
* @obj: sync object
9489
*
95-
* This acquires additional reference to @obj. It is illegal to call this
90+
* This acquires an additional reference to @obj. It is illegal to call this
9691
* without already holding a reference. No locks required.
9792
*/
9893
static inline void
@@ -111,6 +106,17 @@ drm_syncobj_put(struct drm_syncobj *obj)
111106
kref_put(&obj->refcount, drm_syncobj_free);
112107
}
113108

109+
/**
110+
* drm_syncobj_fence_get - get a reference to a fence in a sync object
111+
* @syncobj: sync object.
112+
*
113+
* This acquires additional reference to &drm_syncobj.fence contained in @obj,
114+
* if not NULL. It is illegal to call this without already holding a reference.
115+
* No locks required.
116+
*
117+
* Returns:
118+
* Either the fence of @obj or NULL if there's none.
119+
*/
114120
static inline struct dma_fence *
115121
drm_syncobj_fence_get(struct drm_syncobj *syncobj)
116122
{

0 commit comments

Comments
 (0)