Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v2] PCI/MSI: Retry a mismatched MSI-X message once during restore
@ 2026-11-30  7:50 raoxu
  2026-11-30  7:59 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-11-30  7:50 UTC (permalink / raw)
  To: bhelgaas
  Cc: luiz.von.dentz, tglx, pmenzel, wangruikang, pengpeng, ligongwei,
	maciej.fijalkowski, halves, 18255117159, xiangzao, vidyas,
	lihaoxiang, linux-pci, raoxu

From: Xu Rao <raoxu@uniontech.com>

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. Manually resetting the
controller restores operation.

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
messages have been restored.

Read back each non-virtual MSI-X message after restoring it when the
device is in D0 and its PCI channel is online. If the message differs
from the cached value, retry the write once before restoring vector
control. Skip the readback when the PCI channel is offline, consistent
with the existing MSI-X programming paths.

In an earlier diagnostic run of 500 S3 cycles, nine initial MSI-X
message readbacks differed from the cached values. All nine matched
after one additional write. Subsequent testing of the single-retry
approach completed 1000 S3 cycles without reproducing the failure.

Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
Changes in v2:
- Use pci_channel_offline() instead of pci_dev_is_disconnected() to
  avoid MSI-X table reads while the PCI channel is frozen or permanently
  failed, as pointed out by Sashiko AI review.
- Keep the single-retry mechanism unchanged and update the test results
  to 1000 successful S3 cycles on the affected platform.

v1: https://lore.kernel.org/all/4EDB2ADA2CFC5963+20261126064901.1798104-1-raoxu@uniontech.com/
Review: https://lore.kernel.org/all/sashiko-outbox-234935@kernel.org/

 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 8a0133a6a28632261c2f5efd399efddddd011eab..f7d6dec60ce7ab038a5b6abe6eb751b34b5beaad 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_channel_offline(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);
 		}
 	}

base-commit: ca20d5a011d35fc25e328fe31ac47f7aae557c5a
-- 
2.50.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  7:50 [PATCH v2] PCI/MSI: Retry a mismatched MSI-X message once during restore raoxu
2026-11-30  7:59 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox