aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/pci-calgary.c
diff options
context:
space:
mode:
authorMuli Ben-Yehuda <muli@il.ibm.com>2006-09-26 04:52:31 -0400
committerAndi Kleen <andi@basil.nowhere.org>2006-09-26 04:52:31 -0400
commit871b17008e93d7e96f96829ce5f0393c9902d25b (patch)
tree03916d1e9c800ed74a50606408481c4b1c984f8e /arch/x86_64/kernel/pci-calgary.c
parentb8f4fe66a560b5ccbb4d4d0d2df356a5d9b98b83 (diff)
[PATCH] Calgary IOMMU: fix reference counting of Calgary PCI devices
The pci_get_device() API decrements the reference count on the 'from' parameter when it continues searching. Therefore, take a ref count on Calgary bus when we initialize them in either translated or non-translated mode. Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com> Signed-off-by: Jon Mason <jdmason@us.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/x86_64/kernel/pci-calgary.c')
-rw-r--r--arch/x86_64/kernel/pci-calgary.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 6c5da1d813f3..7302834718c8 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -786,6 +786,7 @@ static inline unsigned int __init locate_register_space(struct pci_dev *dev)
786 786
787static int __init calgary_init_one_nontraslated(struct pci_dev *dev) 787static int __init calgary_init_one_nontraslated(struct pci_dev *dev)
788{ 788{
789 pci_dev_get(dev);
789 dev->sysdata = NULL; 790 dev->sysdata = NULL;
790 dev->bus->self = dev; 791 dev->bus->self = dev;
791 792
@@ -810,6 +811,7 @@ static int __init calgary_init_one(struct pci_dev *dev)
810 if (ret) 811 if (ret)
811 goto iounmap; 812 goto iounmap;
812 813
814 pci_dev_get(dev);
813 dev->bus->self = dev; 815 dev->bus->self = dev;
814 calgary_enable_translation(dev); 816 calgary_enable_translation(dev);
815 817
@@ -836,10 +838,9 @@ static int __init calgary_init(void)
836 calgary_init_one_nontraslated(dev); 838 calgary_init_one_nontraslated(dev);
837 continue; 839 continue;
838 } 840 }
839 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots) { 841 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
840 pci_dev_put(dev);
841 continue; 842 continue;
842 } 843
843 ret = calgary_init_one(dev); 844 ret = calgary_init_one(dev);
844 if (ret) 845 if (ret)
845 goto error; 846 goto error;
@@ -860,9 +861,10 @@ error:
860 } 861 }
861 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots) 862 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
862 continue; 863 continue;
864
863 calgary_disable_translation(dev); 865 calgary_disable_translation(dev);
864 calgary_free_bus(dev); 866 calgary_free_bus(dev);
865 pci_dev_put(dev); 867 pci_dev_put(dev); /* Undo calgary_init_one()'s pci_dev_get() */
866 } 868 }
867 869
868 return ret; 870 return ret;