aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_gtt.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-05-10 09:25:09 -0400
committerDave Airlie <airlied@redhat.com>2012-05-23 05:47:10 -0400
commit1286ff7397737e407cdd8e5cd574318db177ba1f (patch)
treed83344e3beba60c8ec8bec566bd8f58a08f696ef /drivers/gpu/drm/i915/i915_gem_gtt.c
parent22b33e8ed0e38b8ddcf082e35580f2e67a3a0262 (diff)
i915: add dmabuf/prime buffer sharing support.
This adds handle->fd and fd->handle support to i915, this is to allow for offloading of rendering in one direction and outputs in the other. v2 from Daniel Vetter: - fixup conflicts with the prepare/finish gtt prep work. - implement ppgtt binding support. Note that we have squat i-g-t testcoverage for any of the lifetime and access rules dma_buf/prime support brings along. And there are quite a few intricate situations here. Also note that the integration with the existing code is a bit hackish, especially around get_gtt_pages and put_gtt_pages. It imo would be easier with the prep code from Chris Wilson's unbound series, but that is for 3.6. Also note that I didn't bother to put the new prepare/finish gtt hooks to good use by moving the dma_buf_map/unmap_attachment calls in there (like we've originally planned for). Last but not least this patch is only compile-tested, but I've changed very little compared to Dave Airlie's version. So there's a decent chance v2 on drm-next works as well as v1 on 3.4-rc. v3: Right when I've hit sent I've noticed that I've screwed up one obj->sg_list (for dmar support) and obj->sg_table (for prime support) disdinction. We should be able to merge these 2 paths, but that's material for another patch. v4: fix the error reporting bugs pointed out by ickle. v5: fix another error, and stop non-gtt mmaps on shared objects stop pread/pwrite on imported objects, add fake kmap Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_gtt.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 29d573c27b3..9fd25a43553 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -267,7 +267,13 @@ void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt,
267 BUG(); 267 BUG();
268 } 268 }
269 269
270 if (dev_priv->mm.gtt->needs_dmar) { 270 if (obj->sg_table) {
271 i915_ppgtt_insert_sg_entries(ppgtt,
272 obj->sg_table->sgl,
273 obj->sg_table->nents,
274 obj->gtt_space->start >> PAGE_SHIFT,
275 pte_flags);
276 } else if (dev_priv->mm.gtt->needs_dmar) {
271 BUG_ON(!obj->sg_list); 277 BUG_ON(!obj->sg_list);
272 278
273 i915_ppgtt_insert_sg_entries(ppgtt, 279 i915_ppgtt_insert_sg_entries(ppgtt,
@@ -371,7 +377,12 @@ void i915_gem_gtt_bind_object(struct drm_i915_gem_object *obj,
371 struct drm_i915_private *dev_priv = dev->dev_private; 377 struct drm_i915_private *dev_priv = dev->dev_private;
372 unsigned int agp_type = cache_level_to_agp_type(dev, cache_level); 378 unsigned int agp_type = cache_level_to_agp_type(dev, cache_level);
373 379
374 if (dev_priv->mm.gtt->needs_dmar) { 380 if (obj->sg_table) {
381 intel_gtt_insert_sg_entries(obj->sg_table->sgl,
382 obj->sg_table->nents,
383 obj->gtt_space->start >> PAGE_SHIFT,
384 agp_type);
385 } else if (dev_priv->mm.gtt->needs_dmar) {
375 BUG_ON(!obj->sg_list); 386 BUG_ON(!obj->sg_list);
376 387
377 intel_gtt_insert_sg_entries(obj->sg_list, 388 intel_gtt_insert_sg_entries(obj->sg_list,