From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00F62371D0E for ; Mon, 27 Apr 2026 20:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777322465; cv=none; b=TZsD0O1WTz4L2WQd8gwms33QCwKV/zFZkL/s9MzkdjRHHia1hJv+lyKPSB5e2gqRhDNlO3UfLCKEJlCi/YjQL9iyocdVfnOcosgVIgUzIrKifG8A+IsUijLZc9M/Enii2iJ7wYI56ihKoY2qqyqShTwsCBdwhGhO/p+AHYQmrsM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777322465; c=relaxed/simple; bh=VtybxAi8wqTRTXeCEm16Hr4v3bL40QteE/s5Hrb0gmM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S1RdriQV72deDw3nphXpbzLCq8/hDrMAbYVf/cqYCEEB5dGn3yPtb6zVpLaWWb7DhvyMP5jQOi2Gonda6JbsLNJvI9wg+NicFgkgrklrhTlybKbYujCzQ7jutLFzPdIl9f7nkaswvhr460cB6b+hXNsh30ryd5o2HFqTkappCRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=l+74P8y5; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="l+74P8y5" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-35dac556bb2so6162438a91.1 for ; Mon, 27 Apr 2026 13:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777322463; x=1777927263; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4wM+QOtZ9yfNrPXhT14ztNpzNE+UB64YzKseERpnZeo=; b=l+74P8y5IvcIyLCJhWfduUcJY6PExFFYPz7uwWtbcQhdHNz+n3ynRYHkqzW7G+vjGm fuaW8tW8lVe6yUmC13/ZSNz1n6C1Ml1F0I144uxlRL2b0YspkmehWAZK1X0LolD68Rm4 j2G6tb7gaeV7op3zWdAlUQQepJ2oHb3jxYMbW1a7nQfKa/Tj5TUcCNtF9m4iRYCIGK+r bbqH2ou7D+xISbfUIeRJl8moQ6zWgopeljKQ9nwGYV+J/zwB1M3oDwoc9agR5lrd3bYq Jdr5a7dfzTp5lyy7V8wqooLMB8P5J+pRbEbVkJzDS5ZmXDi1FkswzutNpTATkTRgnElg tx1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777322463; x=1777927263; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4wM+QOtZ9yfNrPXhT14ztNpzNE+UB64YzKseERpnZeo=; b=hbe28NTsRTLE7LM5eVZl41HOX6ijfXpDcIKtEvEEqsFtDJdxlgKbWmOW5tH/FLIAHa 1S0WUksrzhU6S0MWRfaixoUioZCLcf2Q5eZ7lZG+9rDDlIX28F6wqsN1XgdwSLNkFRY5 vyMPUtU6uiEn+LkvsL8wPrRq0Jd3LfF3G3096MsihFGeYiOy3sjrVmQJK6cbvhhHsCr8 6O32jrjfHz2GqowuuqEH/FQ8yZraFrTcxHPxnR+gQ7GdlPi3PVhuEpZnO/2XUvI7sHyR QFH5ek9FzhpDZSt3DV/XKe3uXnwKDSlcp/IZxG1vmqKhaHkKPUIIuLsmgW61PXjIMNkY LB4Q== X-Forwarded-Encrypted: i=1; AFNElJ/ewQ6xHE7zCakYTY0KFdE+xTk5aJHUonvmeJVY3O3ThAjMjpkXF7HvGPmC8YmlH71uopYnAj8i/8I1JWI=@vger.kernel.org X-Gm-Message-State: AOJu0YyeEb1sq2xDyt4OZy9//LvjCOYziiqRndFNV9e7iVuZadcTSGY8 hNRlpTmvkYU3VRZEW/L1ybh9ai1K0Fj2rF8xkh8axrzPEuNU3R/9kbDVkbz3mjhtI5wKA1IvU0h +HWuJzgFD X-Gm-Gg: AeBDievI9DaMUzeJaei6g3YuZJWP3Q981sJMgAyABCOad2DCP+SniugxG3RMjMLrS9T thOEL8GsGnPv0OYCqLa2NNDsAcd3lyA5ylShGhHvrh/sSEpoOyU2DAk6ei/gy5bGIuOswI3nOl6 +8L0pfPrukor77PVaxLaANKni6qF1NlSV9p6N/VzSKeVVzDvYW0YPZVme/g0dCO8H6hxV8xWJBS rdDTWyFkOgxi93hDL7KiKKcMTnrpI1d0ZyofMWSULpWoEtlX1j7AGUcC8tB/3l0p8+2HmS+97qt YHmViR9qvBGnYNOEpIOAXc0D3zTuWib4ThpKnNd8DCNMNXbuMnivrvX3/0+X7EzLNQ7ss93VPjt +NsJvrwpDt3Q973uW1R3rqQg04aCd/9u0tpcGyLXgCqyMescscpsCADb9ZUHutMgMJs+n3tzEEy Cbx5SuJvcQofKSQvvGdT39o0ymebQtlvL06c21lpRBr+8z/vcX3PMnUUHDzl8GdnDhxLYvg1KHk +dIj0KbqAAxtMSy X-Received: by 2002:a17:902:c412:b0:2ae:57e6:616c with SMTP id d9443c01a7336-2b97c3cba0cmr1478985ad.3.1777322462621; Mon, 27 Apr 2026 13:41:02 -0700 (PDT) Received: from google.com (76.9.127.34.bc.googleusercontent.com. [34.127.9.76]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b97ac784c5sm3813795ad.45.2026.04.27.13.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 13:41:01 -0700 (PDT) Date: Mon, 27 Apr 2026 20:40:58 +0000 From: David Matlack To: Jacob Pan Cc: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Rientjes , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Subject: Re: [PATCH v4 05/11] PCI: liveupdate: Inherit bus numbers during Live Update Message-ID: References: <20260423212316.3431746-1-dmatlack@google.com> <20260423212316.3431746-6-dmatlack@google.com> <20260427114745.00000656@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260427114745.00000656@linux.microsoft.com> On 2026-04-27 11:47 AM, Jacob Pan wrote: > On Thu, 23 Apr 2026 21:23:09 +0000 > David Matlack wrote: > > To keep things simple, inherit the secondary and subordinate bus > > numbers on all bridges if any PCI devices were preserved (i.e. even > > bridges without any downstream endpoints that were preserved). This > > avoids accidentally assigning a bridge a new window that overlaps > > with a preserved device that is downstream of a different bridge. > > > > If a bridge is enumerated with a broken topology or has no bus numbers > > set during a Live Update, refuse to assign it new bus numbers and > > refuse to enumerate devices below it. This is a safety measure to > > prevent topology conflicts. > > > > Require that CONFIG_CARDBUS is not enabled to enable > > CONFIG_PCI_LIVEUPDATE since inheriting bus numbers on PCI-to-CardBus > > bridges requires additional work but is not a priority at the moment. > > > > Signed-off-by: David Matlack > > + /* > > + * During a Live Update, preserved devices are allowed to > > continue > > + * performing memory transactions. The kernel must not > > change the fabric > > + * topology, including bus numbers, since that would require > > disabling > > + * and flushing any memory transactions first. > > + * > > + * To keep things simple, inherit the secondary and > > subordinate bus > > + * numbers on _all_ bridges if _any_ PCI devices were > > preserved (i.e. > > + * even bridges without any downstream endpoints that were > > preserved). > > + * This avoids accidentally assigning a bridge a new window > > that > > + * overlaps with a preserved device that is downstream of a > > different > > + * bridge. > > + */ > > + dev->liveupdate_inherit_buses = true; > > + > This flag never gets cleared after the incoming kernel boot up, what if > the user does a manual rescan via sysfs? i.e. > # echo 1 > /sys/bus/pci/rescan > pcibios_assign_all_busses() will never gets called for this device, and > may hit this > if (dev->liveupdate_inherit_buses) { > pci_err(dev, "Cannot reconfigure bridge during > Live Update!\n"); > > So, maybe clear it in pci_liveupdate_finish()? I think we can allo wa rescan to assign new bus numbers once all devices go through pci_liveupdate_finish() by clearing dev->liveupdate_inherit_buses on all devices in pci_flb_finish(). We would need to hold pci_rescan_remove_lock to avoid this racing with such a rescan. Now that you bring up /sys/bus/pci/rescan... I think we also need to set dev->liveupdate_inherit_buses in the outgoing kernel, to avoid bus numbers changing on outgoing preserved devices. pci_flb_preserve() should take pci_rescan_remove_lock and set dev->liveupdate_inherit_buses on all devices, and pci_flb_unpreserve() should do the opposite. If we did all then then /sys/bus/pci/rescan can work like normal as long as no devices are preserved (incoming or outgoing). If any devices are preserved then dev->liveupdate_inherit_buses gets set to prevent bus numbers from changing during a possible rescan.