aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2012-08-15 20:15:34 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-08-17 04:10:06 -0400
commitec6f1bb90c9865d4a5af01b1c643bcf020d88706 (patch)
treeba4ab858b7d96ea08ace354332eb9c79bafb65eb /drivers
parent0826874a664f9e9479d50fda23923b87a50cda0d (diff)
drm/i915: implement dma buf begin_cpu_access (v2)
In order for udl vmap to work properly, we need to push the object into the CPU domain before we start copying the data to the USB device. This along with the udl change avoids userspace explicit mapping to be used. v2: add a flag for userspace to query to know if Intel kernel driver can deal with the vmap flushing properly. In theory udl would need a flag also, but I intend to push the patches very close to each other and other drivers should do the right thing from the start. I've added a test to my intel-gpu-tools prime branch, however testing this is a bit messy since the only way to get udl to vmap is to rendering something. I've tested this with real code as well to make sure it works. Signed-off-by: Dave Airlie <airlied@redhat.com> [danvet: resolved conflict, which required reallocating the PARAM number to 21.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_dmabuf.c17
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2285ae31717a..2cba7b4a04ed 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1012,6 +1012,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
1012 case I915_PARAM_HAS_SEMAPHORES: 1012 case I915_PARAM_HAS_SEMAPHORES:
1013 value = i915_semaphore_is_enabled(dev); 1013 value = i915_semaphore_is_enabled(dev);
1014 break; 1014 break;
1015 case I915_PARAM_HAS_PRIME_VMAP_FLUSH:
1016 value = 1;
1017 break;
1015 default: 1018 default:
1016 DRM_DEBUG_DRIVER("Unknown parameter %d\n", 1019 DRM_DEBUG_DRIVER("Unknown parameter %d\n",
1017 param->param); 1020 param->param);
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
index aa308e1337db..ceaad5af01a4 100644
--- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
@@ -151,6 +151,22 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *
151 return -EINVAL; 151 return -EINVAL;
152} 152}
153 153
154static int i915_gem_begin_cpu_access(struct dma_buf *dma_buf, size_t start, size_t length, enum dma_data_direction direction)
155{
156 struct drm_i915_gem_object *obj = dma_buf->priv;
157 struct drm_device *dev = obj->base.dev;
158 int ret;
159 bool write = (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE);
160
161 ret = i915_mutex_lock_interruptible(dev);
162 if (ret)
163 return ret;
164
165 ret = i915_gem_object_set_to_cpu_domain(obj, write);
166 mutex_unlock(&dev->struct_mutex);
167 return ret;
168}
169
154static const struct dma_buf_ops i915_dmabuf_ops = { 170static const struct dma_buf_ops i915_dmabuf_ops = {
155 .map_dma_buf = i915_gem_map_dma_buf, 171 .map_dma_buf = i915_gem_map_dma_buf,
156 .unmap_dma_buf = i915_gem_unmap_dma_buf, 172 .unmap_dma_buf = i915_gem_unmap_dma_buf,
@@ -162,6 +178,7 @@ static const struct dma_buf_ops i915_dmabuf_ops = {
162 .mmap = i915_gem_dmabuf_mmap, 178 .mmap = i915_gem_dmabuf_mmap,
163 .vmap = i915_gem_dmabuf_vmap, 179 .vmap = i915_gem_dmabuf_vmap,
164 .vunmap = i915_gem_dmabuf_vunmap, 180 .vunmap = i915_gem_dmabuf_vunmap,
181 .begin_cpu_access = i915_gem_begin_cpu_access,
165}; 182};
166 183
167struct dma_buf *i915_gem_prime_export(struct drm_device *dev, 184struct dma_buf *i915_gem_prime_export(struct drm_device *dev,