Release 4.7 drivers/gpu/drm/msm/msm_fence.c
  
  
/*
 * Copyright (C) 2013-2016 Red Hat
 * Author: Rob Clark <robdclark@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include <linux/fence.h>
#include "msm_drv.h"
#include "msm_fence.h"
struct msm_fence_context *
msm_fence_context_alloc(struct drm_device *dev, const char *name)
{
	struct msm_fence_context *fctx;
	fctx = kzalloc(sizeof(*fctx), GFP_KERNEL);
	if (!fctx)
		return ERR_PTR(-ENOMEM);
	fctx->dev = dev;
	fctx->name = name;
	fctx->context = fence_context_alloc(1);
	init_waitqueue_head(&fctx->event);
	spin_lock_init(&fctx->spinlock);
	return fctx;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 87 | 100.00% | 2 | 100.00% | 
 | Total | 87 | 100.00% | 2 | 100.00% | 
void msm_fence_context_free(struct msm_fence_context *fctx)
{
	kfree(fctx);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 15 | 100.00% | 1 | 100.00% | 
 | Total | 15 | 100.00% | 1 | 100.00% | 
static inline bool fence_completed(struct msm_fence_context *fctx, uint32_t fence)
{
	return (int32_t)(fctx->completed_fence - fence) >= 0;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 29 | 100.00% | 2 | 100.00% | 
 | Total | 29 | 100.00% | 2 | 100.00% | 
/* legacy path for WAIT_FENCE ioctl: */
int msm_wait_fence(struct msm_fence_context *fctx, uint32_t fence,
		ktime_t *timeout, bool interruptible)
{
	int ret;
	if (fence > fctx->last_fence) {
		DRM_ERROR("%s: waiting on invalid fence: %u (of %u)\n",
				fctx->name, fence, fctx->last_fence);
		return -EINVAL;
	}
	if (!timeout) {
		/* no-wait: */
		ret = fence_completed(fctx, fence) ? 0 : -EBUSY;
	} else {
		unsigned long remaining_jiffies = timeout_to_jiffies(timeout);
		if (interruptible)
			ret = wait_event_interruptible_timeout(fctx->event,
				fence_completed(fctx, fence),
				remaining_jiffies);
		else
			ret = wait_event_timeout(fctx->event,
				fence_completed(fctx, fence),
				remaining_jiffies);
		if (ret == 0) {
			DBG("timeout waiting for fence: %u (completed: %u)",
					fence, fctx->completed_fence);
			ret = -ETIMEDOUT;
		} else if (ret != -ERESTARTSYS) {
			ret = 0;
		}
	}
	return ret;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 168 | 100.00% | 3 | 100.00% | 
 | Total | 168 | 100.00% | 3 | 100.00% | 
/* called from workqueue */
void msm_update_fence(struct msm_fence_context *fctx, uint32_t fence)
{
	spin_lock(&fctx->spinlock);
	fctx->completed_fence = max(fence, fctx->completed_fence);
	spin_unlock(&fctx->spinlock);
	wake_up_all(&fctx->event);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 50 | 100.00% | 3 | 100.00% | 
 | Total | 50 | 100.00% | 3 | 100.00% | 
struct msm_fence {
	
struct msm_fence_context *fctx;
	
struct fence base;
};
static inline struct msm_fence *to_msm_fence(struct fence *fence)
{
	return container_of(fence, struct msm_fence, base);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 25 | 100.00% | 1 | 100.00% | 
 | Total | 25 | 100.00% | 1 | 100.00% | 
static const char *msm_fence_get_driver_name(struct fence *fence)
{
	return "msm";
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 16 | 100.00% | 1 | 100.00% | 
 | Total | 16 | 100.00% | 1 | 100.00% | 
static const char *msm_fence_get_timeline_name(struct fence *fence)
{
	struct msm_fence *f = to_msm_fence(fence);
	return f->fctx->name;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 30 | 100.00% | 1 | 100.00% | 
 | Total | 30 | 100.00% | 1 | 100.00% | 
static bool msm_fence_enable_signaling(struct fence *fence)
{
	return true;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 14 | 100.00% | 1 | 100.00% | 
 | Total | 14 | 100.00% | 1 | 100.00% | 
static bool msm_fence_signaled(struct fence *fence)
{
	struct msm_fence *f = to_msm_fence(fence);
	return fence_completed(f->fctx, f->base.seqno);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 35 | 100.00% | 1 | 100.00% | 
 | Total | 35 | 100.00% | 1 | 100.00% | 
static void msm_fence_release(struct fence *fence)
{
	struct msm_fence *f = to_msm_fence(fence);
	kfree_rcu(f, base.rcu);
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 30 | 100.00% | 1 | 100.00% | 
 | Total | 30 | 100.00% | 1 | 100.00% | 
static const struct fence_ops msm_fence_ops = {
	.get_driver_name = msm_fence_get_driver_name,
	.get_timeline_name = msm_fence_get_timeline_name,
	.enable_signaling = msm_fence_enable_signaling,
	.signaled = msm_fence_signaled,
	.wait = fence_default_wait,
	.release = msm_fence_release,
};
struct fence *
msm_fence_alloc(struct msm_fence_context *fctx)
{
	struct msm_fence *f;
	f = kzalloc(sizeof(*f), GFP_KERNEL);
	if (!f)
		return ERR_PTR(-ENOMEM);
	f->fctx = fctx;
	fence_init(&f->base, &msm_fence_ops, &fctx->spinlock,
			fctx->context, ++fctx->last_fence);
	return &f->base;
}
Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 79 | 100.00% | 1 | 100.00% | 
 | Total | 79 | 100.00% | 1 | 100.00% | 
Overall Contributors
 | Person | Tokens | Prop | Commits | CommitProp | 
| rob clark | rob clark | 642 | 100.00% | 4 | 100.00% | 
 | Total | 642 | 100.00% | 4 | 100.00% | 
  
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.