From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 311C5371867 for ; Mon, 8 Jun 2026 11:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780919913; cv=none; b=HiNs2SxkenTdqFESOZYNmK7AdSux8B7hYEfxZhZdzn3PF3AkQ65TIOgeD4UsxS68o4h4lD5D41nWbx8k/WlIhXain9hQUlMJsBzinOsGpeIq5n+Wj7PRBorzlU2QDqI3BoAvjnPer9rJKd58xJjU8uZil+eW2P8ngjtKcnbk+gA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780919913; c=relaxed/simple; bh=lRADBLgkLa3yPDCBWXAV1K5xrYWvA85f/dwiJB5B0jw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bdx8EIiyZNAA9AzdTEPLjRIXHrsdto5CP0g8L+8YcnngeO1XJsVGYmOt0XAgql5IBY3jvinWauE8fqTWAVu8KmxpZb4S0XGD7/LBgO1RZ856zd8RZUnnHgfsSfPCmZY3+b4Lj6OZbIjlJfybajKSHWsuznNJVPd7dYHMxUxip3U= 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=bSxhHpFZ; arc=none smtp.client-ip=209.85.214.171 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="bSxhHpFZ" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2bf2911f93cso298115ad.1 for ; Mon, 08 Jun 2026 04:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780919910; x=1781524710; 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=8CB2k4eqEZ/J9Iam1QvalqCdyib5VuBIoGU6FvxH5X0=; b=bSxhHpFZsVgn9x8ibm2PwJlVAoyYbkqJl073AizUP+8WcOD4/OMYfrnSyMNm3oZrx6 F7ueLeJX02jewkcw8yGBRjWBChNfDTutokXjnPYsgVpQr0IT/yFgZyLUNMabegc4gBKU 8M8ajpSewCYI1BuRNlGM3TJ+FQhbbOISAaUwl0zY8KzJ9NyGeoY5WsXRKU+6II76E/Iz 5W2dEHqdmm+d72lzWs2pVqXu7MxHYosWp4Tw7kLzOARSlgWXMHsIMYraMoOQRF5KvcV7 JJfa4ZZj0cmZjKtzfuOytS0yA+k/o1+2kacpLGzVQQu3BXxz+8fdqZ29hOfAzP8gRNdu oxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780919910; x=1781524710; 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=8CB2k4eqEZ/J9Iam1QvalqCdyib5VuBIoGU6FvxH5X0=; b=IOeK70A0N9ULbUXxK8w7moDNoY7d8K5QAUrYrLsF7fjriIQ+GBeWi6kc8ig999iLec dcMpJcbbqEXy2EtjSIqj7Rw0fKcsLPDm6Kx4FtLb+9mnYBcwKpRXfgRpgNU9bNkYvd8Y b2l0gloaX8evSoV/DKZTv5VYVRlhJd3ZZGBY7BOASvJEjQZrbN/Wycj2mxcv1wEEax1p DqZS080/7dcIhdyQ31hzWC5XIVGnHUIQo4nUfL7eswxzYVFLj6D2S5wYLbz3op/22Qn9 oevrRL6lzT1WOcvpZqHNWH149MwNMHKPMrH92bdYlBR6loHJ9JJth+4zLlhFfjw3GRAd ymjg== X-Forwarded-Encrypted: i=1; AFNElJ+Z7dfshaABVgXiXfQOHJtKMOU7zniIpI+w2Jhx182HlsmJg6LW12I2oyI+6WKCuSL+JeWBuUj6sMscyfA=@vger.kernel.org X-Gm-Message-State: AOJu0YymM4FkqIM+2R48pEyUN1sVI9d0GkuKgksxW3uWi3stMDaZGuMt NtVzvMDyMc39MrzOVH1p5E43+Gk3QM3i/SmAmHor7FLf/HvACM/emquu1LuSh60/1w== X-Gm-Gg: Acq92OH6H5QmvpgPBevKOwbkklrAM3gaVH2kRTKQf0f6nApA2Vq9qUNkI8v818Ax+Dc Zul+9TqfoFqj8qfSIMNA6xRcno3YBGrm2o+WdeBo/2GHm6kHesTIzxHjHvQ4FVY54Cl78DEL815 anDF3HkWkSze6PqBwrNzTf/ksbihxA5umASyB8ul3hA+KCj98oYTwMgyDkqj3XXaM055Nw9IuAe VoAEH3hbEjH2ECEC7+y5REftAG+OJATKdit8QYH3TH1V/kv+xDdkxkObmIkfLOB/pCqp0JHZtNf 6UlNov+WKTGy8G8T1vzSRiqoVAvRH90WJQCm86Y1g9zaf09PxiYYTSCTlGrHXBCQ8o55ZrQzmok 4cTtz1rAKhcRIqhK8FB4EK4Ne3Wawd0mkZ35qBHoeJzWaxzf1Ckl6NifbwxNgeBqwG4ErMXB59p y9piY416ZumC0EkNjOo+o9EKhi36rnSbnmqBZCaqxVFJkWXLyCqusfAcW/DIGxcMjrZgnn7rU= X-Received: by 2002:a17:902:f787:b0:2b2:70ba:305c with SMTP id d9443c01a7336-2c1eafbd48cmr5222305ad.8.1780919910000; Mon, 08 Jun 2026 04:58:30 -0700 (PDT) Received: from google.com (199.255.142.34.bc.googleusercontent.com. [34.142.255.199]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0b56c5sm15740485a12.27.2026.06.08.04.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 04:58:29 -0700 (PDT) Date: Mon, 8 Jun 2026 11:58:20 +0000 From: Pranjal Shrivastava To: David Matlack Cc: 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 , Jacob Pan , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pratyush Yadav , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Vipin Sharma , William Tu , Yi Liu Subject: Re: [PATCH v6 11/12] PCI: liveupdate: Do not disable bus mastering on preserved devices during kexec Message-ID: References: <20260522202410.3104264-1-dmatlack@google.com> <20260522202410.3104264-12-dmatlack@google.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: <20260522202410.3104264-12-dmatlack@google.com> On Fri, May 22, 2026 at 08:24:09PM +0000, David Matlack wrote: > Do not disable bus mastering on outgoing preserved devices during > pci_device_shutdown() for kexec. > > Preserved devices must be allowed to perform memory transactions during > a Live Update to ensure continuous operation. Clearing the bus > mastering bit would prevent these devices from issuing any memory > requests while the new kernel boots. > > Because bridges upstream of preserved endpoint devices are also > automatically preserved, this change also avoids clearing bus mastering > on them. This is critical because clearing bus mastering on an upstream > bridge prevents the bridge from forwarding memory requests upstream (i.e. > it would prevent the endpoint device from accessing system RAM and doing > peer-to-peer transactions with devices not downstream of the bridge). > > Signed-off-by: David Matlack > --- > drivers/pci/liveupdate.c | 11 +++++++++++ > drivers/pci/liveupdate.h | 6 ++++++ > drivers/pci/pci-driver.c | 7 +++++-- > 3 files changed, 22 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c > index d404e64a4e55..a6f2790bc1bf 100644 > --- a/drivers/pci/liveupdate.c > +++ b/drivers/pci/liveupdate.c > @@ -132,6 +132,10 @@ > * * 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. > + * > + * * The PCI core does not disable bus mastering on outgoing preserved devices > + * during kexec. This allows preserved devices to issue memory transactions > + * throughout the Live Update. > */ > > #define pr_fmt(fmt) "PCI: liveupdate: " fmt > @@ -790,6 +794,13 @@ int pci_liveupdate_configure_ari(struct pci_dev *dev) > return 0; > } > > +bool pci_liveupdate_is_outgoing(struct pci_dev *dev) > +{ > + guard(rwsem_read)(&pci_liveupdate.rwsem); > + pci_WARN_ONCE(dev, !dev->liveupdate.frozen, "Preservation status is unstable!\n"); > + return dev->liveupdate.outgoing; > +} > + [...] > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > index f7a5e65a7c75..0b1f8d01d7a5 100644 > --- a/drivers/pci/pci-driver.c > +++ b/drivers/pci/pci-driver.c > @@ -546,11 +546,14 @@ static void pci_device_shutdown(struct device *dev) > /* > * If this is a kexec reboot, turn off Bus Master bit on the > * device to tell it to not continue to do DMA. Don't touch > - * devices in D3cold or unknown states. > + * devices being preserved for Live Update or in D3cold or > + * unknown states. > + * > * If it is not a kexec reboot, firmware will hit the PCI > * devices with big hammer and stop their DMA any way. > */ > - if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot)) > + if (kexec_in_progress && !pci_liveupdate_is_outgoing(pci_dev) && > + pci_dev->current_state <= PCI_D3hot) > pci_clear_master(pci_dev); > } Looks good. Reviewed-by: Pranjal Shrivastava Thanks, Praan