Message ID | 20210628144626.76126-6-thomas.hellstrom@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/gem: Introduce a migrate interface | expand |
>-----Original Message----- >From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of >Thomas Hellström >Sent: Monday, June 28, 2021 10:46 AM >To: intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org >Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>; Auld, Matthew ><matthew.auld@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.hellstrom@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. Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Mike >diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c >b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c >index 24735d6c12a2..b6278dba98d0 100644 >--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c >+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c >@@ -94,7 +94,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; > >-- >2.31.1
On 6/28/21 9:45 PM, Ruhl, Michael J wrote: >> -----Original Message----- >> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of >> Thomas Hellström >> Sent: Monday, June 28, 2021 10:46 AM >> To: intel-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org >> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>; Auld, Matthew >> <matthew.auld@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.hellstrom@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.ruhl@intel.com> > > Mike Thanks for the reviews! Thomas
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; diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c index 24735d6c12a2..b6278dba98d0 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c @@ -94,7 +94,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;
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.hellstrom@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(-)