Commit f56e4481 authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Jesse Barnes

PCI MSI: Unify msi_free_irqs() and msix_free_all_irqs()

Unify msi_free_irqs() and msix_free_all_irqs(), and rename it to a
common void function free_msi_irqs().

And relocate the common function to where the prototype is located now.
Reviewed-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 9cc8d548
...@@ -272,7 +272,30 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg) ...@@ -272,7 +272,30 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg)
write_msi_msg_desc(desc, msg); write_msi_msg_desc(desc, msg);
} }
static int msi_free_irqs(struct pci_dev* dev); static void free_msi_irqs(struct pci_dev *dev)
{
struct msi_desc *entry, *tmp;
list_for_each_entry(entry, &dev->msi_list, list) {
int i, nvec;
if (!entry->irq)
continue;
nvec = 1 << entry->msi_attrib.multiple;
for (i = 0; i < nvec; i++)
BUG_ON(irq_has_action(entry->irq + i));
}
arch_teardown_msi_irqs(dev);
list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
if (entry->msi_attrib.is_msix) {
if (list_is_last(&entry->list, &dev->msi_list))
iounmap(entry->mask_base);
}
list_del(&entry->list);
kfree(entry);
}
}
static struct msi_desc *alloc_msi_entry(struct pci_dev *dev) static struct msi_desc *alloc_msi_entry(struct pci_dev *dev)
{ {
...@@ -396,7 +419,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec) ...@@ -396,7 +419,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI); ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI);
if (ret) { if (ret) {
msi_mask_irq(entry, mask, ~mask); msi_mask_irq(entry, mask, ~mask);
msi_free_irqs(dev); free_msi_irqs(dev);
return ret; return ret;
} }
...@@ -454,7 +477,7 @@ static int msix_capability_init(struct pci_dev *dev, ...@@ -454,7 +477,7 @@ static int msix_capability_init(struct pci_dev *dev,
if (!i) if (!i)
iounmap(base); iounmap(base);
else else
msi_free_irqs(dev); free_msi_irqs(dev);
/* No enough memory. Don't try again */ /* No enough memory. Don't try again */
return -ENOMEM; return -ENOMEM;
} }
...@@ -486,7 +509,7 @@ static int msix_capability_init(struct pci_dev *dev, ...@@ -486,7 +509,7 @@ static int msix_capability_init(struct pci_dev *dev,
} }
if (ret) { if (ret) {
msi_free_irqs(dev); free_msi_irqs(dev);
return ret; return ret;
} }
...@@ -644,37 +667,10 @@ void pci_disable_msi(struct pci_dev* dev) ...@@ -644,37 +667,10 @@ void pci_disable_msi(struct pci_dev* dev)
return; return;
pci_msi_shutdown(dev); pci_msi_shutdown(dev);
msi_free_irqs(dev); free_msi_irqs(dev);
} }
EXPORT_SYMBOL(pci_disable_msi); EXPORT_SYMBOL(pci_disable_msi);
static int msi_free_irqs(struct pci_dev* dev)
{
struct msi_desc *entry, *tmp;
list_for_each_entry(entry, &dev->msi_list, list) {
int i, nvec;
if (!entry->irq)
continue;
nvec = 1 << entry->msi_attrib.multiple;
for (i = 0; i < nvec; i++)
BUG_ON(irq_has_action(entry->irq + i));
}
arch_teardown_msi_irqs(dev);
list_for_each_entry_safe(entry, tmp, &dev->msi_list, list) {
if (entry->msi_attrib.is_msix) {
if (list_is_last(&entry->list, &dev->msi_list))
iounmap(entry->mask_base);
}
list_del(&entry->list);
kfree(entry);
}
return 0;
}
/** /**
* pci_msix_table_size - return the number of device's MSI-X table entries * pci_msix_table_size - return the number of device's MSI-X table entries
* @dev: pointer to the pci_dev data structure of MSI-X device function * @dev: pointer to the pci_dev data structure of MSI-X device function
...@@ -745,11 +741,6 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) ...@@ -745,11 +741,6 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
} }
EXPORT_SYMBOL(pci_enable_msix); EXPORT_SYMBOL(pci_enable_msix);
static void msix_free_all_irqs(struct pci_dev *dev)
{
msi_free_irqs(dev);
}
void pci_msix_shutdown(struct pci_dev* dev) void pci_msix_shutdown(struct pci_dev* dev)
{ {
struct msi_desc *entry; struct msi_desc *entry;
...@@ -774,7 +765,7 @@ void pci_disable_msix(struct pci_dev* dev) ...@@ -774,7 +765,7 @@ void pci_disable_msix(struct pci_dev* dev)
return; return;
pci_msix_shutdown(dev); pci_msix_shutdown(dev);
msix_free_all_irqs(dev); free_msi_irqs(dev);
} }
EXPORT_SYMBOL(pci_disable_msix); EXPORT_SYMBOL(pci_disable_msix);
...@@ -792,11 +783,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev) ...@@ -792,11 +783,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
if (!pci_msi_enable || !dev) if (!pci_msi_enable || !dev)
return; return;
if (dev->msi_enabled) if (dev->msi_enabled || dev->msix_enabled)
msi_free_irqs(dev); free_msi_irqs(dev);
if (dev->msix_enabled)
msix_free_all_irqs(dev);
} }
void pci_no_msi(void) void pci_no_msi(void)
......
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