Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2/drm Implement drm_lock_free a...
details: https://anonhg.NetBSD.org/src/rev/c57815e0a9b2
branches: riastradh-drm2
changeset: 788180:c57815e0a9b2
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 02:35:35 2013 +0000
description:
Implement drm_lock_free and drm_i_have_hw_lock.
diffstat:
sys/external/bsd/drm2/drm/drm_lock.c | 48 ++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 2 deletions(-)
diffs (76 lines):
diff -r f8793d7a36c3 -r c57815e0a9b2 sys/external/bsd/drm2/drm/drm_lock.c
--- a/sys/external/bsd/drm2/drm/drm_lock.c Wed Jul 24 02:35:22 2013 +0000
+++ b/sys/external/bsd/drm2/drm/drm_lock.c Wed Jul 24 02:35:35 2013 +0000
@@ -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 @@
}
/*
+ * 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 @@
}
/*
+ * 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.
Home |
Main Index |
Thread Index |
Old Index