From 6ef79263b68402687ccc2b7447dd908c00e35057 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 29 Mar 2003 03:38:47 +0000 Subject: Add DRMFILE definitions and supply filp for BSD in the post-drm-filp-0-1-branch world. The filp is a void * cast from the current pid. This is a temporary solution which maintains the status quo until a proper solution is implemented. What is really needed is a unique pointer per open, hopefully with a device private area. This can be done in FreeBSD for all entry points except mmap, but is difficult (sys/dev/streams/streams.c is an example). I have partially completed code for this but have not had time to debug, so this is a temporary fix. --- bsd/drm_drv.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'bsd/drm_drv.h') diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index d477a0f8..74655ee9 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -705,7 +705,7 @@ static int DRM(takedown)( drm_device_t *dev ) #endif if ( dev->lock.hw_lock ) { dev->lock.hw_lock = NULL; /* SHM removed */ - dev->lock.pid = 0; + dev->lock.filp = NULL; DRM_WAKEUP_INT((void *)&dev->lock.lock_queue); } DRM_UNLOCK; @@ -929,7 +929,8 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) drm_file_t *priv; DRM_DEVICE; int retcode = 0; - + DRMFILE __unused filp = (void *)(DRM_CURRENTPID); + DRM_DEBUG( "open_count = %d\n", dev->open_count ); priv = DRM(find_file_by_proc)(dev, p); if (!priv) { @@ -952,7 +953,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) #endif if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) - && dev->lock.pid == DRM_CURRENTPID) { + && dev->lock.filp == (void *)DRM_CURRENTPID) { DRM_DEBUG("Process %d dead, freeing lock for context %d\n", DRM_CURRENTPID, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); @@ -1002,7 +1003,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) } } #elif __HAVE_DMA - DRM(reclaim_buffers)( dev, priv->pid ); + DRM(reclaim_buffers)( dev, (void *)priv->pid ); #endif #if defined (__FreeBSD__) && (__FreeBSD_version >= 500000) @@ -1052,12 +1053,13 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) /* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm. */ -int DRM(ioctl)( DRM_IOCTL_ARGS ) +int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags, + DRM_STRUCTPROC *p) { DRM_DEVICE; int retcode = 0; drm_ioctl_desc_t *ioctl; - d_ioctl_t *func; + int (*func)(DRM_IOCTL_ARGS); int nr = DRM_IOCTL_NR(cmd); DRM_PRIV; @@ -1123,7 +1125,7 @@ int DRM(ioctl)( DRM_IOCTL_ARGS ) || ( ioctl->auth_needed && !priv->authenticated ) ) { retcode = EACCES; } else { - retcode = func( kdev, cmd, data, flags, p ); + retcode = func(kdev, cmd, data, flags, p, (void *)DRM_CURRENTPID); } } @@ -1178,7 +1180,7 @@ int DRM(lock)( DRM_IOCTL_ARGS ) } if ( DRM(lock_take)( &dev->lock.hw_lock->lock, lock.context ) ) { - dev->lock.pid = DRM_CURRENTPID; + dev->lock.filp = (void *)DRM_CURRENTPID; dev->lock.lock_time = jiffies; atomic_inc( &dev->counts[_DRM_STAT_LOCKS] ); break; /* Got lock */ -- cgit v1.2.3