Module Name:    src
Committed By:   riastradh
Date:           Wed Jul 24 00:49:19 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: spinlock.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \
    src/sys/external/bsd/drm2/include/linux/spinlock.h

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/include/linux/spinlock.h
diff -u src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.2
--- src/sys/external/bsd/drm2/include/linux/spinlock.h:1.1.2.1	Wed Jul 24 00:33:12 2013
+++ src/sys/external/bsd/drm2/include/linux/spinlock.h	Wed Jul 24 00:49:19 2013
@@ -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_ */

Reply via email to