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 D374D606A322 for ; Wed, 2 Dec 2026 23:34:27 +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=QEreKk4P Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DABA112663; Wed, 2 Dec 2026 23:34:19 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F6AF112654; Wed, 2 Dec 2026 23:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796254449; x=1827790449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=riOn4p0nhpDENBi/aAFKit9GQ6GS5+tLXL4PZ1DpACw=; b=QEreKk4PZ3uGip5oqxt7+EZf5gdqxPKHRV64LB4Jzs/L5KiC+fX8nKxb 0JG1Rm07RME70PHq1day3KBwicWKq9bMCRiwSMlM1/gGl5j9lH+A8tv6v Q2DyXxzaquu35zWToPkXp4RStW8woTybGl6/4NhjkZZWfC4+7C1Z2XoUt M4UTp5CHX1ObmN+WL877pVrfltvoo1ac2tL4GpYf4ZXwn36iqkjWiFDnp mvEAaKAwZY4iGz+Bwd82GRdx0kHNgMJ2kiVWhOZ2EwHP2MVRzl77JMwea +K0rXCkTPSFbu20e4MwPbHWw/Ty6DHfllW8iemWobWyO5WmAhbnnPqyYm w==; X-CSE-ConnectionGUID: Ag/XZyewR3OsSAaik6/u+Q== X-CSE-MsgGUID: M1IlwO7GSEmF8GWv4IUpLA== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5203336" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5203336" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 15:33:32 -0800 X-CSE-ConnectionGUID: coOznSFQR/uBz4jpes639w== X-CSE-MsgGUID: +u+mt2BdQFihj9+JIjnDvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13484121" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 15:33:30 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Natalie Vock , Arun Pravin Subject: [PATCH v5 34/36] drm/xe: Grow the USM batch pool to 2M and map it via a single PDE Date: Wed, 2 Dec 2026 15:33:21 -0800 Message-Id: <20261202233323.3743190-35-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261202233323.3743190-1-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" 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 --- 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 7eacbe950ccd..7fb89bb5df75 100644 --- a/drivers/gpu/drm/xe/xe_gt.c +++ b/drivers/gpu/drm/xe/xe_gt.c @@ -660,10 +660,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 c894cd1f1305..5844d085d418 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