Skip to content

Commit 361fd37

Browse files
committed
PCI/MSI: Do not set invalid bits in MSI mask
msi_mask_irq() takes a mask and a flags argument. The mask argument is used to mask out bits from the cached mask and the flags argument to set bits. Some places invoke it with a flags argument which sets bits which are not used by the device, i.e. when the device supports up to 8 vectors a full unmask in some places sets the mask to 0xFFFFFF00. While devices probably do not care, it's still bad practice. Fixes: 7ba1930 ("PCI MSI: Unmask MSI if setup failed") Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Marc Zyngier <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent b9255a7 commit 361fd37

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/pci/msi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,21 +656,21 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
656656
/* Configure MSI capability structure */
657657
ret = pci_msi_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
658658
if (ret) {
659-
msi_mask_irq(entry, mask, ~mask);
659+
msi_mask_irq(entry, mask, 0);
660660
free_msi_irqs(dev);
661661
return ret;
662662
}
663663

664664
ret = msi_verify_entries(dev);
665665
if (ret) {
666-
msi_mask_irq(entry, mask, ~mask);
666+
msi_mask_irq(entry, mask, 0);
667667
free_msi_irqs(dev);
668668
return ret;
669669
}
670670

671671
ret = populate_msi_sysfs(dev);
672672
if (ret) {
673-
msi_mask_irq(entry, mask, ~mask);
673+
msi_mask_irq(entry, mask, 0);
674674
free_msi_irqs(dev);
675675
return ret;
676676
}
@@ -962,7 +962,7 @@ static void pci_msi_shutdown(struct pci_dev *dev)
962962
/* Return the device with MSI unmasked as initial states */
963963
mask = msi_mask(desc->msi_attrib.multi_cap);
964964
/* Keep cached state to be restored */
965-
__pci_msi_desc_mask_irq(desc, mask, ~mask);
965+
__pci_msi_desc_mask_irq(desc, mask, 0);
966966

967967
/* Restore dev->irq to its default pin-assertion IRQ */
968968
dev->irq = desc->msi_attrib.default_irq;

0 commit comments

Comments
 (0)