Commit 37553983 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'topic/drm-fixes-2015-07-16' of git://anongit.freedesktop.org/drm-intel into drm-fixes

Ok next attempt at drm-fixes pull. Big thing really is just the compat32
one for addfb2.1.

* tag 'topic/drm-fixes-2015-07-16' of git://anongit.freedesktop.org/drm-intel:
  drm: Provide compat ioctl for addfb2.1
  Documentation: drm: Fix tablulation in KMS properties table
  drm: add a check for x/y in drm_mode_setcrtc
  drm/rockchip: use drm_gem_mmap helpers
parents 90438ac8 c631d5f9
...@@ -3383,7 +3383,7 @@ void intel_crt_init(struct drm_device *dev) ...@@ -3383,7 +3383,7 @@ void intel_crt_init(struct drm_device *dev)
<td valign="top" >TBD</td> <td valign="top" >TBD</td>
</tr> </tr>
<tr> <tr>
<td rowspan="2" valign="top" >omap</td> <td valign="top" >omap</td>
<td valign="top" >Generic</td> <td valign="top" >Generic</td>
<td valign="top" >“zorder”</td> <td valign="top" >“zorder”</td>
<td valign="top" >RANGE</td> <td valign="top" >RANGE</td>
......
...@@ -2706,8 +2706,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ...@@ -2706,8 +2706,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL; return -EINVAL;
/* For some reason crtc x/y offsets are signed internally. */ /*
if (crtc_req->x > INT_MAX || crtc_req->y > INT_MAX) * Universal plane src offsets are only 16.16, prevent havoc for
* drivers using universal plane code internally.
*/
if (crtc_req->x & 0xffff0000 || crtc_req->y & 0xffff0000)
return -ERANGE; return -ERANGE;
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
......
...@@ -70,6 +70,8 @@ ...@@ -70,6 +70,8 @@
#define DRM_IOCTL_WAIT_VBLANK32 DRM_IOWR(0x3a, drm_wait_vblank32_t) #define DRM_IOCTL_WAIT_VBLANK32 DRM_IOWR(0x3a, drm_wait_vblank32_t)
#define DRM_IOCTL_MODE_ADDFB232 DRM_IOWR(0xb8, drm_mode_fb_cmd232_t)
typedef struct drm_version_32 { typedef struct drm_version_32 {
int version_major; /**< Major version */ int version_major; /**< Major version */
int version_minor; /**< Minor version */ int version_minor; /**< Minor version */
...@@ -1016,6 +1018,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, ...@@ -1016,6 +1018,63 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
return 0; return 0;
} }
typedef struct drm_mode_fb_cmd232 {
u32 fb_id;
u32 width;
u32 height;
u32 pixel_format;
u32 flags;
u32 handles[4];
u32 pitches[4];
u32 offsets[4];
u64 modifier[4];
} __attribute__((packed)) drm_mode_fb_cmd232_t;
static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
unsigned long arg)
{
struct drm_mode_fb_cmd232 __user *argp = (void __user *)arg;
struct drm_mode_fb_cmd232 req32;
struct drm_mode_fb_cmd2 __user *req64;
int i;
int err;
if (copy_from_user(&req32, argp, sizeof(req32)))
return -EFAULT;
req64 = compat_alloc_user_space(sizeof(*req64));
if (!access_ok(VERIFY_WRITE, req64, sizeof(*req64))
|| __put_user(req32.width, &req64->width)
|| __put_user(req32.height, &req64->height)
|| __put_user(req32.pixel_format, &req64->pixel_format)
|| __put_user(req32.flags, &req64->flags))
return -EFAULT;
for (i = 0; i < 4; i++) {
if (__put_user(req32.handles[i], &req64->handles[i]))
return -EFAULT;
if (__put_user(req32.pitches[i], &req64->pitches[i]))
return -EFAULT;
if (__put_user(req32.offsets[i], &req64->offsets[i]))
return -EFAULT;
if (__put_user(req32.modifier[i], &req64->modifier[i]))
return -EFAULT;
}
err = drm_ioctl(file, DRM_IOCTL_MODE_ADDFB2, (unsigned long)req64);
if (err)
return err;
if (__get_user(req32.fb_id, &req64->fb_id))
return -EFAULT;
if (copy_to_user(argp, &req32, sizeof(req32)))
return -EFAULT;
return 0;
}
static drm_ioctl_compat_t *drm_compat_ioctls[] = { static drm_ioctl_compat_t *drm_compat_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version, [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
...@@ -1048,6 +1107,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = { ...@@ -1048,6 +1107,7 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw, [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
#endif #endif
[DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
[DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
}; };
/** /**
......
...@@ -54,55 +54,56 @@ static void rockchip_gem_free_buf(struct rockchip_gem_object *rk_obj) ...@@ -54,55 +54,56 @@ static void rockchip_gem_free_buf(struct rockchip_gem_object *rk_obj)
&rk_obj->dma_attrs); &rk_obj->dma_attrs);
} }
int rockchip_gem_mmap_buf(struct drm_gem_object *obj, static int rockchip_drm_gem_object_mmap(struct drm_gem_object *obj,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
int ret;
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj); struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
struct drm_device *drm = obj->dev; struct drm_device *drm = obj->dev;
unsigned long vm_size;
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
vm_size = vma->vm_end - vma->vm_start;
if (vm_size > obj->size) /*
return -EINVAL; * dma_alloc_attrs() allocated a struct page table for rk_obj, so clear
* VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap().
*/
vma->vm_flags &= ~VM_PFNMAP;
return dma_mmap_attrs(drm->dev, vma, rk_obj->kvaddr, rk_obj->dma_addr, ret = dma_mmap_attrs(drm->dev, vma, rk_obj->kvaddr, rk_obj->dma_addr,
obj->size, &rk_obj->dma_attrs); obj->size, &rk_obj->dma_attrs);
if (ret)
drm_gem_vm_close(vma);
return ret;
} }
/* drm driver mmap file operations */ int rockchip_gem_mmap_buf(struct drm_gem_object *obj,
int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
struct drm_file *priv = filp->private_data; struct drm_device *drm = obj->dev;
struct drm_device *dev = priv->minor->dev;
struct drm_gem_object *obj;
struct drm_vma_offset_node *node;
int ret; int ret;
if (drm_device_is_unplugged(dev)) mutex_lock(&drm->struct_mutex);
return -ENODEV; ret = drm_gem_mmap_obj(obj, obj->size, vma);
mutex_unlock(&drm->struct_mutex);
if (ret)
return ret;
mutex_lock(&dev->struct_mutex); return rockchip_drm_gem_object_mmap(obj, vma);
}
node = drm_vma_offset_exact_lookup(dev->vma_offset_manager, /* drm driver mmap file operations */
vma->vm_pgoff, int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma)
vma_pages(vma)); {
if (!node) { struct drm_gem_object *obj;
mutex_unlock(&dev->struct_mutex); int ret;
DRM_ERROR("failed to find vma node.\n");
return -EINVAL;
} else if (!drm_vma_node_is_allowed(node, filp)) {
mutex_unlock(&dev->struct_mutex);
return -EACCES;
}
obj = container_of(node, struct drm_gem_object, vma_node); ret = drm_gem_mmap(filp, vma);
ret = rockchip_gem_mmap_buf(obj, vma); if (ret)
return ret;
mutex_unlock(&dev->struct_mutex); obj = vma->vm_private_data;
return ret; return rockchip_drm_gem_object_mmap(obj, vma);
} }
struct rockchip_gem_object * struct rockchip_gem_object *
......
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