From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/xe: Copy cpu_caching when importing DMA-BUF.
Date: Fri, 21 Mar 2025 11:23:39 +0100 [thread overview]
Message-ID: <60417daf928897560acf961ad0e14b51e170e676.camel@linux.intel.com> (raw)
In-Reply-To: <20250320211519.632432-2-dev@lankhorst.se>
Hi, Maarten.
On Thu, 2025-03-20 at 22:15 +0100, Maarten Lankhorst wrote:
> When testing xe with P2PDMA DMA-BUF import,
> VM_BIND was failing because cpu_caching was not set.
>
> Set cpu_caching if available from another xe driver,
> to allow uncached VM_BIND on imported DMA-BUF.
>
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
I don't think this is correct, we shouldn't assume anything about
imported dma-bufs, really. If we do we might end up in a situation
where code works for dma-bufs imported from one device but not from
another.
I think what we can do is to relax the COH mode check. It only really
matters on IGPU. On DGPU, all accesses to system memory is coherent.
Next step would perhaps be to assume that on p2p access, a dma-buf is
coherently cleared when all KERNEL dma-fences are signaled, but that
would require a cross-driver agreement, so in essence allow non-
coherent VM_BIND to device memory. This would matter only for IGPU
mapping a device p2p.
/Thomas
> ---
> drivers/gpu/drm/xe/xe_dma_buf.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c
> b/drivers/gpu/drm/xe/xe_dma_buf.c
> index c5b95470fa324..9b1813e65e0a4 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> @@ -266,12 +266,12 @@ struct drm_gem_object
> *xe_gem_prime_import(struct drm_device *dev,
> const struct dma_buf_attach_ops *attach_ops;
> struct dma_buf_attachment *attach;
> struct drm_gem_object *obj;
> - struct xe_bo *bo;
> + struct xe_bo *bo, *foreign_bo = NULL;
>
> - if (dma_buf->ops == &xe_dmabuf_ops) {
> + if (dma_buf->ops == &xe_dmabuf_ops &&
> + !XE_TEST_ONLY(test && test->force_different_devices)) {
> obj = dma_buf->priv;
> - if (obj->dev == dev &&
> - !XE_TEST_ONLY(test && test-
> >force_different_devices)) {
> + if (obj->dev == dev) {
> /*
> * Importing dmabuf exported from out own
> gem increases
> * refcount on gem itself instead of f_count
> of dmabuf.
> @@ -279,6 +279,8 @@ struct drm_gem_object *xe_gem_prime_import(struct
> drm_device *dev,
> drm_gem_object_get(obj);
> return obj;
> }
> +
> + foreign_bo = gem_to_xe_bo(obj);
> }
>
> /*
> @@ -310,6 +312,9 @@ struct drm_gem_object *xe_gem_prime_import(struct
> drm_device *dev,
>
> get_dma_buf(dma_buf);
> obj->import_attach = attach;
> + if (foreign_bo)
> + bo->cpu_caching = foreign_bo->cpu_caching;
> +
> return obj;
>
> out_err:
next prev parent reply other threads:[~2025-03-21 10:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 21:15 [PATCH 1/2] drm/xe: Remove extra spaces in xe_vm.c Maarten Lankhorst
2025-03-20 21:15 ` [PATCH 2/2] drm/xe: Copy cpu_caching when importing DMA-BUF Maarten Lankhorst
2025-03-21 0:23 ` Matthew Brost
2025-03-21 10:23 ` Thomas Hellström [this message]
2025-03-25 8:10 ` Maarten Lankhorst
2025-03-20 21:45 ` [PATCH 1/2] drm/xe: Remove extra spaces in xe_vm.c Matthew Brost
2025-03-20 22:01 ` ✓ CI.Patch_applied: success for series starting with [1/2] " Patchwork
2025-03-20 22:01 ` ✗ CI.checkpatch: warning " Patchwork
2025-03-20 22:02 ` ✓ CI.KUnit: success " Patchwork
2025-03-20 22:19 ` ✓ CI.Build: " Patchwork
2025-03-20 22:21 ` ✓ CI.Hooks: " Patchwork
2025-03-20 22:30 ` ✓ CI.checksparse: " Patchwork
2025-03-21 5:43 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-25 8:55 ` ✓ CI.Patch_applied: success for series starting with [1/2] drm/xe: Remove extra spaces in xe_vm.c (rev2) Patchwork
2025-03-25 8:55 ` ✗ CI.checkpatch: warning " Patchwork
2025-03-25 8:56 ` ✓ CI.KUnit: success " Patchwork
2025-03-25 9:13 ` ✓ CI.Build: " Patchwork
2025-03-25 9:15 ` ✓ CI.Hooks: " Patchwork
2025-03-25 9:16 ` ✓ CI.checksparse: " Patchwork
2025-03-25 9:37 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-03-25 10:41 ` Maarten Lankhorst
2025-03-25 13:41 ` Matthew Auld
2025-03-25 19:05 ` Thomas Hellström
2025-03-26 17:51 ` Matthew Auld
2025-03-25 15:12 ` ✗ Xe.CI.Full: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60417daf928897560acf961ad0e14b51e170e676.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox