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 2A7F4606A322 for ; Fri, 4 Dec 2026 02:10:13 +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=YhGEkUMj Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3A1210EBA7; Fri, 4 Dec 2026 02:10:07 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id 337DA10EBA7 for ; Fri, 4 Dec 2026 02:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796350201; x=1827886201; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=q3Y6hUzFKKmBieRrOzQEWsv6u4JjLluQLJ6NVRe2RY4=; b=YhGEkUMjJM1GbCPo7zEk+sdK/HYTnA8OIHsOzHbt8F5mCaeXTRRPs+AF z8EBna4Y/ItZpnJJHFfoybVHwH/2r8iO6JACnp0c1lR2mD7uYdz3Q+cd2 ruORApZF/iB2R0cvk9MH6V0VBvB9b7EBtUOUEpWGfRrucSyqMxYo7rhTU J00fnSwQrvmODX8s184SkjZfpzJ0kUk14sSYUCsudI9r6VCG9MxE2oBH2 /59qRoXLHD0gil9Nlc1QABj3IC6f94Dk3BQJcwUSFQ+I3WWkDDsczT9Gc pwbgcosyxhGKvRfds89sHTV5mdhf9VWKx+9CxQTK82xDnWZukjQ3cZF7Q Q==; X-CSE-ConnectionGUID: j3OTP3XNTg6bkGIimROpuQ== X-CSE-MsgGUID: R1Tx+vSZQBijTTKy3vbndQ== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5430352" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5430352" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 18:10:01 -0800 X-CSE-ConnectionGUID: 4QK9F2q/QQG2KypoGp0/kA== X-CSE-MsgGUID: tIFS9I38TIW3Mhecm50P5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13870550" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by fmviesa004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 18:10:00 -0800 Received: from ORSMSX902.amr.corp.intel.com (10.22.229.24) 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 18:09:59 -0800 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) by ORSMSX902.amr.corp.intel.com (10.22.229.24) 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 18:09:59 -0800 Received: from CO1PR03CU002.outbound.protection.outlook.com (52.101.46.17) 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 18:09:59 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q5dF84BXgA2l/MdmEwu1x2tSZerBG+Op/7wD89sMB84OfBOduUoI8vBYEeVoCruAPWRXDzy4UEATw0ozlMABiyqmaWnzytS7uvFnWKDiDviEoEXQ2GvJ+loIW+bpB95w1AF+7eW5YwgL9gi3ItvIGq6uZF3X8xL4Foe+XmUKJwSpLXvM7v+DaZTkASpsU6ScYRwwsbu4qMufss3W5jlbvW3yuaRCjoTkzjiMn8dSvCRnbXHzTx7ScRA0XEX2XqJT0L92Uwr74U4n9BPhsgiuY0S6DuHpa1KD+4bvVxLUgMxdaUnhtGXm7XBXYiskjepIs8DQoft55a6oDTsJiPPgDQ== 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=HMgHG6vDkhFkEyijkE6ITHNmlsAZqcp5mVjiJGKxxhY=; b=N+RsCDNz2PmNopn+O4OSlvbly+KLpUHBCQefwqvPFH827cp08SWVfq0aH89Bh0r9V6kxr7Uj3aoN/sTer1NHTmhp3OhoyZWySYGpDsi31zWO9+p2AvAf0sprjFaWy6GS1XI85COhxQDWeVggvtnbksj7nGaWo/4MSkz8fyMQM+2GN4VDVLxhbKcfbCJPzX93qnhMDDi0H9z5GxteVPpMI+b1R3oFFtKSy0xgGiOM/Xh4QCL7ffIzekBkcnUPZ9FzAJPSp/pLv22FvVFlWM2y3xEptz8P6Oyblyy0nCPlSm6DYz4Maugof7uS2dlbgNsknBZ4AwvIR/cG/8PWBSPgvg== 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 LV2PR11MB6000.namprd11.prod.outlook.com (2603:10b6:408:17c::12) by MN0PR11MB6231.namprd11.prod.outlook.com (2603:10b6:208:3c4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 02:09:57 +0000 Received: from LV2PR11MB6000.namprd11.prod.outlook.com ([fe80::7fd:3ebd:962e:1390]) by LV2PR11MB6000.namprd11.prod.outlook.com ([fe80::7fd:3ebd:962e:1390%3]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 02:09:57 +0000 Date: Thu, 3 Dec 2026 21:09:53 -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 v3 5/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV VF Message-ID: References: <20261203231835.437637-1-piotr.piorkowski@intel.com> <20261203231835.437637-6-piotr.piorkowski@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261203231835.437637-6-piotr.piorkowski@intel.com> X-ClientProxiedBy: PH8PR07CA0045.namprd07.prod.outlook.com (2603:10b6:510:2cf::14) To LV2PR11MB6000.namprd11.prod.outlook.com (2603:10b6:408:17c::12) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR11MB6000:EE_|MN0PR11MB6231:EE_ X-MS-Office365-Filtering-Correlation-Id: b54fe12b-88f3-489c-001d-08df51abb16d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|366016|23010399003|11063799006|4143699003|261009223027099003|18002099003|22082099003|261022113327099003|260925021311599003|260925021911599003|260925022911599003|10067099003|56012099006|261021135927099003|261102123227099003|261102130727099003|261022075727099003|261028144727099003|261022115727099003|261022105027099003|261021121427099003|261021130227099003|261021123027099003|261026121527099003|261026140227099003; X-Microsoft-Antispam-Message-Info: PF2c7yfbL+V/cm5FB4yVqzUOCDrwZHyi1KcnGyhHjV4UE6ox+R84wL4QBwmSXkviRFS2xTmiQH3ey9joFLYoyrEZb+6G4F2Uhjt2OESKsR/il2UZAwfTfDUhHXfGaoEZS6sGrWNreRzBjYZPjKoSkMCnwIWczdi5ByXB6z7wIWPsPKOL+7QPBhO37QjdcgIa1U3q7nZaCJPE7Dpr6Qz8vU0zhLhXTX3UjSqNZ9VWuDBGeT2ubDb+FSoyETcD5GjYVZgpbRobBDwloTIZQkLzBAN9D1kpEC1Nnvr7lqDiraPA4xKwiO3gtGXvRdZafXpoF00dr6QlTukbMi11Ri3DprzLG3aYwqhsEvIXVTNocd7vxqpj4UeOJKAsyJcjricPlsP+iK+suPKa8XL5tFTodJLSlemNP4cex/ekQcKsvALSVw1JjTW4fKFZW3xDvJ50hd5bnHOnhyzKgNBAq3Yc7gxVjVAL8Rle8lacVFXofIVCTRZCZBB6QBKmcXwsmXCqk9eLWNanV8gdwAnzTx4e1jJtvuGhDuq3OPcsKWbAepkgmnoXcnkj4vmIonsg6CXVKAhuYPXdYNqjPHxpwqNHXO0FyNrYkXSTQgjUTcAis6rHzXrLKp60FqwvX9LM/hWDr2ZQuOpPKliV8pajPFoUZO63M9pVxr2IC3WmdPu/h5E= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV2PR11MB6000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(23010399003)(11063799006)(4143699003)(261009223027099003)(18002099003)(22082099003)(261022113327099003)(260925021311599003)(260925021911599003)(260925022911599003)(10067099003)(56012099006)(261021135927099003)(261102123227099003)(261102130727099003)(261022075727099003)(261028144727099003)(261022115727099003)(261022105027099003)(261021121427099003)(261021130227099003)(261021123027099003)(261026121527099003)(261026140227099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkC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6vEMrappKhdGzAJUX3025YG8C7ybS/6JLrfoxTsBWlOULItXm?= =?iso-8859-1?Q?8J6uC6An66N2ObyCK6kctXPyWsqX1z3XHGjvnJKShoZ+D+DwY+zA0jz2Gh?= =?iso-8859-1?Q?CgK2nfpVgA=3D=3D?= X-Exchange-RoutingPolicyChecked: a847fqbQ4L57lhq0D+M56EZIKwtHtFTjKT58vvPgVVgozLlJrW0g1GKrofXbc4LXfqnhhko1oegBv2MVDh0RKyBxeWEWAKEbShL5UcwKZwDQu9Tgw6UbRYxsw7UreM2XTr9vzeWbKWTzwLVTWe6NvlEmItsmBMMSvpjXV6D1dj2HYnPDJhFXGGgmfQJpvM/8cjHgQJ2Lm8raG7YctJNviET+lmCPS+s6OosvR8tnfjudZGjuyE3vRgD2lbUHvy1iiju+AClNNoJwkzJWMMh8D0EY4A//6Of4NyJkvzLdidjGVMeHEjxYeTSach7WsZtjwYHxXkVNqyQcZUrqxQHJSQ== X-MS-Exchange-CrossTenant-Network-Message-Id: b54fe12b-88f3-489c-001d-08df51abb16d X-MS-Exchange-CrossTenant-AuthSource: LV2PR11MB6000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 02:09:57.0328 (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: CokPSVBZqhQBCS4MnlxqgpG6xpqZNL4oakRos+fQsfMnfzkDuHulRFZfEmUcMJGEiqg4/9tvBvP+UtYTl72fMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB6231 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 Fri, Dec 04, 2026 at 12:18:35AM +0100, Piórkowski, Piotr wrote: > From: Varun Gupta > > Wa_14028597154 requires the low-4MB GGTT PTEs to be backed by a dummy > page, as the HW may write multi-queue semaphore tokens there. > > The PF driver assigns these PTEs to each VF, matching the GGTT range > provisioned for that VF. The VF driver then has to map them to its own > dummy page. > > 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 to verify the mapping > and log an error on resume if they were not written. Keep the top 4MB > chunk of the VF GGTT range out of the usable range. > > The WA can only be applied if the PF has enabled the GuC part of it, > the VF GGTT range is 4MB aligned, starts at or above 4MB, is at least > 8MB and its low-4MB PTEs are assigned to the VF. Multi-queue is not used > during the probe, so instead of failing the probe, don't use multi-queue > on the VF if any of this is not met. Query the GuC part of the WA from > the GuC together with the multi-queue status. Check the GGTT range and > write a test PTE to each of the low-4MB PTEs in xe_ggtt_init_early(). > Map the VF dummy page in xe_ggtt_init() before the scratch page is set > up, so the scratch setup sees the final multi-queue state. > > Let xe_ggtt_shift_nodes() return an error, without moving the nodes, if > the low-4MB PTEs of the new GGTT range can't be mapped, so the > post-migration recovery fails. > > v3: > - Don't use multi-queue on the VF instead of failing the probe if the > WA can't be applied > - Flush the GSM writes before reading back the low-4MB PTEs > - Move the VF GGTT range setup to a helper (Tomasz) > - Reword comments and commit message (Tomasz) > > 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 Reviewed-by: Rodrigo Vivi pushing it soon > --- > drivers/gpu/drm/xe/xe_ggtt.c | 181 +++++++++++++++++++++++++--- > drivers/gpu/drm/xe/xe_ggtt.h | 2 +- > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 37 +++++- > 3 files changed, 197 insertions(+), 23 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c > index 64b81c0c48a38..065247ed358b6 100644 > --- a/drivers/gpu/drm/xe/xe_ggtt.c > +++ b/drivers/gpu/drm/xe/xe_ggtt.c > @@ -280,6 +280,11 @@ static void ggtt_set_low_4m_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte) > __xe_ggtt_set_pte(ggtt, addr, pte); > } > > +static void ggtt_flush_pte_writes(struct xe_ggtt *ggtt) > +{ > + xe_mmio_read32(xe_root_tile_mmio(tile_to_xe(ggtt->tile)), VF_CAP_REG); > +} > + > static void xe_ggtt_set_pte_and_flush(struct xe_ggtt *ggtt, u64 addr, u64 pte) > { > xe_ggtt_set_pte(ggtt, addr, pte); > @@ -493,14 +498,22 @@ static bool ggtt_needs_low_4m_wa(struct xe_ggtt *ggtt) > xe_gt_has_multi_queue(tile->primary_gt); > } > > +/* Wa_14028597154: the top 4MB chunk of the VF GGTT range is not usable */ > +static void ggtt_init_vf_low_4m(struct xe_ggtt *ggtt, u64 start, u64 size) > +{ > + ggtt_init_ranges(ggtt, start, size, size - SZ_4M, 0); > +} > + > 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)) > + ggtt_init_vf_low_4m(ggtt, start, size); > + 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, > @@ -521,6 +534,39 @@ int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 start, u32 size) > } > EXPORT_SYMBOL_IF_KUNIT(xe_ggtt_init_kunit); > > +/* > + * Wa_14028597154: the PF provisions VF GGTT ranges 4MB aligned, above 4MB and > + * of at least 8MB, and assigns the matching low-4MB PTEs to the VF. The VF can > + * only modify these PTEs if the PF has assigned them, so write a non-present > + * test PTE to each of them, read it back and restore the previous value. > + */ > +static bool ggtt_vf_low_4m_usable(struct xe_ggtt *ggtt, u64 start, u64 size) > +{ > + u64 mask = XE_PAGE_ADDR_MASK(XE_PTE_SHIFT); > + u64 va; > + > + if (start < SZ_4M || size < SZ_8M || !IS_ALIGNED(start | size, SZ_4M)) > + return false; > + > + for (va = start; va < start + size; va += SZ_4M) { > + u64 __iomem *pte = &ggtt->gsm[(va >> 10) >> XE_PTE_SHIFT]; > + u64 old = readq(pte); > + u64 test = (old & mask) == XE_PAGE_SIZE ? 2 * XE_PAGE_SIZE : XE_PAGE_SIZE; > + bool written; > + > + writeq(test, pte); > + ggtt_flush_pte_writes(ggtt); > + written = (readq(pte) & mask) == test; > + writeq(old, pte); > + ggtt_flush_pte_writes(ggtt); > + > + if (!written) > + return false; > + } > + > + return true; > +} > + > static void dev_fini_ggtt(void *arg) > { > struct xe_ggtt *ggtt = arg; > @@ -563,6 +609,18 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) > else > ggtt->pt_ops = &xelp_pt_ops; > > + /* > + * Wa_14028597154: multi-queue is not used yet, so if the WA can't be > + * applied to the VF GGTT range, don't use multi-queue on the VF. > + */ > + if (IS_SRIOV_VF(xe) && ggtt_needs_low_4m_wa(ggtt) && > + !ggtt_vf_low_4m_usable(ggtt, ggtt_start, ggtt_size)) { > + xe_tile_warn(ggtt->tile, > + "Wa_14028597154 can't be applied to GGTT %#llx-%#llx, disabling multi-queue\n", > + ggtt_start, ggtt_start + ggtt_size - 1); > + xe_gt_disable_multi_queue(ggtt->tile->primary_gt); > + } > + > ggtt->wq = alloc_workqueue("xe-ggtt-wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); > if (!ggtt->wq) > return -ENOMEM; > @@ -581,6 +639,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 +728,42 @@ 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); > + > + ggtt_flush_pte_writes(ggtt); > + > + 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 +776,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 +802,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 +817,21 @@ 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); > + if (err) > + ggtt->low_4m_pte = 0; > + } > + > + /* Multi-queue is not used yet, so the VF can still go without it */ > + if (err) { > + xe_tile_warn(tile, > + "Low-4MB GGTT range %#llx-%#llx not writable, disabling multi-queue (%pe)\n", > + ggtt->start >> 10, > + ((ggtt->start + ggtt->full_size) >> 10) - 1, ERR_PTR(err)); > + xe_gt_disable_multi_queue(tile->primary_gt); > } > > return 0; > @@ -839,6 +954,11 @@ int xe_ggtt_init(struct xe_ggtt *ggtt) > struct xe_device *xe = tile_to_xe(ggtt->tile); > int err; > > + /* Before scratch, as the VF may disable multi-queue here */ > + err = ggtt_map_low_4m_wa(ggtt); > + if (err) > + return err; > + > /* > * Multi-queue misses engine GGTT TLB invalidations (GuC lite-restore > * skips the full context restore), so skip scratch: a stale translation > @@ -868,10 +988,6 @@ int xe_ggtt_init(struct xe_ggtt *ggtt) > xe_bo_size(ggtt->scratch)); > } > > - err = ggtt_map_low_4m_wa(ggtt); > - if (err) > - goto err; > - > /* Also invalidates GGTT TLBs for the low 4MB entries above */ > xe_ggtt_initial_clear(ggtt); > > @@ -945,23 +1061,48 @@ 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 the low-4MB PTEs for the > + * new range can't be mapped, in which case the nodes are not moved. > */ > -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 > > + /* > + * Wa_14028597154: the low-4MB PTEs lie outside the VF GGTT range, so no > + * node covers them and they are not migrated with the VF. Map them again. > + */ > + if (ggtt->low_4m_pte) { > + err = ggtt_vf_map_low_4m_locked(ggtt, new_start); > + if (err) { > + xe_tile_err(ggtt->tile, > + "Failed to map low-4MB GGTT PTEs for Wa_14028597154 (%pe)\n", > + ERR_PTR(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 7b5221d6f733d..22cf19d2b8eb2 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 6cad30e4a892b..f28af714e7849 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c > @@ -10,6 +10,8 @@ > #include > #include > > +#include > + > #include "abi/guc_actions_sriov_abi.h" > #include "abi/guc_communication_mmio_abi.h" > #include "abi/guc_klvs_abi.h" > @@ -38,6 +40,7 @@ > #include "xe_tile_sriov_vf.h" > #include "xe_tlb_inval.h" > #include "xe_uc_fw.h" > +#include "xe_wa.h" > #include "xe_wedge.h" > > #define make_u64_from_u32(hi, lo) ((u64)((u64)(u32)(hi) << 32 | (u32)(lo))) > @@ -535,9 +538,12 @@ static int vf_get_ggtt_info(struct xe_gt *gt) > * 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(tile->mem.ggtt, start); > + err = xe_ggtt_shift_nodes(tile->mem.ggtt, start); > + if (err) > + xe_gt_sriov_err(gt, "Failed to move GGTT to %#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) > @@ -729,6 +735,23 @@ int xe_gt_sriov_vf_query_config(struct xe_gt *gt) > return 0; > } > > +/* Wa_14028597154: check that the PF has enabled the GuC part of the WA */ > +static bool vf_low_4m_wa_enabled(struct xe_gt *gt) > +{ > + u32 key = GUC_FEATURE_KLV_DISABLE_PPHWSP_ACCESS_FOR_MULTIQ_SEM_TOKEN_64; > + u32 enabled; > + int err; > + > + err = guc_action_query_single_klv32(>->uc.guc, key, &enabled); > + if (err) { > + xe_gt_sriov_dbg(gt, "Failed to query Wa_14028597154 status (%pe)\n", > + ERR_PTR(err)); > + return false; > + } > + > + return enabled; > +} > + > /** > * xe_gt_sriov_vf_check_multi_queue() - Check if multi-queue is enabled in GuC. > * @gt: the &xe_gt > @@ -737,6 +760,9 @@ int xe_gt_sriov_vf_query_config(struct xe_gt *gt) > * Query the GuC and don't use multi-queue on the VF if it is disabled there. > * If the GuC can't report it, assume multi-queue is enabled. > * > + * If Wa_14028597154 applies, also don't use multi-queue if the GuC part of > + * the WA is not enabled. > + * > * This function is for VF use only. > */ > void xe_gt_sriov_vf_check_multi_queue(struct xe_gt *gt) > @@ -763,6 +789,13 @@ void xe_gt_sriov_vf_check_multi_queue(struct xe_gt *gt) > if (disabled) { > xe_gt_sriov_info(gt, "Multi-queue disabled by the PF\n"); > xe_gt_disable_multi_queue(gt); > + return; > + } > + > + if (XE_GT_WA(gt, 14028597154) && !vf_low_4m_wa_enabled(gt)) { > + xe_gt_sriov_notice(gt, > + "Wa_14028597154 not enabled in GuC, disabling multi-queue\n"); > + xe_gt_disable_multi_queue(gt); > } > } > > -- > 2.34.1 >