Re: [PATCH v11 09/13] PCI: liveupdate: Adopt ACS controls in incoming preserved devices

From: David Matlack

Date: Fri Nov 20 2026 - 14:30:41 EST


On Fri Nov 20, 2026 at 7:17 AM PST, Pranjal Shrivastava wrote:
> On Wed, Nov 18, 2026 at 10:37:00PM +0000, David Matlack wrote:
>> Adopt Access Control Services (ACS) controls on all incoming preserved
>> devices (endpoints and upstream bridges) during a Live Update.
>>
>> Adopting ACS controls avoids changing routing rules while memory
>> transactions are in flight from preserved devices. It also keeps IOMMU
>> groups from changing during or after Live Update.
>>
>> The adopted controls are recorded by the pci_save_state() call in
>> pci_bus_add_device(), which runs before drivers bind, so they are
>> reapplied by pci_restore_state() if the device is reset. Allocate the
>> ACS save buffer for incoming preserved devices even if they match a
>> device-specific ACS quirk, since their adopted controls live in the ACS
>> capability, and panic if it could not be allocated.
>>
>> To simplify ACS adoption, reject preserving any devices that require
>> quirks to enable ACS as those quirks would also have to take Live Update
>> into account. If such a quirk matches an incoming preserved device
>> anyway, e.g. because it was added in the new kernel, log a warning and
>> adopt the device's ACS controls regardless, rather than reprogram a
>> device in the path of a preserved device's memory transactions.
>>
>> Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
>> ---
>> drivers/pci/liveupdate.c | 75 ++++++++++++++++++++++++++++++++++++++++
>> drivers/pci/liveupdate.h | 16 +++++++++
>> drivers/pci/pci.c | 13 +++++--
>> 3 files changed, 102 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c
>> index 00d6fa5236e9..b99a88c2c199 100644
>> --- a/drivers/pci/liveupdate.c
>> +++ b/drivers/pci/liveupdate.c
>> @@ -123,6 +123,9 @@
>> *
>> * * The device cannot be a Virtual Function (VF).
>> *
>> + * * The device cannot require device-specific quirks to enable Access
>> + * Control Services (ACS).
>> + *
>
> [...]
>
>> +#include "liveupdate.h"
>> #include "pci.h"
>>
>> DEFINE_MUTEX(pci_slot_mutex);
>> @@ -1071,9 +1073,13 @@ static void pci_allocate_acs_save_buffer(struct pci_dev *dev)
>> /*
>> * Devices that rely on device-specific quirks to enable an ACS
>> * equivalent keep that configuration outside of the ACS Control
>> - * register, so they are configured from scratch on restore.
>> + * register, so they are configured from scratch on restore. The
>> + * exception is devices preserved across a Live Update, which always
>> + * adopt the ACS controls established by the previous kernel and need
>> + * the buffer to keep them across resets.
>> */
>> - if (pci_need_dev_specific_enable_acs(dev))
>> + if (pci_need_dev_specific_enable_acs(dev) &&
>> + !pci_liveupdate_was_incoming(dev))
>> return;
>>
>
> The ACS save buffer is forced for incoming devices that match an
> enable_acs quirk, but neither existing quirk keeps its controls where
> the generic code saves them (Intel PCH Root Ports have no ACS cap,
> SPT/UPT has the Control register at +8, not +6). Is the intent that
> such devices just lose their adopted controls if they ever lose config
> state later? (e.g. a Root Port D3 cycle after pci_liveupdate_finish())
> If so, maybe worth calling it out in a comment?

The previous kernel refuses to preserve any device that requires a
device-specific quirk to enable ACS, and every kernel that supports
preserving PCI devices already has the PCH and SPT/UPT quirks. So
neither of those quirks can match a device that was preserved by the
previous kernel.

A quirk can only match an incoming preserved device if it is new in the
current kernel (or the previous kernel was built without
CONFIG_PCI_QUIRKS). In that case the previous kernel did not apply the
quirk and programmed the device's standard ACS Control register, which
is what the save buffer captures. So the device just continues with its
non-quirked ACS configuration from the previous kernel.

I will expand the comment and the changelog in v12 to make that clearer:

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b5b578355a1b..f3d58b5e7a5d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1073,10 +1073,14 @@ static void pci_allocate_acs_save_buffer(struct pci_dev *dev)
/*
* Devices that rely on device-specific quirks to enable an ACS
* equivalent keep that configuration outside of the ACS Control
- * register, so they are configured from scratch on restore. The
- * exception is devices preserved across a Live Update, which always
- * adopt the ACS controls established by the previous kernel and need
- * the buffer to keep them across resets.
+ * register, so they are configured from scratch on restore.
+ *
+ * The exception is devices preserved across a Live Update. The
+ * previous kernel refuses to preserve devices that need such a quirk,
+ * so a quirk can only match here if the previous kernel did not apply
+ * it (e.g. the quirk is new in this kernel). The previous kernel then
+ * programmed the standard ACS Control register, so save it to keep
+ * the adopted controls across resets.
*/
if (pci_need_dev_specific_enable_acs(dev) &&
!pci_liveupdate_was_incoming(dev))

>
> Apart from that:
>
> Reviewed-by: Pranjal Shrivastava <praan@xxxxxxxxxx>
>
> Thanks,
> Praan

Thanks for the review!