From be3099f26547f48066bbdd7a36578b54da9170b4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 22 Jul 2007 09:51:34 +0100 Subject: Fix copy'n'paste-o in FreeBSD drawable code. --- bsd-core/drm_drawable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsd-core') diff --git a/bsd-core/drm_drawable.c b/bsd-core/drm_drawable.c index 14a29407..7e038ab9 100644 --- a/bsd-core/drm_drawable.c +++ b/bsd-core/drm_drawable.c @@ -45,7 +45,7 @@ drm_drawable_compare(struct bsd_drm_drawable_info *a, { if (a->handle > b->handle) return 1; - if (a->handle > b->handle) + if (a->handle < b->handle) return -1; return 0; } -- cgit v1.2.3 From 263775c454f381fffc8f5d4f309b4e1b131c3734 Mon Sep 17 00:00:00 2001 From: vehemens Date: Mon, 13 Aug 2007 10:24:39 -0700 Subject: Fix drm_auth.c locking to not recurse on dev_lock. --- bsd-core/drm_auth.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bsd-core') diff --git a/bsd-core/drm_auth.c b/bsd-core/drm_auth.c index 964f9a42..14cfc225 100644 --- a/bsd-core/drm_auth.c +++ b/bsd-core/drm_auth.c @@ -43,6 +43,8 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) drm_magic_entry_t *pt; int hash = drm_hash_magic(magic); + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { if (pt->magic == magic) { return pt->priv; @@ -59,6 +61,8 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) DRM_DEBUG("%d\n", magic); + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + hash = drm_hash_magic(magic); entry = malloc(sizeof(*entry), M_DRM, M_ZERO | M_NOWAIT); if (!entry) return ENOMEM; @@ -85,10 +89,11 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) drm_magic_entry_t *pt; int hash; + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + DRM_DEBUG("%d\n", magic); hash = drm_hash_magic(magic); - DRM_LOCK(); for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { if (pt->magic == magic) { if (dev->magiclist[hash].head == pt) { @@ -100,11 +105,9 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) if (prev) { prev->next = pt->next; } - DRM_UNLOCK(); return 0; } } - DRM_UNLOCK(); free(pt, M_DRM); return EINVAL; @@ -129,8 +132,8 @@ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) continue; } while (drm_find_file(dev, auth->magic)); file_priv->magic = auth->magic; - DRM_UNLOCK(); drm_add_magic(dev, file_priv, auth->magic); + DRM_UNLOCK(); } DRM_DEBUG("%u\n", auth->magic); -- cgit v1.2.3 From 3b07a37a48ca6dc22d538221b59b430dd72c6203 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 13 Aug 2007 10:50:25 -0700 Subject: Add doxygen and fix whitespace for drm_auth.c --- bsd-core/drm_auth.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'bsd-core') diff --git a/bsd-core/drm_auth.c b/bsd-core/drm_auth.c index 14cfc225..9b5f4f74 100644 --- a/bsd-core/drm_auth.c +++ b/bsd-core/drm_auth.c @@ -1,4 +1,4 @@ -/* drm_auth.h -- IOCTLs for authentication -*- linux-c -*- +/* drm_auth.c -- IOCTLs for authentication -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com */ /*- @@ -38,6 +38,9 @@ static int drm_hash_magic(drm_magic_t magic) return magic & (DRM_HASH_SIZE-1); } +/** + * Returns the file private associated with the given magic number. + */ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *pt; @@ -54,6 +57,10 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) return NULL; } +/** + * Inserts the given magic number into the hash table of used magic number + * lists. + */ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) { int hash; @@ -83,6 +90,10 @@ static int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) return 0; } +/** + * Removes the given magic number from the hash table of used magic number + * lists. + */ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) { drm_magic_entry_t *prev = NULL; @@ -113,6 +124,14 @@ static int drm_remove_magic(drm_device_t *dev, drm_magic_t magic) return EINVAL; } +/** + * Called by the client, this returns a unique magic number to be authorized + * by the master. + * + * The master may use its own knowledge of the client (such as the X + * connection that the magic is passed over) to determine if the magic number + * should be authenticated. + */ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) { static drm_magic_t sequence = 0; @@ -125,9 +144,9 @@ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) DRM_LOCK(); do { int old = sequence; - + auth->magic = old+1; - + if (!atomic_cmpset_int(&sequence, old, auth->magic)) continue; } while (drm_find_file(dev, auth->magic)); @@ -141,6 +160,9 @@ int drm_getmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) return 0; } +/** + * Marks the client associated with the given magic number as authenticated. + */ int drm_authmagic(drm_device_t *dev, void *data, struct drm_file *file_priv) { drm_auth_t *auth = data; -- cgit v1.2.3 From 4340f49bf79a5421886363e08501ad347973b083 Mon Sep 17 00:00:00 2001 From: vehemens Date: Mon, 13 Aug 2007 10:17:47 -0700 Subject: Bug #11951: Fix an errno sign inversion on pre-FreeBSD 5. Also, annotate where signs change, to hopefully remind the reader of these issues in the future. --- bsd-core/drmP.h | 4 +++- bsd-core/drm_dma.c | 1 + bsd-core/drm_fops.c | 1 + bsd-core/drm_irq.c | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) (limited to 'bsd-core') diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 73342d09..8a768f0c 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -377,6 +377,7 @@ do { \ } while (0) #if defined(__FreeBSD__) && __FreeBSD_version > 500000 +/* Returns -errno to shared code */ #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ DRM_UNLOCK(); \ @@ -388,11 +389,12 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ DRM_LOCK(); \ } #else +/* Returns -errno to shared code */ #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ int s = spldrm(); \ if (!(condition)) \ - ret = tsleep( &(queue), PZERO | PCATCH, \ + ret = -tsleep( &(queue), PZERO | PCATCH, \ "drmwtq", (timeout) ); \ splx(s); \ } diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c index fc1e1250..4896cf22 100644 --- a/bsd-core/drm_dma.c +++ b/bsd-core/drm_dma.c @@ -121,6 +121,7 @@ int drm_dma(drm_device_t *dev, void *data, struct drm_file *file_priv) { if (dev->driver.dma_ioctl) { + /* shared code returns -errno */ return -dev->driver.dma_ioctl(dev, data, file_priv); } else { DRM_DEBUG("DMA ioctl on driver with no dma handler\n"); diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c index 870e4d29..2d037ea5 100644 --- a/bsd-core/drm_fops.c +++ b/bsd-core/drm_fops.c @@ -93,6 +93,7 @@ int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, priv->authenticated = DRM_SUSER(p); if (dev->driver.open) { + /* shared code returns -errno */ retcode = -dev->driver.open(dev, priv); if (retcode != 0) { free(priv, M_DRM); diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c index 1ab532fe..9c437e9d 100644 --- a/bsd-core/drm_irq.c +++ b/bsd-core/drm_irq.c @@ -241,6 +241,7 @@ int drm_wait_vblank(drm_device_t *dev, void *data, struct drm_file *file_priv) ret = EINVAL; } else { DRM_LOCK(); + /* shared code returns -errno */ ret = -dev->driver.vblank_wait(dev, &vblwait->request.sequence); DRM_UNLOCK(); -- cgit v1.2.3