On 6/28/21 9:45 PM, Ruhl, Michael J wrote:
-----Original Message-----
From: dri-devel <dri-devel-boun...@lists.freedesktop.org> On Behalf Of
Thomas Hellström
Sent: Monday, June 28, 2021 10:46 AM
To: intel-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org
Cc: Thomas Hellström <thomas.hellst...@linux.intel.com>; Auld, Matthew
<matthew.a...@intel.com>
Subject: [PATCH v3 5/5] drm/i915/gem: Migrate to system at dma-buf map
time

Until we support p2p dma or as a complement to that, migrate data
to system memory at dma-buf map time if possible.

v2:
- Rebase on dynamic exporter. Update the igt_dmabuf_import_same_driver
  selftest to migrate if we are LMEM capable.

Signed-off-by: Thomas Hellström <thomas.hellst...@linux.intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c           | 7 ++++++-
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 4 +++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 1d1eeb167d28..5207aa3af009 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -29,7 +29,12 @@ static struct sg_table *i915_gem_map_dma_buf(struct
dma_buf_attachment *attachme

        assert_object_held(obj);

-       ret = i915_gem_object_pin_pages(obj);
+       if (!i915_gem_object_can_migrate(obj, INTEL_REGION_SMEM))
+               return ERR_PTR(-EOPNOTSUPP);
+
+       ret = i915_gem_object_migrate(obj, NULL, INTEL_REGION_SMEM);
+       if (!ret)
+               ret = i915_gem_object_pin_pages(obj);
        if (ret)
                goto err;
With the caveats of the previous patches this looks good.
Yes, this sort of sucks, but knowing that we have a correct implementation in the works...

Reviewed-by: Michael J. Ruhl <michael.j.r...@intel.com>

Mike

Thanks for the reviews!

Thomas


Reply via email to