From 7458909beae274198ca2a29b510a808ce2feca0a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 19 Dec 2006 21:48:18 +1100 Subject: fixup i915 return values from kernel --- shared-core/i915_dma.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'shared-core/i915_dma.c') diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c index 60e3e945..3373f1b0 100644 --- a/shared-core/i915_dma.c +++ b/shared-core/i915_dma.c @@ -263,7 +263,7 @@ static int i915_dma_init(DRM_IOCTL_ARGS) retcode = i915_dma_resume(dev); break; default: - retcode = -EINVAL; + retcode = DRM_ERR(EINVAL); break; } @@ -360,10 +360,9 @@ static int i915_emit_cmds(drm_device_t * dev, int __user * buffer, int dwords) for (i = 0; i < dwords;) { int cmd, sz; - if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) { - + if (DRM_COPY_FROM_USER_UNCHECKED(&cmd, &buffer[i], sizeof(cmd))) return DRM_ERR(EINVAL); - } + if ((sz = validate_cmd(cmd)) == 0 || i + sz > dwords) return DRM_ERR(EINVAL); @@ -395,7 +394,7 @@ static int i915_emit_box(drm_device_t * dev, RING_LOCALS; if (DRM_COPY_FROM_USER_UNCHECKED(&box, &boxes[i], sizeof(box))) { - return EFAULT; + return DRM_ERR(EFAULT); } if (box.y2 <= box.y1 || box.x2 <= box.x1 || box.y2 <= 0 || box.x2 <= 0) { -- cgit v1.2.3 From f7180349fde6947e229ecde17215c2984e6e883b Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Mon, 4 Dec 2006 15:48:04 +0800 Subject: i915: ARB_Occlusion_query(MMIO ioctl) support. This adds a new ioctl for passing counter information from the chip back to applications, these counters include the data needed to perform OC. --- shared-core/i915_dma.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'shared-core/i915_dma.c') diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c index 3373f1b0..943a1772 100644 --- a/shared-core/i915_dma.c +++ b/shared-core/i915_dma.c @@ -775,6 +775,61 @@ static int i915_setparam(DRM_IOCTL_ARGS) return 0; } +drm_i915_mmio_entry_t mmio_table[] = { + [MMIO_REGS_PS_DEPTH_COUNT] = { + I915_MMIO_MAY_READ|I915_MMIO_MAY_WRITE, + 0x2350, + 8 + } +}; + +static int mmio_table_size = sizeof(mmio_table)/sizeof(drm_i915_mmio_entry_t); + +static int i915_mmio(DRM_IOCTL_ARGS) +{ + char buf[32]; + DRM_DEVICE; + drm_i915_private_t *dev_priv = dev->dev_private; + drm_i915_mmio_entry_t *e; + drm_i915_mmio_t mmio; + void __iomem *base; + if (!dev_priv) { + DRM_ERROR("%s called with no initialization\n", __FUNCTION__); + return DRM_ERR(EINVAL); + } + DRM_COPY_FROM_USER_IOCTL(mmio, (drm_i915_setparam_t __user *) data, + sizeof(mmio)); + + if (mmio.reg >= mmio_table_size) + return DRM_ERR(EINVAL); + + e = &mmio_table[mmio.reg]; + base = dev_priv->mmio_map->handle + e->offset; + + switch (mmio.read_write) { + case I915_MMIO_READ: + if (!(e->flag & I915_MMIO_MAY_READ)) + return DRM_ERR(EINVAL); + memcpy_fromio(buf, base, e->size); + if (DRM_COPY_TO_USER(mmio.data, buf, e->size)) { + DRM_ERROR("DRM_COPY_TO_USER failed\n"); + return DRM_ERR(EFAULT); + } + break; + + case I915_MMIO_WRITE: + if (!(e->flag & I915_MMIO_MAY_WRITE)) + return DRM_ERR(EINVAL); + if(DRM_COPY_FROM_USER(buf, mmio.data, e->size)) { + DRM_ERROR("DRM_COPY_TO_USER failed\n"); + return DRM_ERR(EFAULT); + } + memcpy_toio(base, buf, e->size); + break; + } + return 0; +} + int i915_driver_load(drm_device_t *dev, unsigned long flags) { /* i915 has 4 more counters */ @@ -824,6 +879,7 @@ drm_ioctl_desc_t i915_ioctls[] = { [DRM_IOCTL_NR(DRM_I915_SET_VBLANK_PIPE)] = { i915_vblank_pipe_set, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, [DRM_IOCTL_NR(DRM_I915_GET_VBLANK_PIPE)] = { i915_vblank_pipe_get, DRM_AUTH }, [DRM_IOCTL_NR(DRM_I915_VBLANK_SWAP)] = {i915_vblank_swap, DRM_AUTH}, + [DRM_IOCTL_NR(DRM_I915_MMIO)] = {i915_mmio, DRM_AUTH}, }; int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); -- cgit v1.2.3