All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Subject: [PATCH 1/3] drm/xe: don't allocate fake mmap offsets for imported dma-bufs
Date: Sat,  7 Nov 2026 17:26:50 +0000	[thread overview]
Message-ID: <20261107-oom-fun-v1-1-be9eb05b82ed@intel.com> (raw)
In-Reply-To: <20261107-oom-fun-v1-0-be9eb05b82ed@intel.com>

ttm_bo_init_reserved() allocates a fake mmap offset (drm_vma_offset
node) for ttm_bo_type_sg BOs, even though xe rejects CPU faults on
imported dma-bufs. Since the offset space is limited to 1 TiB per
device on 64-bit, heavy P2P dma-buf importing on multi-GPU systems can
exhaust it and cause imports to fail with -ENOSPC.

Remove the vma_node once an imported BO is created and reject BOs
without one in xe_gem_mmap_offset_ioctl().

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/xe/xe_bo.c      | 6 ++++++
 drivers/gpu/drm/xe/xe_dma_buf.c | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 42a6aa1a2e4a..0181f73ef66d 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -3851,6 +3851,12 @@ int xe_gem_mmap_offset_ioctl(struct drm_device *dev, void *data,
 	if (XE_IOCTL_DBG(xe, !gem_obj))
 		return -ENOENT;
 
+	/* Imported dma-bufs have no mmap offset since CPU access is rejected. */
+	if (XE_IOCTL_DBG(xe, !drm_vma_node_size(&gem_obj->vma_node))) {
+		xe_bo_put(gem_to_xe_bo(gem_obj));
+		return -EINVAL;
+	}
+
 	/* The mmap offset was set up at BO allocation time. */
 	args->offset = drm_vma_node_offset_addr(&gem_obj->vma_node);
 
diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
index 5bf13dc4b61d..17a8663a68de 100644
--- a/drivers/gpu/drm/xe/xe_dma_buf.c
+++ b/drivers/gpu/drm/xe/xe_dma_buf.c
@@ -12,6 +12,7 @@
 
 #include <drm/drm_device.h>
 #include <drm/drm_prime.h>
+#include <drm/drm_vma_manager.h>
 #include <drm/ttm/ttm_tt.h>
 
 #include "tests/xe_test.h"
@@ -353,6 +354,14 @@ xe_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)
 	}
 	drm_gem_object_put(dummy_obj);
 
+	/*
+	 * CPU faults on imported BOs are rejected, so there is no point in
+	 * consuming fake mmap offset space for them.
+	 */
+	if (!ret)
+		drm_vma_offset_remove(bo->ttm.bdev->vma_manager,
+				      &bo->ttm.base.vma_node);
+
 	return ret ? ERR_PTR(ret) : &bo->ttm.base;
 }
 

-- 
2.56.0

  reply	other threads:[~2026-11-07 17:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 17:26 [PATCH 0/3] Spurious OOM with P2P dma-buf imports on multi-GPU systems Matthew Auld
2026-11-07 17:26 ` Matthew Auld [this message]
2026-11-07 17:43   ` [PATCH 1/3] drm/xe: don't allocate fake mmap offsets for imported dma-bufs sashiko-bot
2026-11-07 17:26 ` [PATCH 2/3] drm/xe: Exclude imported dma-buf BOs from the TT budget Matthew Auld
2026-11-07 17:36   ` sashiko-bot
2026-11-07 17:26 ` [PATCH 3/3] drm/ttm, drm/xe: Drop the ttm_tt on null moves to VRAM Matthew Auld
2026-11-07 17:36 ` ✓ CI.KUnit: success for Spurious OOM with P2P dma-buf imports on multi-GPU systems Patchwork
2026-11-07 18:10 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-08  8:22 ` ✓ 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=20261107-oom-fun-v1-1-be9eb05b82ed@intel.com \
    --to=matthew.auld@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.