Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45D0D606A32D for ; Thu, 3 Dec 2026 20:24:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=SUGlxiN9 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B82ED112BE1; Thu, 3 Dec 2026 20:24:45 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AE70112B90; Thu, 3 Dec 2026 20:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329475; x=1827865475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CZJ6QOKv7QjMoTyte2S7sxkBVIrr1YTiR+QsMeBERhU=; b=SUGlxiN9yZNrCc6raSLqPjXTIdnep4zfy6OSCOtNyjG28gVLYN1OYVEr WVL+MP/pI7UO9d9yOJpgm/hajYrCpxkaHRUzOJiNcb/bfogIuUBVY60mq yef/KeelFPDTg+wz3B5E8kLcafx+89PeY1m5nSM0a2spMwXWpceisSpLC 6yBebTENhrA0mTJqK9T5JYmhtMpVitxftJykqK4jV5HNhIdGQDMUWIX0B JQOpff6OoLKqOgElBp0aXkvmHMIY5Gk3rpuBvTEF+w4zVW2W0m3SfhbO/ wrMv3xYF2iUevvcalmBUakPOlVBLxIWEZ70fMW1CZ4SaMzU5cGdDmzGvz g==; X-CSE-ConnectionGUID: 3qT3tPqgStiR6cquy/v/jQ== X-CSE-MsgGUID: wuqsh/PxR7OzbnuCAV97xg== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5351255" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5351255" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:24:08 -0800 X-CSE-ConnectionGUID: hwftsfBqSk6TumjurAEbBg== X-CSE-MsgGUID: E/4nKv79QtCIwLeUsslCxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="15862542" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:24:08 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Natalie Vock , Arun Pravin , Matthew Auld , Niranjana Vishwanathapura Subject: [PATCH v6 33/35] drm/xe: Grow the USM batch pool to 2M and map it via a single PDE Date: Thu, 3 Dec 2026 12:23:50 -0800 Message-Id: <20261203202352.4153159-34-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261203202352.4153159-1-matthew.brost@intel.com> References: <20261203202352.4153159-1-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The defrag copy path submits its migration batches from the USM batch pool. When the pool is small, xe_bb_new() backs up in the suballocator waiting for prior migrate batches to retire, and that stall happens while the BO reservation lock is held during the move. Traces of a 32MB defrag move showed the entire ~37ms lock hold sitting inside xe_migrate_copy_*() at xe_bb_new(), i.e. pool backpressure rather than actual copy time. Grow the USM batch pool from 512K (integrated) / 1M (DGFX) to a uniform 2M to give the migrate engine enough in-flight batch space to avoid this backpressure. On integrated (non-DGFX) the pool is mapped into the migrate VM through the shared level-0 pagetable alongside the 1M kernel batch pool. A full 2M needs 512 PTEs and no longer fits in that shared table's 2M window. Instead, map the USM pool through a dedicated level-0 pagetable (reusing an otherwise unused pt_bo page, as the vram identity map pages are only consumed on DGFX) and point a single reserved 2M PDE at it, mirroring the large_page_copy reservation. DGFX is unaffected as it reaches the pool through the vram identity map. Cc: Natalie Vock Cc: Arun Pravin Signed-off-by: Matthew Brost Reviewed-by: Matthew Auld Reviewed-by: Niranjana Vishwanathapura --- drivers/gpu/drm/xe/xe_gt.c | 4 +--- drivers/gpu/drm/xe/xe_migrate.c | 34 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c index d52a4a330661..e09de6ed2b4d 100644 --- a/drivers/gpu/drm/xe/xe_gt.c +++ b/drivers/gpu/drm/xe/xe_gt.c @@ -663,10 +663,8 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt) * USM has its only SA pool to non-block behind user operations */ if (gt_to_xe(gt)->info.has_usm) { - struct xe_device *xe = gt_to_xe(gt); - gt->usm.bb_pool = xe_sa_bo_manager_init(gt_to_tile(gt), - IS_DGFX(xe) ? SZ_1M : SZ_512K, 16); + SZ_2M, 16); if (IS_ERR(gt->usm.bb_pool)) return PTR_ERR(gt->usm.bb_pool); } diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c index d6c6ef17d4d9..fb2b94b819c8 100644 --- a/drivers/gpu/drm/xe/xe_migrate.c +++ b/drivers/gpu/drm/xe/xe_migrate.c @@ -505,22 +505,42 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m, level++; } if (xe->info.has_usm) { + u64 usm_pt_ofs; + u32 usm_pde_slot, usm_pte; + xe_tile_assert(tile, xe_bo_size(batch) == SZ_1M); batch = tile->primary_gt->usm.bb_pool->bo; - m->usm_batch_base_ofs = m->batch_base_ofs + SZ_1M; - xe_tile_assert(tile, xe_bo_size(batch) == SZ_512K); + xe_tile_assert(tile, xe_bo_size(batch) == SZ_2M); - for (i = 0; i < xe_bo_size(batch); + /* + * The usm batch pool is a full 2M and no longer fits in + * the shared level-0 pagetable alongside the kernel + * batch pool. Map it through a dedicated level-0 + * pagetable (reusing an otherwise unused pt_bo page, as + * the vram identity map pages are only consumed on + * DGFX) and point a single reserved 2M PDE at it, + * mirroring the large_page_copy reservation below. + */ + usm_pt_ofs = xe_bo_size(bo) - 2 * XE_PAGE_SIZE; + for (i = 0, usm_pte = 0; i < xe_bo_size(batch); i += vm->flags & XE_VM_FLAG_64K ? XE_64K_PAGE_SIZE : - XE_PAGE_SIZE) { + XE_PAGE_SIZE, usm_pte++) { entry = vm->pt_ops->pte_encode_bo(batch, i, pat_index, 0); - xe_map_wr(xe, &bo->vmap, map_ofs + level * 8, u64, - entry); - level++; + xe_map_wr(xe, &bo->vmap, + usm_pt_ofs + usm_pte * 8, u64, entry); } + + usm_pde_slot = NUM_PT_SLOTS - 1; + xe_tile_assert(tile, + usm_pde_slot > map_ofs / XE_PAGE_SIZE); + entry = vm->pt_ops->pde_encode_bo(bo, usm_pt_ofs); + xe_map_wr(xe, &bo->vmap, map_ofs + XE_PAGE_SIZE + + usm_pde_slot * 8, u64, entry); + m->usm_batch_base_ofs = (u64)usm_pde_slot << + xe_pt_shift(1); } } else { u64 batch_addr = xe_bo_addr(batch, 0, XE_PAGE_SIZE); -- 2.34.1