diff options
Diffstat (limited to 'drivers/iommu/irq_remapping.c')
-rw-r--r-- | drivers/iommu/irq_remapping.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c index dcfea4e39be7..39f81aeefcd6 100644 --- a/drivers/iommu/irq_remapping.c +++ b/drivers/iommu/irq_remapping.c | |||
@@ -51,26 +51,27 @@ static void irq_remapping_disable_io_apic(void) | |||
51 | 51 | ||
52 | static int do_setup_msi_irqs(struct pci_dev *dev, int nvec) | 52 | static int do_setup_msi_irqs(struct pci_dev *dev, int nvec) |
53 | { | 53 | { |
54 | int node, ret, sub_handle, index = 0; | 54 | int node, ret, sub_handle, nvec_pow2, index = 0; |
55 | unsigned int irq; | 55 | unsigned int irq; |
56 | struct msi_desc *msidesc; | 56 | struct msi_desc *msidesc; |
57 | 57 | ||
58 | nvec = __roundup_pow_of_two(nvec); | ||
59 | |||
60 | WARN_ON(!list_is_singular(&dev->msi_list)); | 58 | WARN_ON(!list_is_singular(&dev->msi_list)); |
61 | msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); | 59 | msidesc = list_entry(dev->msi_list.next, struct msi_desc, list); |
62 | WARN_ON(msidesc->irq); | 60 | WARN_ON(msidesc->irq); |
63 | WARN_ON(msidesc->msi_attrib.multiple); | 61 | WARN_ON(msidesc->msi_attrib.multiple); |
62 | WARN_ON(msidesc->nvec_used); | ||
64 | 63 | ||
65 | node = dev_to_node(&dev->dev); | 64 | node = dev_to_node(&dev->dev); |
66 | irq = __create_irqs(get_nr_irqs_gsi(), nvec, node); | 65 | irq = __create_irqs(get_nr_irqs_gsi(), nvec, node); |
67 | if (irq == 0) | 66 | if (irq == 0) |
68 | return -ENOSPC; | 67 | return -ENOSPC; |
69 | 68 | ||
70 | msidesc->msi_attrib.multiple = ilog2(nvec); | 69 | nvec_pow2 = __roundup_pow_of_two(nvec); |
70 | msidesc->nvec_used = nvec; | ||
71 | msidesc->msi_attrib.multiple = ilog2(nvec_pow2); | ||
71 | for (sub_handle = 0; sub_handle < nvec; sub_handle++) { | 72 | for (sub_handle = 0; sub_handle < nvec; sub_handle++) { |
72 | if (!sub_handle) { | 73 | if (!sub_handle) { |
73 | index = msi_alloc_remapped_irq(dev, irq, nvec); | 74 | index = msi_alloc_remapped_irq(dev, irq, nvec_pow2); |
74 | if (index < 0) { | 75 | if (index < 0) { |
75 | ret = index; | 76 | ret = index; |
76 | goto error; | 77 | goto error; |
@@ -95,6 +96,7 @@ error: | |||
95 | * IRQs from tearing down again in default_teardown_msi_irqs() | 96 | * IRQs from tearing down again in default_teardown_msi_irqs() |
96 | */ | 97 | */ |
97 | msidesc->irq = 0; | 98 | msidesc->irq = 0; |
99 | msidesc->nvec_used = 0; | ||
98 | msidesc->msi_attrib.multiple = 0; | 100 | msidesc->msi_attrib.multiple = 0; |
99 | 101 | ||
100 | return ret; | 102 | return ret; |