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/include/linux Implement Linux...
details: https://anonhg.NetBSD.org/src/rev/d85e408b2427
branches: riastradh-drm2
changeset: 787998:d85e408b2427
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 00:49:19 2013 +0000
description:
Implement Linux spin lock in terms of kmutex_t in drm2's <linux/spinlock.h>.
Currently a spin lock will be an adaptive mutex, until I identify
cases in drm2 that actually require spinning and interrupt deferral.
diffstat:
sys/external/bsd/drm2/include/linux/spinlock.h | 41 +++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diffs (53 lines):
diff -r 4f8d9faafdd8 -r d85e408b2427 sys/external/bsd/drm2/include/linux/spinlock.h
--- a/sys/external/bsd/drm2/include/linux/spinlock.h Wed Jul 24 00:49:04 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/spinlock.h Wed Jul 24 00:49:19 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spinlock.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */
+/* $NetBSD: spinlock.h,v 1.1.2.2 2013/07/24 00:49:19 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,43 @@
#ifndef _LINUX_SPINLOCK_H_
#define _LINUX_SPINLOCK_H_
+#include <sys/cdefs.h>
+#include <sys/mutex.h>
+
+typedef struct {
+ kmutex_t sl_lock;
+} spinlock_t;
+
+static inline void
+spin_lock(spinlock_t *spinlock)
+{
+ mutex_enter(&spinlock->sl_lock);
+}
+
+static inline void
+spin_unlock(spinlock_t *spinlock)
+{
+ mutex_exit(&spinlock->sl_lock);
+}
+
+/* Must be a macro because the second argument is to be assigned. */
+#define spin_lock_irqsave(SPINLOCK, FLAGS) \
+ do { \
+ (FLAGS) = 0; \
+ mutex_enter(&((spinlock_t *)(SPINLOCK))->sl_lock); \
+ } while (0)
+
+static inline void
+spin_lock_irqrestore(spinlock_t *spinlock, unsigned long __unused flags)
+{
+ mutex_exit(&spinlock->sl_lock);
+}
+
+static inline void
+spin_lock_init(spinlock_t *spinlock)
+{
+ /* XXX Need to identify which need to block intrs. */
+ mutex_init(&spinlock->sl_lock, MUTEX_DEFAULT, IPL_NONE);
+}
+
#endif /* _LINUX_SPINLOCK_H_ */
Home |
Main Index |
Thread Index |
Old Index