Fix atomic operations on context_flag without altering semantics.

This commit is contained in:
Jung-uk Kim 2013-08-29 18:36:47 +00:00
parent 4b0f6e5b60
commit 0289d87d9c

View File

@ -182,7 +182,7 @@ int drm_setsareactx(struct drm_device *dev, void *data,
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 *dev, int old, int new)
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 drm_device *dev, int new)
/* 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;
}