diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-11-07 04:11:15 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-11-07 04:11:15 +0000 |
commit | a1d9e5abafe60ca2b7f96cadd1013695ada4ac41 (patch) | |
tree | ff8a462ecf2fea9ee35c8988ac0d9a37b7206808 /bsd-core/drm_drv.c | |
parent | c5bededa5130a58273448188c04c15bc9c1097f3 (diff) |
Refine the locking of the DRM. Most significant is covering the driver
ioctls with dev_lock, which is a major step toward being able to remove
Giant. Covers some new pieces (dev->unique*) in the core, and avoids
one call down into system internals with the drm lock held, which is
usually bad (FreeBSD LOR #23, #27).
Diffstat (limited to 'bsd-core/drm_drv.c')
-rw-r--r-- | bsd-core/drm_drv.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 7880f76c..fb9313af 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -809,9 +809,17 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, drm_ioctl_desc_t *ioctl; int (*func)(DRM_IOCTL_ARGS); int nr = DRM_IOCTL_NR(cmd); + int is_driver_ioctl = 0; drm_file_t *priv; + DRMFILE filp = (DRMFILE)(uintptr_t)DRM_CURRENTPID; - DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID); + DRM_LOCK(); + priv = drm_find_file_by_proc(dev, p); + DRM_UNLOCK(); + if (priv == NULL) { + DRM_ERROR("can't find authenticator\n"); + return EINVAL; + } atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] ); ++priv->ioctl_count; @@ -868,6 +876,7 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, return EINVAL; } ioctl = &dev->driver_ioctls[nr]; + is_driver_ioctl = 1; } func = ioctl->func; @@ -879,7 +888,11 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, !priv->authenticated)) return EACCES; - retcode = func(kdev, cmd, data, flags, p, (void *)(uintptr_t)DRM_CURRENTPID); + if (is_driver_ioctl) + DRM_LOCK(); + retcode = func(kdev, cmd, data, flags, p, filp); + if (is_driver_ioctl) + DRM_UNLOCK(); if (retcode != 0) DRM_DEBUG(" returning %d\n", retcode); |