Module Name:    src
Committed By:   riastradh
Date:           Wed Jul 24 02:00:22 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/dist/drm [riastradh-drm2]: drm_auth.c

Log Message:
Replace trivial spinlock by atomics in drm_getmagic.

(This whole drm_getmagic thing smells awfully fishy...)


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 \
    src/sys/external/bsd/drm2/dist/drm/drm_auth.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/dist/drm/drm_auth.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.2 src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.3
--- src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.2	Tue Jul 23 21:28:21 2013
+++ src/sys/external/bsd/drm2/dist/drm/drm_auth.c	Wed Jul 24 02:00:22 2013
@@ -142,7 +142,9 @@ int drm_remove_magic(struct drm_master *
 int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
 	static drm_magic_t sequence = 0;
+#ifndef __NetBSD__
 	static DEFINE_SPINLOCK(lock);
+#endif
 	struct drm_auth *auth = data;
 
 	/* Find unique magic */
@@ -150,11 +152,15 @@ int drm_getmagic(struct drm_device *dev,
 		auth->magic = file_priv->magic;
 	} else {
 		do {
+#ifdef __NetBSD__
+			auth->magic = atomic_inc_uint_nv(&sequence);
+#else
 			spin_lock(&lock);
 			if (!sequence)
 				++sequence;	/* reserve 0 */
 			auth->magic = sequence++;
 			spin_unlock(&lock);
+#endif
 		} while (drm_find_file(file_priv->master, auth->magic));
 		file_priv->magic = auth->magic;
 		drm_add_magic(file_priv->master, file_priv, auth->magic);

Reply via email to