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 2764C606A322 for ; Thu, 3 Dec 2026 20:31: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=AQJN/ZaG Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC6BB10EB41; Thu, 3 Dec 2026 20:31:45 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BDEF10EB4D for ; Thu, 3 Dec 2026 20:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329899; x=1827865899; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=kcM7zMYzW6+xLMZJk7dNmtrllzrK9rX+Uld3VIBOR8I=; b=AQJN/ZaGIuO4vE8ynCsz3h2Eh3jYAKQJtOZfT1cBP1I6Be9c1XQGhlDc 8gGo11d5KFPx5fPpnb7DBg5FEm5A70fWfFyNEZgtgIUbcNmaFPfVDHLyN iqdX4JSONL96X0mhi/KMl0OmS5cnH4Rrdl5ogybvwz0s15s3tIE9X7BxV Cvrmbch4gLDyvYQeP+DLoVs7IRTUCdxZwKl31g2AyGKoTvRTYRQi9Z2t7 F9QNRyBdB3ZPyQut2Mc/Gsx1oNtcQC35JQk7qe5Qo435vqxMRHCFlejYV 5iitrD0k2CkWBRZqfZLBTKhjGgzG4m49VCDMf3z+76MQsSW7/RHx4/ZM6 Q==; X-CSE-ConnectionGUID: E8pCmvl2T168DuptsCC8BA== X-CSE-MsgGUID: EHfF5OYNR4q3PPhbrt41aw== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5209598" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5209598" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:31:39 -0800 X-CSE-ConnectionGUID: Z/Lr6UFVRGCxPPZY7goHZQ== X-CSE-MsgGUID: YX8Ku/VnSP+udvJ+4yCxIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14474433" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by fmviesa010.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:31:39 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX901.amr.corp.intel.com (10.22.229.23) 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 12:31:38 -0800 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) 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 12:31:38 -0800 Received: from BN8PR05CU002.outbound.protection.outlook.com (52.101.57.50) by edgegateway.intel.com (134.134.137.111) 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 12:31:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oZE+JWcXmSCa8XF0iMmB+CvFUpWsqaq+dVvbPsvfcAsd25SSf7KiNo44ykL+FUp3eWwisNg3HWlrmxE2+FW8Ryi+Ag2tgRtofrgB+CzKty8LfyTQfelWHoXXtvANwr6O/DnBByCyM3oex4d/9taqEF8CmV9qnQCt09B6o7kuvdHxm8c3ObgLA8236DrKpQc+yVn7nVueIk72b1camumt2BB+lodefd1VW4L1vSJjDQWzJnmPpPZxQCVq84tMPeh7pEuAA71aqcQgONs990wRj3eWgLI3oBXmq5UonRCNB2nJpFLH5BPPZEztmG1QFVb7v+CSNs9+9SIwbsMkmcodKQ== 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=dQYPS9H0/8EBg/CsvXxRI88nYrkcsnakTkvVrRQhv2Y=; b=u5J04Tnp2C7c9a0HU09phIgZm/tF1IJx5Zvn2N47GPCpoJ+MHP4LyFhBwyXxYbEOa9SDTDq4mnJJPeedYSz4gA9JXYCsVslawvb+I0ytgcHuG4WMB3nWN9nwElt91Y483GnmzDRToO23SsZtvevHo3dGpD4RcmytrVSN0dZ1zd0HX9AP9pjwe44p0gcUnHG2gYhPjKs5VvE+8wX1sxuzNJFtHMHDmUyT3JNmjV1eCijb1yFzULqWfKkDwNp9oyrHfEwYlHaDS/85/RuMxzPVZSwE9bFEmZsrk/xgW/KyHpB/Nz4/3n9tPjN+4lrqYwFJ/V6fQyjiPMETizPY4rd+1w== 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 DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) by DM4PR11MB6191.namprd11.prod.outlook.com (2603:10b6:8:ac::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 20:31:28 +0000 Received: from DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899]) by DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899%3]) with mapi id 15.21.0688.010; Thu, 3 Dec 2026 20:31:28 +0000 Date: Thu, 3 Dec 2026 15:31:25 -0500 From: Rodrigo Vivi To: =?iso-8859-1?Q?Pi=F3rkowski=2C?= Piotr CC: , Varun Gupta , Matt Atwood , Satyanarayana K V P , Tangudu Tilak Tirumalesh , Tomasz Lis Subject: Re: [PATCH v2 5/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV VF Message-ID: References: <20261203181408.362175-1-piotr.piorkowski@intel.com> <20261203181408.362175-6-piotr.piorkowski@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261203181408.362175-6-piotr.piorkowski@intel.com> X-ClientProxiedBy: PH8PR22CA0008.namprd22.prod.outlook.com (2603:10b6:510:2d1::20) To DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR11MB5990:EE_|DM4PR11MB6191:EE_ X-MS-Office365-Filtering-Correlation-Id: b798f047-511b-4cc9-21e8-08df517c68b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|23010399003|366016|4143699003|11063799006|261009223027099003|22082099003|18002099003|260925021311599003|260925022911599003|260925021911599003|56012099006|10067099003|261022075727099003|261028144727099003|261022105027099003|261021123027099003|261102123227099003|261026140227099003|261021121427099003|261026121527099003; X-Microsoft-Antispam-Message-Info: qPYUXxaJtvAcXCni7YuIP47IUukXg4m4F9J9O98MwU0H6t39KU+j4OGu3N11EVqb9tU9FNhEkQ5VLzX5Vbo+QSshfDz346w5TOgi11P/fB5U9INicUUX3fIxBNCHvIQsAwDg3vZ4/nA/1YydEHotmvzFQWIFlj6M/qVtNUwJC6V2nE/XG54aNWurr8L+bazTRfpEHHWahq2emj8PrbOCSH4EWO5JI3d7R45Fv72X9e6hsO+3HpBZJqGawlCVLDTCi2qUBclGJmF+uR5utJAMiJmr11bEBYhbDb1hdUcDbsRVws26DDmhkDc4elQAsvDEKubqGmzQ7TzVfHI+3NpRLvSuhmytHRyPhxjbFLpV7uMqxt1yiYQAuXqVoUt1XA3AEAWBW4TSItNg37h/T1PuF1snGYbvkJ2P0zjO+WYkbPV6cgUj7y+JCy230Y/mGMuqbV5Ox675g9W6uWMpQFt5Da3v0YOnifjWyFpGwNmtdOnpuQB/dRqvCMmMo8rPWxN3yR9lhD6o+6l3qx7yB5IulxP/BrTIOvMkHkvZEGCM22IwmpKXawAurCWWbjg38wsc+u+6CJ/IMV/9AMikbsSXDGi22PSeTjrpEily95QEEF1lbMzDwx04+cg4yE/GVB8iZ8hlbCHpMJFVQM4tcmscppvLKhkJRL9Tqr2SVFgXQV0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR11MB5990.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(23010399003)(366016)(4143699003)(11063799006)(261009223027099003)(22082099003)(18002099003)(260925021311599003)(260925022911599003)(260925021911599003)(56012099006)(10067099003)(261022075727099003)(261028144727099003)(261022105027099003)(261021123027099003)(261102123227099003)(261026140227099003)(261021121427099003)(261026121527099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?/lJtEYq6Qc1/r+g85fwYfJYuQxmF6pc7lLqMAMYRlbFs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?Q?HO81zbDG7Q=3D=3D?= X-Exchange-RoutingPolicyChecked: Y9tdwrRMaQq/8FJa0pUz/XpP4WoJpENNhjJCpT3lvKqttLMGMepLB/CkKjSOXSBqHILjusB+GB8DIfqyyLEfGy4Op9ZWsh95zkJULKnP4WdFEOYhxqWJWt/mmDHFC2EAouiLvQXM0cM48YAbwrs03milQcpCOEagsMv16Q6pc8uCBeM5dwpIrD+seNM8L+sYKEa2AxQzr1P1esoLFCYL2m4PHLhQe0MJCe0LjRB2hBGit0nZE7wrR7C8eKEXV003WIBMD0/0wAc4Frl5ytuTG0FW6c2/pUcYxIueIZQAAZFc6sWv9BPFzvBq3odHBQqLamtIkC4qdOJBVNtUxi4Q5Q== X-MS-Exchange-CrossTenant-Network-Message-Id: b798f047-511b-4cc9-21e8-08df517c68b5 X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5990.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 20:31:28.6933 (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: cy3TMw0RSjG1/0vsfIbACrQ/+gPUeMtO7Zq6hSE6DfuVRyU0ZD/d0Jg0o3XDSyS4ChsNR2sl/xdWx8bUpiMKvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6191 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=-15.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 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 07:14:08PM +0100, Piórkowski, Piotr wrote: > From: Varun Gupta > > The PF assigns the low-4MB GGTT PTEs matching a VF GGTT range to the VF > together with the range, but it is the VF that has to back them with its > own dummy page for Wa_14028597154. > > When the WA is active, map the VF dummy page into the low-4MB PTEs > matching the VF GGTT range at probe, on resume and in > xe_ggtt_shift_nodes(), even if the GGTT base did not change, as these > PTEs are not migrated with the VF. Read them back and fail the probe if > they were not written. Also fail the probe if the VF GGTT range is not > 4MB aligned, starts below 4MB or is smaller than 8MB. Keep the top 4MB > chunk of the VF GGTT range out of the usable range. > > Let xe_ggtt_shift_nodes() return an error, without moving the nodes, so > the post-migration recovery fails if the low-4MB PTEs of the new GGTT > range can't be mapped. > > Cc: Matt Atwood > Cc: Rodrigo Vivi > Cc: Satyanarayana K V P > Cc: Tangudu Tilak Tirumalesh > Cc: Tomasz Lis > Signed-off-by: Varun Gupta > Signed-off-by: Piotr Piórkowski > --- > drivers/gpu/drm/xe/xe_ggtt.c | 123 ++++++++++++++++++++++++---- > drivers/gpu/drm/xe/xe_ggtt.h | 2 +- > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 12 ++- > 3 files changed, 116 insertions(+), 21 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c > index 64b81c0c48a3..4cf0ee203cd9 100644 > --- a/drivers/gpu/drm/xe/xe_ggtt.c > +++ b/drivers/gpu/drm/xe/xe_ggtt.c > @@ -497,10 +497,16 @@ static void ggtt_init_generic(struct xe_ggtt *ggtt, u64 start, u64 size) > { > struct xe_device *xe = tile_to_xe(ggtt->tile); > > - if (!IS_SRIOV_PF(xe)) > - ggtt_init_native(ggtt, start, size); > - else > + if (IS_SRIOV_PF(xe)) > ggtt_init_shared(ggtt, start, size); > + else if (IS_SRIOV_VF(xe) && ggtt_needs_low_4m_wa(ggtt)) > + /* > + * Wa_14028597154: keep the top 4MB chunk of the VF GGTT range > + * out of the usable range. > + */ > + ggtt_init_ranges(ggtt, start, size, size - SZ_4M, 0); > + else > + ggtt_init_native(ggtt, start, size); > > xe_tile_info(ggtt->tile, "GGTT usable %#llx-%#llx = %lluK\n", > ggtt->start, ggtt->start + ggtt->size - 1, > @@ -563,6 +569,20 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) > else > ggtt->pt_ops = &xelp_pt_ops; > > + /* > + * Wa_14028597154: the PF provisions VF GGTT ranges 4MB aligned, above > + * 4MB and of at least 8MB. Refuse any other range, as the WA can't be > + * applied to it. > + */ > + if (IS_SRIOV_VF(xe) && ggtt_needs_low_4m_wa(ggtt) && > + (ggtt_start < SZ_4M || ggtt_size < SZ_8M || > + !IS_ALIGNED(ggtt_start | ggtt_size, SZ_4M))) { Please see my reply on 1/5 about failing the probe here. Reviewed-by: Rodrigo Vivi > + xe_log_err_fatal(ggtt->tile, GGTT, -ERANGE, > + "GGTT %#llx-%#llx unusable for Wa_14028597154\n", > + ggtt_start, ggtt_start + ggtt_size - 1); > + return -ERANGE; > + } > + > ggtt->wq = alloc_workqueue("xe-ggtt-wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); > if (!ggtt->wq) > return -ENOMEM; > @@ -581,6 +601,14 @@ ALLOW_ERROR_INJECTION(xe_ggtt_init_early, ERRNO); /* See xe_pci_probe() */ > static void xe_ggtt_invalidate(struct xe_ggtt *ggtt); > static void xe_ggtt_invalidate_engine(struct xe_ggtt *ggtt); > > +static u64 ggtt_get_low_4m_pte(struct xe_ggtt *ggtt, u64 addr) > +{ > + xe_tile_assert(ggtt->tile, addr >= XE_PAGE_SIZE && addr < SZ_4M); > + xe_tile_assert(ggtt->tile, !(addr & XE_PTE_MASK)); > + > + return readq(&ggtt->gsm[addr >> XE_PTE_SHIFT]); > +} > + > /* > * Return the low-4MB PTEs of the VF chunks in [start, start + size) to the PF > * dummy page. Chunks not assigned to a VF are left alone, so releasing a PF > @@ -662,8 +690,40 @@ static u64 ggtt_low_4m_hole_start(struct xe_ggtt *ggtt, u64 hole_start) > return hole_start + SZ_4M; > } > > +/* > + * Map the VF dummy page into the low-4MB PTEs matching the whole VF GGTT > + * range from @start. The VF can only modify them if the PF has assigned them > + * to it, so read them back to verify the mapping. > + */ > +static int ggtt_vf_map_low_4m_locked(struct xe_ggtt *ggtt, u64 start) > +{ > + u64 mask = XE_PAGE_ADDR_MASK(XE_PTE_SHIFT) | XE_PAGE_PRESENT; > + u64 end = start + ggtt->full_size; > + u64 va; > + > + xe_tile_assert(ggtt->tile, IS_SRIOV_VF(tile_to_xe(ggtt->tile))); > + xe_tile_assert(ggtt->tile, ggtt->low_4m_pte); > + lockdep_assert_held(&ggtt->lock); > + > + if (start < SZ_4M || !IS_ALIGNED(start | ggtt->full_size, SZ_4M)) > + return -ERANGE; > + > + for (va = start; va < end; va += SZ_4M) > + ggtt_set_low_4m_pte(ggtt, va >> 10, ggtt->low_4m_pte); > + > + for (va = start; va < end; va += SZ_4M) { > + u64 pte = ggtt_get_low_4m_pte(ggtt, va >> 10); > + > + if ((pte & mask) != (ggtt->low_4m_pte & mask)) > + return -EPERM; > + } > + > + return 0; > +} > + > static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt) > { > + struct xe_device *xe = tile_to_xe(ggtt->tile); > u64 low_start = max_t(u64, ALIGN_DOWN(ggtt->start, SZ_4M) >> 10, > XE_PAGE_SIZE); > u64 low_end = min_t(u64, > @@ -676,6 +736,14 @@ static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt) > if (!ggtt->low_4m_pte) > return; > > + /* A VF only owns the low-4MB PTEs matching its own GGTT range */ > + if (IS_SRIOV_VF(xe)) { > + if (ggtt_vf_map_low_4m_locked(ggtt, ggtt->start)) > + xe_tile_err(ggtt->tile, > + "Failed to restore low-4MB GGTT PTEs for Wa_14028597154\n"); > + return; > + } > + > for (addr = low_start; addr < low_end; addr += XE_PAGE_SIZE) { > if (test_bit(addr >> XE_PTE_SHIFT, ggtt->vf_chunks)) > continue; > @@ -694,16 +762,9 @@ static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt) > struct xe_device *xe = tile_to_xe(tile); > u16 pat_index = xe_cache_pat_idx(xe, XE_CACHE_WB); > struct xe_bo *bo; > + int err = 0; > u64 pte; > > - /* > - * TODO: SR-IOV VF support for Wa_14028597154 is deferred to a follow-up > - * (requires PF 4MB-aligned VF GGTT provisioning, low-4MB VFID PTE > - * assignment, and VF dummy-page mapping). > - */ > - if (IS_SRIOV_VF(xe)) > - return 0; > - > if (!ggtt_needs_low_4m_wa(ggtt)) > return 0; > > @@ -716,7 +777,19 @@ static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt) > > scoped_guard(mutex, &ggtt->lock) { > ggtt->low_4m_pte = pte; > - ggtt_restore_low_4m_locked(ggtt); > + if (IS_SRIOV_VF(xe)) > + err = ggtt_vf_map_low_4m_locked(ggtt, ggtt->start); > + else > + ggtt_restore_low_4m_locked(ggtt); > + } > + > + /* The PF has to assign the low-4MB PTEs together with the VF range */ > + if (err) { > + xe_log_err_fatal(tile, GGTT, err, > + "Low-4MB GGTT range %#llx-%#llx not writable, required by Wa_14028597154\n", > + ggtt->start >> 10, > + ((ggtt->start + ggtt->full_size) >> 10) - 1); > + return err; > } > > return 0; > @@ -945,23 +1018,41 @@ static void xe_ggtt_invalidate_engine(struct xe_ggtt *ggtt) > * Ensure that all struct &xe_ggtt_node are moved to the @new_start base address > * by changing the base offset of the GGTT. > * > - * This function may be called multiple times during recovery, but if > - * @new_start is unchanged from the current base, it's a noop. > + * This function may be called multiple times during recovery. If @new_start > + * is unchanged from the current base, the nodes stay where they are. > + * > + * When Wa_14028597154 is applied, the low-4MB PTEs matching the VF GGTT range > + * are mapped to the VF dummy page again on every call, even if the base is > + * unchanged, as they are not migrated with the VF. > * > * @new_start should be a value between the WOPCM size and #GUC_GGTT_TOP. VFs > * don't have access to the WOPCM size so we can't test against that. > + * > + * Return: 0 on success or a negative error code if @new_start is unusable for > + * Wa_14028597154 or the low-4MB PTEs can't be mapped. > */ > -void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_start) > +int xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_start) > { > + int err; > + > guard(mutex)(&ggtt->lock); > > - xe_tile_assert(ggtt->tile, new_start + ggtt->size <= GUC_GGTT_TOP); > + xe_tile_assert(ggtt->tile, new_start + ggtt->full_size <= GUC_GGTT_TOP); > #ifdef CONFIG_PCI_IOV > xe_tile_assert(ggtt->tile, ggtt->shareable_size == 0); > #endif > > + /* Don't move the nodes to a range unusable for Wa_14028597154 */ > + if (ggtt->low_4m_pte) { > + err = ggtt_vf_map_low_4m_locked(ggtt, new_start); > + if (err) > + return err; > + } > + > /* pairs with READ_ONCE in xe_ggtt_node_addr() */ > WRITE_ONCE(ggtt->start, new_start); > + > + return 0; > } > > static int ggtt_insert_node_in_range_locked(struct xe_ggtt_node *node, u32 size, > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h > index 7b5221d6f733..22cf19d2b8eb 100644 > --- a/drivers/gpu/drm/xe/xe_ggtt.h > +++ b/drivers/gpu/drm/xe/xe_ggtt.h > @@ -20,7 +20,7 @@ int xe_ggtt_init(struct xe_ggtt *ggtt); > void xe_ggtt_resume(struct xe_ggtt *ggtt); > bool xe_ggtt_has_low_4m_wa(struct xe_ggtt *ggtt); > > -void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_base); > +int xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_base); > u64 xe_ggtt_start(struct xe_ggtt *ggtt); > u64 xe_ggtt_size(struct xe_ggtt *ggtt); > > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > index 60f1b29358f9..1a5395486327 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > @@ -531,12 +531,16 @@ static int vf_get_ggtt_info(struct xe_gt *gt) > /* > * This function can be called repeatedly from post migration fixups, > * at which point we inform the GGTT of the new base address. > - * xe_ggtt_shift_nodes() may be called multiple times for each migration, > - * but will be a noop if the base is unchanged. > + * xe_ggtt_shift_nodes() may be called multiple times for each migration. > + * The nodes stay in place if the base is unchanged, but the low-4MB PTEs > + * of Wa_14028597154 are mapped again, as they are not migrated. > */ > - xe_ggtt_shift_nodes(tile->mem.ggtt, start); > + err = xe_ggtt_shift_nodes(tile->mem.ggtt, start); > + if (err) > + xe_gt_sriov_err(gt, "Failed to apply Wa_14028597154 to GGTT %#llx-%#llx (%pe)\n", > + start, start + size - 1, ERR_PTR(err)); > > - return 0; > + return err; > } > > static int vf_get_lmem_info(struct xe_gt *gt) > -- > 2.34.1 >