@@ -602,7 +602,9 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
if (err)
goto err_unpin;
- i915_vma_set_ggtt_write(vma);
+ if (!i915_gem_object_is_lmem(vma->obj) &&
+ i915_vma_is_map_and_fenceable(vma))
+ i915_vma_set_ggtt_write(vma);
/* NB Access through the GTT requires the device to be awake. */
return page_mask_bits(ptr);
@@ -615,8 +617,19 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
void i915_vma_flush_writes(struct i915_vma *vma)
{
+ /*
+ * i915_vma_iomap() could have mapped the underlying memory in one
+ * of the three ways, depending on which we have to choose the most
+ * appropriate flushing mechanism.
+ *
+ * If the mapping method was via the aperture the appropriate flag will
+ * be set via i915_vma_set_ggtt_write(), and if not then we know it is
+ * enough to simply flush the CPU side write-combine buffer.
+ */
if (i915_vma_unset_ggtt_write(vma))
intel_gt_flush_ggtt_writes(vma->vm->gt);
+ else
+ wmb();
}
void i915_vma_unpin_iomap(struct i915_vma *vma)