Re: [PATCH v2 1/2] PCI/MSI: Skip MSI-X restoration when configuration is inaccessible

From: Richard Cheng

Date: Mon Nov 16 2026 - 01:18:01 EST


On Fri, Nov 06, 2026 at 10:30:50AM +0800, Farhan Ali wrote:
>
> On 11/6/2026 3:18 AM, Richard Cheng wrote:
> > PCI state restoration runs even when a reset fails. If the device's
> > configuration space remains inaccessible, MSI-X restoration can issue
> > table MMIO accesses that trigger additional errors, including DPC
> > containment.
> >
> > Check the existing PCI Command register read and skip MSI-X restoration
> > if it fails or returns all ones. Preserve the existing handling of a
> > valid Command register with Memory Space Enable clear, which temporarily
> > enables memory decoding while restoring the MSI-X table.
> >
> > Limit the change to MSI-X restoration. Leave other PCI state
> > restoration, driver reset callbacks, and reset return values unchanged.
> >
> > Signed-off-by: Richard Cheng <icheng@xxxxxxxxxx>
>
> Just curious, why are we limiting this to only MSI-X and not MSI? I think
> MSI restoration will fail as well since the config space is not accessible.
>

Hi Farhan,

The orginal intention was to keep the change small, and the failure I hit
was DPC triggered by the MSI-X table writes, which are MMIO, I didn't
expect MSI to cause the same error since it's programmed entirely in
config space, so I left it alone.

But I think you're right, the MSI restoration is equally pointless when
config space is inaccessible, and it ends up writing back values derived
from all-ones reads. I'll cover both MSI and MSI-X in v3.


> > ---
> > drivers/pci/msi/msi.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> > index 8a0133a6a286..37de31f4cfb6 100644
> > --- a/drivers/pci/msi/msi.c
> > +++ b/drivers/pci/msi/msi.c
> > @@ -887,7 +887,11 @@ void __pci_restore_msix_state(struct pci_dev *dev)
> > * Since the MSI-X Table and PBA are in Memory Space, enable it
> > * while restoring them.
> > */
> > - pci_read_config_word(dev, PCI_COMMAND, &cmd);
> > + if (pci_read_config_word(dev, PCI_COMMAND, &cmd) ||
> > + PCI_POSSIBLE_ERROR(cmd)) {
> > + pci_warn(dev, "Device config space inaccessible; unable to restore MSI-X state\n");
> > + return;
> > + }
>
> We have a helper function pci_dev_config_accessible() that does the same
> check, so might be appropriate to use (of course we would have to make the
> function global rather than static).
>

Agree, I'll make it non-static in v3.

> And maybe the check should be moved up before any config space access in
> this function?
>
> Thanks
>
> Farhan
>

Yes, will do, this will be covered in v3.

Thanks for the review.

Best regards,
Richard Cheng.

>
> > pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
> > write_msg = arch_restore_msi_irqs(dev);