Commit e4279631 authored by Dave Airlie's avatar Dave Airlie

remove DRIVER_FILE_FIELDS, replace with a private driver structure

allocated in open helper and freed in free_filp_priv.
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent dffec26d
...@@ -411,9 +411,7 @@ typedef struct drm_file { ...@@ -411,9 +411,7 @@ typedef struct drm_file {
struct drm_device *dev; struct drm_device *dev;
int remove_auth_on_close; int remove_auth_on_close;
unsigned long lock_count; unsigned long lock_count;
#ifdef DRIVER_FILE_FIELDS void *driver_priv;
DRIVER_FILE_FIELDS;
#endif
} drm_file_t; } drm_file_t;
/** Wait queue */ /** Wait queue */
...@@ -559,7 +557,8 @@ struct drm_driver_fn { ...@@ -559,7 +557,8 @@ struct drm_driver_fn {
int (*postcleanup)(struct drm_device *); int (*postcleanup)(struct drm_device *);
int (*presetup)(struct drm_device *); int (*presetup)(struct drm_device *);
int (*postsetup)(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 (*free_filp_priv)(struct drm_device *, drm_file_t *);
void (*release)(struct drm_device *, struct file *filp); void (*release)(struct drm_device *, struct file *filp);
void (*dma_ready)(struct drm_device *); void (*dma_ready)(struct drm_device *);
int (*dma_quiescent)(struct drm_device *); int (*dma_quiescent)(struct drm_device *);
......
...@@ -865,6 +865,9 @@ int DRM(release)( struct inode *inode, struct file *filp ) ...@@ -865,6 +865,9 @@ int DRM(release)( struct inode *inode, struct file *filp )
} }
up( &dev->struct_sem ); up( &dev->struct_sem );
if (dev->fn_tbl.free_filp_priv)
dev->fn_tbl.free_filp_priv(dev, priv);
DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES ); DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
/* ======================================================== /* ========================================================
......
...@@ -53,6 +53,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -53,6 +53,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
{ {
int minor = iminor(inode); int minor = iminor(inode);
drm_file_t *priv; drm_file_t *priv;
int ret;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
if (!DRM(cpu_valid)()) return -EINVAL; if (!DRM(cpu_valid)()) return -EINVAL;
...@@ -72,8 +73,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -72,8 +73,11 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
priv->authenticated = capable(CAP_SYS_ADMIN); priv->authenticated = capable(CAP_SYS_ADMIN);
priv->lock_count = 0; priv->lock_count = 0;
if (dev->fn_tbl.open_helper) 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); down(&dev->struct_sem);
if (!dev->file_last) { if (!dev->file_last) {
...@@ -105,6 +109,10 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev) ...@@ -105,6 +109,10 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
#endif #endif
return 0; return 0;
out_free:
DRM(free)(priv, sizeof(*priv), DRM_MEM_FILES);
filp->private_data=NULL;
return ret;
} }
/** No-op. */ /** No-op. */
......
...@@ -109,9 +109,6 @@ ...@@ -109,9 +109,6 @@
[DRM_IOCTL_NR(DRM_IOCTL_RADEON_IRQ_WAIT)] = { radeon_irq_wait, 1, 0 }, \ [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 }, \ [DRM_IOCTL_NR(DRM_IOCTL_RADEON_SETPARAM)] = { radeon_cp_setparam, 1, 0 }, \
#define DRIVER_FILE_FIELDS \
int64_t radeon_fb_delta; \
/* DMA customization: /* DMA customization:
*/ */
#define __HAVE_DMA 1 #define __HAVE_DMA 1
......
...@@ -60,6 +60,9 @@ typedef struct drm_radeon_depth_clear_t { ...@@ -60,6 +60,9 @@ typedef struct drm_radeon_depth_clear_t {
u32 se_cntl; u32 se_cntl;
} drm_radeon_depth_clear_t; } drm_radeon_depth_clear_t;
struct drm_radeon_driver_file_fields {
int64_t radeon_fb_delta;
};
struct mem_block { struct mem_block {
struct mem_block *next; struct mem_block *next;
......
...@@ -43,12 +43,14 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p ...@@ -43,12 +43,14 @@ static __inline__ int radeon_check_and_fixup_offset( drm_radeon_private_t *dev_p
drm_file_t *filp_priv, drm_file_t *filp_priv,
u32 *offset ) { u32 *offset ) {
u32 off = *offset; u32 off = *offset;
struct drm_radeon_driver_file_fields *radeon_priv;
if ( off >= dev_priv->fb_location && if ( off >= dev_priv->fb_location &&
off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) ) off < ( dev_priv->gart_vm_start + dev_priv->gart_size ) )
return 0; 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 ); DRM_DEBUG( "offset fixed up to 0x%x\n", off );
...@@ -2525,6 +2527,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { ...@@ -2525,6 +2527,7 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
drm_radeon_private_t *dev_priv = dev->dev_private; drm_radeon_private_t *dev_priv = dev->dev_private;
drm_file_t *filp_priv; drm_file_t *filp_priv;
drm_radeon_setparam_t sp; drm_radeon_setparam_t sp;
struct drm_radeon_driver_file_fields *radeon_priv;
if ( !dev_priv ) { if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ ); DRM_ERROR( "%s called with no initialization\n", __FUNCTION__ );
...@@ -2538,7 +2541,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) { ...@@ -2538,7 +2541,8 @@ int radeon_cp_setparam( DRM_IOCTL_ARGS ) {
switch( sp.param ) { switch( sp.param ) {
case RADEON_SETPARAM_FB_LOCATION: 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; break;
default: default:
DRM_DEBUG( "Invalid parameter %d\n", sp.param ); DRM_DEBUG( "Invalid parameter %d\n", sp.param );
...@@ -2571,13 +2575,30 @@ static void radeon_driver_pretakedown(drm_device_t *dev) ...@@ -2571,13 +2575,30 @@ static void radeon_driver_pretakedown(drm_device_t *dev)
radeon_do_release(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; 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 ) if ( dev_priv )
filp_priv->radeon_fb_delta = dev_priv->fb_location; radeon_priv->radeon_fb_delta = dev_priv->fb_location;
else else
filp_priv->radeon_fb_delta = 0; radeon_priv->radeon_fb_delta = 0;
return 0;
}
static void radeon_driver_free_filp_priv(drm_device_t *dev, drm_file_t *filp_priv)
{
struct drm_radeon_driver_file_fields *radeon_priv = filp_priv->driver_priv;
DRM(free)(radeon_priv, sizeof(*radeon_priv), DRM_MEM_FILES);
} }
void radeon_driver_register_fns(struct drm_device *dev) void radeon_driver_register_fns(struct drm_device *dev)
...@@ -2587,4 +2608,5 @@ void radeon_driver_register_fns(struct drm_device *dev) ...@@ -2587,4 +2608,5 @@ void radeon_driver_register_fns(struct drm_device *dev)
dev->fn_tbl.prerelease = radeon_driver_prerelease; dev->fn_tbl.prerelease = radeon_driver_prerelease;
dev->fn_tbl.pretakedown = radeon_driver_pretakedown; dev->fn_tbl.pretakedown = radeon_driver_pretakedown;
dev->fn_tbl.open_helper = radeon_driver_open_helper; dev->fn_tbl.open_helper = radeon_driver_open_helper;
dev->fn_tbl.free_filp_priv = radeon_driver_free_filp_priv;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment