diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-10-19 23:35:58 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-10-19 23:35:58 +0000 |
commit | 0cf1887139eb1ce18d09f7be0567aa93d802040d (patch) | |
tree | 05704a5a90bc9b0fbabed4029f200f9eff955953 /bsd/drm_fops.h | |
parent | 59fbe01fea8f77fc3810643c14a1738d197d4291 (diff) |
- SMPng lock the DRM. This is only partial -- there are a few code paths
used by root (the X Server) which are not locked. However, it should
deal with lost-IRQ issues on -current which I think people have been
experiencing but I am unable to reproduce (though I understand why they
would occur, because of a bug of mine). Note that most of the locking
(DRM_LOCK()/UNLOCK()) is all covered by Giant still, so it doesn't
matter yet.
- Remove locking on FreeBSD-stable and NetBSD. These are covered by the
fact that there is no reentrancy of the kernel except by interrupts,
which are locked using spldrm()/splx() instead.
Diffstat (limited to 'bsd/drm_fops.h')
-rw-r--r-- | bsd/drm_fops.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bsd/drm_fops.h b/bsd/drm_fops.h index b44254b8..3c4553de 100644 --- a/bsd/drm_fops.h +++ b/bsd/drm_fops.h @@ -33,6 +33,7 @@ #include "drmP.h" +/* Requires device lock held */ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) { #if __FreeBSD_version >= 500021 @@ -50,8 +51,7 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) return NULL; } -/* DRM(open) is called whenever a process opens /dev/drm. */ - +/* DRM(open_helper) is called whenever a process opens /dev/drm. */ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, drm_device_t *dev) { @@ -64,12 +64,16 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); - /* FIXME: linux mallocs and bzeros here */ + DRM_LOCK(); priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); if (priv) { priv->refs++; } else { priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES); + if (priv == NULL) { + DRM_UNLOCK(); + return DRM_ERR(ENOMEM); + } bzero(priv, sizeof(*priv)); #if __FreeBSD_version >= 500000 priv->uid = p->td_ucred->cr_svuid; @@ -84,10 +88,9 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, priv->devXX = dev; priv->ioctl_count = 0; priv->authenticated = !DRM_SUSER(p); - DRM_LOCK(); TAILQ_INSERT_TAIL(&dev->files, priv, link); - DRM_UNLOCK(); } + DRM_UNLOCK(); #ifdef __FreeBSD__ kdev->si_drv1 = dev; #endif |