aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/pci/pci.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 48de2be7b46a..e6f15b5d8b7d 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -627,17 +627,6 @@ void zpci_free_device(struct zpci_dev *zdev)
627 kfree(zdev); 627 kfree(zdev);
628} 628}
629 629
630static void zpci_scan_devices(void)
631{
632 struct zpci_dev *zdev;
633
634 mutex_lock(&zpci_list_lock);
635 list_for_each_entry(zdev, &zpci_list, entry)
636 if (zdev->state == ZPCI_FN_STATE_CONFIGURED)
637 zpci_scan_device(zdev);
638 mutex_unlock(&zpci_list_lock);
639}
640
641/* 630/*
642 * Too late for any s390 specific setup, since interrupts must be set up 631 * Too late for any s390 specific setup, since interrupts must be set up
643 * already which requires DMA setup too and the pci scan will access the 632 * already which requires DMA setup too and the pci scan will access the
@@ -846,6 +835,7 @@ int pcibios_add_device(struct pci_dev *pdev)
846{ 835{
847 struct zpci_dev *zdev = get_zdev(pdev); 836 struct zpci_dev *zdev = get_zdev(pdev);
848 837
838 zdev->pdev = pdev;
849 zpci_debug_init_device(zdev); 839 zpci_debug_init_device(zdev);
850 zpci_fmb_enable_device(zdev); 840 zpci_fmb_enable_device(zdev);
851 zpci_map_resources(zdev); 841 zpci_map_resources(zdev);
@@ -853,7 +843,7 @@ int pcibios_add_device(struct pci_dev *pdev)
853 return 0; 843 return 0;
854} 844}
855 845
856static int zpci_create_device_bus(struct zpci_dev *zdev) 846static int zpci_scan_bus(struct zpci_dev *zdev)
857{ 847{
858 struct resource *res; 848 struct resource *res;
859 LIST_HEAD(resources); 849 LIST_HEAD(resources);
@@ -890,8 +880,8 @@ static int zpci_create_device_bus(struct zpci_dev *zdev)
890 pci_add_resource(&resources, res); 880 pci_add_resource(&resources, res);
891 } 881 }
892 882
893 zdev->bus = pci_create_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops, 883 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
894 zdev, &resources); 884 zdev, &resources);
895 if (!zdev->bus) 885 if (!zdev->bus)
896 return -EIO; 886 return -EIO;
897 887
@@ -955,9 +945,16 @@ int zpci_create_device(struct zpci_dev *zdev)
955 if (rc) 945 if (rc)
956 goto out; 946 goto out;
957 947
958 rc = zpci_create_device_bus(zdev); 948 if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
949 rc = zpci_enable_device(zdev);
950 if (rc)
951 goto out_free;
952
953 zdev->state = ZPCI_FN_STATE_ONLINE;
954 }
955 rc = zpci_scan_bus(zdev);
959 if (rc) 956 if (rc)
960 goto out_bus; 957 goto out_disable;
961 958
962 mutex_lock(&zpci_list_lock); 959 mutex_lock(&zpci_list_lock);
963 list_add_tail(&zdev->entry, &zpci_list); 960 list_add_tail(&zdev->entry, &zpci_list);
@@ -965,21 +962,12 @@ int zpci_create_device(struct zpci_dev *zdev)
965 hotplug_ops->create_slot(zdev); 962 hotplug_ops->create_slot(zdev);
966 mutex_unlock(&zpci_list_lock); 963 mutex_unlock(&zpci_list_lock);
967 964
968 if (zdev->state == ZPCI_FN_STATE_STANDBY)
969 return 0;
970
971 rc = zpci_enable_device(zdev);
972 if (rc)
973 goto out_start;
974 return 0; 965 return 0;
975 966
976out_start: 967out_disable:
977 mutex_lock(&zpci_list_lock); 968 if (zdev->state == ZPCI_FN_STATE_ONLINE)
978 list_del(&zdev->entry); 969 zpci_disable_device(zdev);
979 if (hotplug_ops) 970out_free:
980 hotplug_ops->remove_slot(zdev);
981 mutex_unlock(&zpci_list_lock);
982out_bus:
983 zpci_free_domain(zdev); 971 zpci_free_domain(zdev);
984out: 972out:
985 return rc; 973 return rc;
@@ -1006,10 +994,7 @@ int zpci_scan_device(struct zpci_dev *zdev)
1006 994
1007 pci_bus_add_devices(zdev->bus); 995 pci_bus_add_devices(zdev->bus);
1008 996
1009 /* now that pdev was added to the bus mark it as used */
1010 zdev->state = ZPCI_FN_STATE_ONLINE;
1011 return 0; 997 return 0;
1012
1013out: 998out:
1014 zpci_dma_exit_device(zdev); 999 zpci_dma_exit_device(zdev);
1015 clp_disable_fh(zdev); 1000 clp_disable_fh(zdev);
@@ -1123,7 +1108,6 @@ static int __init pci_base_init(void)
1123 if (rc) 1108 if (rc)
1124 goto out_find; 1109 goto out_find;
1125 1110
1126 zpci_scan_devices();
1127 return 0; 1111 return 0;
1128 1112
1129out_find: 1113out_find: