On Wed, Dec 16, 2015 at 08:25:36PM -0200, Tiago Vignatti wrote:
This function is meant to be used with dma-buf mmap, when finishing the CPU access of the mapped pointer.
+static void i915_gem_end_cpu_access(struct dma_buf *dma_buf, enum dma_data_direction direction) +{
- struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
- struct drm_device *dev = obj->base.dev;
- struct drm_i915_private *dev_priv = to_i915(dev);
- bool was_interruptible, write = (direction == DMA_BIDIRECTIONAL || direction == DMA_TO_DEVICE);
- int ret;
- mutex_lock(&dev->struct_mutex);
- was_interruptible = dev_priv->mm.interruptible;
- dev_priv->mm.interruptible = false;
- ret = i915_gem_object_set_to_gtt_domain(obj, write);
This only needs to pass .write=false. The dma-buf direction is only for the period of the user access, and we are now flushing the caches. This is equivalent to the sw-finish ioctl and ideally we just want the i915_gem_object_flush_cpu_write_domain(). -Chris