Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Aug 2013 18:36:47 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255037 - head/sys/dev/drm2
Message-ID:  <201308291836.r7TIalTv012584@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Aug 29 18:36:47 2013
New Revision: 255037
URL: http://svnweb.freebsd.org/changeset/base/255037

Log:
  Fix atomic operations on context_flag without altering semantics.

Modified:
  head/sys/dev/drm2/drm_context.c

Modified: head/sys/dev/drm2/drm_context.c
==============================================================================
--- head/sys/dev/drm2/drm_context.c	Thu Aug 29 17:45:13 2013	(r255036)
+++ head/sys/dev/drm2/drm_context.c	Thu Aug 29 18:36:47 2013	(r255037)
@@ -182,7 +182,7 @@ bad:
 
 int drm_context_switch(struct drm_device *dev, int old, int new)
 {
-	if (test_and_set_bit(0, &dev->context_flag)) {
+	if (atomic_xchg(&dev->context_flag, 1) != 0) {
 		DRM_ERROR("Reentering -- FIXME\n");
 		return EBUSY;
 	}
@@ -190,7 +190,7 @@ int drm_context_switch(struct drm_device
 	DRM_DEBUG("Context switch from %d to %d\n", old, new);
 
 	if (new == dev->last_context) {
-		clear_bit(0, &dev->context_flag);
+		atomic_xchg(&dev->context_flag, 0);
 		return 0;
 	}
 
@@ -208,7 +208,7 @@ int drm_context_switch_complete(struct d
 	/* If a context switch is ever initiated
 	   when the kernel holds the lock, release
 	   that lock here. */
-	clear_bit(0, &dev->context_flag);
+	atomic_xchg(&dev->context_flag, 0);
 
 	return 0;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308291836.r7TIalTv012584>