summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/drmP.h6
-rw-r--r--linux-core/drm_fops.c10
-rw-r--r--linux/drmP.h6
-rw-r--r--linux/drm_fops.h10
-rw-r--r--shared-core/radeon_drv.h3
-rw-r--r--shared-core/radeon_state.c27
-rw-r--r--shared/radeon.h3
-rw-r--r--shared/radeon_drv.h3
-rw-r--r--shared/radeon_state.c27
9 files changed, 70 insertions, 25 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index b6b275b99..1be3375cd 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -371,9 +371,7 @@ typedef struct drm_file {
struct drm_device *dev;
int remove_auth_on_close;
unsigned long lock_count;
-#ifdef DRIVER_FILE_FIELDS
- DRIVER_FILE_FIELDS;
-#endif
+ void *driver_priv;
} drm_file_t;
/** Wait queue */
@@ -519,7 +517,7 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *);
- void (*open_helper)(struct drm_device *, drm_file_t *);
+ int (*open_helper)(struct drm_device *, drm_file_t *);
void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *);
diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c
index d21f7898e..4589231fe 100644
--- a/linux-core/drm_fops.c
+++ b/linux-core/drm_fops.c
@@ -54,6 +54,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
{
int minor = iminor(inode);
drm_file_t *priv;
+ int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL;
@@ -74,7 +75,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->lock_count = 0;
if (dev->fn_tbl.open_helper)
- dev->fn_tbl.open_helper(dev, priv);
+ {
+ ret=dev->fn_tbl.open_helper(dev, priv);
+ if (ret < 0)
+ goto out_free;
+ }
down(&dev->struct_sem);
if (!dev->file_last) {
@@ -106,6 +111,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif
return 0;
+ out_free:
+ DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
+ return ret;
}
/** No-op. */
diff --git a/linux/drmP.h b/linux/drmP.h
index b6b275b99..1be3375cd 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -371,9 +371,7 @@ typedef struct drm_file {
struct drm_device *dev;
int remove_auth_on_close;
unsigned long lock_count;
-#ifdef DRIVER_FILE_FIELDS
- DRIVER_FILE_FIELDS;
-#endif
+ void *driver_priv;
} drm_file_t;
/** Wait queue */
@@ -519,7 +517,7 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *);
int (*postsetup)(struct drm_device *);
- void (*open_helper)(struct drm_device *, drm_file_t *);
+ int (*open_helper)(struct drm_device *, drm_file_t *);
void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *);
diff --git a/linux/drm_fops.h b/linux/drm_fops.h
index d21f7898e..4589231fe 100644
--- a/linux/drm_fops.h
+++ b/linux/drm_fops.h
@@ -54,6 +54,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
{
int minor = iminor(inode);
drm_file_t *priv;
+ int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL;
@@ -74,7 +75,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->lock_count = 0;
if (dev->fn_tbl.open_helper)
- dev->fn_tbl.open_helper(dev, priv);
+ {
+ ret=dev->fn_tbl.open_helper(dev, priv);
+ if (ret < 0)
+ goto out_free;
+ }
down(&dev->struct_sem);
if (!dev->file_last) {
@@ -106,6 +111,9 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif
return 0;
+ out_free:
+ DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
+ return ret;
}
/** No-op. */
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index 283ad6d76..8c5848643 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -72,6 +72,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 mem_block {
struct mem_block *next;
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index 31215dc05..80c095847 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -43,12 +43,15 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv,
u32 *offset ) {
u32 off = *offset;
+ struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0;
- off += filp_priv->radeon_fb_delta;
+ radeon_priv = filp_priv->driver_priv;
+
+ off += radeon_priv->radeon_fb_delta;
DRM_DEBUG( "offset fixed up to 0x%x\n", off );
@@ -2525,7 +2528,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv;
drm_radeon_setparam_t sp;
-
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
return DRM_ERR( EINVAL );
@@ -2538,7 +2542,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION:
- filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
+ radeon_priv = filp_priv->driver_priv;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
break;
default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param );
@@ -2571,13 +2576,23 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(dev);
}
-static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
+ radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
+
+ if (!radeon_priv)
+ return -ENOMEM;
+
+ filp_priv->driver_priv = radeon_priv;
+
if ( dev_priv )
- filp_priv->radeon_fb_delta = dev_priv->fb_location;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else
- filp_priv->radeon_fb_delta = 0;
+ radeon_priv->radeon_fb_delta = 0;
+ return 0;
}
void radeon_driver_register_fns(struct drm_device *dev)
diff --git a/shared/radeon.h b/shared/radeon.h
index 417b55b8b..43723d53e 100644
--- a/shared/radeon.h
+++ b/shared/radeon.h
@@ -109,7 +109,4 @@
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \
-#define DRIVER_FILE_FIELDS \
- int64_t radeon_fb_delta; \
-
#endif
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index 283ad6d76..8c5848643 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -72,6 +72,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 mem_block {
struct mem_block *next;
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index 31215dc05..80c095847 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -43,12 +43,15 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv,
u32 *offset ) {
u32 off = *offset;
+ struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0;
- off += filp_priv->radeon_fb_delta;
+ radeon_priv = filp_priv->driver_priv;
+
+ off += radeon_priv->radeon_fb_delta;
DRM_DEBUG( "offset fixed up to 0x%x\n", off );
@@ -2525,7 +2528,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv;
drm_radeon_setparam_t sp;
-
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
return DRM_ERR( EINVAL );
@@ -2538,7 +2542,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION:
- filp_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
+ radeon_priv = filp_priv->driver_priv;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location - sp.value;
break;
default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param );
@@ -2571,13 +2576,23 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(dev);
}
-static void radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
+static int radeon_driver_open_helper(drm_device_t *dev, drm_file_t *filp_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
+ struct drm_radeon_driver_file_fields *radeon_priv;
+
+ radeon_priv = (struct drm_radeon_driver_file_fields *)DRM(alloc)(sizeof(*radeon_priv), DRM_MEM_FILES);
+
+ if (!radeon_priv)
+ return -ENOMEM;
+
+ filp_priv->driver_priv = radeon_priv;
+
if ( dev_priv )
- filp_priv->radeon_fb_delta = dev_priv->fb_location;
+ radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else
- filp_priv->radeon_fb_delta = 0;
+ radeon_priv->radeon_fb_delta = 0;
+ return 0;
}
void radeon_driver_register_fns(struct drm_device *dev)