Merge "msm: sde: Cache capture fence descriptor"

This commit is contained in:
Linux Build Service Account 2017-07-03 07:58:00 -07:00 committed by Gerrit - the friendly Code Review server
commit 1b28f2e8fb

View file

@ -1785,6 +1785,7 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,
struct msm_sde_rotator_fence *fence = arg; struct msm_sde_rotator_fence *fence = arg;
struct msm_sde_rotator_comp_ratio *comp_ratio = arg; struct msm_sde_rotator_comp_ratio *comp_ratio = arg;
struct sde_rotator_vbinfo *vbinfo; struct sde_rotator_vbinfo *vbinfo;
int ret;
switch (cmd) { switch (cmd) {
case VIDIOC_S_SDE_ROTATOR_FENCE: case VIDIOC_S_SDE_ROTATOR_FENCE:
@ -1843,19 +1844,39 @@ static long sde_rotator_private_ioctl(struct file *file, void *fh,
vbinfo = &ctx->vbinfo_cap[fence->index]; vbinfo = &ctx->vbinfo_cap[fence->index];
if (vbinfo->fence == NULL) { if (!vbinfo)
vbinfo->fd = -1; return -EINVAL;
} else {
vbinfo->fd = if (vbinfo->fence) {
sde_rotator_get_sync_fence_fd(vbinfo->fence); ret = sde_rotator_get_sync_fence_fd(vbinfo->fence);
if (vbinfo->fd < 0) { if (ret < 0) {
SDEDEV_ERR(rot_dev->dev, SDEDEV_ERR(rot_dev->dev,
"fail get fence fd s:%d\n", "fail get fence fd s:%d\n",
ctx->session_id); ctx->session_id);
return vbinfo->fd; return ret;
} }
/*
* Loose any reference to sync fence once we pass
* it to user. Driver does not clean up user
* unclosed fence descriptors.
*/
vbinfo->fence = NULL; vbinfo->fence = NULL;
/*
* Cache fence descriptor in case user calls this
* ioctl multiple times. Cached value would be stale
* if user duplicated and closed old descriptor.
*/
vbinfo->fd = ret;
} else if (!sde_rotator_get_fd_sync_fence(vbinfo->fd)) {
/*
* User has closed cached fence descriptor.
* Invalidate descriptor cache.
*/
vbinfo->fd = -1;
} }
fence->fd = vbinfo->fd; fence->fd = vbinfo->fd;
SDEDEV_DBG(rot_dev->dev, SDEDEV_DBG(rot_dev->dev,