Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH v4 3/5] drm/xe/svm: Extend MAP range to reduce vma fragmentation
Date: Mon,  3 Nov 2025 11:39:55 +0530	[thread overview]
Message-ID: <20251103060957.957760-4-himal.prasad.ghimiray@intel.com> (raw)
In-Reply-To: <20251103060957.957760-1-himal.prasad.ghimiray@intel.com>

When DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR is set during VM_BIND_OP_MAP,
the mapping logic now checks adjacent cpu_addr_mirror VMAs with default
attributes and expands the mapping range accordingly. This ensures that
bo_unmap operations ideally target the same area and helps reduce
fragmentation by coalescing nearby compatible VMAs into a single mapping.

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_vm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 944eb35bb2b8..d78eb95a954f 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2231,6 +2231,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
 	struct drm_gpuva_ops *ops;
 	struct drm_gpuva_op *__op;
 	struct drm_gpuvm_bo *vm_bo;
+	u64 range_start = addr;
 	u64 range_end = addr + range;
 	int err;
 
@@ -2243,10 +2244,14 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_vma_ops *vops,
 
 	switch (operation) {
 	case DRM_XE_VM_BIND_OP_MAP:
+		if (flags & DRM_XE_VM_BIND_FLAG_CPU_ADDR_MIRROR)
+			xe_vm_find_cpu_addr_mirror_vma_range(vm, &range_start, &range_end);
+
+		fallthrough;
 	case DRM_XE_VM_BIND_OP_MAP_USERPTR: {
 		struct drm_gpuvm_map_req map_req = {
-			.map.va.addr = addr,
-			.map.va.range = range,
+			.map.va.addr = range_start,
+			.map.va.range = range_end - range_start,
 			.map.gem.obj = obj,
 			.map.gem.offset = bo_offset_or_userptr,
 		};
-- 
2.34.1


  parent reply	other threads:[~2025-11-03  5:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03  6:09 [PATCH v4 0/5] Improve VMA merging for CPU-address-mirrored mappings Himal Prasad Ghimiray
2025-11-03  5:53 ` ✓ CI.KUnit: success for Improve VMA merging for CPU-address-mirrored mappings (rev4) Patchwork
2025-11-03  6:09 ` [PATCH v4 1/5] drm/xe: Add helper to extend CPU-mirrored VMA range for merge Himal Prasad Ghimiray
2025-11-22 21:48   ` Matthew Brost
2025-11-03  6:09 ` [PATCH v4 2/5] drm/xe: Merge adjacent default-attribute VMAs during garbage collection Himal Prasad Ghimiray
2025-11-22 21:55   ` Matthew Brost
2025-11-03  6:09 ` Himal Prasad Ghimiray [this message]
2025-11-03  6:09 ` [PATCH v4 4/5] drm/xe/svm: Enable UNMAP for VMA merging operations Himal Prasad Ghimiray
2025-11-22 22:01   ` Matthew Brost
2025-11-24  6:01     ` Ghimiray, Himal Prasad
2025-11-24 16:58       ` Matthew Brost
2025-11-03  6:09 ` [PATCH v4 5/5] drm/xe/vm: Skip ufence association for CPU address mirror VMA during MAP Himal Prasad Ghimiray
2025-11-22 22:02   ` Matthew Brost
2025-11-03  7:04 ` ✓ Xe.CI.BAT: success for Improve VMA merging for CPU-address-mirrored mappings (rev4) Patchwork
2025-11-03  8:20 ` ✗ Xe.CI.Full: failure " 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=20251103060957.957760-4-himal.prasad.ghimiray@intel.com \
    --to=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    /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