[PATCH] PCI/MSI: Clear MSI/MSI-X on resume if it's not enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MSI/MSI-X can have garbage data after system resume.

Before suspend:
Capabilities: [a0] MSI: Enable- Count=1/4 Maskable- 64bit+
	Address: 0000000000000000  Data: 0000
Capabilities: [c0] MSI-X: Enable+ Count=4 Masked-
	Vector table: BAR=5 offset=00042000
	PBA: BAR=5 offset=00043000

After resume:
Capabilities: [a0] MSI: Enable+ Count=128/4 Maskable- 64bit+
	Address: fffffffffffffffc  Data: ffff
Capabilities: [c0] MSI-X: Enable+ Count=4 Masked-
	Vector table: BAR=5 offset=00042000
	PBA: BAR=5 offset=00043000

So clear the MSI/MSI-X config on resume to ensure it's not enabled
unintentionally.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216242
Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
---
 drivers/pci/msi/msi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 9037a7827eca7..cf8374a877f3f 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -263,8 +263,12 @@ static void __pci_restore_msi_state(struct pci_dev *dev)
 	struct msi_desc *entry;
 	u16 control;
 
-	if (!dev->msi_enabled)
+	if (!dev->msi_enabled) {
+		if (dev->msi_cap)
+			pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, 0);
+
 		return;
+	}
 
 	entry = irq_get_msi_desc(dev->irq);
 
@@ -295,8 +299,12 @@ static void __pci_restore_msix_state(struct pci_dev *dev)
 	struct msi_desc *entry;
 	bool write_msg;
 
-	if (!dev->msix_enabled)
+	if (!dev->msix_enabled) {
+		if (dev->msix_cap)
+			pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, 0);
+
 		return;
+	}
 
 	/* route the table */
 	pci_intx_for_msi(dev, 0);
-- 
2.36.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux