Skip to contentSkip to conversation

genirq/msi: Do not use pci_msi_[un]mask_irq as default methods

PATCH In review Marc Zyngier 4 participants 5 messages Oct 13, 2015 – Oct 16, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genirq/msi: Do not use pci_msi_[un]mask_irq as default methods

When we create a generic MSI domain, that MSI_FLAG_USE_DEF_CHIP_OPS is set, and that any of .mask or .unmask are NULL in the irq_chip structure, we set them to pci_msi_[un]mask_irq.

This is a bad idea for at least two reasons:
- PCI_MSI might not be selected, kernel fails to build (yes, this is legitimate, at least on arm64!)
- This may not be a PCI/MSI domain at all (platform MSI, for example)

Either way, this looks wrong. Move the overriding of mask/unmask to the PCI counterpart, and panic is any of these two methods is not set in the core code (they really should be present).

---
 drivers/pci/msi.c | 4 ++++
 kernel/irq/msi.c  | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/msi.c +4 -0
index d449714..4a7da3c 100644
@@ -1243,6 +1243,10 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
 	BUG_ON(!chip);
 	if (!chip->irq_write_msi_msg)
 		chip->irq_write_msi_msg = pci_msi_domain_write_msg;
+	if (!chip->irq_mask)
+		chip->irq_mask = pci_msi_mask_irq;
+	if (!chip->irq_unmask)
+		chip->irq_unmask = pci_msi_unmask_irq;
 }
 
 /**
kernel/irq/msi.c +1 -5
index 7e6512b..be9149f 100644
@@ -228,11 +228,7 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
 {
 	struct irq_chip *chip = info->chip;
 
-	BUG_ON(!chip);
-	if (!chip->irq_mask)
-		chip->irq_mask = pci_msi_mask_irq;
-	if (!chip->irq_unmask)
-		chip->irq_unmask = pci_msi_unmask_irq;
+	BUG_ON(!chip || !chip->irq_mask || !chip->irq_unmask);
 	if (!chip->irq_set_affinity)
 		chip->irq_set_affinity = msi_domain_set_affinity;
 }
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Marc Zyngier

When we create a generic MSI domain, that MSI_FLAG_USE_DEF_CHIP_OPS is set, and that any of .mask or .unmask are NULL in the irq_chip structure, we set them to pci_msi_[un]mask_irq.

Quoted 8 lines

This is a bad idea for at least two reasons:
- PCI_MSI might not be selected, kernel fails to build (yes, this is legitimate, at least on arm64!)
- This may not be a PCI/MSI domain at all (platform MSI, for example)

Either way, this looks wrong. Move the overriding of mask/unmask to the PCI counterpart, and panic is any of these two methods is not set in the core code (they really should be present).

Hi Marc,
Thanks for fixing this,

Thanks,
Gerry

Quoted 40 lines
---
 drivers/pci/msi.c | 4 ++++
 kernel/irq/msi.c  | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/msi.c +4 -0
index d449714..4a7da3c 100644
@@ -1243,6 +1243,10 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
 	BUG_ON(!chip);
 	if (!chip->irq_write_msi_msg)
 		chip->irq_write_msi_msg = pci_msi_domain_write_msg;
+	if (!chip->irq_mask)
+		chip->irq_mask = pci_msi_mask_irq;
+	if (!chip->irq_unmask)
+		chip->irq_unmask = pci_msi_unmask_irq;
 }
 
 /**
kernel/irq/msi.c +1 -5
index 7e6512b..be9149f 100644
@@ -228,11 +228,7 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
 {
 	struct irq_chip *chip = info->chip;
 
-	BUG_ON(!chip);
-	if (!chip->irq_mask)
-		chip->irq_mask = pci_msi_mask_irq;
-	if (!chip->irq_unmask)
-		chip->irq_unmask = pci_msi_unmask_irq;
+	BUG_ON(!chip || !chip->irq_mask || !chip->irq_unmask);
 	if (!chip->irq_set_affinity)
 		chip->irq_set_affinity = msi_domain_set_affinity;
 }
Reviewed-by on v1 1/1
#2 lore raw
In reply to Marc Zyngier
Quoted 9 lines · Marc Zyngier

When we create a generic MSI domain, that MSI_FLAG_USE_DEF_CHIP_OPS is set, and that any of .mask or .unmask are NULL in the irq_chip structure, we set them to pci_msi_[un]mask_irq.

This is a bad idea for at least two reasons:
- PCI_MSI might not be selected, kernel fails to build (yes, this is legitimate, at least on arm64!)
- This may not be a PCI/MSI domain at all (platform MSI, for example)

Quoted 5 lines

Either way, this looks wrong. Move the overriding of mask/unmask to the PCI counterpart, and panic is any of these two methods is not set in the core code (they really should be present).

Quoted 41 lines
---
 drivers/pci/msi.c | 4 ++++
 kernel/irq/msi.c  | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/msi.c +4 -0
index d449714..4a7da3c 100644
@@ -1243,6 +1243,10 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
 	BUG_ON(!chip);
 	if (!chip->irq_write_msi_msg)
 		chip->irq_write_msi_msg = pci_msi_domain_write_msg;
+	if (!chip->irq_mask)
+		chip->irq_mask = pci_msi_mask_irq;
+	if (!chip->irq_unmask)
+		chip->irq_unmask = pci_msi_unmask_irq;
 }
 
 /**
kernel/irq/msi.c +1 -5
index 7e6512b..be9149f 100644
@@ -228,11 +228,7 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
 {
 	struct irq_chip *chip = info->chip;
 
-	BUG_ON(!chip);
-	if (!chip->irq_mask)
-		chip->irq_mask = pci_msi_mask_irq;
-	if (!chip->irq_unmask)
-		chip->irq_unmask = pci_msi_unmask_irq;
+	BUG_ON(!chip || !chip->irq_mask || !chip->irq_unmask);
 	if (!chip->irq_set_affinity)
 		chip->irq_set_affinity = msi_domain_set_affinity;
 }
Signature · 1 line
2.1.4
#3 lore raw

Bjorn,

Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · Marc Zyngier

When we create a generic MSI domain, that MSI_FLAG_USE_DEF_CHIP_OPS is set, and that any of .mask or .unmask are NULL in the irq_chip structure, we set them to pci_msi_[un]mask_irq.

This is a bad idea for at least two reasons:
- PCI_MSI might not be selected, kernel fails to build (yes, this is legitimate, at least on arm64!)
- This may not be a PCI/MSI domain at all (platform MSI, for example)

Quoted 5 lines
Quoted 5 lines

Either way, this looks wrong. Move the overriding of mask/unmask to the PCI counterpart, and panic is any of these two methods is not set in the core code (they really should be present).

Should I take that one?

Thanks,

tglx

#4 lore raw

[tip:irq/urgent] genirq/msi: Do not use pci_msi_[un] mask_irq as default methods

In reply to Marc Zyngier
genirq/msi: Do not use pci_msi_[un]mask_irq as default methods
Commit-ID:  0701c53e460ea64daf0ee789d0b08fef57800016
Gitweb:     http://git.kernel.org/tip/0701c53e460ea64daf0ee789d0b08fef57800016
Author:     Marc Zyngier <[email protected]>
AuthorDate: Tue, 13 Oct 2015 19:14:45 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 16 Oct 2015 12:40:43 +0200

genirq/msi: Do not use pci_msi_[un]mask_irq as default methods

When we create a generic MSI domain, that MSI_FLAG_USE_DEF_CHIP_OPS is set, and that any of .mask or .unmask are NULL in the irq_chip structure, we set them to pci_msi_[un]mask_irq.

This is a bad idea for at least two reasons:
- PCI_MSI might not be selected, kernel fails to build (yes, this is legitimate, at least on arm64!)
- This may not be a PCI/MSI domain at all (platform MSI, for example)

Either way, this looks wrong. Move the overriding of mask/unmask to the PCI counterpart, and panic is any of these two methods is not set in the core code (they really should be present).

---
 drivers/pci/msi.c | 4 ++++
 kernel/irq/msi.c  | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pci/msi.c +4 -0
index d449714..4a7da3c 100644
@@ -1243,6 +1243,10 @@ static void pci_msi_domain_update_chip_ops(struct msi_domain_info *info)
 	BUG_ON(!chip);
 	if (!chip->irq_write_msi_msg)
 		chip->irq_write_msi_msg = pci_msi_domain_write_msg;
+	if (!chip->irq_mask)
+		chip->irq_mask = pci_msi_mask_irq;
+	if (!chip->irq_unmask)
+		chip->irq_unmask = pci_msi_unmask_irq;
 }
 
 /**
kernel/irq/msi.c +1 -5
index 7e6512b..be9149f 100644
@@ -228,11 +228,7 @@ static void msi_domain_update_chip_ops(struct msi_domain_info *info)
 {
 	struct irq_chip *chip = info->chip;
 
-	BUG_ON(!chip);
-	if (!chip->irq_mask)
-		chip->irq_mask = pci_msi_mask_irq;
-	if (!chip->irq_unmask)
-		chip->irq_unmask = pci_msi_unmask_irq;
+	BUG_ON(!chip || !chip->irq_mask || !chip->irq_unmask);
 	if (!chip->irq_set_affinity)
 		chip->irq_set_affinity = msi_domain_set_affinity;
 }