summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/pci/drm/drmP.h7
-rw-r--r--sys/dev/pci/drm/drm_drv.c23
-rw-r--r--sys/dev/pci/drm/i915_dma.c2
-rw-r--r--sys/dev/pci/drm/i915_drv.c2
-rw-r--r--sys/dev/pci/drm/i915_drv.h2
-rw-r--r--sys/dev/pci/drm/r128_drv.c2
-rw-r--r--sys/dev/pci/drm/r128_drv.h2
-rw-r--r--sys/dev/pci/drm/r128_state.c2
-rw-r--r--sys/dev/pci/drm/radeon_drv.c4
-rw-r--r--sys/dev/pci/drm/radeon_drv.h9
-rw-r--r--sys/dev/pci/drm/radeon_state.c33
11 files changed, 34 insertions, 54 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index d11cef347ec..c4b3bd0fbb6 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -311,7 +311,6 @@ typedef struct drm_buf_entry {
typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
struct drm_file {
TAILQ_ENTRY(drm_file) link;
- void *driver_priv;
int authenticated;
unsigned long ioctl_count;
dev_t kdev;
@@ -439,8 +438,7 @@ struct drm_driver_info {
int (*open)(struct drm_device *, struct drm_file *);
int (*ioctl)(struct drm_device*, u_long, caddr_t,
struct drm_file *);
- void (*preclose)(struct drm_device *, struct drm_file *);
- void (*postclose)(struct drm_device *, struct drm_file *);
+ void (*close)(struct drm_device *, struct drm_file *);
void (*lastclose)(struct drm_device *);
void (*reclaim_buffers_locked)(struct drm_device *,
struct drm_file *);
@@ -456,7 +454,8 @@ struct drm_driver_info {
int (*enable_vblank)(struct drm_device *, int);
void (*disable_vblank)(struct drm_device *, int);
- int buf_priv_size;
+ size_t buf_priv_size;
+ size_t file_priv_size;
int major;
int minor;
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index e84445fed60..8eacc31377f 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -402,8 +402,9 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
DRM_UNLOCK();
}
-
- priv = drm_calloc(1, sizeof(*priv), DRM_MEM_FILES);
+ /* always allocate at least enough space for our data */
+ priv = drm_calloc(1, max(dev->driver->file_priv_size,
+ sizeof(*priv)), DRM_MEM_FILES);
if (priv == NULL) {
ret = ENOMEM;
goto err;
@@ -440,7 +441,8 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
return (0);
free_priv:
- drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ drm_free(priv, max(dev->driver->file_priv_size,
+ sizeof(*priv)), DRM_MEM_FILES);
err:
DRM_LOCK();
--dev->open_count;
@@ -459,16 +461,15 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
DRM_LOCK();
file_priv = drm_find_file_by_minor(dev, minor(kdev));
- if (!file_priv) {
- DRM_UNLOCK();
+ DRM_UNLOCK();
+ if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
retcode = EINVAL;
goto done;
}
- DRM_UNLOCK();
- if (dev->driver->preclose != NULL)
- dev->driver->preclose(dev, file_priv);
+ if (dev->driver->close != NULL)
+ dev->driver->close(dev, file_priv);
DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
DRM_CURRENTPID, (long)&dev->device, dev->open_count);
@@ -517,12 +518,10 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
dev->buf_pgid = 0;
- if (dev->driver->postclose != NULL)
- dev->driver->postclose(dev, file_priv);
-
DRM_LOCK();
TAILQ_REMOVE(&dev->files, file_priv, link);
- drm_free(file_priv, sizeof(*file_priv), DRM_MEM_FILES);
+ drm_free(file_priv, max(dev->driver->file_priv_size,
+ sizeof(*file_priv)), DRM_MEM_FILES);
done:
if (--dev->open_count == 0) {
diff --git a/sys/dev/pci/drm/i915_dma.c b/sys/dev/pci/drm/i915_dma.c
index 83f0954ff86..adb5b0484d0 100644
--- a/sys/dev/pci/drm/i915_dma.c
+++ b/sys/dev/pci/drm/i915_dma.c
@@ -814,7 +814,7 @@ void i915_driver_lastclose(struct drm_device * dev)
i915_dma_cleanup(dev);
}
-void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
+void i915_driver_close(struct drm_device * dev, struct drm_file *file_priv)
{
drm_i915_private_t *dev_priv = dev->dev_private;
i915_mem_release(dev, file_priv, dev_priv->agp_heap);
diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c
index 43dc8edaf07..ec82d8f28ec 100644
--- a/sys/dev/pci/drm/i915_drv.c
+++ b/sys/dev/pci/drm/i915_drv.c
@@ -91,7 +91,7 @@ static drm_pci_id_list_t inteldrm_pciidlist[] = {
static const struct drm_driver_info inteldrm_driver = {
.ioctl = inteldrm_ioctl,
- .preclose = i915_driver_preclose,
+ .close = i915_driver_close,
.lastclose = i915_driver_lastclose,
.vblank_pipes = 2,
.get_vblank_counter = i915_get_vblank_counter,
diff --git a/sys/dev/pci/drm/i915_drv.h b/sys/dev/pci/drm/i915_drv.h
index 7a6787ffd4e..1433df78243 100644
--- a/sys/dev/pci/drm/i915_drv.h
+++ b/sys/dev/pci/drm/i915_drv.h
@@ -231,7 +231,7 @@ typedef struct drm_i915_private {
/* i915_dma.c */
extern void i915_kernel_lost_context(struct drm_device * dev);
extern void i915_driver_lastclose(struct drm_device * dev);
-extern void i915_driver_preclose(struct drm_device *dev,
+extern void i915_driver_close(struct drm_device *dev,
struct drm_file *file_priv);
extern int i915_driver_device_is_agp(struct drm_device * dev);
extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c
index b84ecc77caf..2e482066256 100644
--- a/sys/dev/pci/drm/r128_drv.c
+++ b/sys/dev/pci/drm/r128_drv.c
@@ -85,7 +85,7 @@ static drm_pci_id_list_t ragedrm_pciidlist[] = {
static const struct drm_driver_info ragedrm_driver = {
.buf_priv_size = sizeof(drm_r128_buf_priv_t),
.ioctl = ragedrm_ioctl,
- .preclose = r128_driver_preclose,
+ .close = r128_driver_close,
.lastclose = r128_driver_lastclose,
.vblank_pipes = 1,
.get_vblank_counter = r128_get_vblank_counter,
diff --git a/sys/dev/pci/drm/r128_drv.h b/sys/dev/pci/drm/r128_drv.h
index c1ef4df5f53..69bd9be3c6d 100644
--- a/sys/dev/pci/drm/r128_drv.h
+++ b/sys/dev/pci/drm/r128_drv.h
@@ -173,7 +173,7 @@ extern irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS);
extern int r128_driver_irq_install(struct drm_device * dev);
extern void r128_driver_irq_uninstall(struct drm_device * dev);
extern void r128_driver_lastclose(struct drm_device * dev);
-extern void r128_driver_preclose(struct drm_device * dev,
+extern void r128_driver_close(struct drm_device * dev,
struct drm_file *file_priv);
extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
diff --git a/sys/dev/pci/drm/r128_state.c b/sys/dev/pci/drm/r128_state.c
index b831029d8c4..d65165b7e11 100644
--- a/sys/dev/pci/drm/r128_state.c
+++ b/sys/dev/pci/drm/r128_state.c
@@ -1646,7 +1646,7 @@ int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv
return 0;
}
-void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
+void r128_driver_close(struct drm_device * dev, struct drm_file *file_priv)
{
drm_r128_private_t *dev_priv = dev->dev_private;
diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c
index c5a412326a6..cae9dac5488 100644
--- a/sys/dev/pci/drm/radeon_drv.c
+++ b/sys/dev/pci/drm/radeon_drv.c
@@ -478,11 +478,11 @@ static drm_pci_id_list_t radeondrm_pciidlist[] = {
static const struct drm_driver_info radeondrm_driver = {
.buf_priv_size = sizeof(drm_radeon_buf_priv_t),
+ .file_priv_size = sizeof(struct drm_radeon_file),
.firstopen = radeon_driver_firstopen,
.open = radeon_driver_open,
.ioctl = radeondrm_ioctl,
- .preclose = radeon_driver_preclose,
- .postclose = radeon_driver_postclose,
+ .close = radeon_driver_close,
.lastclose = radeon_driver_lastclose,
.vblank_pipes = 2,
.get_vblank_counter = radeon_get_vblank_counter,
diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h
index c733cb0baf8..e6d8acfa53e 100644
--- a/sys/dev/pci/drm/radeon_drv.h
+++ b/sys/dev/pci/drm/radeon_drv.h
@@ -190,8 +190,9 @@ typedef struct drm_radeon_depth_clear_t {
u32 se_cntl;
} drm_radeon_depth_clear_t;
-struct drm_radeon_driver_file_fields {
- int64_t radeon_fb_delta;
+struct drm_radeon_file {
+ struct drm_file file_priv;
+ int64_t radeon_fb_delta;
};
struct mem_block {
@@ -409,10 +410,8 @@ extern int radeon_vblank_crtc_get(struct drm_device *dev);
extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
extern int radeon_driver_firstopen(struct drm_device *dev);
-extern void radeon_driver_preclose(struct drm_device * dev,
+extern void radeon_driver_close(struct drm_device * dev,
struct drm_file *file_priv);
-extern void radeon_driver_postclose(struct drm_device * dev,
- struct drm_file *file_priv);
extern void radeon_driver_lastclose(struct drm_device * dev);
extern int radeon_driver_open(struct drm_device * dev,
struct drm_file * file_priv);
diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c
index 1de5d1693e7..7005224fe7f 100644
--- a/sys/dev/pci/drm/radeon_state.c
+++ b/sys/dev/pci/drm/radeon_state.c
@@ -44,7 +44,7 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
{
u64 off = *offset;
u32 fb_end = dev_priv->fb_location + dev_priv->fb_size - 1;
- struct drm_radeon_driver_file_fields *radeon_priv;
+ struct drm_radeon_file *radeon_priv;
/* Hrm ... the story of the offset ... So this function converts
* the various ideas of what userland clients might have for an
@@ -71,7 +71,7 @@ static __inline__ int radeon_check_and_fixup_offset(drm_radeon_private_t *
* magic offset we get from SETPARAM or calculated from fb_location
*/
if (off < (dev_priv->fb_size + dev_priv->gart_size)) {
- radeon_priv = file_priv->driver_priv;
+ radeon_priv = (struct drm_radeon_file *)file_priv;
off += radeon_priv->radeon_fb_delta;
}
@@ -3114,7 +3114,7 @@ int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file
{
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_setparam_t *sp = data;
- struct drm_radeon_driver_file_fields *radeon_priv;
+ struct drm_radeon_file *radeon_priv;
if (!dev_priv) {
DRM_ERROR("called with no initialization\n");
@@ -3123,7 +3123,7 @@ int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file
switch (sp->param) {
case RADEON_SETPARAM_FB_LOCATION:
- radeon_priv = file_priv->driver_priv;
+ radeon_priv = (struct drm_radeon_file *)file_priv;
radeon_priv->radeon_fb_delta = dev_priv->fb_location -
sp->value;
break;
@@ -3174,7 +3174,7 @@ int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file
*
* DRM infrastructure takes care of reclaiming dma buffers.
*/
-void radeon_driver_preclose(struct drm_device *dev,
+void radeon_driver_close(struct drm_device *dev,
struct drm_file *file_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -3199,29 +3199,12 @@ void radeon_driver_lastclose(struct drm_device *dev)
int radeon_driver_open(struct drm_device *dev, struct drm_file *file_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
- struct drm_radeon_driver_file_fields *radeon_priv;
+ struct drm_radeon_file *radeon_priv =
+ (struct drm_radeon_file *)file_priv;
DRM_DEBUG("\n");
- radeon_priv =
- (struct drm_radeon_driver_file_fields *)
- drm_alloc(sizeof(*radeon_priv), DRM_MEM_FILES);
- if (!radeon_priv)
- return ENOMEM;
-
- file_priv->driver_priv = radeon_priv;
-
- if (dev_priv)
- radeon_priv->radeon_fb_delta = dev_priv->fb_location;
- else
- radeon_priv->radeon_fb_delta = 0;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location;
return 0;
}
-void radeon_driver_postclose(struct drm_device *dev, struct drm_file *file_priv)
-{
- struct drm_radeon_driver_file_fields *radeon_priv =
- file_priv->driver_priv;
-
- drm_free(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
-}