Re: [PATCH 3/4] PCI: Skip state restoration when configuration is inaccessible

From: Cheatham, Benjamin

Date: Fri Oct 30 2026 - 17:15:56 EST


On 9/28/2026 9:04 PM, Richard Cheng wrote:
> pci_dev_restore() restores state even when the device is inaccessible.
> MSI-X restoration can then issue MMIO accesses that trigger DPC.
>
> Check configuration accessibility before restoring state. Keep driver
> reset callbacks and reset return values unchanged.
>
> Signed-off-by: Richard Cheng <icheng@xxxxxxxxxx>
> ---
> drivers/pci/pci.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index d59a374a350d..9a343f8b5429 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5127,7 +5127,9 @@ static void pci_dev_restore(struct pci_dev *dev)
> const struct pci_error_handlers *err_handler =
> dev->driver ? dev->driver->err_handler : NULL;
>
> - pci_restore_state(dev);
> + /* MSI-X restoration may access device MMIO. */
> + if (pci_dev_config_accessible(dev, "restore state"))
> + pci_restore_state(dev);

Again, far from an expert, but this one seems a bit more cut and dry. I looked at the CXL reset_done handler
since I know that code, and it seems like it expects this state to be restored. There's a good amount of
drivers that implement this handler, so messing with this seems a bit cavalier. Seeing the next patch kind
of confirms that as well. If this is going to change you'll probably need to check and/or modify the other
handlers as well, or mention why they're left unmodified in the commit description.

If MSI-X restoration is the thing causing the issue, then maybe the right move is to leave MSI-X unrestored
in pci_restore_state()? It still has the same issue as not restoring everything, but the surface area is
a lot smaller.

I think the best thing to do would be to come at this from the device's driver that you're seeing this issue
with though.

Thanks,
Ben

>
> /*
> * dev->driver->err_handler->reset_done() is protected against