Message ID | 1343621216-14212-1-git-send-email-airlied@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jul 30, 2012 at 02:06:54PM +1000, Dave Airlie wrote: > From: Dave Airlie <airlied@redhat.com> > > 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. > > question: what is direction here in terms of read/write to the device. > > This along with the udl change avoids userspace explicit mapping to > be used. > > Signed-off-by: Dave Airlie <airlied@redhat.com> In my understanding TO_DEVICE means cpu writes, devices reads. FROM is devices writes, cpu reads. So your patch looks correct. One thing I wonder is how much lockdep likes this one here ... But I guess it's not the first one ;-) Also, do we have a simple testcase that clears the bo with the intel igd and then tells udl the updated damage, just to exercise the code a bit? -Daniel
On Mon, Aug 6, 2012 at 6:52 AM, Daniel Vetter <daniel@ffwll.ch> wrote: > On Mon, Jul 30, 2012 at 02:06:54PM +1000, Dave Airlie wrote: >> From: Dave Airlie <airlied@redhat.com> >> >> 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. >> >> question: what is direction here in terms of read/write to the device. >> >> This along with the udl change avoids userspace explicit mapping to >> be used. >> >> Signed-off-by: Dave Airlie <airlied@redhat.com> > > In my understanding TO_DEVICE means cpu writes, devices reads. FROM is > devices writes, cpu reads. So your patch looks correct. > > One thing I wonder is how much lockdep likes this one here ... But I guess > it's not the first one ;-) Also, do we have a simple testcase that clears > the bo with the intel igd and then tells udl the updated damage, just to > exercise the code a bit? no more lockdep that previously, which is to say one big splat. I have real code to exercise the code a bit :-), but I'll try and add another test to my intel-gpu-tools branches this week, Dave.
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index cf6bdec..ee51c63 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c @@ -147,6 +147,22 @@ static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct * return -EINVAL; } +static int i915_gem_begin_cpu_access(struct dma_buf *dma_buf, size_t start, size_t length, enum dma_data_direction direction) +{ + struct drm_i915_gem_object *obj = dma_buf->priv; + struct drm_device *dev = obj->base.dev; + int ret; + bool write = (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE); + + ret = i915_mutex_lock_interruptible(dev); + if (ret) + return ret; + + ret = i915_gem_object_set_to_cpu_domain(obj, write); + mutex_unlock(&dev->struct_mutex); + return ret; +} + static const struct dma_buf_ops i915_dmabuf_ops = { .map_dma_buf = i915_gem_map_dma_buf, .unmap_dma_buf = i915_gem_unmap_dma_buf, @@ -158,6 +174,7 @@ static const struct dma_buf_ops i915_dmabuf_ops = { .mmap = i915_gem_dmabuf_mmap, .vmap = i915_gem_dmabuf_vmap, .vunmap = i915_gem_dmabuf_vunmap, + .begin_cpu_access = i915_gem_begin_cpu_access, }; struct dma_buf *i915_gem_prime_export(struct drm_device *dev,