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 D7135606A322 for ; Thu, 3 Dec 2026 20:31:02 +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=m/31s/Lv Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D83710E36D; Thu, 3 Dec 2026 20:30:57 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id D02ED10E36D for ; Thu, 3 Dec 2026 20:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329852; x=1827865852; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=xDhyLKMs70dy2F1nSWbhS7ltjf5US/BR//AtsD2vQE0=; b=m/31s/LvokHSEsJE3ILbz3XoCeQ41LbqfvKszeQiY6JychbWH2xiH8ND ZsIBkCcCWpuDCDpof6YJxAblqXuAvPU48f3eKvwXpgvk4x9p7mg8Mp1hh shOjyGhp1cC4p77qKAIQ5JVf78171IpKByb9+S1SvE1QFzhxlsfaD/5bZ ubbrvoYKy5MjAwC2ndbFjUCiRUxQQOUlCORNI3X9ScCxfAg+fqqlZ4uuA g0bo/rF8R+LQBVrDiywEu+pWE42pINVD5eGYUlYnYsoGOuBMr0OFXaQEV 81icoR7JsPzs7Jp/REcEi8/3K3muEBMpfxQbA3LFe5FUi+oi6ZoEVqirg A==; X-CSE-ConnectionGUID: ePE7MjcuQt22+fDVQ2NkRQ== X-CSE-MsgGUID: xwpA5ac9TCKwhEgRVFyi2g== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="6982" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="6982" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa116.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:30:51 -0800 X-CSE-ConnectionGUID: m/anLQm2TI6YpsnKgVxaRA== X-CSE-MsgGUID: vqm7HLlVQeiFjyyeZNzUCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14069467" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by fmviesa009.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:30:52 -0800 Received: from FMSMSX901.amr.corp.intel.com (10.18.126.90) by fmsmsx902.amr.corp.intel.com (10.18.126.91) 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:30:51 -0800 Received: from fmsedg903.ED.cps.intel.com (10.1.192.145) by FMSMSX901.amr.corp.intel.com (10.18.126.90) 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:30:51 -0800 Received: from PH7PR06CU001.outbound.protection.outlook.com (52.101.201.68) by edgegateway.intel.com (192.55.55.83) 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:30:50 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HgfothrwsA8BE/L+/Ge3yqUaQQmG4+kHKp9+/IY18A6dKc/dxEGobXxmtQarO3BGELXOUYbdOxisMMBt7XhSvR3k0FhRLvxC5ioIsZG+iR9NBmoe1y9DekUOHsf7Nkhjx2iwNO8+MuKMIvghkcFGNuuJCaW3ExwMJHFDVEjNPYVnVGQt62LcTCm4Sc/WqzQRhza1zfDPqRak8HrVvA8cvDbiesmHeTH4kJ1EBl0mR6lbKO8P7bPI7m6LtItcb2atyhv7VHaAp2F3dlMeUzQSQNmEkU5DUgeTaMsacIdBCG8P4Biu4qYR3NliWPXaJtN9T7AUuXCk+wBH28ZYBbH4dw== 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=kSoAuTHXMIe1/zdtSN/abtF0lJvyRdShA4FzESKW1ck=; b=AiZ+PauVJPhUbwfa1BKkPt5qtNMF/pzwNSvt2c4I9TAI2ZFtiZFW3jxl+SZNrILRN4bCVfrn3EkuIMX9liAgiaa+ar3jxog9uY3OM7AgoILlXKN2ujigj4R0/B1QKevi/zh3XYDu3cJE8D56abJE7zMIt5BgMF63detGHgyF8qdNZqeuKUyLN3Bumx5WxTB0QsUZ/Q4Qc3p9Zq7D6WfI+IgGivgrhBpMeCs7m57VERLcFasqPGhR+PVTgrGAr/HXTCmNza1O8C5OQVKy7HdDe5XWlXHAPb5F5WkgrIxu9X9xpM7opCVvP0l7Vm0Q6o8rJ7v7mt6qjZJaPd3DsHAwRg== 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:30:47 +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:30:47 +0000 Date: Thu, 3 Dec 2026 15:30:43 -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 Subject: Re: [PATCH v2 4/5] drm/xe/xe3p_lpg: Apply Wa_14028597154 to SR-IOV PF Message-ID: References: <20261203181408.362175-1-piotr.piorkowski@intel.com> <20261203181408.362175-5-piotr.piorkowski@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261203181408.362175-5-piotr.piorkowski@intel.com> X-ClientProxiedBy: PH8P221CA0064.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:349::16) 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: d9fb2640-29be-4e60-15df-08df517c5023 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: JmK6f35dkf4cAtu048YsDPq8l4hImmFO4axoMBuK50fyCgRhbqW2QoFssg7h96MJF6JaBQcwihjJCy02fSgsAREYkhSDhnFHYP/V/PYppMRUJT2LBfzfprSuQUJTWjLo5UjRYPwlyEvB8frmZyO2tAZ7CgSK8xnNoX3JGs5XTfolsijhOvIZ5zYdPdCfWKStbaTNu3nZOv/mdAXlzYBSAJGaSYgUPJggAYxmGzNIwSgk6op2GmfbCSBX2TImHXP2u+S8K88XHnhga7W5b2MVEh/bNcG3y/2/RcnREtg6JVOOH09UcU7O6CUbINEXjR1DCZUv9EojB0M+IYn217o6SBBuWfEhP9JZWlKLD2gbOQ1K6lVz9/NyqGJjSNobZimdqCA28SsUka7ks3Q0BLNUFZX2gL2zGTwSWJvPxpT8J7Rcy6tcFpvoiXXdbpv3LfR+cuNY9s4zYszUwqRpBcai3yPxK09gQsUC4SYb5pR9Ko2yfeLB7PcjFcfLfILa2x/m2IWQzD8swAf9qIN8ICOzCrInjHE/B/YAHYbHupqWkUrzOcRAk6XSIOo9nfFRrAIiXYgzZglkvSQzrK/uMERoadiEEKkrpKDzwIA8Z1sR2+uLkn0ogyqigiBumLJsAve3FiIEDK07uZ3djKGTXWI7A9Rl43569hFgNDtG5GCvt1Y= 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?Pc6OcK0pFq7n9asHw7vH4/hyVJd135MfWdSoG6ly+AUhfszZ8f1KQClq5H?= =?i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e?= =?iso-8859-1?Q?Ybt0b5/tuw=3D=3D?= X-Exchange-RoutingPolicyChecked: n9Y13xNcxmRXAWGviFMKOoI3R4g8AOCfbtn+aZurEpp2+tHb+ENnCdarNYDN3yJfjnVLnQJh51t1RW94VZ669TJX2DeOd4XCm8OmVXrut8uULn+s6OQpEIISbQCk4HbGJbG0qFwYmbkFENeJODc/RX+bqvoAt4o8DNckidiAAIX6aOLYfbdnqClukwfrazTMii1+xsYKPz0/CpQTC/GIEPiZ54/QdQI+pV6A8Spz4v7b3igRt4/4N+ILqaD2wGT5E9HMxkzHW4jGQrUtMwf6EqUmJLgXkPzy2aglCZ1Xow1hzoR/NXj5rmZw3tn3/UfzLtWeEJJpUyDI5LnyrRhgaQ== X-MS-Exchange-CrossTenant-Network-Message-Id: d9fb2640-29be-4e60-15df-08df517c5023 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:30:47.5029 (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: DM4Y7Tsysas08fLuVeD6DCA1339UWtu+c3nbAOnEpyWDs+dlS7ywlcjeUG0JHlYJCzyY+MEwPGT0IVuOYNZ65g== 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:07PM +0100, Piórkowski, Piotr wrote: > From: Varun Gupta > > Wa_14028597154 requires the low-4MB GGTT PTE matching each 4MB chunk of > GGTT (addr >> 10), plus the following page, to be backed by a dummy page > of the function owning that chunk. With SR-IOV this also applies to the > GGTT ranges of the VFs. > > When the WA is active, provision VF GGTT ranges 4MB aligned and in whole > 4MB chunks. Make them at least 8MB, as the VF keeps the top 4MB of its > range unused, and don't estimate a fair VF GGTT size below 8MB. > > Hand the low-4MB PTEs matching a VF range to the VF together with the > range, as VFID-only PTEs like the range itself. On release, restore the > PF dummy page in them and invalidate the GGTT TLBs. > > Keep the 4MB chunk right below a VF range free of PF allocations. Place > PF BOs at least 4MB below the lowest VF chunk, and place a VF range only > where the chunk below is free or owned by another VF. Track the > VF-owned chunks, so PF resume leaves their low-4MB PTEs alone. > > The VF side of the WA is added in a follow-up patch. > > v2: > - Fix build without CONFIG_PCI_IOV (CI) > > Cc: Matt Atwood > Cc: Rodrigo Vivi > Cc: Satyanarayana K V P > Cc: Tangudu Tilak Tirumalesh > Signed-off-by: Varun Gupta > Signed-off-by: Piotr Piórkowski > --- > drivers/gpu/drm/xe/xe_ggtt.c | 159 +++++++++++++++++++-- > drivers/gpu/drm/xe/xe_ggtt.h | 1 + > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 19 ++- > 3 files changed, 164 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c > index f3836a04eefd..64b81c0c48a3 100644 > --- a/drivers/gpu/drm/xe/xe_ggtt.c > +++ b/drivers/gpu/drm/xe/xe_ggtt.c > @@ -6,6 +6,7 @@ > #include "xe_ggtt.h" > > #include > +#include > #include > #include > #include > @@ -72,6 +73,8 @@ > #define XE_GGTT_FLAGS_64K BIT(0) > #define XE_GGTT_FLAGS_ONLINE BIT(1) > > +#define XE_GGTT_NUM_4M_CHUNKS (SZ_4G / SZ_4M) > + > /** > * struct xe_ggtt_node - A node in GGTT. > * > @@ -132,6 +135,8 @@ struct xe_ggtt { > struct xe_bo *scratch; > /** @low_4m_pte: PTE backing GGTT [4K, 4M), 0 if unused */ > u64 low_4m_pte; > + /** @vf_chunks: Bitmap of 4MB GGTT chunks assigned to VFs */ > + DECLARE_BITMAP(vf_chunks, XE_GGTT_NUM_4M_CHUNKS); > /** @lock: Mutex lock to protect GGTT data */ > struct mutex lock; > /** > @@ -480,6 +485,14 @@ static void ggtt_init_shared(struct xe_ggtt *ggtt, u64 start, u64 size) > ggtt_init_ranges(ggtt, start, size, size, size); > } > > +static bool ggtt_needs_low_4m_wa(struct xe_ggtt *ggtt) > +{ > + struct xe_tile *tile = ggtt->tile; > + > + return tile->primary_gt && XE_GT_WA(tile->primary_gt, 14028597154) && > + xe_gt_has_multi_queue(tile->primary_gt); > +} > + > static void ggtt_init_generic(struct xe_ggtt *ggtt, u64 start, u64 size) > { > struct xe_device *xe = tile_to_xe(ggtt->tile); > @@ -568,6 +581,87 @@ 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); > > +/* > + * 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 > + * node does not touch the low 4MB. > + */ > +static void ggtt_release_low_4m_locked(struct xe_ggtt *ggtt, u64 start, u64 size) > +{ > + u64 va; > + > + lockdep_assert_held(&ggtt->lock); > + xe_tile_assert(ggtt->tile, ggtt->low_4m_pte); > + > + for (va = ALIGN_DOWN(start, SZ_4M); va < start + size; va += SZ_4M) > + if (__test_and_clear_bit(va / SZ_4M, ggtt->vf_chunks)) > + ggtt_set_low_4m_pte(ggtt, va >> 10, ggtt->low_4m_pte); > +} > + > +#ifdef CONFIG_PCI_IOV > +static u64 xe_encode_vfid_pte(u16 vfid) > +{ > + return FIELD_PREP(GGTT_PTE_VFID, vfid) | XE_PAGE_PRESENT; > +} > + > +/* > + * Wa_14028597154: hand the low-4MB PTE matching every 4MB chunk of a VF range > + * (va >> 10) to that VF, as a VFID-only PTE like in xe_ggtt_assign_locked(). > + */ > +static void ggtt_assign_low_4m_locked(struct xe_ggtt *ggtt, u64 start, u64 size, > + u16 vfid) > +{ > + u64 pte = xe_encode_vfid_pte(vfid); > + u64 va; > + > + lockdep_assert_held(&ggtt->lock); > + xe_tile_assert(ggtt->tile, ggtt->low_4m_pte); > + xe_tile_assert(ggtt->tile, IS_ALIGNED(start, SZ_4M) && IS_ALIGNED(size, SZ_4M)); > + > + for (va = start; va < start + size; va += SZ_4M) { > + ggtt_set_low_4m_pte(ggtt, va >> 10, pte); > + __set_bit(va / SZ_4M, ggtt->vf_chunks); > + } > +} > + > +/* > + * Wa_14028597154: the 4MB chunk right below a VF range must not hold PF > + * allocations. It has to be free, below the GGTT start, or owned by another > + * VF. > + */ > +static bool ggtt_low_4m_room_below(struct xe_ggtt *ggtt, u64 addr, u64 hole_start) > +{ > + if (!ggtt->low_4m_pte || addr >= hole_start + SZ_4M) > + return true; > + > + if (hole_start == ggtt->start) > + return true; > + > + if (addr < SZ_4M) > + return false; > + > + return test_bit(addr / SZ_4M - 1, ggtt->vf_chunks); > +} > +#endif > + > +/* > + * Return the lowest drm_mm offset in a hole that can hold a VF range. If the > + * hole starts right above a node not owned by a VF, skip its first 4MB, see > + * ggtt_low_4m_room_below(). > + */ > +static u64 ggtt_low_4m_hole_start(struct xe_ggtt *ggtt, u64 hole_start) > +{ > + u64 addr = ggtt->start + hole_start; > + > + if (!ggtt->low_4m_pte || !hole_start) > + return hole_start; > + > + if (IS_ALIGNED(addr, SZ_4M) && test_bit(addr / SZ_4M - 1, ggtt->vf_chunks)) > + return hole_start; > + > + return hole_start + SZ_4M; > +} > + > static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt) > { > u64 low_start = max_t(u64, ALIGN_DOWN(ggtt->start, SZ_4M) >> 10, > @@ -582,8 +676,11 @@ static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt) > if (!ggtt->low_4m_pte) > return; > > - for (addr = low_start; addr < low_end; addr += XE_PAGE_SIZE) > + for (addr = low_start; addr < low_end; addr += XE_PAGE_SIZE) { > + if (test_bit(addr >> XE_PTE_SHIFT, ggtt->vf_chunks)) > + continue; > ggtt_set_low_4m_pte(ggtt, addr, ggtt->low_4m_pte); > + } > } > > /* > @@ -607,8 +704,7 @@ static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt) > if (IS_SRIOV_VF(xe)) > return 0; > > - if (!tile->primary_gt || !XE_GT_WA(tile->primary_gt, 14028597154) || > - !xe_gt_has_multi_queue(tile->primary_gt)) > + if (!ggtt_needs_low_4m_wa(ggtt)) > return 0; > > bo = xe_managed_bo_create_pin_map(xe, tile, XE_PAGE_SIZE, XE_BO_FLAG_SYSTEM); > @@ -640,6 +736,17 @@ void xe_ggtt_resume(struct xe_ggtt *ggtt) > ggtt_restore_low_4m_locked(ggtt); > } > > +/** > + * xe_ggtt_has_low_4m_wa() - Check if the low-4MB GGTT mapping is applied > + * @ggtt: the &xe_ggtt > + * > + * Return: true if the low-4MB GGTT mapping for Wa_14028597154 is in place. > + */ > +bool xe_ggtt_has_low_4m_wa(struct xe_ggtt *ggtt) > +{ > + return ggtt->low_4m_pte; > +} > + > static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt) > { > struct drm_mm_node *hole; > @@ -666,8 +773,13 @@ static void ggtt_node_remove(struct xe_ggtt_node *node) > > mutex_lock(&ggtt->lock); > bound = ggtt->flags & XE_GGTT_FLAGS_ONLINE; > - if (bound) > + if (bound) { > xe_ggtt_clear(ggtt, xe_ggtt_node_addr(node), xe_ggtt_node_size(node)); > + /* Return a released VF range's low-4MB PTEs to the PF dummy page */ > + if (IS_SRIOV_PF(tile_to_xe(ggtt->tile)) && ggtt->low_4m_pte) > + ggtt_release_low_4m_locked(ggtt, xe_ggtt_node_addr(node), > + xe_ggtt_node_size(node)); > + } > drm_mm_remove_node(&node->base); > node->base.size = 0; > if (bound && node->invalidate_on_remove) { > @@ -941,9 +1053,9 @@ struct xe_ggtt_node *xe_ggtt_insert_node(struct xe_ggtt *ggtt, u32 size, u32 ali > #ifdef CONFIG_PCI_IOV > /* > * drm_mm aligns offsets from ggtt->start, but the GGTT address of a VF range > - * is what has to be aligned. If ggtt->start is not aligned to @align, look for > - * the highest offset with an aligned GGTT address in the holes of the > - * shareable range directly. > + * is what has to be aligned. If ggtt->start is not aligned to @align, or the > + * placement has to follow Wa_14028597154, look for the highest offset with an > + * aligned GGTT address in the holes of the shareable range directly. > */ > static int ggtt_insert_node_shareable_locked(struct xe_ggtt_node *node, u64 size, > u64 align) > @@ -956,11 +1068,13 @@ static int ggtt_insert_node_shareable_locked(struct xe_ggtt_node *node, u64 size > > lockdep_assert_held(&ggtt->lock); > > - if (align <= 1 || IS_ALIGNED(ggtt->start, align)) > + if ((align <= 1 || IS_ALIGNED(ggtt->start, align)) && !ggtt->low_4m_pte) > return ggtt_insert_node_in_range_locked(node, size, align, range_start, > ggtt->shareable_size, > DRM_MM_INSERT_HIGH); > > + /* Wa_14028597154: VF ranges are handed out in whole 4MB chunks */ > + align = max_t(u64, align, ggtt->low_4m_pte ? SZ_4M : 1); > xe_tile_assert(ggtt->tile, is_power_of_2(align)); > > if (!size) > @@ -978,6 +1092,10 @@ static int ggtt_insert_node_shareable_locked(struct xe_ggtt_node *node, u64 size > if (addr < ggtt->start + lo) > continue; > > + /* Wa_14028597154: keep PF allocations out of the chunk below */ > + if (!ggtt_low_4m_room_below(ggtt, addr, ggtt->start + hole_start)) > + continue; > + > if (best == U64_MAX || addr - ggtt->start > best) > best = addr - ggtt->start; > } > @@ -1198,6 +1316,21 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, > > end = min(end, ggtt->size); > > + /* > + * Wa_14028597154: keep PF allocations at least 4MB below the lowest > + * VF-owned chunk. > + */ > + if (ggtt->low_4m_pte && IS_SRIOV_PF(tile_to_xe(ggtt->tile))) { Only BOs get this limit, display fb pins don't. Fine if only contexts matter for this WA, right? Maybe say it in the comment. Reviewed-by: Rodrigo Vivi > + unsigned long first_vf = find_first_bit(ggtt->vf_chunks, > + XE_GGTT_NUM_4M_CHUNKS); > + > + if (first_vf < XE_GGTT_NUM_4M_CHUNKS) { > + u64 limit = (u64)first_vf * SZ_4M - SZ_4M; > + > + end = limit > ggtt->start ? min(end, limit - ggtt->start) : 0; > + } > + } > + > if (end < start + xe_bo_size(bo)) > err = -ENOSPC; > else > @@ -1315,6 +1448,7 @@ u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare) > > mutex_lock(&ggtt->lock); > drm_mm_for_each_hole(entry, mm, hole_start, hole_end) { > + hole_start = ggtt_low_4m_hole_start(ggtt, hole_start); > if (!ggtt_align_hole(ggtt, alignment, &hole_start, &hole_end)) > continue; > hole_size = hole_end - hole_start; > @@ -1329,11 +1463,6 @@ u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare) > } > > #ifdef CONFIG_PCI_IOV > -static u64 xe_encode_vfid_pte(u16 vfid) > -{ > - return FIELD_PREP(GGTT_PTE_VFID, vfid) | XE_PAGE_PRESENT; > -} > - > static void xe_ggtt_assign_locked(const struct xe_ggtt_node *node, u16 vfid) > { > struct xe_ggtt *ggtt = node->ggtt; > @@ -1344,6 +1473,9 @@ static void xe_ggtt_assign_locked(const struct xe_ggtt_node *node, u16 vfid) > > lockdep_assert_held(&ggtt->lock); > > + if (ggtt->low_4m_pte) > + ggtt_assign_low_4m_locked(ggtt, start, size, vfid); > + > while (start < end) { > ggtt->pt_ops->ggtt_set_pte(ggtt, start, pte); > start += XE_PAGE_SIZE; > @@ -1487,6 +1619,7 @@ u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer > > mutex_lock(&ggtt->lock); > drm_mm_for_each_hole(entry, mm, hole_start, hole_end) { > + hole_start = ggtt_low_4m_hole_start(ggtt, hole_start); > if (!ggtt_align_hole(ggtt, alignment, &hole_start, &hole_end)) > continue; > hole_size = hole_end - hole_start; > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h > index 78e68c2ca3ad..7b5221d6f733 100644 > --- a/drivers/gpu/drm/xe/xe_ggtt.h > +++ b/drivers/gpu/drm/xe/xe_ggtt.h > @@ -18,6 +18,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt); > int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size); > 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); > u64 xe_ggtt_start(struct xe_ggtt *ggtt); > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > index 926f1e83bd79..0b136b4616e7 100644 > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c > @@ -442,6 +442,10 @@ static u64 pf_get_ggtt_alignment(struct xe_gt *gt) > { > struct xe_device *xe = gt_to_xe(gt); > > + /* Wa_14028597154: VF GGTT ranges must start on and span whole 4MB chunks */ > + if (xe_ggtt_has_low_4m_wa(gt_to_tile(gt)->mem.ggtt)) > + return SZ_4M; > + > return IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K ? SZ_64K : SZ_4K; > } > > @@ -495,7 +499,9 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6 > > static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_config *config) > { > - xe_ggtt_node_remove(config->ggtt_region, false); > + /* Wa_14028597154: drop TLB entries for the VF's own low-4MB dummy page */ > + xe_ggtt_node_remove(config->ggtt_region, > + xe_ggtt_has_low_4m_wa(gt_to_tile(gt)->mem.ggtt)); > config->ggtt_region = NULL; > } > > @@ -514,6 +520,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size) > > size = round_up(size, alignment); > > + /* Wa_14028597154: the VF keeps its top 4MB free, so give it at least 8MB */ > + if (size && xe_ggtt_has_low_4m_wa(ggtt)) > + size = max_t(u64, size, SZ_8M); > + > if (config->ggtt_region) { > err = pf_distribute_config_ggtt(tile, vfid, 0, 0); > if (unlikely(err)) > @@ -545,7 +555,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size) > config->ggtt_region = node; > return 0; > err: > - xe_ggtt_node_remove(node, false); > + xe_ggtt_node_remove(node, xe_ggtt_has_low_4m_wa(ggtt)); > return err; > } > > @@ -751,6 +761,11 @@ static u64 pf_estimate_fair_ggtt(struct xe_gt *gt, unsigned int num_vfs) > > fair = div_u64(available, num_vfs); > fair = ALIGN_DOWN(fair, alignment); > + > + /* Wa_14028597154: each VF needs at least 8MB, see pf_provision_vf_ggtt() */ > + if (fair < SZ_8M && xe_ggtt_has_low_4m_wa(gt_to_tile(gt)->mem.ggtt)) > + fair = 0; > + > xe_gt_sriov_dbg_verbose(gt, "GGTT available(%lluK) fair(%u x %lluK)\n", > available / SZ_1K, num_vfs, fair / SZ_1K); > return fair; > -- > 2.34.1 >