From: Matthew Brost <matthew.brost@intel.com>
To: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
"Carlos Santa" <carlos.santa@intel.com>,
"Ryan Neph" <ryanneph@google.com>,
"Christian Koenig" <christian.koenig@amd.com>,
"Huang Rui" <ray.huang@amd.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
linux-kernel@vger.kernel.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH v3 25/33] drm/xe: Preallocate system BO backing outside the dma-resv lock
Date: Tue, 24 Nov 2026 12:44:08 -0800 [thread overview]
Message-ID: <awX3GIscscnIWKQ4@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <avQa-BlJQMKkoI4k@nvishwa1-desk>
On Tue, Nov 10, 2026 at 11:36:24PM -0800, Niranjana Vishwanathapura wrote:
> On Fri, Jul 10, 2026 at 07:56:11PM -0700, Matthew Brost wrote:
> > xe_gem_create_ioctl() populates a buffer object's backing store inside
> > xe_validation_guard(), i.e. under the dma-resv lock. For a system-memory
> > buffer that means the whole page allocation - potentially stalling in
> > reclaim or compaction - happens in the critical section, holding the
> > reservation and blocking anything that contends on it.
> >
> > Use the TTM full-preallocation mechanism to move that work out of the
> > lock. For a system-only, non-deferred user BO, allocate the entire tt
> > backing up front, before entering the validation guard, and hand the bag
> > down to the populate so it merely installs the pages:
> >
> > - Thread an optional struct ttm_pool_prealloc through xe_bo_create_user()
> > -> __xe_bo_create_locked() -> xe_bo_init_locked(), which stashes it in
> > ttm_operation_ctx::prealloc. All other callers pass NULL.
> >
> > - In xe_gem_create_ioctl(), for XE_BO_FLAG_SYSTEM BOs that are not VRAM,
> > stolen or deferred-backing, call ttm_pool_prealloc_fill_full() before
> > the guard and ttm_pool_prealloc_fini() after it. The bag size covers
> > both the data pages and the appended CCS backup pages, matching the tt
> > layout in xe_ttm_tt_create(), and the caching mirrors the same path.
> >
> > The fill is best-effort: on a short fill (or if it is skipped) the pool
> > allocates the remainder in-line as before, so this is purely an
> > optimisation with no behavioural change to the created BO. fini() only
> > releases the unconsumed tail, so it is safe on every success, error and
> > OOM-retry path (consumed pages are owned by the tt).
> >
> > The fill requests reclaim backoff for higher-order chunks
> > (@beneficial_reclaim_backoff): Xe runs a background defragmenter that
> > upgrades suboptimal pages to beneficial order in place, so there is no
> > need to stall this user context reclaiming/compacting for contiguity.
> >
> > To size the preallocation before the xe_bo exists, factor the CCS-pages
> > decision in xe_bo_needs_ccs_pages() into a parameterised helper,
> > __xe_bo_needs_ccs_pages(), and query it directly from the ioctl.
> >
> > Cc: Carlos Santa <carlos.santa@intel.com>
> > Cc: Ryan Neph <ryanneph@google.com>
> > Cc: Christian Koenig <christian.koenig@amd.com>
> > Cc: Huang Rui <ray.huang@amd.com>
> > Cc: Matthew Auld <matthew.auld@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Cc: Maxime Ripard <mripard@kernel.org>
> > Cc: Thomas Zimmermann <tzimmermann@suse.de>
> > Cc: David Airlie <airlied@gmail.com>
> > Cc: Simona Vetter <simona@ffwll.ch>
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Assisted-by: GitHub_Copilot:claude-opus-4.8
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> >
> > ---
> >
> > v3:
> > - Preallocate only when the backing fits the available TT space
> > (Sashiko)
> > ---
> > drivers/gpu/drm/xe/tests/xe_bo.c | 8 +-
> > drivers/gpu/drm/xe/tests/xe_dma_buf.c | 2 +-
> > drivers/gpu/drm/xe/tests/xe_migrate.c | 6 +-
> > drivers/gpu/drm/xe/xe_bo.c | 139 +++++++++++++++++++++-----
> > drivers/gpu/drm/xe/xe_bo.h | 8 +-
> > drivers/gpu/drm/xe/xe_dma_buf.c | 2 +-
> > 6 files changed, 128 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> > index 49c95ed67d7e..78781317b420 100644
> > --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> > +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> > @@ -141,7 +141,7 @@ static void ccs_test_run_tile(struct xe_device *xe, struct xe_tile *tile,
> > kunit_info(test, "Testing system memory\n");
> >
> > bo = xe_bo_create_user(xe, NULL, SZ_1M, DRM_XE_GEM_CPU_CACHING_WC,
> > - bo_flags, exec);
> > + bo_flags, NULL, exec);
> > if (IS_ERR(bo)) {
> > KUNIT_FAIL(test, "Failed to create bo.\n");
> > return;
> > @@ -220,7 +220,7 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
> > xe_vm_lock(vm, false);
> > bo = xe_bo_create_user(xe, vm, 0x10000,
> > DRM_XE_GEM_CPU_CACHING_WC,
> > - bo_flags, exec);
> > + bo_flags, NULL, exec);
> > xe_vm_unlock(vm);
> > if (IS_ERR(bo)) {
> > KUNIT_FAIL(test, "bo create err=%pe\n", bo);
> > @@ -229,7 +229,7 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
> >
> > external = xe_bo_create_user(xe, NULL, 0x10000,
> > DRM_XE_GEM_CPU_CACHING_WC,
> > - bo_flags, NULL);
> > + bo_flags, NULL, NULL);
> > if (IS_ERR(external)) {
> > KUNIT_FAIL(test, "external bo create err=%pe\n", external);
> > goto cleanup_bo;
> > @@ -494,7 +494,7 @@ static int shrink_test_run_device(struct xe_device *xe)
> > /* We can create bos using WC caching here. But it is slower. */
> > bo = xe_bo_create_user(xe, NULL, XE_BO_SHRINK_SIZE,
> > DRM_XE_GEM_CPU_CACHING_WB,
> > - XE_BO_FLAG_SYSTEM, NULL);
> > + XE_BO_FLAG_SYSTEM, NULL, NULL);
> > if (IS_ERR(bo)) {
> > if (bo != ERR_PTR(-ENOMEM) && bo != ERR_PTR(-ENOSPC) &&
> > bo != ERR_PTR(-EINTR) && bo != ERR_PTR(-ERESTARTSYS))
> > diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> > index 0be8440b3976..e4fdc247c0c7 100644
> > --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> > +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> > @@ -127,7 +127,7 @@ static void xe_test_dmabuf_import_same_driver(struct xe_device *xe)
> >
> > kunit_info(test, "running %s\n", __func__);
> > bo = xe_bo_create_user(xe, NULL, size, DRM_XE_GEM_CPU_CACHING_WC,
> > - params->mem_mask, NULL);
> > + params->mem_mask, NULL, NULL);
> > if (IS_ERR(bo)) {
> > KUNIT_FAIL(test, "xe_bo_create() failed with err=%ld\n",
> > PTR_ERR(bo));
> > diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
> > index 3c1be809be82..41de648b2c86 100644
> > --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
> > +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
> > @@ -647,7 +647,7 @@ static void validate_ccs_test_run_tile(struct xe_device *xe, struct xe_tile *til
> > DRM_XE_GEM_CPU_CACHING_WC,
> > XE_BO_FLAG_SYSTEM |
> > XE_BO_FLAG_NEEDS_CPU_ACCESS |
> > - XE_BO_FLAG_PINNED, NULL);
> > + XE_BO_FLAG_PINNED, NULL, NULL);
> >
> > if (IS_ERR(sys_bo)) {
> > KUNIT_FAIL(test, "xe_bo_create() failed with err=%ld\n",
> > @@ -673,7 +673,7 @@ static void validate_ccs_test_run_tile(struct xe_device *xe, struct xe_tile *til
> > ccs_bo = xe_bo_create_user(xe, NULL, SZ_4M,
> > DRM_XE_GEM_CPU_CACHING_WC,
> > bo_flags | XE_BO_FLAG_NEEDS_CPU_ACCESS |
> > - XE_BO_FLAG_PINNED, NULL);
> > + XE_BO_FLAG_PINNED, NULL, NULL);
> >
> > if (IS_ERR(ccs_bo)) {
> > KUNIT_FAIL(test, "xe_bo_create() failed with err=%ld\n",
> > @@ -698,7 +698,7 @@ static void validate_ccs_test_run_tile(struct xe_device *xe, struct xe_tile *til
> > vram_bo = xe_bo_create_user(xe, NULL, SZ_4M,
> > DRM_XE_GEM_CPU_CACHING_WC,
> > bo_flags | XE_BO_FLAG_NEEDS_CPU_ACCESS |
> > - XE_BO_FLAG_PINNED, NULL);
> > + XE_BO_FLAG_PINNED, NULL, NULL);
> > if (IS_ERR(vram_bo)) {
> > KUNIT_FAIL(test, "xe_bo_create() failed with err=%ld\n",
> > PTR_ERR(vram_bo));
> > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> > index 25e5b72f870c..a646a72122d4 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.c
> > +++ b/drivers/gpu/drm/xe/xe_bo.c
> > @@ -1948,7 +1948,7 @@ int xe_bo_notifier_prepare_pinned(struct xe_bo *bo)
> > backup = xe_bo_init_locked(xe, NULL, NULL, bo->ttm.base.resv, NULL, xe_bo_size(bo),
> > DRM_XE_GEM_CPU_CACHING_WB, ttm_bo_type_kernel,
> > XE_BO_FLAG_SYSTEM | XE_BO_FLAG_NEEDS_CPU_ACCESS |
> > - XE_BO_FLAG_PINNED, &exec);
> > + XE_BO_FLAG_PINNED, NULL, &exec);
> > if (IS_ERR(backup)) {
> > drm_exec_retry_on_contention(&exec);
> > ret = PTR_ERR(backup);
> > @@ -2089,7 +2089,7 @@ int xe_bo_evict_pinned(struct xe_bo *bo)
> > xe_bo_size(bo),
> > DRM_XE_GEM_CPU_CACHING_WB, ttm_bo_type_kernel,
> > XE_BO_FLAG_SYSTEM | XE_BO_FLAG_NEEDS_CPU_ACCESS |
> > - XE_BO_FLAG_PINNED, &exec);
> > + XE_BO_FLAG_PINNED, NULL, &exec);
> > if (IS_ERR(backup)) {
> > drm_exec_retry_on_contention(&exec);
> > ret = PTR_ERR(backup);
> > @@ -2884,6 +2884,8 @@ void xe_bo_free(struct xe_bo *bo)
> > * @cpu_caching: The cpu caching used for system memory backing store.
> > * @type: The TTM buffer object type.
> > * @flags: XE_BO_FLAG_ flags.
> > + * @prealloc: Optional pages preallocated outside the dma-resv lock to back the
> > + * bo (see ttm_operation_ctx::prealloc), or NULL.
> > * @exec: The drm_exec transaction to use for exhaustive eviction.
> > *
> > * Initialize or create an xe buffer object. On failure, any allocated buffer
> > @@ -2895,12 +2897,14 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, struct xe_bo *bo,
> > struct xe_tile *tile, struct dma_resv *resv,
> > struct ttm_lru_bulk_move *bulk, size_t size,
> > u16 cpu_caching, enum ttm_bo_type type,
> > - u32 flags, struct drm_exec *exec)
> > + u32 flags, struct ttm_pool_prealloc *prealloc,
> > + struct drm_exec *exec)
> > {
> > struct ttm_operation_ctx ctx = {
> > .interruptible = true,
> > .no_wait_gpu = false,
> > .gfp_retry_mayfail = true,
> > + .prealloc = prealloc,
> > };
> > struct ttm_placement *placement;
> > uint32_t alignment;
> > @@ -3077,7 +3081,8 @@ __xe_bo_create_locked(struct xe_device *xe,
> > struct xe_tile *tile, struct xe_vm *vm,
> > size_t size, u64 start, u64 end,
> > u16 cpu_caching, enum ttm_bo_type type, u32 flags,
> > - u64 alignment, struct drm_exec *exec)
> > + u64 alignment, struct ttm_pool_prealloc *prealloc,
> > + struct drm_exec *exec)
> > {
> > struct xe_bo *bo = NULL;
> > int err;
> > @@ -3102,7 +3107,7 @@ __xe_bo_create_locked(struct xe_device *xe,
> > vm && !xe_vm_in_fault_mode(vm) &&
> > flags & XE_BO_FLAG_USER ?
> > &vm->lru_bulk_move : NULL, size,
> > - cpu_caching, type, flags, exec);
> > + cpu_caching, type, flags, prealloc, exec);
> > if (IS_ERR(bo))
> > return bo;
> >
> > @@ -3177,7 +3182,7 @@ struct xe_bo *xe_bo_create_locked(struct xe_device *xe, struct xe_tile *tile,
> > struct drm_exec *exec)
> > {
> > return __xe_bo_create_locked(xe, tile, vm, size, 0, ~0ULL, 0, type,
> > - flags, 0, exec);
> > + flags, 0, NULL, exec);
> > }
> >
> > static struct xe_bo *xe_bo_create_novm(struct xe_device *xe, struct xe_tile *tile,
> > @@ -3193,7 +3198,7 @@ static struct xe_bo *xe_bo_create_novm(struct xe_device *xe, struct xe_tile *til
> > xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {.interruptible = intr},
> > ret) {
> > bo = __xe_bo_create_locked(xe, tile, NULL, size, 0, ~0ULL,
> > - cpu_caching, type, flags, alignment, &exec);
> > + cpu_caching, type, flags, alignment, NULL, &exec);
> > drm_exec_retry_on_contention(&exec);
> > if (IS_ERR(bo)) {
> > ret = PTR_ERR(bo);
> > @@ -3213,6 +3218,9 @@ static struct xe_bo *xe_bo_create_novm(struct xe_device *xe, struct xe_tile *til
> > * @size: The storage size to use for the bo.
> > * @cpu_caching: The caching mode to be used for system backing store.
> > * @flags: XE_BO_FLAG_ flags.
> > + * @prealloc: Optional pages preallocated outside the dma-resv lock to back the
> > + * bo (see ttm_operation_ctx::prealloc), or NULL. Only consumed on the locked
> > + * (@vm or @exec) path.
> > * @exec: The drm_exec transaction to use for exhaustive eviction, or NULL
> > * if such a transaction should be initiated by the call.
> > *
> > @@ -3223,7 +3231,8 @@ static struct xe_bo *xe_bo_create_novm(struct xe_device *xe, struct xe_tile *til
> > struct xe_bo *xe_bo_create_user(struct xe_device *xe,
> > struct xe_vm *vm, size_t size,
> > u16 cpu_caching,
> > - u32 flags, struct drm_exec *exec)
> > + u32 flags, struct ttm_pool_prealloc *prealloc,
> > + struct drm_exec *exec)
> > {
> > struct xe_bo *bo;
> >
> > @@ -3233,7 +3242,7 @@ struct xe_bo *xe_bo_create_user(struct xe_device *xe,
> > xe_assert(xe, exec);
> > bo = __xe_bo_create_locked(xe, NULL, vm, size, 0, ~0ULL,
> > cpu_caching, ttm_bo_type_device,
> > - flags, 0, exec);
> > + flags, 0, prealloc, exec);
> > if (!IS_ERR(bo))
> > xe_bo_unlock_vm_held(bo);
> > } else {
> > @@ -3272,7 +3281,7 @@ struct xe_bo *xe_bo_create_pin_range_novm(struct xe_device *xe, struct xe_tile *
> >
> > xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
> > bo = __xe_bo_create_locked(xe, tile, NULL, size, start, end,
> > - 0, type, flags, 0, &exec);
> > + 0, type, flags, 0, NULL, &exec);
> > if (IS_ERR(bo)) {
> > drm_exec_retry_on_contention(&exec);
> > err = PTR_ERR(bo);
> > @@ -3311,7 +3320,7 @@ static struct xe_bo *xe_bo_create_pin_map_at_aligned(struct xe_device *xe,
> >
> > bo = __xe_bo_create_locked(xe, tile, vm, size, start, end, 0, type,
> > flags | XE_BO_FLAG_NEEDS_CPU_ACCESS | XE_BO_FLAG_PINNED,
> > - alignment, exec);
> > + alignment, NULL, exec);
> > if (IS_ERR(bo))
> > return bo;
> >
> > @@ -3926,6 +3935,10 @@ static int gem_create_user_extensions(struct xe_device *xe, struct xe_bo *bo,
> > return 0;
> > }
> >
> > +static bool __xe_bo_needs_ccs_pages(struct xe_device *xe,
> > + enum ttm_bo_type type, u32 flags,
> > + u16 cpu_caching);
> > +
> > int xe_gem_create_ioctl(struct drm_device *dev, void *data,
> > struct drm_file *file)
> > {
> > @@ -3936,6 +3949,8 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
> > struct drm_exec exec;
> > struct xe_vm *vm = NULL;
> > struct xe_bo *bo;
> > + struct ttm_pool_prealloc prealloc = {};
> > + bool have_prealloc = false;
> > unsigned int bo_flags;
> > u32 handle;
> > int err;
> > @@ -4018,6 +4033,64 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
> > return -ENOENT;
> > }
> >
> > + /*
> > + * For system-only BOs, preallocate the whole backing outside the
> > + * dma-resv lock so the populate under the validation guard does not
> > + * stall in reclaim/compaction. The caching mirrors the system-BO path
> > + * in xe_ttm_tt_create(); the pool falls back to in-line allocation for
> > + * any shortfall, so a failed fill is harmless.
> > + */
> > + if ((bo_flags & XE_BO_FLAG_SYSTEM) &&
> > + !(bo_flags & (XE_BO_FLAG_DEFER_BACKING | XE_BO_FLAG_VRAM_MASK |
> > + XE_BO_FLAG_STOLEN))) {
> > + struct ttm_resource_manager *tt_man =
> > + ttm_manager_type(&xe->ttm, XE_PL_TT);
> > + enum ttm_caching caching = ttm_cached;
> > + unsigned long num_pages = args->size >> PAGE_SHIFT;
> > +
> > + if (!IS_DGFX(xe) &&
> > + args->cpu_caching == DRM_XE_GEM_CPU_CACHING_WC)
> > + caching = ttm_write_combined;
> > +
> > + /*
> > + * Cover the CCS backup pages appended to the tt (see
> > + * xe_ttm_tt_create()) so the whole tt is preallocated.
> > + */
> > + if (__xe_bo_needs_ccs_pages(xe, ttm_bo_type_device, bo_flags,
> > + args->cpu_caching))
> > + num_pages += DIV_ROUND_UP(xe_device_ccs_bytes(xe,
> > + args->size),
> > + PAGE_SIZE);
> > +
> > + /*
> > + * Only prealloc when the backing fits the currently-available
> > + * TT space (manager size minus current usage). This skips the
> > + * up-front reclaim/compaction both for over-large,
> > + * user-controlled sizes and when TT is already near full; the
> > + * populate under the validation guard handles those cases.
> > + */
> > + if (tt_man) {
> > + u64 used = ttm_resource_manager_usage(tt_man);
> > + u64 shift_size = tt_man->size << PAGE_SHIFT;
> > + u64 avail = shift_size > used ? shift_size - used : 0;
> > +
> > + if ((u64)num_pages << PAGE_SHIFT <= avail) {
> > + /*
> > + * Back off aggressive reclaim/compaction for
> > + * higher-order chunks here: Xe runs a background
> > + * defragmenter that upgrades suboptimal pages to
> > + * beneficial order in place later, so there is no
> > + * need to stall this user context reclaiming for
> > + * contiguity.
> > + */
> > + ttm_pool_prealloc_fill_full(&xe->ttm.pool,
> > + caching, &prealloc,
> > + num_pages, true);
> > + have_prealloc = true;
> > + }
> > + }
> > + }
> > +
>
> May be extract this new code block into a separte static function?
>
Let me see what that will look like.
Matt
> Niranjana
>
> > err = 0;
> > xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {.interruptible = true},
> > err) {
> > @@ -4028,7 +4101,8 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
> > break;
> > }
> > bo = xe_bo_create_user(xe, vm, args->size, args->cpu_caching,
> > - bo_flags, &exec);
> > + bo_flags, have_prealloc ? &prealloc : NULL,
> > + &exec);
> > drm_exec_retry_on_contention(&exec);
> > if (IS_ERR(bo)) {
> > err = PTR_ERR(bo);
> > @@ -4036,6 +4110,8 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
> > break;
> > }
> > }
> > + if (have_prealloc)
> > + ttm_pool_prealloc_fini(&xe->ttm.pool, &prealloc);
> > if (err)
> > goto out_vm;
> >
> > @@ -4331,21 +4407,19 @@ int xe_bo_evict(struct xe_bo *bo, struct drm_exec *exec)
> > return 0;
> > }
> >
> > -/**
> > - * xe_bo_needs_ccs_pages - Whether a bo needs to back up CCS pages when
> > - * placed in system memory.
> > - * @bo: The xe_bo
> > - *
> > - * Return: true if extra pages need to be allocated, false otherwise.
> > +/*
> > + * Whether a bo with the given attributes needs to back up CCS pages when placed
> > + * in system memory. Split out so callers can query before the xe_bo exists (see
> > + * xe_gem_create_ioctl() preallocation).
> > */
> > -bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
> > +static bool __xe_bo_needs_ccs_pages(struct xe_device *xe,
> > + enum ttm_bo_type type, u32 flags,
> > + u16 cpu_caching)
> > {
> > - struct xe_device *xe = xe_bo_device(bo);
> > -
> > if (GRAPHICS_VER(xe) >= 20 && IS_DGFX(xe))
> > return false;
> >
> > - if (!xe_device_has_flat_ccs(xe) || bo->ttm.type != ttm_bo_type_device)
> > + if (!xe_device_has_flat_ccs(xe) || type != ttm_bo_type_device)
> > return false;
> >
> > /* On discrete GPUs, if the GPU can access this buffer from
> > @@ -4353,24 +4427,37 @@ bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
> > * can't be used since there's no CCS storage associated with
> > * non-VRAM addresses.
> > */
> > - if (IS_DGFX(xe) && (bo->flags & XE_BO_FLAG_SYSTEM))
> > + if (IS_DGFX(xe) && (flags & XE_BO_FLAG_SYSTEM))
> > return false;
> >
> > /* Check if userspace explicitly requested no compression */
> > - if (bo->flags & XE_BO_FLAG_NO_COMPRESSION)
> > + if (flags & XE_BO_FLAG_NO_COMPRESSION)
> > return false;
> >
> > /*
> > * For WB (Write-Back) CPU caching mode, check if the device
> > * supports WB compression with coherency.
> > */
> > - if (bo->cpu_caching == DRM_XE_GEM_CPU_CACHING_WB &&
> > + if (cpu_caching == DRM_XE_GEM_CPU_CACHING_WB &&
> > xe->pat.idx[XE_CACHE_WB_COMPRESSION] == XE_PAT_INVALID_IDX)
> > return false;
> >
> > return true;
> > }
> >
> > +/**
> > + * xe_bo_needs_ccs_pages - Whether a bo needs to back up CCS pages when
> > + * placed in system memory.
> > + * @bo: The xe_bo
> > + *
> > + * Return: true if extra pages need to be allocated, false otherwise.
> > + */
> > +bool xe_bo_needs_ccs_pages(struct xe_bo *bo)
> > +{
> > + return __xe_bo_needs_ccs_pages(xe_bo_device(bo), bo->ttm.type,
> > + bo->flags, bo->cpu_caching);
> > +}
> > +
> > /**
> > * __xe_bo_release_dummy() - Dummy kref release function
> > * @kref: The embedded struct kref.
> > @@ -4477,7 +4564,7 @@ int xe_bo_dumb_create(struct drm_file *file_priv,
> > DRM_XE_GEM_CPU_CACHING_WC,
> > XE_BO_FLAG_VRAM_IF_DGFX(xe_device_get_root_tile(xe)) |
> > XE_BO_FLAG_FORCE_WC |
> > - XE_BO_FLAG_NEEDS_CPU_ACCESS, NULL);
> > + XE_BO_FLAG_NEEDS_CPU_ACCESS, NULL, NULL);
> > if (IS_ERR(bo))
> > return PTR_ERR(bo);
> >
> > diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> > index 38d50f8122cb..18fcccd082b7 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.h
> > +++ b/drivers/gpu/drm/xe/xe_bo.h
> > @@ -111,6 +111,7 @@ enum xe_madv_purgeable_state {
> >
> > struct sg_table;
> > struct ttm_tt;
> > +struct ttm_pool_prealloc;
> >
> > struct xe_bo *xe_bo_alloc(void);
> > void xe_bo_free(struct xe_bo *bo);
> > @@ -119,13 +120,16 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, struct xe_bo *bo,
> > struct xe_tile *tile, struct dma_resv *resv,
> > struct ttm_lru_bulk_move *bulk, size_t size,
> > u16 cpu_caching, enum ttm_bo_type type,
> > - u32 flags, struct drm_exec *exec);
> > + u32 flags, struct ttm_pool_prealloc *prealloc,
> > + struct drm_exec *exec);
> > struct xe_bo *xe_bo_create_locked(struct xe_device *xe, struct xe_tile *tile,
> > struct xe_vm *vm, size_t size,
> > enum ttm_bo_type type, u32 flags,
> > struct drm_exec *exec);
> > struct xe_bo *xe_bo_create_user(struct xe_device *xe, struct xe_vm *vm, size_t size,
> > - u16 cpu_caching, u32 flags, struct drm_exec *exec);
> > + u16 cpu_caching, u32 flags,
> > + struct ttm_pool_prealloc *prealloc,
> > + struct drm_exec *exec);
> > struct xe_bo *xe_bo_create_pin_map(struct xe_device *xe, struct xe_tile *tile,
> > struct xe_vm *vm, size_t size,
> > enum ttm_bo_type type, u32 flags,
> > diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> > index 8a920e58245c..ec947d86a1ce 100644
> > --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> > +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> > @@ -302,7 +302,7 @@ xe_dma_buf_create_obj(struct drm_device *dev, struct dma_buf *dma_buf)
> >
> > bo = xe_bo_init_locked(xe, NULL, NULL, resv, NULL, dma_buf->size,
> > 0, /* Will require 1way or 2way for vm_bind */
> > - ttm_bo_type_sg, XE_BO_FLAG_SYSTEM, &exec);
> > + ttm_bo_type_sg, XE_BO_FLAG_SYSTEM, NULL, &exec);
> > drm_exec_retry_on_contention(&exec);
> > if (IS_ERR(bo)) {
> > ret = PTR_ERR(bo);
> > --
> > 2.34.1
> >
next prev parent reply other threads:[~2026-11-24 20:44 UTC|newest]
Thread overview: 129+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 2:55 [PATCH v3 00/33] drm/ttm, drm/xe: Minimize dma-resv hold times and defragment sub-optimally backed BOs Matthew Brost
2026-07-11 2:55 ` [PATCH v3 01/33] drm/ttm/pool: Allow backing off reclaim at the beneficial order Matthew Brost
2026-11-06 2:55 ` Niranjana Vishwanathapura
2026-11-19 18:47 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 02/33] drm/ttm/pool: Add ttm_pool_page_order_nodma() helper Matthew Brost
2026-11-05 11:27 ` Matthew Auld
2026-11-06 2:30 ` Niranjana Vishwanathapura
2026-07-11 2:55 ` [PATCH v3 03/33] drm/ttm: Record sub-optimal page order allocations in ttm_tt Matthew Brost
2026-11-06 2:34 ` Niranjana Vishwanathapura
2026-11-06 20:06 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 04/33] drm/ttm: Introduce ttm_pool_alloc_iter for __ttm_pool_alloc() Matthew Brost
2026-11-06 2:39 ` Niranjana Vishwanathapura
2026-11-19 19:14 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 05/33] drm/ttm: Support defragmentation moves Matthew Brost
2026-11-06 2:51 ` Niranjana Vishwanathapura
2026-11-19 20:15 ` Matthew Brost
2026-11-21 6:30 ` Niranjana Vishwanathapura
2026-11-23 17:53 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 06/33] drm/ttm: Add fault injection for beneficial-order allocation failures Matthew Brost
2026-11-06 2:54 ` Niranjana Vishwanathapura
2026-11-19 20:49 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 07/33] drm/ttm: Harvest beneficial-order pages on defragmentation moves Matthew Brost
2026-11-10 2:37 ` Niranjana Vishwanathapura
2026-11-19 21:39 ` Matthew Brost
2026-11-20 23:09 ` Niranjana Vishwanathapura
2026-11-23 18:08 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 08/33] drm/ttm: Bound page (re)allocation per defragmentation move Matthew Brost
2026-11-10 2:44 ` Niranjana Vishwanathapura
2026-11-20 2:14 ` Matthew Brost
2026-11-20 20:37 ` Niranjana Vishwanathapura
2026-11-23 21:24 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 09/33] drm/ttm: Preallocate beneficial-order defrag pages outside the lock Matthew Brost
2026-11-11 0:29 ` Niranjana Vishwanathapura
2026-11-23 21:36 ` Matthew Brost
2026-11-11 7:49 ` Niranjana Vishwanathapura
2026-11-20 2:29 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 10/33] drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() Matthew Brost
2026-11-11 7:31 ` Niranjana Vishwanathapura
2026-11-20 5:48 ` Matthew Brost
2026-11-21 5:03 ` Niranjana Vishwanathapura
2026-07-11 2:55 ` [PATCH v3 11/33] drm/gpusvm: Add a DMA-mapping accounting callback Matthew Brost
2026-11-04 3:41 ` Niranjana Vishwanathapura
2026-11-04 4:10 ` Niranjana Vishwanathapura
2026-11-04 21:35 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 12/33] drm/xe: Add debugfs stats for DMA-mapped pages per order Matthew Brost
2026-11-04 4:06 ` Niranjana Vishwanathapura
2026-11-04 21:45 ` Matthew Brost
2026-07-11 2:55 ` [PATCH v3 13/33] drm/xe: Flush L2 asynchronously in xe_bo_trigger_rebind() Matthew Brost
2026-11-03 12:02 ` Matthew Auld
2026-11-03 20:10 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 14/33] drm/xe: Destroy page tables after unlinking all VMAs on VM close Matthew Brost
2026-11-04 1:44 ` Niranjana Vishwanathapura
2026-11-04 1:46 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 15/33] drm/xe: Track BOs backed at a sub-optimal page order Matthew Brost
2026-11-07 4:49 ` Niranjana Vishwanathapura
2026-11-20 6:02 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 16/33] drm/xe: Back off beneficial-order reclaim under defrag pressure Matthew Brost
2026-11-07 5:02 ` Niranjana Vishwanathapura
2026-11-20 6:08 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 17/33] drm/xe: Add xe_migrate_copy_defrag() for on-GPU defrag copies Matthew Brost
2026-11-03 12:58 ` Matthew Auld
2026-11-03 20:08 ` Matthew Brost
2026-11-04 12:37 ` Matthew Auld
2026-11-20 6:11 ` Matthew Brost
2026-11-07 5:07 ` Niranjana Vishwanathapura
2026-07-11 2:56 ` [PATCH v3 18/33] drm/xe: Handle defrag moves in xe_bo_move() Matthew Brost
2026-11-07 5:12 ` Niranjana Vishwanathapura
2026-11-24 15:37 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 19/33] drm/xe: Skip self-copies for borrowed pages on defrag moves Matthew Brost
2026-11-10 4:25 ` Niranjana Vishwanathapura
2026-11-24 16:08 ` Matthew Brost
2026-11-24 16:21 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 20/33] drm/xe: Add a page defragmentation worker Matthew Brost
2026-11-07 5:27 ` Niranjana Vishwanathapura
2026-11-24 18:54 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 21/33] drm/xe: Add defrag GT stats Matthew Brost
2026-11-09 1:10 ` Niranjana Vishwanathapura
2026-11-24 20:13 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 22/33] drm/xe: Add Kconfig.profile options for BO defrag configuration Matthew Brost
2026-11-09 1:31 ` Niranjana Vishwanathapura
2026-11-24 20:25 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 23/33] drm/xe: Defrag using out-of-lock page preallocation Matthew Brost
2026-11-11 0:39 ` Niranjana Vishwanathapura
2026-11-24 20:34 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 24/33] drm/xe: Add defrag profiling tracepoints Matthew Brost
2026-11-09 4:34 ` Niranjana Vishwanathapura
2026-11-24 20:42 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 25/33] drm/xe: Preallocate system BO backing outside the dma-resv lock Matthew Brost
2026-11-11 7:36 ` Niranjana Vishwanathapura
2026-11-24 20:44 ` Matthew Brost [this message]
2026-07-11 2:56 ` [PATCH v3 26/33] drm/xe: Add tracepoint for xe_gem_create_ioctl Matthew Brost
2026-11-11 7:37 ` Niranjana Vishwanathapura
2026-11-24 20:45 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 27/33] drm/xe: Add IOVA-based xe_res_cursor variant Matthew Brost
2026-11-04 12:23 ` Matthew Auld
2026-11-13 6:14 ` Niranjana Vishwanathapura
2026-07-11 2:56 ` [PATCH v3 28/33] drm/xe: Use IOVA-based DMA mapping for eligible tt BOs Matthew Brost
2026-11-03 19:00 ` Matthew Auld
2026-11-03 20:21 ` Matthew Brost
2026-11-04 11:39 ` Matthew Auld
2026-11-05 3:04 ` Matthew Brost
2026-11-13 6:28 ` Niranjana Vishwanathapura
2026-11-13 20:09 ` Matthew Brost
2026-11-16 4:10 ` Niranjana Vishwanathapura
2026-07-11 2:56 ` [PATCH v3 29/33] drm/xe: Add per-device dependency scheduler for IOVA defrag finalize Matthew Brost
2026-11-14 1:47 ` Niranjana Vishwanathapura
2026-11-24 20:57 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 30/33] drm/xe: Add packed copy-step IOVA mapping for defrag Matthew Brost
2026-11-14 1:52 ` Niranjana Vishwanathapura
2026-11-24 21:00 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 31/33] drm/xe: Blit src-natural to dst-packed for defrag-IOVA copies Matthew Brost
2026-11-14 1:57 ` Niranjana Vishwanathapura
2026-11-24 21:18 ` Matthew Brost
2026-11-16 0:41 ` Niranjana Vishwanathapura
2026-11-24 21:12 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 32/33] drm/xe: Finalize defrag-IOVA moves with post-copy job Matthew Brost
2026-11-14 2:02 ` Niranjana Vishwanathapura
2026-11-24 21:08 ` Matthew Brost
2026-07-11 2:56 ` [PATCH v3 33/33] drm/amdgpu: Preallocate system BO pages outside the reservation lock Matthew Brost
2026-07-11 10:46 ` Christian König
2026-07-13 20:24 ` Matthew Brost
2026-07-14 9:17 ` Christian König
2026-07-14 15:15 ` Matthew Brost
2026-07-11 3:05 ` ✗ CI.checkpatch: warning for drm/ttm, drm/xe: Minimize dma-resv hold times and defragment sub-optimally backed BOs (rev2) Patchwork
2026-07-11 3:07 ` ✓ CI.KUnit: success " Patchwork
2026-07-11 3:22 ` ✗ CI.checksparse: warning " Patchwork
2026-07-11 3:42 ` ✓ Xe.CI.BAT: success " Patchwork
2026-07-11 10:20 ` ✓ Xe.CI.FULL: " Patchwork
2026-11-16 1:01 ` [PATCH v3 00/33] drm/ttm, drm/xe: Minimize dma-resv hold times and defragment sub-optimally backed BOs Niranjana Vishwanathapura
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=awX3GIscscnIWKQ4@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=airlied@gmail.com \
--cc=carlos.santa@intel.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=mripard@kernel.org \
--cc=niranjana.vishwanathapura@intel.com \
--cc=ray.huang@amd.com \
--cc=ryanneph@google.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
/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