diff mbox series

PCI/MSI: Prevent MSI/X masking IO to a removed device

Message ID 1540489489-2622-1-git-send-email-jonathan.derrick@intel.com
State Superseded
Delegated to: Bjorn Helgaas
Headers show
Series PCI/MSI: Prevent MSI/X masking IO to a removed device | expand

Commit Message

Jon Derrick Oct. 25, 2018, 5:44 p.m. UTC
A removed device won't be able to accept mmio or config cycles setting
or clearing MSI/X mask bits. Shortcut this path by preventing the writes
and subsequent reads which may result in unsupported requests or
completer abort.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 drivers/pci/msi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index af24ed5..3a41024 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -227,6 +227,14 @@  static void msi_set_mask_bit(struct irq_data *data, u32 flag)
 {
 	struct msi_desc *desc = irq_data_get_msi_desc(data);
 
+	/*
+	 * Prevent non-posted IO to the device if it has been removed and is in
+	 * the process of removal cleanup, in order to prevent unsupported
+	 * requests or completer aborts or other issues.
+	 */
+	if (pci_dev_is_disconnected(msi_desc_to_pci_dev(desc)))
+		return;
+
 	if (desc->msi_attrib.is_msix) {
 		msix_mask_irq(desc, flag);
 		readl(desc->mask_base);		/* Flush write to device */