From 5346fc5f36b5e7c55fc7b5cd46f1e4d7563a86a4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 14 Aug 2007 14:41:24 -0700 Subject: BSD: Replace brief description in each file's first line with doxygen later on. The brief descriptions usually had the wrong filename in them. --- bsd-core/drm_lock.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'bsd-core/drm_lock.c') diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c index 5acb13d3..326c083b 100644 --- a/bsd-core/drm_lock.c +++ b/bsd-core/drm_lock.c @@ -1,6 +1,3 @@ -/* lock.c -- IOCTLs for locking -*- linux-c -*- - * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com - */ /*- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. @@ -31,6 +28,25 @@ * */ +/** @file drm_lock.c + * Implementation of the ioctls and other support code for dealing with the + * hardware lock. + * + * The DRM hardware lock is a shared structure between the kernel and userland. + * + * On uncontended access where the new context was the last context, the + * client may take the lock without dropping down into the kernel, using atomic + * compare-and-set. + * + * If the client finds during compare-and-set that it was not the last owner + * of the lock, it calls the DRM lock ioctl, which may sleep waiting for the + * lock, and may have side-effects of kernel-managed context switching. + * + * When the client releases the lock, if the lock is marked as being contended + * by another client, then the DRM unlock ioctl is called so that the + * contending client may be woken up. + */ + #include "drmP.h" int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) -- cgit v1.2.3 From 6e93c35ba7c5001e756d0c9d1a4f534384652a5a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 15 Aug 2007 13:42:04 -0700 Subject: BSD: Return EINVAL if drm_unlock is called on an unheld or other-owner lock. --- bsd-core/drm_lock.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bsd-core/drm_lock.c') diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c index 326c083b..fb86fc68 100644 --- a/bsd-core/drm_lock.c +++ b/bsd-core/drm_lock.c @@ -173,6 +173,12 @@ int drm_unlock(drm_device_t *dev, void *data, struct drm_file *file_priv) DRM_CURRENTPID, lock->context); return EINVAL; } + /* Check that the context unlock being requested actually matches + * who currently holds the lock. + */ + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) != lock->context) + return EINVAL; atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]); -- cgit v1.2.3