From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 E4D14375AA8 for ; Tue, 12 May 2026 18:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778611741; cv=none; b=Y/YcK5e3ToVfGBkCWgj+Y9ZLvAuzbiinUFFE4aixpGXOdFzZGSvKY4h/Ai2d5YUGle50Sm5gOMsoT0yatYvzZd2Wp1zQbdRNcMOENgpW8PGpyDtFQ4LXYySf+beAu8LYFg6sb5gAuKCcPMnORxXR1zdkgRAcHx2pcMy8MrEY8Ok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778611741; c=relaxed/simple; bh=gWcVhKA3hjPU8Csfp22CPX9edPkpFWJugHmseYOTvg8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tJ2O1aDcJyQ439v6cR6KC9coJZjUNVT+XZUzWgIM86Rufudtt+43Rm/m8ouyqWLrRZbtrjfP2wYp10ft2O3XTU0nJY9rDT2fqpkt8ifS6fnS2hbsB0C2cncNYBQP5M3Oe8LJZgmz+SDf8vIe2u8XmDODKzcKLlvUlqsX5all7bY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=sl2YDFDo; arc=none smtp.client-ip=209.85.215.202 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=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sl2YDFDo" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c823549b1fcso7905777a12.0 for ; Tue, 12 May 2026 11:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778611738; x=1779216538; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=suL1O4sFcS7rc/4d5OPs7kFFwy+U1yVMYGR9ND8RmlQ=; b=sl2YDFDoAeBSP/Yeu086Tm7a3hSHuXGFZ+AKuhhMRjUnFu9pMBzTBbml/6Cu5nDbAD b+NzWQ4fQnMRkQYezky85HnX/P40WT/9NPG6BNOWXGtwtdC5cAsDzsFWdItWV9bCyBm7 DP2K08tgAdRkGvD74NlYPhXVvYIDP4C9MXg6NAAIccjx3TbteOcaPCm5yzNQRRFXcdbQ TvCNNz7qwAvwgP40lds6I8N9oPRAMaXDelQMow+yTbtDtNrgGJQRq+PBeUV3pJ10K4cS 3JMU2JNIb9kbUp+TQ3ncqCtLPHVW0nAZyXVlfb3YfrMHqT6HjQQze+MwZ6hsly71Kba9 mzFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778611738; x=1779216538; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=suL1O4sFcS7rc/4d5OPs7kFFwy+U1yVMYGR9ND8RmlQ=; b=VgKNratHeQOFcVrinJXjXphcRQSpXalqqM58leOPFIWTEEIiOnr1RHTZaHcojL7EAE 5ftJC6roaYzGlm/tCcSboNxf75HO5QD7yatommltKigvs6zQrCBS2++68mfAnlUstaDM J0NmUsajXI20TsRyTgVyx4xrK/fdb5cu775+vs1fGY6qLoEHtqttZHpZ1Jkuv/lX70pk MhBi2aybRXAz+BMUZ8JisiPB6rh00WGrMuURTiQnHlNNDtUniTOSfoA7X90rg+Jyt/I+ UqCboPij7vEU73eFqMKoZ22dZqNX24rHmLs0TiCsugBmQ8G8xhHj5YvvD9AENr7775en WHvQ== X-Forwarded-Encrypted: i=1; AFNElJ9SwWH/A529KO3/3K6zV+9g34vUaF71jUuf/j9RlYwn3LXRSo5qNGYwuPM76NjHeXXl7Er2HV7Ec0G8TV4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx13MHQv2QVeGj7QIVXf/Nn4F7Ziy0tB0iq/SScwzzLGAbcse7o ZhPSSmutI2MlwOjW4xUuaD7KHBBzcQHl1XWWfB7b43A3S5m+29Ga7iitQ5kyYG53z5715AX3m/7 Hqb48fe2l0xQeMg== X-Received: from pfbdu1.prod.google.com ([2002:a05:6a00:2b41:b0:82f:5b50:db30]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:8012:b0:82c:d986:e917 with SMTP id d2e1a72fcca58-83eebbaf559mr4596279b3a.22.1778611737978; Tue, 12 May 2026 11:48:57 -0700 (PDT) Date: Tue, 12 May 2026 18:48:43 +0000 In-Reply-To: <20260512184846.119396-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260512184846.119396-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260512184846.119396-9-dmatlack@google.com> Subject: [PATCH v5 08/11] PCI: liveupdate: Inherit ARI Forwarding Enable on preserved bridges From: David Matlack To: kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Vipin Sharma , William Tu , Yi Liu Content-Type: text/plain; charset="UTF-8" Inherit the ARI Forwarding Enable on preserved bridges and update pci_dev->ari_enabled accordingly during a Live Update. This ensures that the preserved devices on the bridge's secondary bus can be identified with the same expanded 8-bit function number after a Live Update. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 18 ++++++++++++++++++ drivers/pci/liveupdate.h | 6 ++++++ drivers/pci/pci.c | 8 +++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index e3cd6d76636c..6ab03bd548b3 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -132,6 +132,10 @@ * way after Live Update and ensures that IOMMU groups do not change. Note * that a device will use its inherited ACS flags for the lifetime of its * struct pci_dev (i.e. even after pci_liveupdate_finish()). + * + * * The PCI core inherits ARI Forwarding Enable on all bridges with downstream + * preserved devices to ensure that all preserved devices on the bridge's + * secondary bus are addressable after the Live Update. */ #define pr_fmt(fmt) "PCI: liveupdate: " fmt @@ -720,6 +724,20 @@ bool pci_liveupdate_inherit_acs(struct pci_dev *dev) return true; } +bool pci_liveupdate_inherit_ari(struct pci_dev *dev) +{ + u16 val; + + guard(read_lock)(&dev->liveupdate.lock); + + if (!dev->liveupdate.incoming) + return false; + + pcie_capability_read_word(dev, PCI_EXP_DEVCTL2, &val); + dev->ari_enabled = !!(val & PCI_EXP_DEVCTL2_ARI); + return true; +} + /** * pci_liveupdate_is_incoming() - Check if a device is incoming preserved * @dev: The PCI device to check diff --git a/drivers/pci/liveupdate.h b/drivers/pci/liveupdate.h index c0826ca717e3..fd7693c7ddd2 100644 --- a/drivers/pci/liveupdate.h +++ b/drivers/pci/liveupdate.h @@ -16,6 +16,7 @@ void pci_liveupdate_cleanup_device(struct pci_dev *dev); bool pci_liveupdate_inherit_buses(void); void pci_liveupdate_init_acs(struct pci_dev *dev); bool pci_liveupdate_inherit_acs(struct pci_dev *dev); +bool pci_liveupdate_inherit_ari(struct pci_dev *dev); #else static inline void pci_liveupdate_setup_device(struct pci_dev *dev) { @@ -38,6 +39,11 @@ static inline bool pci_liveupdate_inherit_acs(struct pci_dev *dev) { return false; } + +static inline bool pci_liveupdate_inherit_ari(struct pci_dev *dev) +{ + return false; +} #endif #endif /* DRIVERS_PCI_LIVEUPDATE_H */ diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index cd2c1f2ada92..7e9768dfe092 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3495,7 +3495,7 @@ void pci_configure_ari(struct pci_dev *dev) u32 cap; struct pci_dev *bridge; - if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) + if (!pci_is_pcie(dev) || dev->devfn) return; bridge = dev->bus->self; @@ -3506,6 +3506,12 @@ void pci_configure_ari(struct pci_dev *dev) if (!(cap & PCI_EXP_DEVCAP2_ARI)) return; + if (pci_liveupdate_inherit_ari(bridge)) + return; + + if (pcie_ari_disabled) + return; + if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) { pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); -- 2.54.0.563.g4f69b47b94-goog