Commit 8120ed5e authored by Dave Airlie's avatar Dave Airlie
Browse files

Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm-next



A couple of independent patches extracted from the 5.3 pull request, fixed for
merge conflicts and a single unused variable warning.

And the drmP.h removal from Sam.

Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parents e7f7287b a0a63940
Loading
Loading
Loading
Loading
+0 −100
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
 */

#include <drm/ttm/ttm_module.h>
#include <linux/atomic.h>
#include <linux/errno.h>
#include <linux/wait.h>
@@ -49,8 +48,6 @@ void ttm_lock_init(struct ttm_lock *lock)
	init_waitqueue_head(&lock->queue);
	lock->rw = 0;
	lock->flags = 0;
	lock->kill_takers = false;
	lock->signal = SIGKILL;
}

void ttm_read_unlock(struct ttm_lock *lock)
@@ -66,11 +63,6 @@ static bool __ttm_read_lock(struct ttm_lock *lock)
	bool locked = false;

	spin_lock(&lock->lock);
	if (unlikely(lock->kill_takers)) {
		send_sig(lock->signal, current, 0);
		spin_unlock(&lock->lock);
		return false;
	}
	if (lock->rw >= 0 && lock->flags == 0) {
		++lock->rw;
		locked = true;
@@ -98,11 +90,6 @@ static bool __ttm_read_trylock(struct ttm_lock *lock, bool *locked)
	*locked = false;

	spin_lock(&lock->lock);
	if (unlikely(lock->kill_takers)) {
		send_sig(lock->signal, current, 0);
		spin_unlock(&lock->lock);
		return false;
	}
	if (lock->rw >= 0 && lock->flags == 0) {
		++lock->rw;
		block = false;
@@ -147,11 +134,6 @@ static bool __ttm_write_lock(struct ttm_lock *lock)
	bool locked = false;

	spin_lock(&lock->lock);
	if (unlikely(lock->kill_takers)) {
		send_sig(lock->signal, current, 0);
		spin_unlock(&lock->lock);
		return false;
	}
	if (lock->rw == 0 && ((lock->flags & ~TTM_WRITE_LOCK_PENDING) == 0)) {
		lock->rw = -1;
		lock->flags &= ~TTM_WRITE_LOCK_PENDING;
@@ -182,88 +164,6 @@ int ttm_write_lock(struct ttm_lock *lock, bool interruptible)
	return ret;
}

static int __ttm_vt_unlock(struct ttm_lock *lock)
{
	int ret = 0;

	spin_lock(&lock->lock);
	if (unlikely(!(lock->flags & TTM_VT_LOCK)))
		ret = -EINVAL;
	lock->flags &= ~TTM_VT_LOCK;
	wake_up_all(&lock->queue);
	spin_unlock(&lock->lock);

	return ret;
}

static void ttm_vt_lock_remove(struct ttm_base_object **p_base)
{
	struct ttm_base_object *base = *p_base;
	struct ttm_lock *lock = container_of(base, struct ttm_lock, base);
	int ret;

	*p_base = NULL;
	ret = __ttm_vt_unlock(lock);
	BUG_ON(ret != 0);
}

static bool __ttm_vt_lock(struct ttm_lock *lock)
{
	bool locked = false;

	spin_lock(&lock->lock);
	if (lock->rw == 0) {
		lock->flags &= ~TTM_VT_LOCK_PENDING;
		lock->flags |= TTM_VT_LOCK;
		locked = true;
	} else {
		lock->flags |= TTM_VT_LOCK_PENDING;
	}
	spin_unlock(&lock->lock);
	return locked;
}

int ttm_vt_lock(struct ttm_lock *lock,
		bool interruptible,
		struct ttm_object_file *tfile)
{
	int ret = 0;

	if (interruptible) {
		ret = wait_event_interruptible(lock->queue,
					       __ttm_vt_lock(lock));
		if (unlikely(ret != 0)) {
			spin_lock(&lock->lock);
			lock->flags &= ~TTM_VT_LOCK_PENDING;
			wake_up_all(&lock->queue);
			spin_unlock(&lock->lock);
			return ret;
		}
	} else
		wait_event(lock->queue, __ttm_vt_lock(lock));

	/*
	 * Add a base-object, the destructor of which will
	 * make sure the lock is released if the client dies
	 * while holding it.
	 */

	ret = ttm_base_object_init(tfile, &lock->base, false,
				   ttm_lock_type, &ttm_vt_lock_remove, NULL);
	if (ret)
		(void)__ttm_vt_unlock(lock);
	else
		lock->vt_holder = tfile;

	return ret;
}

int ttm_vt_unlock(struct ttm_lock *lock)
{
	return ttm_ref_object_base_unref(lock->vt_holder,
					 lock->base.handle, TTM_REF_USAGE);
}

void ttm_suspend_unlock(struct ttm_lock *lock)
{
	spin_lock(&lock->lock);
+1 −31
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@
#ifndef _TTM_LOCK_H_
#define _TTM_LOCK_H_

#include <linux/wait.h>
#include <linux/atomic.h>
#include <linux/wait.h>

#include "ttm_object.h"

@@ -63,8 +63,6 @@
 * @lock: Spinlock protecting some lock members.
 * @rw: Read-write lock counter. Protected by @lock.
 * @flags: Lock state. Protected by @lock.
 * @kill_takers: Boolean whether to kill takers of the lock.
 * @signal: Signal to send when kill_takers is true.
 */

struct ttm_lock {
@@ -73,9 +71,6 @@ struct ttm_lock {
	spinlock_t lock;
	int32_t rw;
	uint32_t flags;
	bool kill_takers;
	int signal;
	struct ttm_object_file *vt_holder;
};


@@ -220,29 +215,4 @@ extern void ttm_write_unlock(struct ttm_lock *lock);
 */
extern int ttm_write_lock(struct ttm_lock *lock, bool interruptible);

/**
 * ttm_lock_set_kill
 *
 * @lock: Pointer to a struct ttm_lock
 * @val: Boolean whether to kill processes taking the lock.
 * @signal: Signal to send to the process taking the lock.
 *
 * The kill-when-taking-lock functionality is used to kill processes that keep
 * on using the TTM functionality when its resources has been taken down, for
 * example when the X server exits. A typical sequence would look like this:
 * - X server takes lock in write mode.
 * - ttm_lock_set_kill() is called with @val set to true.
 * - As part of X server exit, TTM resources are taken down.
 * - X server releases the lock on file release.
 * - Another dri client wants to render, takes the lock and is killed.
 *
 */
static inline void ttm_lock_set_kill(struct ttm_lock *lock, bool val,
				     int signal)
{
	lock->kill_takers = val;
	if (val)
		lock->signal = signal;
}

#endif
+4 −3
Original line number Diff line number Diff line
@@ -37,11 +37,12 @@
#ifndef _TTM_OBJECT_H_
#define _TTM_OBJECT_H_

#include <linux/list.h>
#include <drm/drm_hashtab.h>
#include <linux/dma-buf.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/rcupdate.h>
#include <linux/dma-buf.h>

#include <drm/drm_hashtab.h>
#include <drm/ttm/ttm_memory.h>

/**
+2 −1
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@
#ifndef _VMWGFX_BINDING_H_
#define _VMWGFX_BINDING_H_

#include "device_include/svga3d_reg.h"
#include <linux/list.h>

#include "device_include/svga3d_reg.h"

#define VMW_MAX_VIEW_BINDINGS 128

struct vmw_private;
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@

#include <drm/ttm/ttm_placement.h>

#include <drm/drmP.h>
#include "vmwgfx_drv.h"
#include "ttm_object.h"

@@ -510,6 +509,8 @@ int vmw_bo_init(struct vmw_private *dev_priv,

	acc_size = vmw_bo_acc_size(dev_priv, size, user);
	memset(vmw_bo, 0, sizeof(*vmw_bo));
	BUILD_BUG_ON(TTM_MAX_BO_PRIORITY <= 3);
	vmw_bo->base.priority = 3;

	INIT_LIST_HEAD(&vmw_bo->res_list);

Loading