Skip to contentSkip to conversation

PCI/MSI: Simplify default_restore_msi_irq()

PATCH Superseded Yijing Wang 2 participants 3 messages Sep 11, 2014 – Sep 24, 2014 PCI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/MSI: Simplify default_restore_msi_irq()

Both MSI and MSI-X irq will be associate to msi_desc, Use irq_get_msi_desc() to get the msi_desc for MSI-X to simplify code. Also use __write_msi_msg() instead of write_msi_msg() to avoid the redundant calls.

---
 drivers/pci/msi.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/pci/msi.c +2 -11
index 5a40516..9ad920a 100644
@@ -119,18 +119,9 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq)
 {
 	struct msi_desc *entry;
 
-	entry = NULL;
-	if (dev->msix_enabled) {
-		list_for_each_entry(entry, &dev->msi_list, list) {
-			if (irq == entry->irq)
-				break;
-		}
-	} else if (dev->msi_enabled)  {
-		entry = irq_get_msi_desc(irq);
-	}
-
+	entry = irq_get_msi_desc(irq);
 	if (entry)
-		write_msi_msg(irq, &entry->msg);
+		__write_msi_msg(entry, &entry->msg);
 }
 
 void __weak arch_restore_msi_irqs(struct pci_dev *dev)
Signature · 1 line
1.7.1
maintainer
#1 lore raw
Quoted 4 lines · Yijing Wang

Both MSI and MSI-X irq will be associate to msi_desc, Use irq_get_msi_desc() to get the msi_desc for MSI-X to simplify code. Also use __write_msi_msg() instead of write_msi_msg() to avoid the redundant calls.

Again, this should mention exactly where the MSI and MSI-X IRQs are associated with the msi_desc.

Quoted 33 lines
---
 drivers/pci/msi.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/pci/msi.c +2 -11
index 5a40516..9ad920a 100644
@@ -119,18 +119,9 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq)
 {
 	struct msi_desc *entry;
 
-	entry = NULL;
-	if (dev->msix_enabled) {
-		list_for_each_entry(entry, &dev->msi_list, list) {
-			if (irq == entry->irq)
-				break;
-		}
-	} else if (dev->msi_enabled)  {
-		entry = irq_get_msi_desc(irq);
-	}
-
+	entry = irq_get_msi_desc(irq);
 	if (entry)
-		write_msi_msg(irq, &entry->msg);
+		__write_msi_msg(entry, &entry->msg);
 }
 
 void __weak arch_restore_msi_irqs(struct pci_dev *dev)
Signature · 1 line
1.7.1
#2 lore raw
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines · Yijing Wang

Both MSI and MSI-X irq will be associate to msi_desc, Use irq_get_msi_desc() to get the msi_desc for MSI-X to simplify code. Also use __write_msi_msg() instead of write_msi_msg() to avoid the redundant calls.

Again, this should mention exactly where the MSI and MSI-X IRQs are associated with the msi_desc.

As mentioned in another mail, ARCH MSI code call irq_set_msi_desc() regardless of MSI or MSI-X type.

So I think use irq_get_msi_desc() for MSI-X is ok .

Thanks!
Yijing.

Quoted 36 lines
Quoted 34 lines
---
 drivers/pci/msi.c |   13 ++-----------
 1 files changed, 2 insertions(+), 11 deletions(-)
drivers/pci/msi.c +2 -11
index 5a40516..9ad920a 100644
@@ -119,18 +119,9 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq)
 {
 	struct msi_desc *entry;
 
-	entry = NULL;
-	if (dev->msix_enabled) {
-		list_for_each_entry(entry, &dev->msi_list, list) {
-			if (irq == entry->irq)
-				break;
-		}
-	} else if (dev->msi_enabled)  {
-		entry = irq_get_msi_desc(irq);
-	}
-
+	entry = irq_get_msi_desc(irq);
 	if (entry)
-		write_msi_msg(irq, &entry->msg);
+		__write_msi_msg(entry, &entry->msg);
 }
 
 void __weak arch_restore_msi_irqs(struct pci_dev *dev)
Signature · 1 line
1.7.1
Signature · 2 lines
Thanks!
Yijing