Skip to content

Commit

Permalink
drm/i915/gem: Migrate to system at dma-buf attach time
Browse files Browse the repository at this point in the history
Until we support p2p dma or as a complement to that, migrate data
to system memory at dma-buf attach time if possible.

v2:
- Rebase on dynamic exporter. Update the igt_dmabuf_import_same_driver
  selftest to migrate if we are LMEM capable.
v3:
- Migrate also in the pin() callback.
v4:
- Migrate in attach

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
  • Loading branch information
Thomas Hellström authored and intel-lab-lkp committed Jul 1, 2021
1 parent 4ffd40e commit d1c1ca8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
Expand Up @@ -170,9 +170,19 @@ static int i915_gem_dmabuf_attach(struct dma_buf *dmabuf,
struct dma_buf_attachment *attach)
{
struct drm_i915_gem_object *obj = dma_buf_to_obj(dmabuf);
int ret;

assert_object_held(obj);
return i915_gem_object_pin_pages(obj);

if (!i915_gem_object_can_migrate(obj, INTEL_REGION_SMEM))
return -EOPNOTSUPP;
ret = i915_gem_object_migrate(obj, NULL, INTEL_REGION_SMEM);
if (!ret)
ret = i915_gem_object_wait_migration(obj, 0);
if (!ret)
ret = i915_gem_object_pin_pages(obj);

return ret;
}

static void i915_gem_dmabuf_detach(struct dma_buf *dmabuf,
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
Expand Up @@ -106,7 +106,9 @@ static int igt_dmabuf_import_same_driver(void *arg)
int err;

force_different_devices = true;
obj = i915_gem_object_create_shmem(i915, PAGE_SIZE);
obj = i915_gem_object_create_lmem(i915, PAGE_SIZE, 0);
if (IS_ERR(obj))
obj = i915_gem_object_create_shmem(i915, PAGE_SIZE);
if (IS_ERR(obj))
goto out_ret;

Expand Down

0 comments on commit d1c1ca8

Please sign in to comment.