Commit bffac3c5 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Jesse Barnes

PCI MSI: Fix undefined shift by 32

Add an msi_mask() function which returns the correct bitmask for the
number of MSI interrupts you have.  This fixes an undefined bug in
msi_capability_init().
Signed-off-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 476e7fae
...@@ -103,6 +103,16 @@ static void msix_set_enable(struct pci_dev *dev, int enable) ...@@ -103,6 +103,16 @@ static void msix_set_enable(struct pci_dev *dev, int enable)
} }
} }
/*
* Essentially, this is ((1 << (1 << x)) - 1), but without the
* undefinedness of a << 32.
*/
static inline __attribute_const__ u32 msi_mask(unsigned x)
{
static const u32 mask[] = { 1, 2, 4, 0xf, 0xff, 0xffff, 0xffffffff };
return mask[x];
}
static void msix_flush_writes(struct irq_desc *desc) static void msix_flush_writes(struct irq_desc *desc)
{ {
struct msi_desc *entry; struct msi_desc *entry;
...@@ -407,8 +417,7 @@ static int msi_capability_init(struct pci_dev *dev) ...@@ -407,8 +417,7 @@ static int msi_capability_init(struct pci_dev *dev)
/* All MSIs are unmasked by default, Mask them all */ /* All MSIs are unmasked by default, Mask them all */
pci_read_config_dword(dev, base, &maskbits); pci_read_config_dword(dev, base, &maskbits);
temp = (1 << multi_msi_capable(control)); temp = msi_mask((control & PCI_MSI_FLAGS_QMASK) >> 1);
temp = ((temp - 1) & ~temp);
maskbits |= temp; maskbits |= temp;
pci_write_config_dword(dev, base, maskbits); pci_write_config_dword(dev, base, maskbits);
entry->msi_attrib.maskbits_mask = temp; entry->msi_attrib.maskbits_mask = temp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment