diff options
-rw-r--r-- | drivers/pci/msi.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index b3db4388f974..a658c0f34e16 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -110,7 +110,7 @@ static void msix_flush_writes(struct irq_desc *desc) | |||
110 | struct msi_desc *entry; | 110 | struct msi_desc *entry; |
111 | 111 | ||
112 | entry = get_irq_desc_msi(desc); | 112 | entry = get_irq_desc_msi(desc); |
113 | BUG_ON(!entry || !entry->dev); | 113 | BUG_ON(!entry); |
114 | if (entry->msi_attrib.is_msix) { | 114 | if (entry->msi_attrib.is_msix) { |
115 | int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + | 115 | int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + |
116 | PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; | 116 | PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; |
@@ -132,7 +132,7 @@ static int msi_set_mask_bits(struct irq_desc *desc, u32 mask, u32 flag) | |||
132 | struct msi_desc *entry; | 132 | struct msi_desc *entry; |
133 | 133 | ||
134 | entry = get_irq_desc_msi(desc); | 134 | entry = get_irq_desc_msi(desc); |
135 | BUG_ON(!entry || !entry->dev); | 135 | BUG_ON(!entry); |
136 | if (entry->msi_attrib.is_msix) { | 136 | if (entry->msi_attrib.is_msix) { |
137 | int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + | 137 | int offset = entry->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + |
138 | PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; | 138 | PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET; |
@@ -248,19 +248,16 @@ void unmask_msi_irq(unsigned int irq) | |||
248 | 248 | ||
249 | static int msi_free_irqs(struct pci_dev* dev); | 249 | static int msi_free_irqs(struct pci_dev* dev); |
250 | 250 | ||
251 | static struct msi_desc* alloc_msi_entry(void) | 251 | static struct msi_desc *alloc_msi_entry(struct pci_dev *dev) |
252 | { | 252 | { |
253 | struct msi_desc *entry; | 253 | struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL); |
254 | 254 | if (!desc) | |
255 | entry = kzalloc(sizeof(struct msi_desc), GFP_KERNEL); | ||
256 | if (!entry) | ||
257 | return NULL; | 255 | return NULL; |
258 | 256 | ||
259 | INIT_LIST_HEAD(&entry->list); | 257 | INIT_LIST_HEAD(&desc->list); |
260 | entry->irq = 0; | 258 | desc->dev = dev; |
261 | entry->dev = NULL; | ||
262 | 259 | ||
263 | return entry; | 260 | return desc; |
264 | } | 261 | } |
265 | 262 | ||
266 | static void pci_intx_for_msi(struct pci_dev *dev, int enable) | 263 | static void pci_intx_for_msi(struct pci_dev *dev, int enable) |
@@ -351,7 +348,7 @@ static int msi_capability_init(struct pci_dev *dev) | |||
351 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | 348 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
352 | pci_read_config_word(dev, msi_control_reg(pos), &control); | 349 | pci_read_config_word(dev, msi_control_reg(pos), &control); |
353 | /* MSI Entry Initialization */ | 350 | /* MSI Entry Initialization */ |
354 | entry = alloc_msi_entry(); | 351 | entry = alloc_msi_entry(dev); |
355 | if (!entry) | 352 | if (!entry) |
356 | return -ENOMEM; | 353 | return -ENOMEM; |
357 | 354 | ||
@@ -362,7 +359,6 @@ static int msi_capability_init(struct pci_dev *dev) | |||
362 | entry->msi_attrib.masked = 1; | 359 | entry->msi_attrib.masked = 1; |
363 | entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ | 360 | entry->msi_attrib.default_irq = dev->irq; /* Save IOAPIC IRQ */ |
364 | entry->msi_attrib.pos = pos; | 361 | entry->msi_attrib.pos = pos; |
365 | entry->dev = dev; | ||
366 | if (entry->msi_attrib.maskbit) { | 362 | if (entry->msi_attrib.maskbit) { |
367 | unsigned int base, maskbits, temp; | 363 | unsigned int base, maskbits, temp; |
368 | 364 | ||
@@ -432,7 +428,7 @@ static int msix_capability_init(struct pci_dev *dev, | |||
432 | 428 | ||
433 | /* MSI-X Table Initialization */ | 429 | /* MSI-X Table Initialization */ |
434 | for (i = 0; i < nvec; i++) { | 430 | for (i = 0; i < nvec; i++) { |
435 | entry = alloc_msi_entry(); | 431 | entry = alloc_msi_entry(dev); |
436 | if (!entry) | 432 | if (!entry) |
437 | break; | 433 | break; |
438 | 434 | ||
@@ -444,7 +440,6 @@ static int msix_capability_init(struct pci_dev *dev, | |||
444 | entry->msi_attrib.masked = 1; | 440 | entry->msi_attrib.masked = 1; |
445 | entry->msi_attrib.default_irq = dev->irq; | 441 | entry->msi_attrib.default_irq = dev->irq; |
446 | entry->msi_attrib.pos = pos; | 442 | entry->msi_attrib.pos = pos; |
447 | entry->dev = dev; | ||
448 | entry->mask_base = base; | 443 | entry->mask_base = base; |
449 | 444 | ||
450 | list_add_tail(&entry->list, &dev->msi_list); | 445 | list_add_tail(&entry->list, &dev->msi_list); |
@@ -581,7 +576,7 @@ void pci_msi_shutdown(struct pci_dev* dev) | |||
581 | struct irq_desc *desc = irq_to_desc(dev->irq); | 576 | struct irq_desc *desc = irq_to_desc(dev->irq); |
582 | msi_set_mask_bits(desc, mask, ~mask); | 577 | msi_set_mask_bits(desc, mask, ~mask); |
583 | } | 578 | } |
584 | if (!entry->dev || entry->msi_attrib.is_msix) | 579 | if (entry->msi_attrib.is_msix) |
585 | return; | 580 | return; |
586 | 581 | ||
587 | /* Restore dev->irq to its default pin-assertion irq */ | 582 | /* Restore dev->irq to its default pin-assertion irq */ |
@@ -598,7 +593,7 @@ void pci_disable_msi(struct pci_dev* dev) | |||
598 | pci_msi_shutdown(dev); | 593 | pci_msi_shutdown(dev); |
599 | 594 | ||
600 | entry = list_entry(dev->msi_list.next, struct msi_desc, list); | 595 | entry = list_entry(dev->msi_list.next, struct msi_desc, list); |
601 | if (!entry->dev || entry->msi_attrib.is_msix) | 596 | if (entry->msi_attrib.is_msix) |
602 | return; | 597 | return; |
603 | 598 | ||
604 | msi_free_irqs(dev); | 599 | msi_free_irqs(dev); |