From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBF71FD9E26 for ; Fri, 27 Feb 2026 00:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7/IXhnnADeIhqB8XjstCGNDdQ5WTGWIX32H4Qcjj2Qw=; b=XSB7jMtkrSs1UcmFUNjLviaiIQ mTtBl7/Yeu9IQLcTYzND3QpwcYjmiIUkn2gfoeIqcPcFG68iXtit/Y4dYj+NKGlEFVJEpLxPSr1SD TtVZ8tlIs7VGnzEg6klaPQIqMkpB5XAgSdgA2Ctl6EeAMMpNveTQFkabLDu5oZmP5r3DvvoY9yAfk lnHvFHyQU2abd5/BIBE1M6jpaQ6oPIKTE8op/DRPdpLsRwRGQ2xIVHics8uyIk6amfO7wX0FGKLgv XXhQJC48c3OzkQ8hGA0/WEgAh2l8hrZ0aQy0OGAUhGwOhhpUYPXfuKeNoJuAUrb1dsjUoQMiXpPSM MS/OJV7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vvlHf-00000007OyR-3UBH; Fri, 27 Feb 2026 00:00:43 +0000 Received: from flow-b4-smtp.messagingengine.com ([202.12.124.139]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vvlHc-00000007Oy4-2bdA for kexec@lists.infradead.org; Fri, 27 Feb 2026 00:00:42 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id C7E2F13010DF; Thu, 26 Feb 2026 19:00:36 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 26 Feb 2026 19:00:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1772150436; x=1772157636; bh=7/IXhnnADeIhqB8XjstCGNDdQ5WTGWIX32H4Qcjj2Qw=; b= KfdyHubK7T6mgbCHRhIr5mD6ruTZ/iS4/fLNIWNjGnhl1gAn6fwi3ppJ06Gd2dJg 4j+2iEI1NgIVGtQ1kbajwBmSZ3kucQpabC7rYBW1w7C9Ns95JC7G2sCDHFGTcMha kv7zoWe4YzeFKlalXC30X01vESpzdydowfQQQlWMPV+oZxWYLCz283lVR3zv2Nju eVuYQ9dFy2UDeoXJmZYe7S7vvDRP/TCyDm8hpE/sG7rbMKSh1TvkY8QDSsY8Cpg1 4cwajHsmuyHaZiq7C2NI+9LmP/V6+FqeD6vXWgw/vHSpDK1AbcXQc1HLUA6FGUn8 /XDw5I/P8HNRXjdutcMDoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1772150436; x= 1772157636; bh=7/IXhnnADeIhqB8XjstCGNDdQ5WTGWIX32H4Qcjj2Qw=; b=Z glLpMDrdH3ybIl6Jfbe8ZlqPwGEGiWIaKq84xdJ3XK72dVh252bgdeEHLhNGg88w 3pDfMb8G+6ch5QZiYiTb2vdJac0ZiodwaNo8erWlfsW8wftbBkxgQ4hNNT4SzETg 9xNYNGzd4JBoge3B2Vd6F//62u+9NBZ8XoKc5pbywbz8xoA1EsZcAiF6eo4hfyBI JQaANqURgm9EvX0L6bVDkSvv6JL/0ItofsOMGisEwrBldJgavCTL7e3d4uzr8Pqy wuJsoR33BNh7JMaPMshYytFmb9FjXE8o89NSJtN+p3BgZBE7aDmAMqP3zTdWMVzY 8D3Z60+RKBqTkQZw6Ixcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeejgeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkjghfofggtgfgsehtjeertdertddvnecuhfhrohhmpeetlhgvgicu hghilhhlihgrmhhsohhnuceorghlvgigsehshhgriigsohhtrdhorhhgqeenucggtffrrg htthgvrhhnpedvkeefjeekvdduhfduhfetkedugfduieettedvueekvdehtedvkefgudeg veeuueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grlhgvgiesshhhrgiisghothdrohhrghdpnhgspghrtghpthhtohepgeehpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegumhgrthhlrggtkhesghhoohhglhgvrdgtohhmpd hrtghpthhtoheprghjrgihrggthhgrnhgurhgrsehnvhhiughirgdrtghomhdprhgtphht thhopehgrhgrfhesrghmrgiiohhnrdgtohhmpdhrtghpthhtoheprghmrghsthhrohesfh gsrdgtohhmpdhrtghpthhtoheprghpohhpphhlvgesnhhvihguihgrrdgtohhmpdhrtghp thhtoheprghkphhmsehlihhnuhigqdhfohhunhgurghtihhonhdrohhrghdprhgtphhtth hopegrnhhkihhtrgesnhhvihguihgrrdgtohhmpdhrtghpthhtohepsghhvghlghgrrghs sehgohhoghhlvgdrtghomhdprhgtphhtthhopegthhhrihhslheskhgvrhhnvghlrdhorh hg X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Feb 2026 19:00:32 -0500 (EST) Date: Thu, 26 Feb 2026 17:00:30 -0700 From: Alex Williamson To: David Matlack Cc: Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Kevin Tian , kexec@lists.infradead.org, kvm@vger.kernel.org, Leon Romanovsky , Leon Romanovsky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Lukas Wunner , " =?UTF-8?B?TWljaGHFgg==?= Winiarski" , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , "Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?=" , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu , Zhu Yanjun , alex@shazbot.org Subject: Re: [PATCH v2 10/22] vfio/pci: Skip reset of preserved device after Live Update Message-ID: <20260226170030.5a938c74@shazbot.org> In-Reply-To: <20260129212510.967611-11-dmatlack@google.com> References: <20260129212510.967611-1-dmatlack@google.com> <20260129212510.967611-11-dmatlack@google.com> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260226_160041_134084_FF563E32 X-CRM114-Status: GOOD ( 25.24 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org On Thu, 29 Jan 2026 21:24:57 +0000 David Matlack wrote: > From: Vipin Sharma > > Do not reset the device when a Live Update preserved vfio-pci device is > retrieved and first enabled. vfio_pci_liveupdate_freeze() guarantees the > device is reset prior to Live Update, so there's no reason to reset it > again after Live Update. > > Since VFIO normally uses the initial reset to detect if the device > supports function resets, pass that from the previous kernel via > struct vfio_pci_core_dev_ser. > > Signed-off-by: Vipin Sharma > Signed-off-by: David Matlack > --- > drivers/vfio/pci/vfio_pci_core.c | 22 +++++++++++++++++----- > drivers/vfio/pci/vfio_pci_liveupdate.c | 1 + > include/linux/kho/abi/vfio_pci.h | 2 ++ > include/linux/vfio_pci_core.h | 1 + > 4 files changed, 21 insertions(+), 5 deletions(-) > > diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c > index b01b94d81e28..c9f73f597797 100644 > --- a/drivers/vfio/pci/vfio_pci_core.c > +++ b/drivers/vfio/pci/vfio_pci_core.c > @@ -515,12 +515,24 @@ int vfio_pci_core_enable(struct vfio_pci_core_device *vdev) > if (ret) > goto out_power; > > - /* If reset fails because of the device lock, fail this path entirely */ > - ret = pci_try_reset_function(pdev); > - if (ret == -EAGAIN) > - goto out_disable_device; > + if (vdev->liveupdate_incoming_state) { > + /* > + * This device was preserved by the previous kernel across a > + * Live Update, so it does not need to be reset. > + */ > + vdev->reset_works = vdev->liveupdate_incoming_state->reset_works; > + } else { > + /* > + * If reset fails because of the device lock, fail this path > + * entirely. > + */ > + ret = pci_try_reset_function(pdev); > + if (ret == -EAGAIN) > + goto out_disable_device; > + > + vdev->reset_works = !ret; > + } This could maybe be incrementally cleaner in a int vfio_pci_core_probe_reset(struct vfio_pci_core_device *vdev) helper. > > - vdev->reset_works = !ret; > pci_save_state(pdev); > vdev->pci_saved_state = pci_store_saved_state(pdev); Isn't this a problem too? In the first kernel we store the initial, post reset state of the device, now we're storing some arbitrary state. This is the state we're restore when the device is closed. > if (!vdev->pci_saved_state) > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c > index 1ad7379c70c4..c52d6bdb455f 100644 > --- a/drivers/vfio/pci/vfio_pci_liveupdate.c > +++ b/drivers/vfio/pci/vfio_pci_liveupdate.c > @@ -57,6 +57,7 @@ static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *args) > > ser->bdf = pci_dev_id(pdev); > ser->domain = pci_domain_nr(pdev->bus); > + ser->reset_works = vdev->reset_works; > > args->serialized_data = virt_to_phys(ser); > return 0; > diff --git a/include/linux/kho/abi/vfio_pci.h b/include/linux/kho/abi/vfio_pci.h > index 9bf58a2f3820..6c3d3c6dfc09 100644 > --- a/include/linux/kho/abi/vfio_pci.h > +++ b/include/linux/kho/abi/vfio_pci.h > @@ -34,10 +34,12 @@ > * > * @bdf: The device's PCI bus, device, and function number. > * @domain: The device's PCI domain number (segment). > + * @reset_works: Non-zero if the device supports function resets. > */ > struct vfio_pci_core_device_ser { > u16 bdf; > u16 domain; > + u8 reset_works; > } __packed; > > #endif /* _LINUX_LIVEUPDATE_ABI_VFIO_PCI_H */ > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h > index 350c30f84a13..95835298e29e 100644 > --- a/include/linux/vfio_pci_core.h > +++ b/include/linux/vfio_pci_core.h > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #ifndef VFIO_PCI_CORE_H > #define VFIO_PCI_CORE_H Wouldn't a forward declaration do, and the kho/abi include can be kept out of the public header? Also should be in the previous patch? Thanks, Alex