aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/msi.c
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2007-03-22 06:51:33 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-05-02 22:02:36 -0400
commitfc4afc7b2bdd81e2dbded5a8222676d3161758d3 (patch)
treef746cc18be366058a764e6cc3c3625efbfbb5765 /drivers/pci/msi.c
parent00ba16ab2658afe11d4fdcaf16a331292c44bee6 (diff)
MSI: Consolidate MSI-X irq freeing code
For the MSI-X case we do exactly the same logic in pci_disable_msix() and msi_remove_pci_irq_vectors(), so consolidate them. msi_remove_pci_irq_vectors() wasn't setting dev->first_msi_irq to 0, but I think it should have been, so the consolidated version does. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r--drivers/pci/msi.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 91fed543fc84..4f326f38f9bf 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -674,10 +674,26 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
674 return status; 674 return status;
675} 675}
676 676
677void pci_disable_msix(struct pci_dev* dev) 677static void msix_free_all_irqs(struct pci_dev *dev)
678{ 678{
679 int irq, head, tail = 0; 679 int irq, head, tail = 0;
680 680
681 irq = head = dev->first_msi_irq;
682 while (head != tail) {
683 tail = get_irq_msi(irq)->link.tail;
684
685 BUG_ON(irq_has_action(irq));
686
687 if (irq != head)
688 msi_free_irq(dev, irq);
689 irq = tail;
690 }
691 msi_free_irq(dev, irq);
692 dev->first_msi_irq = 0;
693}
694
695void pci_disable_msix(struct pci_dev* dev)
696{
681 if (!pci_msi_enable) 697 if (!pci_msi_enable)
682 return; 698 return;
683 if (!dev) 699 if (!dev)
@@ -690,18 +706,7 @@ void pci_disable_msix(struct pci_dev* dev)
690 pci_intx(dev, 1); /* enable intx */ 706 pci_intx(dev, 1); /* enable intx */
691 dev->msix_enabled = 0; 707 dev->msix_enabled = 0;
692 708
693 irq = head = dev->first_msi_irq; 709 msix_free_all_irqs(dev);
694 while (head != tail) {
695 tail = get_irq_msi(irq)->link.tail;
696
697 BUG_ON(irq_has_action(irq));
698
699 if (irq != head) /* Release MSI-X irq */
700 msi_free_irq(dev, irq);
701 irq = tail;
702 }
703 msi_free_irq(dev, irq);
704 dev->first_msi_irq = 0;
705} 710}
706 711
707/** 712/**
@@ -722,23 +727,9 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
722 BUG_ON(irq_has_action(dev->first_msi_irq)); 727 BUG_ON(irq_has_action(dev->first_msi_irq));
723 msi_free_irq(dev, dev->first_msi_irq); 728 msi_free_irq(dev, dev->first_msi_irq);
724 } 729 }
725 if (dev->msix_enabled) {
726 int irq, head, tail = 0;
727 void __iomem *base = NULL;
728 730
729 irq = head = dev->first_msi_irq; 731 if (dev->msix_enabled)
730 while (head != tail) { 732 msix_free_all_irqs(dev);
731 tail = get_irq_msi(irq)->link.tail;
732 base = get_irq_msi(irq)->mask_base;
733
734 BUG_ON(irq_has_action(irq));
735
736 if (irq != head) /* Release MSI-X irq */
737 msi_free_irq(dev, irq);
738 irq = tail;
739 }
740 msi_free_irq(dev, irq);
741 }
742} 733}
743 734
744void pci_no_msi(void) 735void pci_no_msi(void)