From mboxrd@z Thu Jan 1 00:00:00 1970 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 2E17D606A330 for ; Fri, 4 Dec 2026 04:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=J+GUDNjd Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D200B10E35D; Fri, 4 Dec 2026 04:10:16 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A5AB10E35D for ; Fri, 4 Dec 2026 04:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796357412; x=1827893412; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=UC94OWHYhMMXho39eDLEPLhlyYUsjqdmgl4xk9V4arc=; b=J+GUDNjdftuGlQQhgipVWsNrKAIHmlUSAAOfft8V5c2yc+HlOSVO2F/N XjFIYcPxpS0X3/R4IbGHuld4HOSSUR2VTjd9s13pOzUPiTkOKzr+X6EYn C4f5d4tbcZlaPyrpQwfkEuhICRkUqj/BanrCjaHmO1OTuzbp5TTpvgw9n qoXoESrAmxaKRRcwOG5PJNmydzWfG1kNTVJelGU5A4yD3lruj8Lh7US1j igZtl05KBwIzCLEoTdNVngcUrCSYf2FQG49TdFv/6igNIbWq1VSgTH1m3 G8BGXP8Y+kQDPbc0NDvDiayv3eRUwN7an/HKFw6Tc6lBKXpCcTZR3mq9C A==; X-CSE-ConnectionGUID: WJzpxU6fSeGt5WuHYq243w== X-CSE-MsgGUID: 8jQExs5cRNOxh4bygyUD8w== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5238631" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5238631" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 20:10:11 -0800 X-CSE-ConnectionGUID: x+6GRSgyRVK6tN8UjIZUqQ== X-CSE-MsgGUID: JAI/Z/vYSMmVWfbuc6bbtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14264974" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by fmviesa007.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 20:10:10 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 20:10:09 -0800 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Thu, 3 Dec 2026 20:10:09 -0800 Received: from SN4PR0501CU005.outbound.protection.outlook.com (40.93.194.22) by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 20:10:09 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wRsSwJ0GroiPybhXb6gPDYT9Xhbn3+ohVAmHlmrBfz/0FbuH3xPkKEbTtb+HV0IMBDYwxUnlcEyyxoOAPXt68RmzwHyJ5CeypzekaT0Cvn0jPP2npPpIJZi2U6myKRR5StphMd7Jk01kCtA425fHNg2VzqqnBsIuzqFIKemHJkqkeInyvVpw4o7sechvIo2+0ofT69Gjdaa35a40y180eMoiO6JDODJTbC/oUhf8aZv7wiBSnHyQhF9tuISLkbMve2CsIk1BItMZqa4z9FU+U0nvq4RMJUArvQbBKSk/gQg4QzTYNOJhl6vteEhBNmHmAZx1LrY86lHKuVHrWdTczQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2IL8cPjo1JVnveh9G1RJCxqKWJsySQyAWE/uUCgQ8zA=; b=rMFnvs1R7+7cASWQ7vB8t8dJIsyYAEirwO7ePpTAJdbtxJCA+G5DWxL9t+ioejDjyBrZxzGvLNF7oFqfxItX5vvUCbyMDRvIN9whYdTVQApTL0QNCffc8g7j0smk3Z/F42/m9Zlj8v93PYEQdi4q9/HsU5gKhk76ltxMfcR+ZRMrDe3xxRXjbXBaGZyEE8k7pVxp/y2GT+3gNk+bWkdvo+3ML6sCCEk6HRpm2O4NIVGhcpDZoH+glRyfR5x8kQzQJhVrhAbQIScT9Lv3uJAMdiT7HivVyn1Rm70wDNHgx77BrQchtJafs79sF3wZgWw8nN3hFKis4oOc7BWbgOpv6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by CH3PR11MB7297.namprd11.prod.outlook.com (2603:10b6:610:140::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 04:10:06 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 04:10:06 +0000 Date: Thu, 3 Dec 2026 20:10:03 -0800 From: Matthew Brost To: "Summers, Stuart" CC: "intel-xe@lists.freedesktop.org" Subject: Re: [PATCH] drm/xe: Remove the 256G VRAM limit in the identity map Message-ID: References: <20261202174137.3331767-1-matthew.brost@intel.com> <7e2844dfecd6b30dfe9b80f576b1f50f58b8f208.camel@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: SJ0PR03CA0258.namprd03.prod.outlook.com (2603:10b6:a03:3a0::23) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|CH3PR11MB7297:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a1c0d6f-919b-4abf-2534-08df51bc7a4a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|23010399003|376014|18002099003|22082099003|10067099003|56012099006|261102123227099003|261021123027099003|261021121427099003|261022113327099003|261022105027099003|261022075727099003|261028144727099003|261026140227099003|261026121527099003|261009221227099003|261009223027099003|11063799006|4143699003; X-Microsoft-Antispam-Message-Info: gA9SDLu1d4yYROp/AY+kp3gBVpLkMk2tilXwfVn6I8zI/ZaSpJ+aFxsdgRZqi9ue8/qeBDk2fSCia4OqnjVRTT+iZaHEXm6iMzoQBdzcXeTKv/bA67TNRBLbr6OQBr2uIHv+MCBH09/eUZHZyBcpK9hJXKpVNzTkcOZH+qpeZADbCyDYKn+4bg0bE5G7Jjg1treQPJwGKzz2vh6lKiQClA4IQ2IzQ1bPi9RyVnhstN2iIfw+xQUj4KjIq26JFP/HrRtkc//th5Viuv7vxuGgD2Oo2esBsggbg4h6hhaHDy1XnmgEZViB86CCrGgCQIfvjBMkHCkZPDbrrQjSBcivtZ2+WmvgO0F3cXQCTSHmaq4rMh7AnewLzBPIRd58kd7luVwmt5TvZxL3CtcXDaq/L5+ru2QuSzKfQM3GyeVdyCavMRTWXbZXsz4If3YSqEtAaGnpUVHftk24+Mwhzt+nvWo+mihIfkcgu2isUqO7dXiN5wDuolWFuYLeYDW7gPBRMTPkT79CbJZxpg9d1zC0UXJexzZz2pAlfecYjJeTdxzr/EY21hBdGFyHvLSrSWkC6R9rjNID5hP3GHPdw0f+tm4A4/Stq5zLmkNpd8TBXMnV7FKAKrdTSy2DIEdazHvC X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(23010399003)(376014)(18002099003)(22082099003)(10067099003)(56012099006)(261102123227099003)(261021123027099003)(261021121427099003)(261022113327099003)(261022105027099003)(261022075727099003)(261028144727099003)(261026140227099003)(261026121527099003)(261009221227099003)(261009223027099003)(11063799006)(4143699003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?7QGL7lkILMuEsTPirmoLp81HO4f+m9OglFGTxzSnLAEgTGVo2dUctAqMfH?= =?iso-8859-1?Q?g59jLffBgJ7PzVlUX/txE2poTcM0EL4miyIISit7362IgWiq2tyXgb8ZRU?= =?iso-8859-1?Q?mlslPB6x8GrIXVIXVWXFhy4yIg7uNGnCPCzgJZ0a00OHnooh56Ft2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ikNShdfBSpv86Q0qC5Fm5/mChd7VLVqw5nIvesj9hIFCdBrzW7cygQ4+mShhlbBmZzSynmVOU+70pkoxEHz2KxlFdEd9IV8PdSNVzTaoHviy7qMW4EnY4erZu76zvvqOOorSS0xJ/F9kx2/vCPbthkP8KqskD7RZFGpKgQw9R3fK7h2Co26YNbjpb0oAtDk2aW0Pabpz2A069WKWyrhRwqG+VTzza0hMXI8Ylbgik7gL+qfQBLoYx+xtcWtG7uNyxRlV/UZsg== X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1c0d6f-919b-4abf-2534-08df51bc7a4a X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 04:10:06.1204 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sjlM1dXdOeL3x4BbDawOCStXI+hozo+Jt7Js/7gMtplhpSpz6/cLlior+Y4yNrn6+hSdD3g24433fBcPYr0Q1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB7297 X-OriginatorOrg: intel.com 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=-16.2 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 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 On Thu, Dec 03, 2026 at 04:28:19PM -0800, Matthew Brost wrote: > On Thu, Dec 03, 2026 at 05:21:33PM -0700, Summers, Stuart wrote: > > At a high level this looks ok to me. I have a couple comments below, > > but I don't quite have time to finish up a couple review details. I'll > > try to get here tonight, otherwise I'll have to respond in the morning > > with a full R-B, assuming the below comments are addressed. > > > > On Wed, 2026-12-02 at 09:41 -0800, Matthew Brost wrote: > > > Dynamically allocate additional migration VM level-2 pages (1 GB leaf > > > entries), allowing the identity map to support an arbitrary amount of > > > VRAM instead of being limited to 256G. > > > > > > Signed-off-by: Matthew Brost > > > --- > > >  drivers/gpu/drm/xe/xe_migrate.c | 83 ++++++++++++++++++++++++++----- > > > -- > > >  1 file changed, 65 insertions(+), 18 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/xe/xe_migrate.c > > > b/drivers/gpu/drm/xe/xe_migrate.c > > > index 23575f9dc651..45096d3db817 100644 > > > --- a/drivers/gpu/drm/xe/xe_migrate.c > > > +++ b/drivers/gpu/drm/xe/xe_migrate.c > > > @@ -265,7 +265,11 @@ struct xe_migrate { > > >  #define NUM_PT_SLOTS 48 > > >  #define LEVEL0_PAGE_TABLE_ENCODE_SIZE SZ_2M > > >  #define MAX_NUM_PTE 512 > > > -#define IDENTITY_OFFSET 256ULL > > > +/* > > > + * VRAM identity map starts at 512GiB, i.e. level-3 PDE 1. Each > > > 512GiB chunk > > > + * uses a dedicated level-2 PT, appended after NUM_PT_SLOTS in the > > > PT BO. > > > + */ > > > +#define IDENTITY_OFFSET 512ULL > > >   > > >  /* > > >   * Although MI_STORE_DATA_IMM's "length" field is 10-bits, 0x3FE is > > > the largest > > > @@ -370,9 +374,24 @@ static u64 xe_migrate_vram_ofs(struct xe_device > > > *xe, u64 addr, bool is_comp_pte) > > >         return addr + (identity_offset << xe_pt_shift(2)); > > >  } > > >   > > > +static u32 xe_migrate_identity_num_l2_pts(struct xe_device *xe) > > > +{ > > > +       u64 num_gb; > > > + > > > +       if (!IS_DGFX(xe)) > > > +               return 0; > > > + > > > +       num_gb = > > > DIV_ROUND_UP_ULL(xe_vram_region_actual_physical_size(xe->mem.vram), > > > +                                 SZ_1G); > > > > Shouldn't this be xe_vram_region_usable_size()? Particularly if we're > > adding the flat ccs size below which was taken off during the vram > > init. > > > > Yes, it should be usable. Will fix. > Actually, this is a bit of an inconsistency in the code, but this is actually correct unless we fix up the code in a few other places. Given that this works, CI passes, and Sashiko is okay with it, I'd lean toward merging this so it can make it into 7.5, and then clean up the inconsistencies in a follow-up. Matt > > > +       if (GRAPHICS_VER(xe) >= 20 && xe_device_has_flat_ccs(xe)) > > > +               num_gb *= 2; > > > + > > > +       return DIV_ROUND_UP_ULL(num_gb, MAX_NUM_PTE); > > > +} > > > + > > >  static void xe_migrate_program_identity(struct xe_device *xe, struct > > > xe_vm *vm, struct xe_bo *bo, > > > -                                       u64 map_ofs, u64 vram_offset, > > > u16 pat_index, u64 pt_2m_ofs, > > > -                                       u64 pt_4k_ofs) > > > +                                       u64 l2_pt_ofs, u64 > > > vram_offset, u16 pat_index, > > > +                                       u64 pt_2m_ofs, u64 pt_4k_ofs) > > >  { > > >         struct xe_vram_region *vram = xe->mem.vram; > > >         resource_size_t dpa_base = xe_vram_region_dpa_base(vram); > > > @@ -381,7 +400,8 @@ static void xe_migrate_program_identity(struct > > > xe_device *xe, struct xe_vm *vm, > > >         u64 vram_limit = xe_vram_region_usable_size(vram) + dpa_base; > > >         u32 level = 2; > > >   > > > -       ofs = map_ofs + XE_PAGE_SIZE * level + vram_offset * 8; > > > +       /* Identity level-2 PTs are contiguous, so this may span > > > several PTs */ > > > +       ofs = l2_pt_ofs + (vram_offset - IDENTITY_OFFSET) * 8; > > >         flags = vm->pt_ops->pte_encode_addr(xe, 0, pat_index, level, > > >                                             true, 0); > > >   > > > @@ -434,6 +454,7 @@ static int xe_migrate_pt_bo_alloc(struct xe_tile > > > *tile, struct xe_migrate *m, > > >  { > > >         struct xe_bo *bo, *batch = tile->mem.kernel_bb_pool->bo; > > >         u32 num_entries = NUM_PT_SLOTS; > > > +       u32 num_identity_pts = xe_migrate_identity_num_l2_pts(vm- > > > >xe); > > >   > > >         /* Can't bump NUM_PT_SLOTS too high */ > > >         BUILD_BUG_ON(NUM_PT_SLOTS > SZ_2M/XE_PAGE_SIZE); > > > @@ -443,8 +464,12 @@ static int xe_migrate_pt_bo_alloc(struct xe_tile > > > *tile, struct xe_migrate *m, > > >         /* Need to be sure everything fits in the first PT, or create > > > more */ > > >         xe_tile_assert(tile, m->batch_base_ofs + xe_bo_size(batch) < > > > SZ_2M); > > >   > > > +       /* Level-3 PDE 0 is used for the kernel mappings */ > > > +       xe_tile_assert(tile, num_identity_pts < MAX_NUM_PTE); > > > + > > >         bo = xe_bo_create_pin_map(vm->xe, tile, vm, > > > -                                 num_entries * XE_PAGE_SIZE, > > > +                                 num_entries * XE_PAGE_SIZE + > > > +                                 round_up((u64)num_identity_pts * > > > XE_PAGE_SIZE, SZ_64K), > > > > I know we're doing an assert of this against the MAX_NUM_PTEs above, > > but I'm a little worried about all the rounding you're doing. > > > > Also shouldn't this be ROUND_UP_ULL - oh I see this is type casting > > inside the round_up function so seems ok. > > > > ROUND_UP_ULL isn't a macro? > > https://elixir.bootlin.com/linux/v7.4-rc2/C/ident/ROUND_UP_ULL > > Matt > > > Thanks, > > Stuart > > > > >                                   ttm_bo_type_kernel, > > >                                   XE_BO_FLAG_VRAM_IF_DGFX(tile) | > > >                                   XE_BO_FLAG_PAGETABLE, exec); > > > @@ -469,9 +494,10 @@ static void xe_migrate_prepare_vm(struct xe_tile > > > *tile, struct xe_migrate *m, > > >         u32 map_ofs, level, i; > > >         struct xe_bo *bo = m->pt_bo, *batch = tile- > > > >mem.kernel_bb_pool->bo; > > >         u64 entry; > > > +       u64 pt_slots_end = NUM_PT_SLOTS * XE_PAGE_SIZE; > > >   > > >         /* PT44..PT47 reserved for 4K and 2M identity map */ > > > -       u64 l1_pt_ofs = xe_bo_size(bo) - 5 * XE_PAGE_SIZE; > > > +       u64 l1_pt_ofs = pt_slots_end - 5 * XE_PAGE_SIZE; > > >   > > >         entry = vm->pt_ops->pde_encode_bo(bo, l1_pt_ofs); > > >         xe_pt_write(xe, &xe_vm_pt_root(vm, id)->bo->vmap, 0, entry); > > > @@ -567,15 +593,37 @@ static void xe_migrate_prepare_vm(struct > > > xe_tile *tile, struct xe_migrate *m, > > >                   | XE_PTE_NULL); > > >         m->cleared_mem_ofs = (255ULL << xe_pt_shift(level)); > > >   > > > -       /* Identity map the entire vram at 256GiB offset */ > > > +       /* Identity map the entire vram at 512GiB offset */ > > >         if (IS_DGFX(xe)) { > > > -               u64 pt46_ofs = xe_bo_size(bo) - 2 * XE_PAGE_SIZE; > > > +               u64 pt44_ofs = pt_slots_end - 4 * XE_PAGE_SIZE; > > > +               u64 pt45_ofs = pt_slots_end - 3 * XE_PAGE_SIZE; > > > +               u64 pt46_ofs = pt_slots_end - 2 * XE_PAGE_SIZE; > > > +               u64 pt47_ofs = pt_slots_end - XE_PAGE_SIZE; > > > +               u32 num_identity_pts = > > > xe_migrate_identity_num_l2_pts(xe); > > >                 resource_size_t actual_phy_size = > > > xe_vram_region_actual_physical_size(xe->mem.vram); > > > +               u64 identity_pts_ofs = pt_slots_end; > > > + > > > +               xe_tile_assert(tile, num_level >= 3); > > > +               xe_tile_assert(tile, xe_bo_size(bo) >= > > > identity_pts_ofs + > > > +                              (u64)num_identity_pts * XE_PAGE_SIZE); > > > + > > > +               /* Hook identity level-2 PTs into level-3 PDEs > > > 1..num_identity_pts */ > > > +               for (i = 0; i < num_identity_pts; i++) { > > > +                       u32 idx = IDENTITY_OFFSET / MAX_NUM_PTE + i; > > > + > > > +                       entry = vm->pt_ops->pde_encode_bo(bo, > > > identity_pts_ofs + > > > +                                                         (u64)i * > > > XE_PAGE_SIZE); > > > +                       if (num_level == 3) > > > +                               xe_pt_write(xe, &xe_vm_pt_root(vm, > > > id)->bo->vmap, > > > +                                           idx, entry); > > > +                       else > > > +                               xe_map_wr(xe, &bo->vmap, map_ofs + > > > XE_PAGE_SIZE * 3 + > > > +                                         idx * 8, u64, entry); > > > +               } > > >   > > > -               u64 pt44_ofs = xe_bo_size(bo) - 4 * XE_PAGE_SIZE; > > > -               xe_migrate_program_identity(xe, vm, bo, map_ofs, > > > IDENTITY_OFFSET, > > > -                                           pat_index, pt46_ofs, > > > pt44_ofs); > > > -               xe_assert(xe, actual_phy_size <= (MAX_NUM_PTE - > > > IDENTITY_OFFSET) * SZ_1G); > > > +               xe_migrate_program_identity(xe, vm, bo, > > > identity_pts_ofs, > > > +                                           IDENTITY_OFFSET, > > > pat_index, pt46_ofs, > > > +                                           pt44_ofs); > > >   > > >                 /* > > >                  * Identity map the entire vram for compressed > > > pat_index for xe2+ > > > @@ -585,13 +633,10 @@ static void xe_migrate_prepare_vm(struct > > > xe_tile *tile, struct xe_migrate *m, > > >                         u16 comp_pat_index = xe_cache_pat_idx(xe, > > > XE_CACHE_NONE_COMPRESSION); > > >                         u64 vram_offset = IDENTITY_OFFSET + > > >                                 DIV_ROUND_UP_ULL(actual_phy_size, > > > SZ_1G); > > > -                       u64 pt47_ofs = xe_bo_size(bo) - XE_PAGE_SIZE; > > >   > > > -                       xe_assert(xe, actual_phy_size <= (MAX_NUM_PTE > > > - IDENTITY_OFFSET - > > > -                                                         > > > IDENTITY_OFFSET / 2) * SZ_1G); > > > -                       u64 pt45_ofs = xe_bo_size(bo) - 3 * > > > XE_PAGE_SIZE; > > > -                       xe_migrate_program_identity(xe, vm, bo, > > > map_ofs, vram_offset, > > > -                                                   comp_pat_index, > > > pt47_ofs, pt45_ofs); > > > +                       xe_migrate_program_identity(xe, vm, bo, > > > identity_pts_ofs, > > > +                                                   vram_offset, > > > comp_pat_index, > > > +                                                   pt47_ofs, > > > pt45_ofs); > > >                 } > > >         } > > >   > > > @@ -599,6 +644,8 @@ static void xe_migrate_prepare_vm(struct xe_tile > > > *tile, struct xe_migrate *m, > > >          * Example layout created above, with root level = 3: > > >          * [PT0...PT7]: kernel PT's for copy/clear; 64 or 4KiB PTE's > > >          * [PT41 = PDE 0] [PT44...PT47 = 4K and 2M vram identity > > > maps] > > > +        * [PT48...]: dGPU only, level-2 PTs for the 1GiB vram > > > identity maps, > > > +        *            hooked into level-3 PDE 1 onward (512GiB+ VA) > > >          * > > >          * This makes the lowest part of the VM point to the > > > pagetables. > > >          * Hence the lowest 2M in the vm should point to itself, with > > > a few writes > >