From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796215740; b=wGxZI4HDIC/e2GgliW+QB4BswcqCzZ6vUOV9jus1yxD0kHk3gfITJYg0RyfUpBwjJduy ra+ywHWBwXPXu5VqJWg2TUjeM81mhahnMn2b0xQGahX2CMVdw075oqU1GozBon+LGsdAE cDMbUVNANB8n5lYdlltjNU6d6/jlFtL6AlO+TONdb0sSOPwgYynBIGXUgvfZnstLtkR6e dVKlyYuzQEMgjhmfk62+8XAEOExSsCrODbxE3BpGlNXC013gu5Z8/XK2kMBVkxrMI3id+ aTyfqdCxY5LXtD5B09sBGnhOwKQl2ne9rVCQfUOByejnktWJubvceWvKEPnE+E/zilw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215740; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:Date:To:cc: Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type; bh=II6IuWN5JhIaYUrp2RAuSusHTh8wyqcYW6j91FAO5vk=; b=b18gUgWaeN7TMwEZIOUBlluuux/cALH/04rHlQb8vFNgzCJ8yNDWYHzqENDgDfK8WD+m V9i0718BEo6medlLj0O4dFwEsEKDrFQUjVgxhdvLWLVsM1YdjVqhHACerjOej3oGjW/XQ 1ubJnQCO4ztpCpVUF0GIZt8gmEaiRzj3syvfPoMyHWjcxTN56mBUC2zsY4uAPwmsi9w0n YmBDYGCbz7cf4L6YF5vLFog2xSAcP2R4GIeHQ0HemaglylVbVebXqmljafZJ1Ty2l3yug O96x5d6wzKtgg7qbR1A75M6faSFk6ez4kRlqUuYye1oCfpuQwKSQoRV2s+TAYrwhylA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Rwv1Tf61; arc=none smtp.remote-ip=192.198.163.9 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4458606A329; Wed, 2 Dec 2026 12:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B4458606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com 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=Rwv1Tf61 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796215739; x=1827751739; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=II6IuWN5JhIaYUrp2RAuSusHTh8wyqcYW6j91FAO5vk=; b=Rwv1Tf610Mr7JSPd8wZHD3jS8XgqleOs9RG11VA/+tlNfm8CbTtL/Osf f6oNJhVAMtlUr2EkguqP02F0V4IWa6f2+f5KeGgRlCk5o0j7OrfHP2hl2 XsV+3nujnrGPISLuI3Em2DNveg6cfakaasOlEF+0aoB5xn8l+Mn5cpBCV F3AZcEm/UFsqkaaNKaGRFMPBbjYugrpck2cH3R5zZFDf1TABUCsQVO/CM R2/N/gPFEPOf/jEDLJ6zDoVmDB+GVVZmpPnkzDPuqyNyywB40vaSfmpB6 UbSHCiZHidyzoBcM5WiNOES3BQ8MrH8epwk2brlF/ALTVgo6KxH2/t2dH w==; X-CSE-ConnectionGUID: K+OLJ/4DT3a24OWir0QwXA== X-CSE-MsgGUID: b3vh3YS+SyGb9cgFdwqy3g== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="4994130" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="4994130" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 04:48:58 -0800 X-CSE-ConnectionGUID: drbwLb66Q/uA/rUhUsXWdQ== X-CSE-MsgGUID: Pr0YTJnhR3Ku3SQlSdHhmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13522923" Received: from ijarvine-mobl1.ger.corp.intel.com (HELO localhost) ([10.245.245.219]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 04:48:56 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Wed, 2 Dec 2026 14:48:53 +0200 (EET) To: Greg Lamberson cc: Bjorn Helgaas , =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= , linux-pci@vger.kernel.org, LKML , regressions@lists.linux.dev Subject: Re: [PATCH] PCI: Don't move a window's start when it holds a non-power-of-2 resource In-Reply-To: <179619168710.49678.17788537403657229665@lamco.io> Message-ID: <14697f43-d43b-886d-7cc9-36f96c3f100d@linux.intel.com> References: <179619168710.49678.17788537403657229665@lamco.io> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 2 Dec 2026, Greg Lamberson wrote: > pci_align_resource() moves a bridge window's start down by the part of > its size that isn't a multiple of its alignment, so the smaller > resources can fill the space before the first aligned address. That > relies on every resource below the window having a power-of-2 size. An > IOV resource is the VF BAR size times TotalVFs, which isn't a power of 2 > unless TotalVFs is. > > On an Intel Arc Pro B60, BAR 2 is 32 GiB and each of the seven VF BAR 2s > is 8 GiB, so the window needs 88 GiB plus 128 MiB, aligned to 32 GiB. > Its start is moved down by 24 GiB plus 128 MiB, BAR 2 is placed at the > lowest 32 GiB boundary in the window, and the 56 GiB IOV resource then > fits neither below nor above it. Since v7.1, enabling SR-IOV fails: > > xe 0000:03:00.0: not enough MMIO resources for SR-IOV > xe 0000:03:00.0: [drm] PF: Failed to enable 5 VFs (-ENOMEM) > > Keep the aligned start for a window that holds a resource whose size > isn't a power of 2, directly or behind child bridges. > > Fixes: 9036bd0efcb6 ("PCI: Align head space better") > Cc: stable@vger.kernel.org # v7.1+ > Signed-off-by: Greg Lamberson > --- > I tested this on Proxmox's 7.3.5 kernel with the patch applied, on an > AMD Raphael board with the B60 behind the card's own switch. With the > patch, VF BAR 2 is assigned at the same address v7.0 gives it and all > five VFs come up. Without it, the same kernel logs the two lines above. > I haven't booted pci/next or mainline on that machine. The patch > applies cleanly to both, and setup-res.c builds with W=1 on pci/next > without warnings. > > I used Claude (claude-opus-5-5) to trace the cause and write this > patch. I've reviewed the change and tested it on the affected machine. Hi, Have you tested if the PCI resource placement generalization series v5 fixes your problem: https://lore.kernel.org/linux-pci/20261106134341.39493-1-ilpo.jarvinen@linux.intel.com/ -- i. > drivers/pci/setup-res.c | 50 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 50 insertions(+) > > diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c > index 376f09630a4a..8b2b6d5ef5ed 100644 > --- a/drivers/pci/setup-res.c > +++ b/drivers/pci/setup-res.c > @@ -260,10 +260,49 @@ resource_size_t pci_resource_alignment(const struct pci_dev *dev, > return resource_alignment(res); > } > > +/* > + * Whether @win of @bus->self holds, directly or behind child bridges, a > + * resource whose size isn't a power of 2. An IOV resource is the VF BAR size > + * times TotalVFs, so it's a power of 2 only when TotalVFs is. > + */ > +static bool pbus_window_holds_npot(struct pci_bus *bus, > + const struct resource *win) > +{ > + struct pci_dev *dev; > + > + list_for_each_entry(dev, &bus->devices, bus_list) { > + struct resource *r; > + int i; > + > + pci_dev_for_each_resource(dev, r, i) { > + if (!r->flags || (r->flags & IORESOURCE_DISABLED) || > + !resource_size(r)) > + continue; > + if (pbus_select_window(bus, r) != win) > + continue; > + if (pci_resource_is_bridge_win(i)) { > + if (dev->subordinate && > + pbus_window_holds_npot(dev->subordinate, r)) > + return true; > + continue; > + } > + if (!is_power_of_2(resource_size(r))) > + return true; > + } > + } > + > + return false; > +} > + > /* > * For mem bridge windows, try to relocate tail remainder space to space > * before res->start if there's enough free space there. This enables > * tighter packing for resources. > + * > + * The head can only be filled when every resource below the window has a > + * power-of-2 size. A resource that isn't one may be larger than the head and > + * still need its own alignment, so a window holding one keeps its aligned > + * start. > */ > resource_size_t pci_align_resource(struct pci_dev *dev, > const struct resource *res, > @@ -290,6 +329,17 @@ resource_size_t pci_align_resource(struct pci_dev *dev, > if (empty_res->start > start_addr) > return res->start; > > + /* > + * @res is the allocator's copy of the window, so find the window itself > + * among the bridge's resources by type. > + */ > + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && dev->subordinate && > + pbus_window_holds_npot(dev->subordinate, > + pci_resource_n(dev, res->flags & IORESOURCE_PREFETCH ? > + PCI_BRIDGE_PREF_MEM_WINDOW : > + PCI_BRIDGE_MEM_WINDOW))) > + return res->start; > + > pci_dbg(dev, "%pR: moving candidate start address below align to %llx\n", > res, (unsigned long long)start_addr); > return start_addr; > -- i.