Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH v3] PCI/MSI: Retry a mismatched MSI-X message once during restore
@ 2026-12-01 12:36 raoxu
  2026-12-01 12:47 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-12-01 12:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: luiz.von.dentz, tglx, wangruikang, pengpeng, ligongwei,
	maciej.fijalkowski, michael.bommarito, 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 can
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. Resetting the controller restores
operation.

The failure was reproduced on Linux 6.6.162. This release includes the
backport of commit 231c7a57d193 ("PCI/MSI: Enable memory decoding
before restoring MSI-X messages").

The following excerpts show MSI-X entry 0 on two S3 cycles. The
msg-after trace records the first message readback after the write in
__pci_restore_msix_state(). The pci-resume trace reads the same entry
at xHCI resume. Both show address high:low/data, with vector control
as the last word of v0.

  Normal cycle 16
  [ 1163.085945] msg-after irq=86
      want=00000000:36850040/00000000 actual=00000000:36850040/00000000
  [ 1163.087494] n=16 pci-resume
      v0=00000000:36850040/00000000/00000000

  Failed cycle 18
  [ 1285.211630] msg-after irq=86
      want=00000000:36850040/00000000 actual=ffffffff:ffffffff/ffffffff
  [ 1285.213401] n=18 pci-resume
      v0=00000000:00000000/00000000/00000000

On cycle 16 the address matched the cached value at both points. On
cycle 18 the first readback returned all ones for both address words
and the data word. The address then read back as zero at xHCI resume.

In a diagnostic run of 500 S3 cycles, nine initial message readbacks
differed from the cached message. All nine matched after one additional
write. Subsequent testing with the single retry completed 1000 S3
cycles without reproducing the failure.

When restoring a non-virtual MSI-X entry with the device in D0 and its
PCI channel online, read back the message address and data. If either
differs from the cached value, repeat the write once before restoring
vector control. Log the table index on retry to help identify affected
devices.

Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
Changes in v3:
- Identify Linux 6.6.162 as the test kernel and show MSI-X entry 0
  after the PCI restore write and at xHCI resume on two S3 cycles.
- Rename the readback variable to actual_msg and group the write,
  readback and retry under the existing write_msg check.
- Emit a rate-limited PCI notice with the MSI-X table index after a
  retry.

v2: https://lore.kernel.org/all/86A15F7DC608A2E9+20261130075042.726555-1-raoxu@uniontech.com/
Review: https://lore.kernel.org/all/2210ce22-0a8a-46b7-993e-0b00d9b95d7f@molgen.mpg.de/

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/

Codex assisted with the v3 changes and changelog in response to review.

 drivers/pci/msi/msi.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 8a0133a6a28632261c2f5efd399efddddd011eab..23f21ea46cb2a96403d173ea128db35b64c22e86 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_msg;
 	bool write_msg;
 	u16 cmd;

@@ -894,8 +895,22 @@ void __pci_restore_msix_state(struct pci_dev *dev)

 	scoped_guard (msi_descs_lock, &dev->dev) {
 		msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) {
-			if (write_msg)
+			if (write_msg) {
 				__pci_write_msi_msg(entry, &entry->msg);
+				if (dev->current_state == PCI_D0 &&
+				    !pci_channel_offline(dev) &&
+				    !entry->pci.msi_attrib.is_virtual) {
+					__pci_read_msi_msg(entry, &actual_msg);
+					if (actual_msg.address_lo != entry->msg.address_lo ||
+					    actual_msg.address_hi != entry->msg.address_hi ||
+					    actual_msg.data != entry->msg.data) {
+						__pci_write_msi_msg(entry, &entry->msg);
+						pci_notice_ratelimited(dev,
+								       "MSI-X entry %u: message mismatch on restore, retried write\n",
+								       entry->msi_index);
+					}
+				}
+			}
 			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

* Re: [PATCH v3] PCI/MSI: Retry a mismatched MSI-X message once during restore
  2026-12-01 12:36 [PATCH v3] PCI/MSI: Retry a mismatched MSI-X message once during restore raoxu
@ 2026-12-01 12:47 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01 12:47 UTC (permalink / raw)
  To: raoxu; +Cc: linux-pci

> From: Xu Rao <raoxu@uniontech.com>
> 
> Repeated S3 cycles on an Inspur CE720F2 with a Phytium D3000 CPU can
> 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. Resetting the controller restores
> operation.
> 
> The failure was reproduced on Linux 6.6.162. This release includes the
> backport of commit 231c7a57d193 ("PCI/MSI: Enable memory decoding
> before restoring MSI-X messages").
> 
> The following excerpts show MSI-X entry 0 on two S3 cycles. The
> msg-after trace records the first message readback after the write in
> __pci_restore_msix_state(). The pci-resume trace reads the same entry
> [ ... ]
> differs from the cached value, repeat the write once before restoring
> vector control. Log the table index on retry to help identify affected
> devices.
> 
> Signed-off-by: Xu Rao <raoxu@uniontech.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/3889F27756A28655+20261201123626.1967698-1-raoxu@uniontech.com?part=1

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

end of thread, other threads:[~2026-12-01 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 12:36 [PATCH v3] PCI/MSI: Retry a mismatched MSI-X message once during restore raoxu
2026-12-01 12:47 ` sashiko-bot

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