summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2013-03-22 06:19:57 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2013-03-22 06:19:57 +0000
commit9ec566114b6c430a27c47054b4f0632cc0528459 (patch)
tree1878cb1f838f47411b1020bfd22cad5a5b77b145
parentf8bc2d0f0e284be1e51ed5e5ecec7964a356de74 (diff)
implement DRM_IOCTL_I915_GEM_SW_FINISH
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.c4
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.h3
-rw-r--r--sys/dev/pci/drm/i915/i915_gem.c34
3 files changed, 37 insertions, 4 deletions
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c
index 2c2aeac8404..307ea603ebe 100644
--- a/sys/dev/pci/drm/i915/i915_drv.c
+++ b/sys/dev/pci/drm/i915/i915_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.c,v 1.4 2013/03/20 12:37:41 jsg Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.5 2013/03/22 06:19:56 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -1329,6 +1329,8 @@ inteldrm_doioctl(struct drm_device *dev, u_long cmd, caddr_t data,
return (intel_get_pipe_from_crtc_id(dev, data, file_priv));
case DRM_IOCTL_I915_GEM_MADVISE:
return (i915_gem_madvise_ioctl(dev, data, file_priv));
+ case DRM_IOCTL_I915_GEM_SW_FINISH:
+ return (i915_gem_sw_finish_ioctl(dev, data, file_priv));
default:
break;
}
diff --git a/sys/dev/pci/drm/i915/i915_drv.h b/sys/dev/pci/drm/i915/i915_drv.h
index 85a193d2997..67700df75b1 100644
--- a/sys/dev/pci/drm/i915/i915_drv.h
+++ b/sys/dev/pci/drm/i915/i915_drv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.h,v 1.3 2013/03/21 08:27:32 jsg Exp $ */
+/* $OpenBSD: i915_drv.h,v 1.4 2013/03/22 06:19:56 jsg Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
/*
@@ -1040,6 +1040,7 @@ int i915_gem_get_tiling(struct drm_device *, void *, struct drm_file *);
int i915_gem_gtt_map_ioctl(struct drm_device *, void *, struct drm_file *);
int i915_gem_mmap_gtt_ioctl(struct drm_device *, void *, struct drm_file *);
int i915_gem_madvise_ioctl(struct drm_device *, void *, struct drm_file *);
+int i915_gem_sw_finish_ioctl(struct drm_device *, void *, struct drm_file *);
/* GEM memory manager functions */
int i915_gem_init_object(struct drm_obj *);
diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c
index 279d19246b8..588c78dd5d3 100644
--- a/sys/dev/pci/drm/i915/i915_gem.c
+++ b/sys/dev/pci/drm/i915/i915_gem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem.c,v 1.2 2013/03/21 21:49:07 kettenis Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.3 2013/03/22 06:19:56 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -644,7 +644,37 @@ unlock:
return ret;
}
-// i915_gem_sw_finish_ioctl
+/**
+ * Called when user space has done writes to this buffer
+ */
+int
+i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file)
+{
+ struct drm_i915_gem_sw_finish *args = data;
+ struct drm_i915_gem_object *obj;
+ int ret = 0;
+
+ ret = i915_mutex_lock_interruptible(dev);
+ if (ret)
+ return ret;
+
+ obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
+ if (&obj->base == NULL) {
+ ret = ENOENT;
+ goto unlock;
+ }
+
+ /* Pinned buffers may be scanout, so flush the cache */
+ if (obj->pin_count)
+ i915_gem_object_flush_cpu_write_domain(obj);
+
+ drm_gem_object_unreference(&obj->base);
+unlock:
+ DRM_UNLOCK();
+ return ret;
+}
+
// i915_gem_mmap_ioctl
int