i810/i830 bug with Jon's file operations changes

main
Dave Airlie 2005-01-01 12:07:51 +00:00
parent e19fa7ada1
commit fe4ade81bb
6 changed files with 29 additions and 8 deletions

View File

@ -110,7 +110,7 @@ static int i810_freelist_put(drm_device_t * dev, drm_buf_t * buf)
return 0;
}
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev;
@ -138,24 +138,35 @@ int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
return 0;
}
static struct file_operations i810_buffer_fops = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i810_mmap_buffers,
.fasync = drm_fasync,
};
static int i810_map_buffer(drm_buf_t * buf, struct file *filp)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
drm_i810_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
int retcode = 0;
if (buf_priv->currently_mapped == I810_BUF_MAPPED)
return -EINVAL;
down_write(&current->mm->mmap_sem);
old_fops = filp->f_op;
filp->f_op = &i810_buffer_fops;
dev_priv->mmap_buffer = buf;
buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
PROT_READ | PROT_WRITE,
MAP_SHARED, buf->bus_address);
dev_priv->mmap_buffer = NULL;
filp->f_op = old_fops;
if ((unsigned long)buf_priv->virtual > -1024UL) {
/* Real error */
DRM_ERROR("mmap error\n");

View File

@ -113,7 +113,7 @@ static struct drm_driver driver = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i810_mmap_buffers,
.mmap = drm_mmap,
.poll = drm_poll,
.fasync = drm_fasync,
},

View File

@ -124,7 +124,6 @@ extern int i810_flush_ioctl(struct inode *inode, struct file *filp,
extern void i810_reclaim_buffers(drm_device_t *dev, struct file *filp);
extern int i810_getage(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
/* Obsolete:
*/

View File

@ -111,7 +111,8 @@ static int i830_freelist_put(drm_device_t * dev, drm_buf_t * buf)
return 0;
}
int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev;
@ -139,12 +140,21 @@ int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
return 0;
}
static struct file_operations i830_buffer_fops = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i830_mmap_buffers,
.fasync = drm_fasync,
};
static int i830_map_buffer(drm_buf_t * buf, struct file *filp)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->head->dev;
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
drm_i830_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
unsigned long virtual;
int retcode = 0;
@ -152,11 +162,13 @@ static int i830_map_buffer(drm_buf_t * buf, struct file *filp)
return -EINVAL;
down_write(&current->mm->mmap_sem);
old_fops = filp->f_op;
filp->f_op = &i830_buffer_fops;
dev_priv->mmap_buffer = buf;
virtual = do_mmap(filp, 0, buf->total, PROT_READ | PROT_WRITE,
MAP_SHARED, buf->bus_address);
dev_priv->mmap_buffer = NULL;
filp->f_op = old_fops;
if (IS_ERR((void *)virtual)) { /* ugh */
/* Real error */
DRM_ERROR("mmap error\n");

View File

@ -123,7 +123,7 @@ static struct drm_driver driver = {
.open = drm_open,
.release = drm_release,
.ioctl = drm_ioctl,
.mmap = i830_mmap_buffers,
.mmap = drm_mmap,
.poll = drm_poll,
.fasync = drm_fasync,
},

View File

@ -132,7 +132,6 @@ extern int i830_flush_ioctl(struct inode *inode, struct file *filp,
extern void i830_reclaim_buffers(drm_device_t *dev, struct file *filp);
extern int i830_getage(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg);
extern int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
extern int i830_copybuf(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i830_docopy(struct inode *inode, struct file *filp,