summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/drmP.h40
-rw-r--r--bsd-core/drm_bufs.c8
-rw-r--r--bsd-core/drm_dma.c9
-rw-r--r--bsd-core/drm_drv.c56
-rw-r--r--bsd-core/drm_irq.c2
-rw-r--r--bsd-core/drm_lock.c6
6 files changed, 53 insertions, 68 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index e9271ff7..84baf5f0 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -217,10 +217,6 @@ MALLOC_DECLARE(M_DRM);
#define spldrm() spltty()
#endif /* __NetBSD__ || __OpenBSD__ */
-/* Currently our DRMFILE (filp) is a void * which is actually the pid
- * of the current process. It should be a per-open unique pointer, but
- * code for that is not yet written */
-#define DRMFILE void *
#define DRM_IRQ_ARGS void *arg
typedef void irqreturn_t;
#define IRQ_HANDLED /* nothing */
@@ -237,7 +233,8 @@ enum {
#define DRM_DEVICE \
drm_device_t *dev = kdev->si_drv1
#define DRM_IOCTL_ARGS struct cdev *kdev, u_long cmd, caddr_t data, \
- int flags, DRM_STRUCTPROC *p, DRMFILE filp
+ int flags, DRM_STRUCTPROC *p, \
+ struct drm_file *file_priv
#define PAGE_ALIGN(addr) round_page(addr)
/* DRM_SUSER returns true if the user is superuser */
@@ -260,8 +257,9 @@ enum {
drm_device_t *dev = (device_lookup(&drm_cd, \
minor(kdev)))->dv_cfdata->cf_driver->cd_devs[minor(kdev)]
#endif /* __OpenBSD__ */
-#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, \
- int flags, DRM_STRUCTPROC *p, DRMFILE filp
+#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, \
+ int flags, DRM_STRUCTPROC *p, \
+ struct drm_file *file_priv
#define CDEV_MAJOR 34
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
@@ -385,23 +383,10 @@ typedef vaddr_t vm_offset_t;
(_map) = (_dev)->context_sareas[_ctx]; \
} while(0)
-#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
-do { \
- if (_filp != (DRMFILE)(intptr_t)DRM_CURRENTPID) { \
- DRM_ERROR("filp doesn't match curproc\n"); \
- return EINVAL; \
- } \
- _priv = drm_find_file_by_proc(dev, DRM_CURPROC); \
- if (_priv == NULL) { \
- DRM_ERROR("can't find authenticator\n"); \
- return EINVAL; \
- } \
-} while (0)
-
-#define LOCK_TEST_WITH_RETURN(dev, filp) \
+#define LOCK_TEST_WITH_RETURN(dev, file_priv) \
do { \
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
- dev->lock.filp != filp) { \
+ dev->lock.file_priv != file_priv) { \
DRM_ERROR("%s called without lock held\n", \
__FUNCTION__); \
return EINVAL; \
@@ -479,7 +464,7 @@ typedef struct drm_buf {
unsigned long bus_address; /* Bus address of buffer */
struct drm_buf *next; /* Kernel-only: used for free list */
__volatile__ int pending; /* On hardware DMA queue */
- DRMFILE filp; /* Unique identifier of holding process */
+ struct drm_file *file_priv; /* Unique identifier of holding process */
int context; /* Kernel queue for this buffer */
enum {
DRM_LIST_NONE = 0,
@@ -541,7 +526,7 @@ struct drm_file {
typedef struct drm_lock_data {
drm_hw_lock_t *hw_lock; /* Hardware lock */
- DRMFILE filp; /* Unique identifier of holding process (NULL is kernel)*/
+ struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/
int lock_queue; /* Queue of blocked processes */
unsigned long lock_time; /* Time of last lock in jiffies */
} drm_lock_data_t;
@@ -645,11 +630,12 @@ struct drm_driver_info {
int (*load)(struct drm_device *, unsigned long flags);
int (*firstopen)(struct drm_device *);
int (*open)(struct drm_device *, drm_file_t *);
- void (*preclose)(struct drm_device *, void *filp);
+ void (*preclose)(struct drm_device *, struct drm_file *file_priv);
void (*postclose)(struct drm_device *, drm_file_t *);
void (*lastclose)(struct drm_device *);
int (*unload)(struct drm_device *);
- void (*reclaim_buffers_locked)(struct drm_device *, void *filp);
+ void (*reclaim_buffers_locked)(struct drm_device *,
+ struct drm_file *file_priv);
int (*dma_ioctl)(DRM_IOCTL_ARGS);
void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *);
@@ -900,7 +886,7 @@ int drm_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request);
int drm_dma_setup(drm_device_t *dev);
void drm_dma_takedown(drm_device_t *dev);
void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
-void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp);
+void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv);
#define drm_core_reclaim_buffers drm_reclaim_buffers
/* IRQ support (drm_irq.c) */
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index de28a2cf..bc019741 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -469,7 +469,7 @@ static int drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
buf->address = (void *)(agp_offset + offset);
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -610,7 +610,7 @@ static int drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
buf->bus_address = dmah->busaddr + offset;
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -724,7 +724,7 @@ static int drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
buf->address = (void *)(agp_offset + offset + dev->sg->handle);
buf->next = NULL;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = malloc(buf->dev_priv_size, M_DRM,
@@ -1008,7 +1008,7 @@ int drm_freebufs(DRM_IOCTL_ARGS)
break;
}
buf = dma->buflist[idx];
- if ( buf->filp != filp ) {
+ if ( buf->file_priv != file_priv ) {
DRM_ERROR("Process %d freeing buffer not owned\n",
DRM_CURRENTPID);
retcode = EINVAL;
diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c
index 90678dfc..fc219039 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -89,18 +89,18 @@ void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
if (!buf) return;
buf->pending = 0;
- buf->filp = NULL;
+ buf->file_priv= NULL;
buf->used = 0;
}
-void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp)
+void drm_reclaim_buffers(drm_device_t *dev, struct drm_file *file_priv)
{
drm_device_dma_t *dma = dev->dma;
int i;
if (!dma) return;
for (i = 0; i < dma->buf_count; i++) {
- if (dma->buflist[i]->filp == filp) {
+ if (dma->buflist[i]->file_priv == file_priv) {
switch (dma->buflist[i]->list) {
case DRM_LIST_NONE:
drm_free_buffer(dev, dma->buflist[i]);
@@ -122,7 +122,8 @@ int drm_dma(DRM_IOCTL_ARGS)
DRM_DEVICE;
if (dev->driver.dma_ioctl) {
- return -dev->driver.dma_ioctl(kdev, cmd, data, flags, p, filp);
+ return -dev->driver.dma_ioctl(kdev, cmd, data, flags, p,
+ file_priv);
} else {
DRM_DEBUG("DMA ioctl on driver with no dma handler\n");
return EINVAL;
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index fa2958b9..0b33ba34 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -499,7 +499,7 @@ static int drm_lastclose(drm_device_t *dev)
drm_dma_takedown(dev);
if ( dev->lock.hw_lock ) {
dev->lock.hw_lock = NULL; /* SHM removed */
- dev->lock.filp = NULL;
+ dev->lock.file_priv = NULL;
DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
}
@@ -704,24 +704,23 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
- drm_file_t *priv;
+ drm_file_t *file_priv;
DRM_DEVICE;
int retcode = 0;
- DRMFILE filp = (void *)(uintptr_t)(DRM_CURRENTPID);
-
+
DRM_DEBUG( "open_count = %d\n", dev->open_count );
DRM_LOCK();
- priv = drm_find_file_by_proc(dev, p);
- if (!priv) {
+ file_priv = drm_find_file_by_proc(dev, p);
+ if (!file_priv) {
DRM_UNLOCK();
DRM_ERROR("can't find authenticator\n");
return EINVAL;
}
if (dev->driver.preclose != NULL)
- dev->driver.preclose(dev, filp);
+ dev->driver.preclose(dev, file_priv);
/* ========================================================
* Begin inline drm_release
@@ -736,12 +735,12 @@ int drm_close(struct cdev *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.filp == filp) {
+ && dev->lock.file_priv == file_priv) {
DRM_DEBUG("Process %d dead, freeing lock for context %d\n",
DRM_CURRENTPID,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
if (dev->driver.reclaim_buffers_locked != NULL)
- dev->driver.reclaim_buffers_locked(dev, filp);
+ dev->driver.reclaim_buffers_locked(dev, file_priv);
drm_lock_free(dev, &dev->lock.hw_lock->lock,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
@@ -761,7 +760,7 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
}
if (drm_lock_take(&dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT)) {
- dev->lock.filp = filp;
+ dev->lock.file_priv = file_priv;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -778,14 +777,14 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
break;
}
if (retcode == 0) {
- dev->driver.reclaim_buffers_locked(dev, filp);
+ dev->driver.reclaim_buffers_locked(dev, file_priv);
drm_lock_free(dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT);
}
}
if (dev->driver.use_dma && !dev->driver.reclaim_buffers_locked)
- drm_reclaim_buffers(dev, filp);
+ drm_reclaim_buffers(dev, file_priv);
#if defined (__FreeBSD__) && (__FreeBSD_version >= 500000)
funsetown(&dev->buf_sigio);
@@ -795,11 +794,11 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
dev->buf_pgid = 0;
#endif /* __NetBSD__ || __OpenBSD__ */
- if (--priv->refs == 0) {
+ if (--file_priv->refs == 0) {
if (dev->driver.postclose != NULL)
- dev->driver.postclose(dev, priv);
- TAILQ_REMOVE(&dev->files, priv, link);
- free(priv, M_DRM);
+ dev->driver.postclose(dev, file_priv);
+ TAILQ_REMOVE(&dev->files, file_priv, link);
+ free(file_priv, M_DRM);
}
/* ========================================================
@@ -830,26 +829,27 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
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_file_t *file_priv;
DRM_LOCK();
- priv = drm_find_file_by_proc(dev, p);
+ file_priv = drm_find_file_by_proc(dev, p);
DRM_UNLOCK();
- if (priv == NULL) {
+ if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return EINVAL;
}
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
- ++priv->ioctl_count;
+ ++file_priv->ioctl_count;
#ifdef __FreeBSD__
DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
- DRM_CURRENTPID, cmd, nr, (long)dev->device, priv->authenticated );
+ DRM_CURRENTPID, cmd, nr, (long)dev->device,
+ file_priv->authenticated );
#elif defined(__NetBSD__) || defined(__OpenBSD__)
DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
- DRM_CURRENTPID, cmd, nr, (long)&dev->device, priv->authenticated );
+ DRM_CURRENTPID, cmd, nr, (long)&dev->device,
+ file_priv->authenticated );
#endif
switch (cmd) {
@@ -904,17 +904,15 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
DRM_DEBUG( "no function\n" );
return EINVAL;
}
- /* ioctl->master check should be against something in the filp set up
- * for the first opener, but it doesn't matter yet.
- */
+
if (((ioctl->flags & DRM_ROOT_ONLY) && !DRM_SUSER(p)) ||
- ((ioctl->flags & DRM_AUTH) && !priv->authenticated) ||
- ((ioctl->flags & DRM_MASTER) && !priv->master))
+ ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
+ ((ioctl->flags & DRM_MASTER) && !file_priv->master))
return EACCES;
if (is_driver_ioctl)
DRM_LOCK();
- retcode = func(kdev, cmd, data, flags, p, filp);
+ retcode = func(kdev, cmd, data, flags, p, file_priv);
if (is_driver_ioctl) {
DRM_UNLOCK();
/* Driver ioctls in shared code follow the linux convention of
diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c
index 215eb0c9..95c84ab5 100644
--- a/bsd-core/drm_irq.c
+++ b/bsd-core/drm_irq.c
@@ -306,7 +306,7 @@ static void drm_locked_task(void *context, int pending __unused)
if (drm_lock_take(&dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT))
{
- dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID;
+ dev->lock.file_priv = NULL; /* kernel owned */
dev->lock.lock_time = jiffies;
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
break; /* Got lock */
diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c
index d0e61d3a..54b64806 100644
--- a/bsd-core/drm_lock.c
+++ b/bsd-core/drm_lock.c
@@ -66,7 +66,7 @@ int drm_lock_transfer(drm_device_t *dev,
{
unsigned int old, new;
- dev->lock.filp = NULL;
+ dev->lock.file_priv = NULL;
do {
old = *lock;
new = context | _DRM_LOCK_HELD;
@@ -80,7 +80,7 @@ int drm_lock_free(drm_device_t *dev,
{
unsigned int old, new;
- dev->lock.filp = NULL;
+ dev->lock.file_priv = NULL;
do {
old = *lock;
new = 0;
@@ -118,7 +118,7 @@ int drm_lock(DRM_IOCTL_ARGS)
DRM_LOCK();
for (;;) {
if (drm_lock_take(&dev->lock.hw_lock->lock, lock.context)) {
- dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID;
+ dev->lock.file_priv = file_priv;
dev->lock.lock_time = jiffies;
atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
break; /* Got lock */