Module Name: src
Committed By: riastradh
Date: Wed Jul 24 02:35:35 UTC 2013
Modified Files:
src/sys/external/bsd/drm2/drm [riastradh-drm2]: drm_lock.c
Log Message:
Implement drm_lock_free and drm_i_have_hw_lock.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/external/bsd/drm2/drm/drm_lock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/drm/drm_lock.c
diff -u src/sys/external/bsd/drm2/drm/drm_lock.c:1.1.2.1 src/sys/external/bsd/drm2/drm/drm_lock.c:1.1.2.2
--- src/sys/external/bsd/drm2/drm/drm_lock.c:1.1.2.1 Wed Jul 24 02:33:17 2013
+++ src/sys/external/bsd/drm2/drm/drm_lock.c Wed Jul 24 02:35:35 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: drm_lock.c,v 1.1.2.1 2013/07/24 02:33:17 riastradh Exp $ */
+/* $NetBSD: drm_lock.c,v 1.1.2.2 2013/07/24 02:35:35 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_lock.c,v 1.1.2.1 2013/07/24 02:33:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_lock.c,v 1.1.2.2 2013/07/24 02:35:35 riastradh Exp $");
#include <sys/types.h>
#include <sys/errno.h>
@@ -191,6 +191,23 @@ out: spin_unlock(&master->lock.spinlock)
}
/*
+ * Drop the lock.
+ *
+ * Return value is an artefact of Linux. Caller must guarantee
+ * preconditions; failure is fatal.
+ */
+int
+drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
+{
+
+ spin_lock(&lock_data->spinlock);
+ drm_lock_release(lock_data, context);
+ spin_unlock(&lock_data->spinlock);
+
+ return 0;
+}
+
+/*
* Take the lock for the kernel's use.
*/
void
@@ -211,6 +228,33 @@ drm_idlelock_release(struct drm_lock_dat
}
/*
+ * Does this file hold this drm device's hardware lock?
+ */
+int
+drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file)
+{
+ struct drm_lock_data *const lock_data = &file->master->lock;
+
+ /* If this file has never locked anything, then no. */
+ if (file->lock_count == 0)
+ return 0;
+
+ /* If there is no lock, then this file doesn't hold it. */
+ if (lock_data->hw_lock == NULL)
+ return 0;
+
+ /* If this lock is not held, then this file doesn't hold it. */
+ if (!_DRM_LOCK_IS_HELD(lock_data->hw_lock->lock))
+ return 0;
+
+ /*
+ * Otherwise, it boils down to whether this file is the owner
+ * or someone else.
+ */
+ return (file == lock_data->file_priv);
+}
+
+/*
* Try to acquire the lock. Return true if successful, false if not.
*
* Lock's spinlock must be held.