[PATCH] PCI/MSI: Retry a mismatched MSI-X message once during restore

From: raoxu

Date: Thu Nov 26 2026 - 01:50:10 EST


From: Xu Rao <raoxu@xxxxxxxxxxxxx>

Repeated S3 cycles on an Inspur CE720F2 with a Phytium D3000 CPU
leave its Renesas xHCI controller (0000:04:00.0, 1912:0014) without
working interrupts. The keyboard and mouse stop responding, and
newly attached USB devices cannot be used.

The failure was reproduced on UOS 6.6.0-arm64-desktop, revision
d7bafad345e0, build #5.

The affected kernel already includes commit 231c7a57d193
("PCI/MSI: Enable memory decoding before restoring MSI-X messages").
However, inconsistent MSI-X message readbacks still occur after the
restore write on this platform.

Diagnostic excerpts below are wrapped and omit repeated device
prefixes and unrelated fields.

On normal cycle 16, the MSI-X message read back after the PCI
restore write matches the intended message:

[ 1163.085945] xhci-s3 msg-after irq=86 read=1
want=00000000:36850040/00000000
actual=00000000:36850040/00000000

On failing cycle 18, the same readback is all ones. At xHCI resume
entry, the message address is zero:

[ 1285.211630] xhci-s3 msg-after irq=86 read=1
want=00000000:36850040/00000000
actual=ffffffff:ffffffff/ffffffff
[ 1285.213401] xhci-s3 n=18 pci-resume ret=0
read=1 v0=00000000:00000000/00000000/00000000

Here, want is the software-cached target message and actual is the
hardware readback, formatted as address_hi:address_lo/data. The
last field in v0 is vector control. An all-ones read can indicate
an unsuccessful MMIO access; it need not be the stored table value.
The later zero address differs from the expected 0x36850040.

The controller then reports a command timeout:

[ 1295.556532] Command timeout, USBSTS: 0x00000018 EINT PCD
[ 1295.556557] xhci-s3 n=18 timeout cmd=01013c01
dma=0x0000002021506000 irqs=0
[ 1295.556560] xhci-s3 n=18 events scanned=10 limit=0
matched=1 cc=1 last_cmd=0000002021506000

matched=1 and cc=1 identify a successful completion of that Stop
Endpoint command in the event ring. irqs=0 means no xHCI interrupt
was recorded after resume. The command completed, but its completion
was not processed normally.

Read back the message after the existing MSI-X restore write. If
either address field or data differs from the cached message, repeat
the write once. Matching entries receive no additional write.

With the retry, cycle 263 records the incorrect zero address and
then the expected message after the additional write:

[16009.367505] xhci-s3 msix-check irq=86 retry=1 match=1
want=00000000:36850040/00000000
before=00000000:00000000/00000000
after=00000000:36850040/00000000

retry=1 confirms that the mismatch triggered the extra write;
match=1 confirms that the subsequent readback matches the target.

In 500 S3 cycles with temporary diagnostics, 491 comparisons matched
without a retry. Nine mismatches triggered a retry and all nine read
back correctly afterwards. The subsequent xHCI resume snapshots
remained correct, no xHCI command timeout occurred, and a USB storage
device attached after testing enumerated successfully.

Signed-off-by: Xu Rao <raoxu@xxxxxxxxxxxxx>
---
drivers/pci/msi/msi.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 8a0133a6a286..a3304829258d 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -871,6 +871,7 @@ int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int
void __pci_restore_msix_state(struct pci_dev *dev)
{
struct msi_desc *entry;
+ struct msi_msg actual;
bool write_msg;
u16 cmd;

@@ -896,6 +897,15 @@ void __pci_restore_msix_state(struct pci_dev *dev)
msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
if (write_msg)
__pci_write_msi_msg(entry, &entry->msg);
+ if (write_msg && dev->current_state == PCI_D0 &&
+ !pci_dev_is_disconnected(dev) &&
+ !entry->pci.msi_attrib.is_virtual) {
+ __pci_read_msi_msg(entry, &actual);
+ if (actual.address_lo != entry->msg.address_lo ||
+ actual.address_hi != entry->msg.address_hi ||
+ actual.data != entry->msg.data)
+ __pci_write_msi_msg(entry, &entry->msg);
+ }
pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl);
}
}
--
2.50.1