diff options
| author | Clarence Ip <cip@codeaurora.org> | 2016-06-09 13:30:07 -0400 |
|---|---|---|
| committer | Dhaval Patel <pdhaval@codeaurora.org> | 2016-08-01 11:58:11 -0700 |
| commit | 6c5ec58a8e551ab0906f40decdcbd2d7a5340b76 (patch) | |
| tree | 89defd6cb7a3dc2e960beeccebc8b8e207635d20 /drivers/gpu | |
| parent | da2ec7aaf1199188913fe8c2d1562712215b1e88 (diff) | |
drm/msm/sde: add wrappers for release fence API
Add functions for creating/incrementing timelines, and
for creating fences at a specified sync point.
Change-Id: Idfd42150f2162fd0e4c3b89916e8ed5a801c27ae
Signed-off-by: Clarence Ip <cip@codeaurora.org>
Diffstat (limited to 'drivers/gpu')
| -rw-r--r-- | drivers/gpu/drm/msm/sde/sde_fence.c | 66 | ||||
| -rw-r--r-- | drivers/gpu/drm/msm/sde/sde_fence.h | 73 |
2 files changed, 134 insertions, 5 deletions
diff --git a/drivers/gpu/drm/msm/sde/sde_fence.c b/drivers/gpu/drm/msm/sde/sde_fence.c index de1e87194c59..5bd5093d5fbc 100644 --- a/drivers/gpu/drm/msm/sde/sde_fence.c +++ b/drivers/gpu/drm/msm/sde/sde_fence.c @@ -11,6 +11,7 @@ */ #include <sync.h> +#include <sw_sync.h> #include "sde_kms.h" #include "sde_fence.h" @@ -33,3 +34,68 @@ int sde_sync_wait(void *fence, long timeout_ms) return sync_fence_wait(fence, timeout_ms); } +#if IS_ENABLED(CONFIG_SW_SYNC) +void *sde_sync_timeline_create(const char *name) +{ + if (!name) + name = ""; + return sw_sync_timeline_create(name); +} + +int sde_sync_fence_create(void *timeline, const char *name, int val) +{ + struct sync_pt *sync_pt; + struct sync_fence *fence; + signed int fd = -EINVAL; + + if (!timeline) { + DRM_ERROR("Invalid timeline\n"); + return fd; + } + + if (val < 0) { + DRM_ERROR("Invalid fence value %d\n", val); + return fd; + } + + if (!name) + name = ""; + + /* create sync point */ + sync_pt = sw_sync_pt_create(timeline, val); + if (sync_pt == NULL) { + DRM_ERROR("Failed to create sync point, %s\n", name); + return fd; + } + + /* create fence */ + fence = sync_fence_create(name, sync_pt); + if (fence == NULL) { + sync_pt_free(sync_pt); + DRM_ERROR("Couldn't create fence, %s\n", name); + return fd; + } + + /* create fd */ + fd = get_unused_fd_flags(0); + if (fd < 0) { + DRM_ERROR("Failed to get_unused_fd_flags(), %s\n", name); + sync_fence_put(fence); + return fd; + } + + sync_fence_install(fence, fd); + + return fd; +} + +void sde_sync_timeline_inc(void *timeline, int val) +{ + if (!timeline) + DRM_ERROR("Invalid timeline\n"); + else if (val <= 0) + DRM_ERROR("Invalid increment, %d\n", val); + else + sw_sync_timeline_inc(timeline, val); +} +#endif diff --git a/drivers/gpu/drm/msm/sde/sde_fence.h b/drivers/gpu/drm/msm/sde/sde_fence.h index 465fa5931cc5..6d83cbbfee50 100644 --- a/drivers/gpu/drm/msm/sde/sde_fence.h +++ b/drivers/gpu/drm/msm/sde/sde_fence.h @@ -13,12 +13,10 @@ #ifndef _SDE_FENCE_H_ #define _SDE_FENCE_H_ -#ifndef CONFIG_SYNC -#define sde_sync_get(D) (0) -#define sde_sync_put(F) -#define sde_sync_wait(F, T) (0) -#else +#include <linux/kernel.h> +#include <linux/errno.h> +#ifdef CONFIG_SYNC /** * sde_sync_get - Query sync fence object from a file handle * @@ -49,6 +47,71 @@ void sde_sync_put(void *fence); * Return: Zero on success, or -ETIME on timeout */ int sde_sync_wait(void *fence, long timeout_ms); +#else +static inline void *sde_sync_get(uint64_t fd) +{ + return NULL; +} + +static inline void sde_sync_put(void *fence) +{ +} + +static inline int sde_sync_wait(void *fence, long timeout_ms) +{ + return 0; +} #endif +#if defined(CONFIG_SYNC) && IS_ENABLED(CONFIG_SW_SYNC) +/** + * sde_sync_timeline_create - Create timeline object + * + * @name: Name for timeline + * + * Return: Pointer to newly created timeline, or NULL on error + */ +void *sde_sync_timeline_create(const char *name); + +/** + * sde_sync_fence_create - Create fence object + * + * This function is NOT thread-safe. + * + * @timeline: Timeline to associate with fence + * @name: Name for fence + * @val: Timeline value at which to signal the fence, must be >= 0 + * + * Return: File descriptor on success, or error code on error + */ +int sde_sync_fence_create(void *timeline, const char *name, int val); + +/** + * sde_sync_timeline_inc - Increment timeline object + * + * This function is NOT thread-safe. + * + * @timeline: Timeline to increment + * @val: Amount by which to increase the timeline + * + * Return: File descriptor on success, or error code on error + */ +void sde_sync_timeline_inc(void *timeline, int val); +#else +static inline void *sde_sync_timeline_create(const char *name) +{ + return NULL; +} + +static inline int sde_sync_fence_create(void *timeline, + const char *name, int val) +{ + return -EINVAL; +} + +static inline void sde_sync_timeline_inc(void *timeline, int val) +{ +} +#endif /* defined(CONFIG_SYNC) && IS_ENABLED(CONFIG_SW_SYNC) */ + #endif /* _SDE_FENCE_H_ */ |
