aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-12-08 04:58:33 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-12-08 04:59:24 -0500
commitec208491936d6adb8a70c3dd4a517cdfe54e823d (patch)
treec7291450e8e559c5fbf3360df30999432204af3c /drivers/pci
parentaa697079ee66315c4b9747a5eb3e48487fb1b8be (diff)
parent7b626acb8f983eb83b396ab96cc24b18d635d487 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Merge the BIOS workarounds from 2.6.32, and the swiotlb fallback on failure.
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/dmar.c59
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c1
-rw-r--r--drivers/pci/hotplug/cpqphp.h1
-rw-r--r--drivers/pci/hotplug/pciehp.h107
-rw-r--r--drivers/pci/hotplug/pciehp_acpi.c17
-rw-r--r--drivers/pci/hotplug/pciehp_core.c136
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c109
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c109
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c23
-rw-r--r--drivers/pci/intel-iommu.c45
-rw-r--r--drivers/pci/pci.c27
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c5
-rw-r--r--drivers/pci/pcie/aspm.c9
-rw-r--r--drivers/pci/pcie/portdrv_pci.c3
-rw-r--r--drivers/pci/quirks.c38
-rw-r--r--drivers/pci/setup-res.c37
16 files changed, 333 insertions, 393 deletions
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 0d064d1e840a..525a32487abd 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -175,15 +175,6 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header)
175 int ret = 0; 175 int ret = 0;
176 176
177 drhd = (struct acpi_dmar_hardware_unit *)header; 177 drhd = (struct acpi_dmar_hardware_unit *)header;
178 if (!drhd->address) {
179 /* Promote an attitude of violence to a BIOS engineer today */
180 WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
181 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
182 dmi_get_system_info(DMI_BIOS_VENDOR),
183 dmi_get_system_info(DMI_BIOS_VERSION),
184 dmi_get_system_info(DMI_PRODUCT_VERSION));
185 return -ENODEV;
186 }
187 dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL); 178 dmaru = kzalloc(sizeof(*dmaru), GFP_KERNEL);
188 if (!dmaru) 179 if (!dmaru)
189 return -ENOMEM; 180 return -ENOMEM;
@@ -622,12 +613,53 @@ int __init dmar_table_init(void)
622 return 0; 613 return 0;
623} 614}
624 615
616int __init check_zero_address(void)
617{
618 struct acpi_table_dmar *dmar;
619 struct acpi_dmar_header *entry_header;
620 struct acpi_dmar_hardware_unit *drhd;
621
622 dmar = (struct acpi_table_dmar *)dmar_tbl;
623 entry_header = (struct acpi_dmar_header *)(dmar + 1);
624
625 while (((unsigned long)entry_header) <
626 (((unsigned long)dmar) + dmar_tbl->length)) {
627 /* Avoid looping forever on bad ACPI tables */
628 if (entry_header->length == 0) {
629 printk(KERN_WARNING PREFIX
630 "Invalid 0-length structure\n");
631 return 0;
632 }
633
634 if (entry_header->type == ACPI_DMAR_TYPE_HARDWARE_UNIT) {
635 drhd = (void *)entry_header;
636 if (!drhd->address) {
637 /* Promote an attitude of violence to a BIOS engineer today */
638 WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
639 "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
640 dmi_get_system_info(DMI_BIOS_VENDOR),
641 dmi_get_system_info(DMI_BIOS_VERSION),
642 dmi_get_system_info(DMI_PRODUCT_VERSION));
643#ifdef CONFIG_DMAR
644 dmar_disabled = 1;
645#endif
646 return 0;
647 }
648 break;
649 }
650
651 entry_header = ((void *)entry_header + entry_header->length);
652 }
653 return 1;
654}
655
625void __init detect_intel_iommu(void) 656void __init detect_intel_iommu(void)
626{ 657{
627 int ret; 658 int ret;
628 659
629 ret = dmar_table_detect(); 660 ret = dmar_table_detect();
630 661 if (ret)
662 ret = check_zero_address();
631 { 663 {
632#ifdef CONFIG_INTR_REMAP 664#ifdef CONFIG_INTR_REMAP
633 struct acpi_table_dmar *dmar; 665 struct acpi_table_dmar *dmar;
@@ -644,10 +676,13 @@ void __init detect_intel_iommu(void)
644 "x2apic and Intr-remapping.\n"); 676 "x2apic and Intr-remapping.\n");
645#endif 677#endif
646#ifdef CONFIG_DMAR 678#ifdef CONFIG_DMAR
647 if (ret && !no_iommu && !iommu_detected && !swiotlb && 679 if (ret && !no_iommu && !iommu_detected && !dmar_disabled)
648 !dmar_disabled)
649 iommu_detected = 1; 680 iommu_detected = 1;
650#endif 681#endif
682#ifdef CONFIG_X86
683 if (ret)
684 x86_init.iommu.iommu_init = intel_iommu_init;
685#endif
651 } 686 }
652 early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size); 687 early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size);
653 dmar_tbl = NULL; 688 dmar_tbl = NULL;
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index a9d926b7d805..e7be66dbac21 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -406,7 +406,6 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
406 __func__, status); 406 __func__, status);
407 return retval; 407 return retval;
408 } 408 }
409 info->hardware_id.string[sizeof(info->hardware_id.length) - 1] = '\0';
410 409
411 if (info->current_status && (info->valid & ACPI_VALID_HID) && 410 if (info->current_status && (info->valid & ACPI_VALID_HID) &&
412 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || 411 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) ||
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index 53836001d511..9c6a9fd26812 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -32,6 +32,7 @@
32#include <asm/io.h> /* for read? and write? functions */ 32#include <asm/io.h> /* for read? and write? functions */
33#include <linux/delay.h> /* for delays */ 33#include <linux/delay.h> /* for delays */
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/sched.h> /* for signal_pending() */
35 36
36#define MY_NAME "cpqphp" 37#define MY_NAME "cpqphp"
37 38
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 36faa9a8e18f..3070f77eb56a 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -72,15 +72,9 @@ do { \
72 72
73#define SLOT_NAME_SIZE 10 73#define SLOT_NAME_SIZE 10
74struct slot { 74struct slot {
75 u8 bus;
76 u8 device;
77 u8 state; 75 u8 state;
78 u8 hp_slot;
79 u32 number;
80 struct controller *ctrl; 76 struct controller *ctrl;
81 struct hpc_ops *hpc_ops;
82 struct hotplug_slot *hotplug_slot; 77 struct hotplug_slot *hotplug_slot;
83 struct list_head slot_list;
84 struct delayed_work work; /* work for button event */ 78 struct delayed_work work; /* work for button event */
85 struct mutex lock; 79 struct mutex lock;
86}; 80};
@@ -92,18 +86,10 @@ struct event_info {
92}; 86};
93 87
94struct controller { 88struct controller {
95 struct mutex crit_sect; /* critical section mutex */
96 struct mutex ctrl_lock; /* controller lock */ 89 struct mutex ctrl_lock; /* controller lock */
97 int num_slots; /* Number of slots on ctlr */
98 int slot_num_inc; /* 1 or -1 */
99 struct pci_dev *pci_dev;
100 struct pcie_device *pcie; /* PCI Express port service */ 90 struct pcie_device *pcie; /* PCI Express port service */
101 struct list_head slot_list; 91 struct slot *slot;
102 struct hpc_ops *hpc_ops;
103 wait_queue_head_t queue; /* sleep & wake process */ 92 wait_queue_head_t queue; /* sleep & wake process */
104 u8 slot_device_offset;
105 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */
106 u8 slot_bus; /* Bus where the slots handled by this controller sit */
107 u32 slot_cap; 93 u32 slot_cap;
108 u8 cap_base; 94 u8 cap_base;
109 struct timer_list poll_timer; 95 struct timer_list poll_timer;
@@ -131,40 +117,20 @@ struct controller {
131#define POWERON_STATE 3 117#define POWERON_STATE 3
132#define POWEROFF_STATE 4 118#define POWEROFF_STATE 4
133 119
134/* Error messages */ 120#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_ABP)
135#define INTERLOCK_OPEN 0x00000002 121#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PCP)
136#define ADD_NOT_SUPPORTED 0x00000003 122#define MRL_SENS(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_MRLSP)
137#define CARD_FUNCTIONING 0x00000005 123#define ATTN_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_AIP)
138#define ADAPTER_NOT_SAME 0x00000006 124#define PWR_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PIP)
139#define NO_ADAPTER_PRESENT 0x00000009 125#define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPS)
140#define NOT_ENOUGH_RESOURCES 0x0000000B 126#define EMI(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_EIP)
141#define DEVICE_TYPE_NOT_SUPPORTED 0x0000000C 127#define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS)
142#define WRONG_BUS_FREQUENCY 0x0000000D 128#define PSN(ctrl) ((ctrl)->slot_cap >> 19)
143#define POWER_FAILURE 0x0000000E
144
145/* Field definitions in Slot Capabilities Register */
146#define ATTN_BUTTN_PRSN 0x00000001
147#define PWR_CTRL_PRSN 0x00000002
148#define MRL_SENS_PRSN 0x00000004
149#define ATTN_LED_PRSN 0x00000008
150#define PWR_LED_PRSN 0x00000010
151#define HP_SUPR_RM_SUP 0x00000020
152#define EMI_PRSN 0x00020000
153#define NO_CMD_CMPL_SUP 0x00040000
154
155#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & ATTN_BUTTN_PRSN)
156#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PWR_CTRL_PRSN)
157#define MRL_SENS(ctrl) ((ctrl)->slot_cap & MRL_SENS_PRSN)
158#define ATTN_LED(ctrl) ((ctrl)->slot_cap & ATTN_LED_PRSN)
159#define PWR_LED(ctrl) ((ctrl)->slot_cap & PWR_LED_PRSN)
160#define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & HP_SUPR_RM_SUP)
161#define EMI(ctrl) ((ctrl)->slot_cap & EMI_PRSN)
162#define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & NO_CMD_CMPL_SUP)
163 129
164extern int pciehp_sysfs_enable_slot(struct slot *slot); 130extern int pciehp_sysfs_enable_slot(struct slot *slot);
165extern int pciehp_sysfs_disable_slot(struct slot *slot); 131extern int pciehp_sysfs_disable_slot(struct slot *slot);
166extern u8 pciehp_handle_attention_button(struct slot *p_slot); 132extern u8 pciehp_handle_attention_button(struct slot *p_slot);
167 extern u8 pciehp_handle_switch_change(struct slot *p_slot); 133extern u8 pciehp_handle_switch_change(struct slot *p_slot);
168extern u8 pciehp_handle_presence_change(struct slot *p_slot); 134extern u8 pciehp_handle_presence_change(struct slot *p_slot);
169extern u8 pciehp_handle_power_fault(struct slot *p_slot); 135extern u8 pciehp_handle_power_fault(struct slot *p_slot);
170extern int pciehp_configure_device(struct slot *p_slot); 136extern int pciehp_configure_device(struct slot *p_slot);
@@ -175,45 +141,30 @@ int pcie_init_notification(struct controller *ctrl);
175int pciehp_enable_slot(struct slot *p_slot); 141int pciehp_enable_slot(struct slot *p_slot);
176int pciehp_disable_slot(struct slot *p_slot); 142int pciehp_disable_slot(struct slot *p_slot);
177int pcie_enable_notification(struct controller *ctrl); 143int pcie_enable_notification(struct controller *ctrl);
144int pciehp_power_on_slot(struct slot *slot);
145int pciehp_power_off_slot(struct slot *slot);
146int pciehp_get_power_status(struct slot *slot, u8 *status);
147int pciehp_get_attention_status(struct slot *slot, u8 *status);
148
149int pciehp_set_attention_status(struct slot *slot, u8 status);
150int pciehp_get_latch_status(struct slot *slot, u8 *status);
151int pciehp_get_adapter_status(struct slot *slot, u8 *status);
152int pciehp_get_max_link_speed(struct slot *slot, enum pci_bus_speed *speed);
153int pciehp_get_max_link_width(struct slot *slot, enum pcie_link_width *val);
154int pciehp_get_cur_link_speed(struct slot *slot, enum pci_bus_speed *speed);
155int pciehp_get_cur_link_width(struct slot *slot, enum pcie_link_width *val);
156int pciehp_query_power_fault(struct slot *slot);
157void pciehp_green_led_on(struct slot *slot);
158void pciehp_green_led_off(struct slot *slot);
159void pciehp_green_led_blink(struct slot *slot);
160int pciehp_check_link_status(struct controller *ctrl);
161void pciehp_release_ctrl(struct controller *ctrl);
178 162
179static inline const char *slot_name(struct slot *slot) 163static inline const char *slot_name(struct slot *slot)
180{ 164{
181 return hotplug_slot_name(slot->hotplug_slot); 165 return hotplug_slot_name(slot->hotplug_slot);
182} 166}
183 167
184static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
185{
186 struct slot *slot;
187
188 list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
189 if (slot->device == device)
190 return slot;
191 }
192
193 ctrl_err(ctrl, "Slot (device=0x%02x) not found\n", device);
194 return NULL;
195}
196
197struct hpc_ops {
198 int (*power_on_slot)(struct slot *slot);
199 int (*power_off_slot)(struct slot *slot);
200 int (*get_power_status)(struct slot *slot, u8 *status);
201 int (*get_attention_status)(struct slot *slot, u8 *status);
202 int (*set_attention_status)(struct slot *slot, u8 status);
203 int (*get_latch_status)(struct slot *slot, u8 *status);
204 int (*get_adapter_status)(struct slot *slot, u8 *status);
205 int (*get_max_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
206 int (*get_cur_bus_speed)(struct slot *slot, enum pci_bus_speed *speed);
207 int (*get_max_lnk_width)(struct slot *slot, enum pcie_link_width *val);
208 int (*get_cur_lnk_width)(struct slot *slot, enum pcie_link_width *val);
209 int (*query_power_fault)(struct slot *slot);
210 void (*green_led_on)(struct slot *slot);
211 void (*green_led_off)(struct slot *slot);
212 void (*green_led_blink)(struct slot *slot);
213 void (*release_ctlr)(struct controller *ctrl);
214 int (*check_lnk_status)(struct controller *ctrl);
215};
216
217#ifdef CONFIG_ACPI 168#ifdef CONFIG_ACPI
218#include <acpi/acpi.h> 169#include <acpi/acpi.h>
219#include <acpi/acpi_bus.h> 170#include <acpi/acpi_bus.h>
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c
index 7163e6a6cfae..37c8d3d0323e 100644
--- a/drivers/pci/hotplug/pciehp_acpi.c
+++ b/drivers/pci/hotplug/pciehp_acpi.c
@@ -33,6 +33,11 @@
33#define PCIEHP_DETECT_AUTO (2) 33#define PCIEHP_DETECT_AUTO (2)
34#define PCIEHP_DETECT_DEFAULT PCIEHP_DETECT_AUTO 34#define PCIEHP_DETECT_DEFAULT PCIEHP_DETECT_AUTO
35 35
36struct dummy_slot {
37 u32 number;
38 struct list_head list;
39};
40
36static int slot_detection_mode; 41static int slot_detection_mode;
37static char *pciehp_detect_mode; 42static char *pciehp_detect_mode;
38module_param(pciehp_detect_mode, charp, 0444); 43module_param(pciehp_detect_mode, charp, 0444);
@@ -77,7 +82,7 @@ static int __init dummy_probe(struct pcie_device *dev)
77 int pos; 82 int pos;
78 u32 slot_cap; 83 u32 slot_cap;
79 acpi_handle handle; 84 acpi_handle handle;
80 struct slot *slot, *tmp; 85 struct dummy_slot *slot, *tmp;
81 struct pci_dev *pdev = dev->port; 86 struct pci_dev *pdev = dev->port;
82 /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */ 87 /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */
83 if (pciehp_get_hp_hw_control_from_firmware(pdev)) 88 if (pciehp_get_hp_hw_control_from_firmware(pdev))
@@ -89,11 +94,11 @@ static int __init dummy_probe(struct pcie_device *dev)
89 if (!slot) 94 if (!slot)
90 return -ENOMEM; 95 return -ENOMEM;
91 slot->number = slot_cap >> 19; 96 slot->number = slot_cap >> 19;
92 list_for_each_entry(tmp, &dummy_slots, slot_list) { 97 list_for_each_entry(tmp, &dummy_slots, list) {
93 if (tmp->number == slot->number) 98 if (tmp->number == slot->number)
94 dup_slot_id++; 99 dup_slot_id++;
95 } 100 }
96 list_add_tail(&slot->slot_list, &dummy_slots); 101 list_add_tail(&slot->list, &dummy_slots);
97 handle = DEVICE_ACPI_HANDLE(&pdev->dev); 102 handle = DEVICE_ACPI_HANDLE(&pdev->dev);
98 if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle)) 103 if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle))
99 acpi_slot_detected = 1; 104 acpi_slot_detected = 1;
@@ -109,11 +114,11 @@ static struct pcie_port_service_driver __initdata dummy_driver = {
109 114
110static int __init select_detection_mode(void) 115static int __init select_detection_mode(void)
111{ 116{
112 struct slot *slot, *tmp; 117 struct dummy_slot *slot, *tmp;
113 pcie_port_service_register(&dummy_driver); 118 pcie_port_service_register(&dummy_driver);
114 pcie_port_service_unregister(&dummy_driver); 119 pcie_port_service_unregister(&dummy_driver);
115 list_for_each_entry_safe(slot, tmp, &dummy_slots, slot_list) { 120 list_for_each_entry_safe(slot, tmp, &dummy_slots, list) {
116 list_del(&slot->slot_list); 121 list_del(&slot->list);
117 kfree(slot); 122 kfree(slot);
118 } 123 }
119 if (acpi_slot_detected && dup_slot_id) 124 if (acpi_slot_detected && dup_slot_id)
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 2317557fdee6..bc234719b1df 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -99,65 +99,55 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
99 kfree(hotplug_slot); 99 kfree(hotplug_slot);
100} 100}
101 101
102static int init_slots(struct controller *ctrl) 102static int init_slot(struct controller *ctrl)
103{ 103{
104 struct slot *slot; 104 struct slot *slot = ctrl->slot;
105 struct hotplug_slot *hotplug_slot; 105 struct hotplug_slot *hotplug = NULL;
106 struct hotplug_slot_info *info; 106 struct hotplug_slot_info *info = NULL;
107 char name[SLOT_NAME_SIZE]; 107 char name[SLOT_NAME_SIZE];
108 int retval = -ENOMEM; 108 int retval = -ENOMEM;
109 109
110 list_for_each_entry(slot, &ctrl->slot_list, slot_list) { 110 hotplug = kzalloc(sizeof(*hotplug), GFP_KERNEL);
111 hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); 111 if (!hotplug)
112 if (!hotplug_slot) 112 goto out;
113 goto error; 113
114 114 info = kzalloc(sizeof(*info), GFP_KERNEL);
115 info = kzalloc(sizeof(*info), GFP_KERNEL); 115 if (!info)
116 if (!info) 116 goto out;
117 goto error_hpslot; 117
118 118 /* register this slot with the hotplug pci core */
119 /* register this slot with the hotplug pci core */ 119 hotplug->info = info;
120 hotplug_slot->info = info; 120 hotplug->private = slot;
121 hotplug_slot->private = slot; 121 hotplug->release = &release_slot;
122 hotplug_slot->release = &release_slot; 122 hotplug->ops = &pciehp_hotplug_slot_ops;
123 hotplug_slot->ops = &pciehp_hotplug_slot_ops; 123 slot->hotplug_slot = hotplug;
124 slot->hotplug_slot = hotplug_slot; 124 snprintf(name, SLOT_NAME_SIZE, "%u", PSN(ctrl));
125 snprintf(name, SLOT_NAME_SIZE, "%u", slot->number); 125
126 126 ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:00 sun=%x\n",
127 ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x " 127 pci_domain_nr(ctrl->pcie->port->subordinate),
128 "hp_slot=%x sun=%x slot_device_offset=%x\n", 128 ctrl->pcie->port->subordinate->number, PSN(ctrl));
129 pci_domain_nr(ctrl->pci_dev->subordinate), 129 retval = pci_hp_register(hotplug,
130 slot->bus, slot->device, slot->hp_slot, slot->number, 130 ctrl->pcie->port->subordinate, 0, name);
131 ctrl->slot_device_offset); 131 if (retval) {
132 retval = pci_hp_register(hotplug_slot, 132 ctrl_err(ctrl,
133 ctrl->pci_dev->subordinate, 133 "pci_hp_register failed with error %d\n", retval);
134 slot->device, 134 goto out;
135 name); 135 }
136 if (retval) { 136 get_power_status(hotplug, &info->power_status);
137 ctrl_err(ctrl, "pci_hp_register failed with error %d\n", 137 get_attention_status(hotplug, &info->attention_status);
138 retval); 138 get_latch_status(hotplug, &info->latch_status);
139 goto error_info; 139 get_adapter_status(hotplug, &info->adapter_status);
140 } 140out:
141 get_power_status(hotplug_slot, &info->power_status); 141 if (retval) {
142 get_attention_status(hotplug_slot, &info->attention_status); 142 kfree(info);
143 get_latch_status(hotplug_slot, &info->latch_status); 143 kfree(hotplug);
144 get_adapter_status(hotplug_slot, &info->adapter_status);
145 } 144 }
146
147 return 0;
148error_info:
149 kfree(info);
150error_hpslot:
151 kfree(hotplug_slot);
152error:
153 return retval; 145 return retval;
154} 146}
155 147
156static void cleanup_slots(struct controller *ctrl) 148static void cleanup_slot(struct controller *ctrl)
157{ 149{
158 struct slot *slot; 150 pci_hp_deregister(ctrl->slot->hotplug_slot);
159 list_for_each_entry(slot, &ctrl->slot_list, slot_list)
160 pci_hp_deregister(slot->hotplug_slot);
161} 151}
162 152
163/* 153/*
@@ -173,7 +163,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
173 hotplug_slot->info->attention_status = status; 163 hotplug_slot->info->attention_status = status;
174 164
175 if (ATTN_LED(slot->ctrl)) 165 if (ATTN_LED(slot->ctrl))
176 slot->hpc_ops->set_attention_status(slot, status); 166 pciehp_set_attention_status(slot, status);
177 167
178 return 0; 168 return 0;
179} 169}
@@ -208,7 +198,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
208 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 198 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
209 __func__, slot_name(slot)); 199 __func__, slot_name(slot));
210 200
211 retval = slot->hpc_ops->get_power_status(slot, value); 201 retval = pciehp_get_power_status(slot, value);
212 if (retval < 0) 202 if (retval < 0)
213 *value = hotplug_slot->info->power_status; 203 *value = hotplug_slot->info->power_status;
214 204
@@ -223,7 +213,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
223 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 213 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
224 __func__, slot_name(slot)); 214 __func__, slot_name(slot));
225 215
226 retval = slot->hpc_ops->get_attention_status(slot, value); 216 retval = pciehp_get_attention_status(slot, value);
227 if (retval < 0) 217 if (retval < 0)
228 *value = hotplug_slot->info->attention_status; 218 *value = hotplug_slot->info->attention_status;
229 219
@@ -238,7 +228,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
238 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 228 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
239 __func__, slot_name(slot)); 229 __func__, slot_name(slot));
240 230
241 retval = slot->hpc_ops->get_latch_status(slot, value); 231 retval = pciehp_get_latch_status(slot, value);
242 if (retval < 0) 232 if (retval < 0)
243 *value = hotplug_slot->info->latch_status; 233 *value = hotplug_slot->info->latch_status;
244 234
@@ -253,7 +243,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
253 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 243 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
254 __func__, slot_name(slot)); 244 __func__, slot_name(slot));
255 245
256 retval = slot->hpc_ops->get_adapter_status(slot, value); 246 retval = pciehp_get_adapter_status(slot, value);
257 if (retval < 0) 247 if (retval < 0)
258 *value = hotplug_slot->info->adapter_status; 248 *value = hotplug_slot->info->adapter_status;
259 249
@@ -269,7 +259,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
269 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 259 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
270 __func__, slot_name(slot)); 260 __func__, slot_name(slot));
271 261
272 retval = slot->hpc_ops->get_max_bus_speed(slot, value); 262 retval = pciehp_get_max_link_speed(slot, value);
273 if (retval < 0) 263 if (retval < 0)
274 *value = PCI_SPEED_UNKNOWN; 264 *value = PCI_SPEED_UNKNOWN;
275 265
@@ -284,7 +274,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
284 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n", 274 ctrl_dbg(slot->ctrl, "%s: physical_slot = %s\n",
285 __func__, slot_name(slot)); 275 __func__, slot_name(slot));
286 276
287 retval = slot->hpc_ops->get_cur_bus_speed(slot, value); 277 retval = pciehp_get_cur_link_speed(slot, value);
288 if (retval < 0) 278 if (retval < 0)
289 *value = PCI_SPEED_UNKNOWN; 279 *value = PCI_SPEED_UNKNOWN;
290 280
@@ -295,7 +285,7 @@ static int pciehp_probe(struct pcie_device *dev)
295{ 285{
296 int rc; 286 int rc;
297 struct controller *ctrl; 287 struct controller *ctrl;
298 struct slot *t_slot; 288 struct slot *slot;
299 u8 value; 289 u8 value;
300 struct pci_dev *pdev = dev->port; 290 struct pci_dev *pdev = dev->port;
301 291
@@ -314,7 +304,7 @@ static int pciehp_probe(struct pcie_device *dev)
314 set_service_data(dev, ctrl); 304 set_service_data(dev, ctrl);
315 305
316 /* Setup the slot information structures */ 306 /* Setup the slot information structures */
317 rc = init_slots(ctrl); 307 rc = init_slot(ctrl);
318 if (rc) { 308 if (rc) {
319 if (rc == -EBUSY) 309 if (rc == -EBUSY)
320 ctrl_warn(ctrl, "Slot already registered by another " 310 ctrl_warn(ctrl, "Slot already registered by another "
@@ -332,15 +322,15 @@ static int pciehp_probe(struct pcie_device *dev)
332 } 322 }
333 323
334 /* Check if slot is occupied */ 324 /* Check if slot is occupied */
335 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 325 slot = ctrl->slot;
336 t_slot->hpc_ops->get_adapter_status(t_slot, &value); 326 pciehp_get_adapter_status(slot, &value);
337 if (value) { 327 if (value) {
338 if (pciehp_force) 328 if (pciehp_force)
339 pciehp_enable_slot(t_slot); 329 pciehp_enable_slot(slot);
340 } else { 330 } else {
341 /* Power off slot if not occupied */ 331 /* Power off slot if not occupied */
342 if (POWER_CTRL(ctrl)) { 332 if (POWER_CTRL(ctrl)) {
343 rc = t_slot->hpc_ops->power_off_slot(t_slot); 333 rc = pciehp_power_off_slot(slot);
344 if (rc) 334 if (rc)
345 goto err_out_free_ctrl_slot; 335 goto err_out_free_ctrl_slot;
346 } 336 }
@@ -349,19 +339,19 @@ static int pciehp_probe(struct pcie_device *dev)
349 return 0; 339 return 0;
350 340
351err_out_free_ctrl_slot: 341err_out_free_ctrl_slot:
352 cleanup_slots(ctrl); 342 cleanup_slot(ctrl);
353err_out_release_ctlr: 343err_out_release_ctlr:
354 ctrl->hpc_ops->release_ctlr(ctrl); 344 pciehp_release_ctrl(ctrl);
355err_out_none: 345err_out_none:
356 return -ENODEV; 346 return -ENODEV;
357} 347}
358 348
359static void pciehp_remove (struct pcie_device *dev) 349static void pciehp_remove(struct pcie_device *dev)
360{ 350{
361 struct controller *ctrl = get_service_data(dev); 351 struct controller *ctrl = get_service_data(dev);
362 352
363 cleanup_slots(ctrl); 353 cleanup_slot(ctrl);
364 ctrl->hpc_ops->release_ctlr(ctrl); 354 pciehp_release_ctrl(ctrl);
365} 355}
366 356
367#ifdef CONFIG_PM 357#ifdef CONFIG_PM
@@ -376,20 +366,20 @@ static int pciehp_resume (struct pcie_device *dev)
376 dev_info(&dev->device, "%s ENTRY\n", __func__); 366 dev_info(&dev->device, "%s ENTRY\n", __func__);
377 if (pciehp_force) { 367 if (pciehp_force) {
378 struct controller *ctrl = get_service_data(dev); 368 struct controller *ctrl = get_service_data(dev);
379 struct slot *t_slot; 369 struct slot *slot;
380 u8 status; 370 u8 status;
381 371
382 /* reinitialize the chipset's event detection logic */ 372 /* reinitialize the chipset's event detection logic */
383 pcie_enable_notification(ctrl); 373 pcie_enable_notification(ctrl);
384 374
385 t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 375 slot = ctrl->slot;
386 376
387 /* Check if slot is occupied */ 377 /* Check if slot is occupied */
388 t_slot->hpc_ops->get_adapter_status(t_slot, &status); 378 pciehp_get_adapter_status(slot, &status);
389 if (status) 379 if (status)
390 pciehp_enable_slot(t_slot); 380 pciehp_enable_slot(slot);
391 else 381 else
392 pciehp_disable_slot(t_slot); 382 pciehp_disable_slot(slot);
393 } 383 }
394 return 0; 384 return 0;
395} 385}
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index b97cb4c3e0fe..84487d126e4d 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -82,7 +82,7 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
82 /* Switch Change */ 82 /* Switch Change */
83 ctrl_dbg(ctrl, "Switch interrupt received\n"); 83 ctrl_dbg(ctrl, "Switch interrupt received\n");
84 84
85 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 85 pciehp_get_latch_status(p_slot, &getstatus);
86 if (getstatus) { 86 if (getstatus) {
87 /* 87 /*
88 * Switch opened 88 * Switch opened
@@ -114,7 +114,7 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
114 /* Switch is open, assume a presence change 114 /* Switch is open, assume a presence change
115 * Save the presence state 115 * Save the presence state
116 */ 116 */
117 p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save); 117 pciehp_get_adapter_status(p_slot, &presence_save);
118 if (presence_save) { 118 if (presence_save) {
119 /* 119 /*
120 * Card Present 120 * Card Present
@@ -143,7 +143,7 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
143 /* power fault */ 143 /* power fault */
144 ctrl_dbg(ctrl, "Power fault interrupt received\n"); 144 ctrl_dbg(ctrl, "Power fault interrupt received\n");
145 145
146 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) { 146 if (!pciehp_query_power_fault(p_slot)) {
147 /* 147 /*
148 * power fault Cleared 148 * power fault Cleared
149 */ 149 */
@@ -172,7 +172,7 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
172{ 172{
173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 173 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
174 if (POWER_CTRL(ctrl)) { 174 if (POWER_CTRL(ctrl)) {
175 if (pslot->hpc_ops->power_off_slot(pslot)) { 175 if (pciehp_power_off_slot(pslot)) {
176 ctrl_err(ctrl, 176 ctrl_err(ctrl,
177 "Issue of Slot Power Off command failed\n"); 177 "Issue of Slot Power Off command failed\n");
178 return; 178 return;
@@ -186,10 +186,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
186 } 186 }
187 187
188 if (PWR_LED(ctrl)) 188 if (PWR_LED(ctrl))
189 pslot->hpc_ops->green_led_off(pslot); 189 pciehp_green_led_off(pslot);
190 190
191 if (ATTN_LED(ctrl)) { 191 if (ATTN_LED(ctrl)) {
192 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 192 if (pciehp_set_attention_status(pslot, 1)) {
193 ctrl_err(ctrl, 193 ctrl_err(ctrl,
194 "Issue of Set Attention Led command failed\n"); 194 "Issue of Set Attention Led command failed\n");
195 return; 195 return;
@@ -208,24 +208,20 @@ static int board_added(struct slot *p_slot)
208{ 208{
209 int retval = 0; 209 int retval = 0;
210 struct controller *ctrl = p_slot->ctrl; 210 struct controller *ctrl = p_slot->ctrl;
211 struct pci_bus *parent = ctrl->pci_dev->subordinate; 211 struct pci_bus *parent = ctrl->pcie->port->subordinate;
212
213 ctrl_dbg(ctrl, "%s: slot device, slot offset, hp slot = %d, %d, %d\n",
214 __func__, p_slot->device, ctrl->slot_device_offset,
215 p_slot->hp_slot);
216 212
217 if (POWER_CTRL(ctrl)) { 213 if (POWER_CTRL(ctrl)) {
218 /* Power on slot */ 214 /* Power on slot */
219 retval = p_slot->hpc_ops->power_on_slot(p_slot); 215 retval = pciehp_power_on_slot(p_slot);
220 if (retval) 216 if (retval)
221 return retval; 217 return retval;
222 } 218 }
223 219
224 if (PWR_LED(ctrl)) 220 if (PWR_LED(ctrl))
225 p_slot->hpc_ops->green_led_blink(p_slot); 221 pciehp_green_led_blink(p_slot);
226 222
227 /* Check link training status */ 223 /* Check link training status */
228 retval = p_slot->hpc_ops->check_lnk_status(ctrl); 224 retval = pciehp_check_link_status(ctrl);
229 if (retval) { 225 if (retval) {
230 ctrl_err(ctrl, "Failed to check link status\n"); 226 ctrl_err(ctrl, "Failed to check link status\n");
231 set_slot_off(ctrl, p_slot); 227 set_slot_off(ctrl, p_slot);
@@ -233,21 +229,21 @@ static int board_added(struct slot *p_slot)
233 } 229 }
234 230
235 /* Check for a power fault */ 231 /* Check for a power fault */
236 if (p_slot->hpc_ops->query_power_fault(p_slot)) { 232 if (pciehp_query_power_fault(p_slot)) {
237 ctrl_dbg(ctrl, "Power fault detected\n"); 233 ctrl_dbg(ctrl, "Power fault detected\n");
238 retval = POWER_FAILURE; 234 retval = -EIO;
239 goto err_exit; 235 goto err_exit;
240 } 236 }
241 237
242 retval = pciehp_configure_device(p_slot); 238 retval = pciehp_configure_device(p_slot);
243 if (retval) { 239 if (retval) {
244 ctrl_err(ctrl, "Cannot add device at %04x:%02x:%02x\n", 240 ctrl_err(ctrl, "Cannot add device at %04x:%02x:00\n",
245 pci_domain_nr(parent), p_slot->bus, p_slot->device); 241 pci_domain_nr(parent), parent->number);
246 goto err_exit; 242 goto err_exit;
247 } 243 }
248 244
249 if (PWR_LED(ctrl)) 245 if (PWR_LED(ctrl))
250 p_slot->hpc_ops->green_led_on(p_slot); 246 pciehp_green_led_on(p_slot);
251 247
252 return 0; 248 return 0;
253 249
@@ -269,11 +265,9 @@ static int remove_board(struct slot *p_slot)
269 if (retval) 265 if (retval)
270 return retval; 266 return retval;
271 267
272 ctrl_dbg(ctrl, "%s: hp_slot = %d\n", __func__, p_slot->hp_slot);
273
274 if (POWER_CTRL(ctrl)) { 268 if (POWER_CTRL(ctrl)) {
275 /* power off slot */ 269 /* power off slot */
276 retval = p_slot->hpc_ops->power_off_slot(p_slot); 270 retval = pciehp_power_off_slot(p_slot);
277 if (retval) { 271 if (retval) {
278 ctrl_err(ctrl, 272 ctrl_err(ctrl,
279 "Issue of Slot Disable command failed\n"); 273 "Issue of Slot Disable command failed\n");
@@ -287,9 +281,9 @@ static int remove_board(struct slot *p_slot)
287 msleep(1000); 281 msleep(1000);
288 } 282 }
289 283
284 /* turn off Green LED */
290 if (PWR_LED(ctrl)) 285 if (PWR_LED(ctrl))
291 /* turn off Green LED */ 286 pciehp_green_led_off(p_slot);
292 p_slot->hpc_ops->green_led_off(p_slot);
293 287
294 return 0; 288 return 0;
295} 289}
@@ -317,18 +311,17 @@ static void pciehp_power_thread(struct work_struct *work)
317 case POWEROFF_STATE: 311 case POWEROFF_STATE:
318 mutex_unlock(&p_slot->lock); 312 mutex_unlock(&p_slot->lock);
319 ctrl_dbg(p_slot->ctrl, 313 ctrl_dbg(p_slot->ctrl,
320 "Disabling domain:bus:device=%04x:%02x:%02x\n", 314 "Disabling domain:bus:device=%04x:%02x:00\n",
321 pci_domain_nr(p_slot->ctrl->pci_dev->subordinate), 315 pci_domain_nr(p_slot->ctrl->pcie->port->subordinate),
322 p_slot->bus, p_slot->device); 316 p_slot->ctrl->pcie->port->subordinate->number);
323 pciehp_disable_slot(p_slot); 317 pciehp_disable_slot(p_slot);
324 mutex_lock(&p_slot->lock); 318 mutex_lock(&p_slot->lock);
325 p_slot->state = STATIC_STATE; 319 p_slot->state = STATIC_STATE;
326 break; 320 break;
327 case POWERON_STATE: 321 case POWERON_STATE:
328 mutex_unlock(&p_slot->lock); 322 mutex_unlock(&p_slot->lock);
329 if (pciehp_enable_slot(p_slot) && 323 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl))
330 PWR_LED(p_slot->ctrl)) 324 pciehp_green_led_off(p_slot);
331 p_slot->hpc_ops->green_led_off(p_slot);
332 mutex_lock(&p_slot->lock); 325 mutex_lock(&p_slot->lock);
333 p_slot->state = STATIC_STATE; 326 p_slot->state = STATIC_STATE;
334 break; 327 break;
@@ -379,10 +372,10 @@ static int update_slot_info(struct slot *slot)
379 if (!info) 372 if (!info)
380 return -ENOMEM; 373 return -ENOMEM;
381 374
382 slot->hpc_ops->get_power_status(slot, &(info->power_status)); 375 pciehp_get_power_status(slot, &info->power_status);
383 slot->hpc_ops->get_attention_status(slot, &(info->attention_status)); 376 pciehp_get_attention_status(slot, &info->attention_status);
384 slot->hpc_ops->get_latch_status(slot, &(info->latch_status)); 377 pciehp_get_latch_status(slot, &info->latch_status);
385 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status)); 378 pciehp_get_adapter_status(slot, &info->adapter_status);
386 379
387 result = pci_hp_change_slot_info(slot->hotplug_slot, info); 380 result = pci_hp_change_slot_info(slot->hotplug_slot, info);
388 kfree (info); 381 kfree (info);
@@ -399,7 +392,7 @@ static void handle_button_press_event(struct slot *p_slot)
399 392
400 switch (p_slot->state) { 393 switch (p_slot->state) {
401 case STATIC_STATE: 394 case STATIC_STATE:
402 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 395 pciehp_get_power_status(p_slot, &getstatus);
403 if (getstatus) { 396 if (getstatus) {
404 p_slot->state = BLINKINGOFF_STATE; 397 p_slot->state = BLINKINGOFF_STATE;
405 ctrl_info(ctrl, 398 ctrl_info(ctrl,
@@ -413,9 +406,9 @@ static void handle_button_press_event(struct slot *p_slot)
413 } 406 }
414 /* blink green LED and turn off amber */ 407 /* blink green LED and turn off amber */
415 if (PWR_LED(ctrl)) 408 if (PWR_LED(ctrl))
416 p_slot->hpc_ops->green_led_blink(p_slot); 409 pciehp_green_led_blink(p_slot);
417 if (ATTN_LED(ctrl)) 410 if (ATTN_LED(ctrl))
418 p_slot->hpc_ops->set_attention_status(p_slot, 0); 411 pciehp_set_attention_status(p_slot, 0);
419 412
420 schedule_delayed_work(&p_slot->work, 5*HZ); 413 schedule_delayed_work(&p_slot->work, 5*HZ);
421 break; 414 break;
@@ -430,13 +423,13 @@ static void handle_button_press_event(struct slot *p_slot)
430 cancel_delayed_work(&p_slot->work); 423 cancel_delayed_work(&p_slot->work);
431 if (p_slot->state == BLINKINGOFF_STATE) { 424 if (p_slot->state == BLINKINGOFF_STATE) {
432 if (PWR_LED(ctrl)) 425 if (PWR_LED(ctrl))
433 p_slot->hpc_ops->green_led_on(p_slot); 426 pciehp_green_led_on(p_slot);
434 } else { 427 } else {
435 if (PWR_LED(ctrl)) 428 if (PWR_LED(ctrl))
436 p_slot->hpc_ops->green_led_off(p_slot); 429 pciehp_green_led_off(p_slot);
437 } 430 }
438 if (ATTN_LED(ctrl)) 431 if (ATTN_LED(ctrl))
439 p_slot->hpc_ops->set_attention_status(p_slot, 0); 432 pciehp_set_attention_status(p_slot, 0);
440 ctrl_info(ctrl, "PCI slot #%s - action canceled " 433 ctrl_info(ctrl, "PCI slot #%s - action canceled "
441 "due to button press\n", slot_name(p_slot)); 434 "due to button press\n", slot_name(p_slot));
442 p_slot->state = STATIC_STATE; 435 p_slot->state = STATIC_STATE;
@@ -474,7 +467,7 @@ static void handle_surprise_event(struct slot *p_slot)
474 info->p_slot = p_slot; 467 info->p_slot = p_slot;
475 INIT_WORK(&info->work, pciehp_power_thread); 468 INIT_WORK(&info->work, pciehp_power_thread);
476 469
477 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 470 pciehp_get_adapter_status(p_slot, &getstatus);
478 if (!getstatus) 471 if (!getstatus)
479 p_slot->state = POWEROFF_STATE; 472 p_slot->state = POWEROFF_STATE;
480 else 473 else
@@ -498,9 +491,9 @@ static void interrupt_event_handler(struct work_struct *work)
498 if (!POWER_CTRL(ctrl)) 491 if (!POWER_CTRL(ctrl))
499 break; 492 break;
500 if (ATTN_LED(ctrl)) 493 if (ATTN_LED(ctrl))
501 p_slot->hpc_ops->set_attention_status(p_slot, 1); 494 pciehp_set_attention_status(p_slot, 1);
502 if (PWR_LED(ctrl)) 495 if (PWR_LED(ctrl))
503 p_slot->hpc_ops->green_led_off(p_slot); 496 pciehp_green_led_off(p_slot);
504 break; 497 break;
505 case INT_PRESENCE_ON: 498 case INT_PRESENCE_ON:
506 case INT_PRESENCE_OFF: 499 case INT_PRESENCE_OFF:
@@ -525,45 +518,38 @@ int pciehp_enable_slot(struct slot *p_slot)
525 int rc; 518 int rc;
526 struct controller *ctrl = p_slot->ctrl; 519 struct controller *ctrl = p_slot->ctrl;
527 520
528 /* Check to see if (latch closed, card present, power off) */ 521 rc = pciehp_get_adapter_status(p_slot, &getstatus);
529 mutex_lock(&p_slot->ctrl->crit_sect);
530
531 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
532 if (rc || !getstatus) { 522 if (rc || !getstatus) {
533 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot)); 523 ctrl_info(ctrl, "No adapter on slot(%s)\n", slot_name(p_slot));
534 mutex_unlock(&p_slot->ctrl->crit_sect);
535 return -ENODEV; 524 return -ENODEV;
536 } 525 }
537 if (MRL_SENS(p_slot->ctrl)) { 526 if (MRL_SENS(p_slot->ctrl)) {
538 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 527 rc = pciehp_get_latch_status(p_slot, &getstatus);
539 if (rc || getstatus) { 528 if (rc || getstatus) {
540 ctrl_info(ctrl, "Latch open on slot(%s)\n", 529 ctrl_info(ctrl, "Latch open on slot(%s)\n",
541 slot_name(p_slot)); 530 slot_name(p_slot));
542 mutex_unlock(&p_slot->ctrl->crit_sect);
543 return -ENODEV; 531 return -ENODEV;
544 } 532 }
545 } 533 }
546 534
547 if (POWER_CTRL(p_slot->ctrl)) { 535 if (POWER_CTRL(p_slot->ctrl)) {
548 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 536 rc = pciehp_get_power_status(p_slot, &getstatus);
549 if (rc || getstatus) { 537 if (rc || getstatus) {
550 ctrl_info(ctrl, "Already enabled on slot(%s)\n", 538 ctrl_info(ctrl, "Already enabled on slot(%s)\n",
551 slot_name(p_slot)); 539 slot_name(p_slot));
552 mutex_unlock(&p_slot->ctrl->crit_sect);
553 return -EINVAL; 540 return -EINVAL;
554 } 541 }
555 } 542 }
556 543
557 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 544 pciehp_get_latch_status(p_slot, &getstatus);
558 545
559 rc = board_added(p_slot); 546 rc = board_added(p_slot);
560 if (rc) { 547 if (rc) {
561 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 548 pciehp_get_latch_status(p_slot, &getstatus);
562 } 549 }
563 550
564 update_slot_info(p_slot); 551 update_slot_info(p_slot);
565 552
566 mutex_unlock(&p_slot->ctrl->crit_sect);
567 return rc; 553 return rc;
568} 554}
569 555
@@ -577,35 +563,29 @@ int pciehp_disable_slot(struct slot *p_slot)
577 if (!p_slot->ctrl) 563 if (!p_slot->ctrl)
578 return 1; 564 return 1;
579 565
580 /* Check to see if (latch closed, card present, power on) */
581 mutex_lock(&p_slot->ctrl->crit_sect);
582
583 if (!HP_SUPR_RM(p_slot->ctrl)) { 566 if (!HP_SUPR_RM(p_slot->ctrl)) {
584 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 567 ret = pciehp_get_adapter_status(p_slot, &getstatus);
585 if (ret || !getstatus) { 568 if (ret || !getstatus) {
586 ctrl_info(ctrl, "No adapter on slot(%s)\n", 569 ctrl_info(ctrl, "No adapter on slot(%s)\n",
587 slot_name(p_slot)); 570 slot_name(p_slot));
588 mutex_unlock(&p_slot->ctrl->crit_sect);
589 return -ENODEV; 571 return -ENODEV;
590 } 572 }
591 } 573 }
592 574
593 if (MRL_SENS(p_slot->ctrl)) { 575 if (MRL_SENS(p_slot->ctrl)) {
594 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 576 ret = pciehp_get_latch_status(p_slot, &getstatus);
595 if (ret || getstatus) { 577 if (ret || getstatus) {
596 ctrl_info(ctrl, "Latch open on slot(%s)\n", 578 ctrl_info(ctrl, "Latch open on slot(%s)\n",
597 slot_name(p_slot)); 579 slot_name(p_slot));
598 mutex_unlock(&p_slot->ctrl->crit_sect);
599 return -ENODEV; 580 return -ENODEV;
600 } 581 }
601 } 582 }
602 583
603 if (POWER_CTRL(p_slot->ctrl)) { 584 if (POWER_CTRL(p_slot->ctrl)) {
604 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 585 ret = pciehp_get_power_status(p_slot, &getstatus);
605 if (ret || !getstatus) { 586 if (ret || !getstatus) {
606 ctrl_info(ctrl, "Already disabled on slot(%s)\n", 587 ctrl_info(ctrl, "Already disabled on slot(%s)\n",
607 slot_name(p_slot)); 588 slot_name(p_slot));
608 mutex_unlock(&p_slot->ctrl->crit_sect);
609 return -EINVAL; 589 return -EINVAL;
610 } 590 }
611 } 591 }
@@ -613,7 +593,6 @@ int pciehp_disable_slot(struct slot *p_slot)
613 ret = remove_board(p_slot); 593 ret = remove_board(p_slot);
614 update_slot_info(p_slot); 594 update_slot_info(p_slot);
615 595
616 mutex_unlock(&p_slot->ctrl->crit_sect);
617 return ret; 596 return ret;
618} 597}
619 598
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 271f917b6f2c..9ef4605c1ef6 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -44,25 +44,25 @@ static atomic_t pciehp_num_controllers = ATOMIC_INIT(0);
44 44
45static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) 45static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
46{ 46{
47 struct pci_dev *dev = ctrl->pci_dev; 47 struct pci_dev *dev = ctrl->pcie->port;
48 return pci_read_config_word(dev, ctrl->cap_base + reg, value); 48 return pci_read_config_word(dev, ctrl->cap_base + reg, value);
49} 49}
50 50
51static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value) 51static inline int pciehp_readl(struct controller *ctrl, int reg, u32 *value)
52{ 52{
53 struct pci_dev *dev = ctrl->pci_dev; 53 struct pci_dev *dev = ctrl->pcie->port;
54 return pci_read_config_dword(dev, ctrl->cap_base + reg, value); 54 return pci_read_config_dword(dev, ctrl->cap_base + reg, value);
55} 55}
56 56
57static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value) 57static inline int pciehp_writew(struct controller *ctrl, int reg, u16 value)
58{ 58{
59 struct pci_dev *dev = ctrl->pci_dev; 59 struct pci_dev *dev = ctrl->pcie->port;
60 return pci_write_config_word(dev, ctrl->cap_base + reg, value); 60 return pci_write_config_word(dev, ctrl->cap_base + reg, value);
61} 61}
62 62
63static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value) 63static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
64{ 64{
65 struct pci_dev *dev = ctrl->pci_dev; 65 struct pci_dev *dev = ctrl->pcie->port;
66 return pci_write_config_dword(dev, ctrl->cap_base + reg, value); 66 return pci_write_config_dword(dev, ctrl->cap_base + reg, value);
67} 67}
68 68
@@ -266,7 +266,7 @@ static void pcie_wait_link_active(struct controller *ctrl)
266 ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n"); 266 ctrl_dbg(ctrl, "Data Link Layer Link Active not set in 1000 msec\n");
267} 267}
268 268
269static int hpc_check_lnk_status(struct controller *ctrl) 269int pciehp_check_link_status(struct controller *ctrl)
270{ 270{
271 u16 lnk_status; 271 u16 lnk_status;
272 int retval = 0; 272 int retval = 0;
@@ -305,7 +305,7 @@ static int hpc_check_lnk_status(struct controller *ctrl)
305 return retval; 305 return retval;
306} 306}
307 307
308static int hpc_get_attention_status(struct slot *slot, u8 *status) 308int pciehp_get_attention_status(struct slot *slot, u8 *status)
309{ 309{
310 struct controller *ctrl = slot->ctrl; 310 struct controller *ctrl = slot->ctrl;
311 u16 slot_ctrl; 311 u16 slot_ctrl;
@@ -344,7 +344,7 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
344 return 0; 344 return 0;
345} 345}
346 346
347static int hpc_get_power_status(struct slot *slot, u8 *status) 347int pciehp_get_power_status(struct slot *slot, u8 *status)
348{ 348{
349 struct controller *ctrl = slot->ctrl; 349 struct controller *ctrl = slot->ctrl;
350 u16 slot_ctrl; 350 u16 slot_ctrl;
@@ -376,7 +376,7 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
376 return retval; 376 return retval;
377} 377}
378 378
379static int hpc_get_latch_status(struct slot *slot, u8 *status) 379int pciehp_get_latch_status(struct slot *slot, u8 *status)
380{ 380{
381 struct controller *ctrl = slot->ctrl; 381 struct controller *ctrl = slot->ctrl;
382 u16 slot_status; 382 u16 slot_status;
@@ -392,7 +392,7 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
392 return 0; 392 return 0;
393} 393}
394 394
395static int hpc_get_adapter_status(struct slot *slot, u8 *status) 395int pciehp_get_adapter_status(struct slot *slot, u8 *status)
396{ 396{
397 struct controller *ctrl = slot->ctrl; 397 struct controller *ctrl = slot->ctrl;
398 u16 slot_status; 398 u16 slot_status;
@@ -408,7 +408,7 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
408 return 0; 408 return 0;
409} 409}
410 410
411static int hpc_query_power_fault(struct slot *slot) 411int pciehp_query_power_fault(struct slot *slot)
412{ 412{
413 struct controller *ctrl = slot->ctrl; 413 struct controller *ctrl = slot->ctrl;
414 u16 slot_status; 414 u16 slot_status;
@@ -422,7 +422,7 @@ static int hpc_query_power_fault(struct slot *slot)
422 return !!(slot_status & PCI_EXP_SLTSTA_PFD); 422 return !!(slot_status & PCI_EXP_SLTSTA_PFD);
423} 423}
424 424
425static int hpc_set_attention_status(struct slot *slot, u8 value) 425int pciehp_set_attention_status(struct slot *slot, u8 value)
426{ 426{
427 struct controller *ctrl = slot->ctrl; 427 struct controller *ctrl = slot->ctrl;
428 u16 slot_cmd; 428 u16 slot_cmd;
@@ -450,7 +450,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
450 return rc; 450 return rc;
451} 451}
452 452
453static void hpc_set_green_led_on(struct slot *slot) 453void pciehp_green_led_on(struct slot *slot)
454{ 454{
455 struct controller *ctrl = slot->ctrl; 455 struct controller *ctrl = slot->ctrl;
456 u16 slot_cmd; 456 u16 slot_cmd;
@@ -463,7 +463,7 @@ static void hpc_set_green_led_on(struct slot *slot)
463 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 463 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
464} 464}
465 465
466static void hpc_set_green_led_off(struct slot *slot) 466void pciehp_green_led_off(struct slot *slot)
467{ 467{
468 struct controller *ctrl = slot->ctrl; 468 struct controller *ctrl = slot->ctrl;
469 u16 slot_cmd; 469 u16 slot_cmd;
@@ -476,7 +476,7 @@ static void hpc_set_green_led_off(struct slot *slot)
476 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 476 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
477} 477}
478 478
479static void hpc_set_green_led_blink(struct slot *slot) 479void pciehp_green_led_blink(struct slot *slot)
480{ 480{
481 struct controller *ctrl = slot->ctrl; 481 struct controller *ctrl = slot->ctrl;
482 u16 slot_cmd; 482 u16 slot_cmd;
@@ -489,7 +489,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
489 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd); 489 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
490} 490}
491 491
492static int hpc_power_on_slot(struct slot * slot) 492int pciehp_power_on_slot(struct slot * slot)
493{ 493{
494 struct controller *ctrl = slot->ctrl; 494 struct controller *ctrl = slot->ctrl;
495 u16 slot_cmd; 495 u16 slot_cmd;
@@ -497,8 +497,6 @@ static int hpc_power_on_slot(struct slot * slot)
497 u16 slot_status; 497 u16 slot_status;
498 int retval = 0; 498 int retval = 0;
499 499
500 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
501
502 /* Clear sticky power-fault bit from previous power failures */ 500 /* Clear sticky power-fault bit from previous power failures */
503 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status); 501 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
504 if (retval) { 502 if (retval) {
@@ -539,7 +537,7 @@ static int hpc_power_on_slot(struct slot * slot)
539 537
540static inline int pcie_mask_bad_dllp(struct controller *ctrl) 538static inline int pcie_mask_bad_dllp(struct controller *ctrl)
541{ 539{
542 struct pci_dev *dev = ctrl->pci_dev; 540 struct pci_dev *dev = ctrl->pcie->port;
543 int pos; 541 int pos;
544 u32 reg; 542 u32 reg;
545 543
@@ -556,7 +554,7 @@ static inline int pcie_mask_bad_dllp(struct controller *ctrl)
556 554
557static inline void pcie_unmask_bad_dllp(struct controller *ctrl) 555static inline void pcie_unmask_bad_dllp(struct controller *ctrl)
558{ 556{
559 struct pci_dev *dev = ctrl->pci_dev; 557 struct pci_dev *dev = ctrl->pcie->port;
560 u32 reg; 558 u32 reg;
561 int pos; 559 int pos;
562 560
@@ -570,7 +568,7 @@ static inline void pcie_unmask_bad_dllp(struct controller *ctrl)
570 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg); 568 pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, reg);
571} 569}
572 570
573static int hpc_power_off_slot(struct slot * slot) 571int pciehp_power_off_slot(struct slot * slot)
574{ 572{
575 struct controller *ctrl = slot->ctrl; 573 struct controller *ctrl = slot->ctrl;
576 u16 slot_cmd; 574 u16 slot_cmd;
@@ -578,8 +576,6 @@ static int hpc_power_off_slot(struct slot * slot)
578 int retval = 0; 576 int retval = 0;
579 int changed; 577 int changed;
580 578
581 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
582
583 /* 579 /*
584 * Set Bad DLLP Mask bit in Correctable Error Mask 580 * Set Bad DLLP Mask bit in Correctable Error Mask
585 * Register. This is the workaround against Bad DLLP error 581 * Register. This is the workaround against Bad DLLP error
@@ -614,8 +610,8 @@ static int hpc_power_off_slot(struct slot * slot)
614static irqreturn_t pcie_isr(int irq, void *dev_id) 610static irqreturn_t pcie_isr(int irq, void *dev_id)
615{ 611{
616 struct controller *ctrl = (struct controller *)dev_id; 612 struct controller *ctrl = (struct controller *)dev_id;
613 struct slot *slot = ctrl->slot;
617 u16 detected, intr_loc; 614 u16 detected, intr_loc;
618 struct slot *p_slot;
619 615
620 /* 616 /*
621 * In order to guarantee that all interrupt events are 617 * In order to guarantee that all interrupt events are
@@ -656,29 +652,27 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
656 if (!(intr_loc & ~PCI_EXP_SLTSTA_CC)) 652 if (!(intr_loc & ~PCI_EXP_SLTSTA_CC))
657 return IRQ_HANDLED; 653 return IRQ_HANDLED;
658 654
659 p_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
660
661 /* Check MRL Sensor Changed */ 655 /* Check MRL Sensor Changed */
662 if (intr_loc & PCI_EXP_SLTSTA_MRLSC) 656 if (intr_loc & PCI_EXP_SLTSTA_MRLSC)
663 pciehp_handle_switch_change(p_slot); 657 pciehp_handle_switch_change(slot);
664 658
665 /* Check Attention Button Pressed */ 659 /* Check Attention Button Pressed */
666 if (intr_loc & PCI_EXP_SLTSTA_ABP) 660 if (intr_loc & PCI_EXP_SLTSTA_ABP)
667 pciehp_handle_attention_button(p_slot); 661 pciehp_handle_attention_button(slot);
668 662
669 /* Check Presence Detect Changed */ 663 /* Check Presence Detect Changed */
670 if (intr_loc & PCI_EXP_SLTSTA_PDC) 664 if (intr_loc & PCI_EXP_SLTSTA_PDC)
671 pciehp_handle_presence_change(p_slot); 665 pciehp_handle_presence_change(slot);
672 666
673 /* Check Power Fault Detected */ 667 /* Check Power Fault Detected */
674 if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) { 668 if ((intr_loc & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) {
675 ctrl->power_fault_detected = 1; 669 ctrl->power_fault_detected = 1;
676 pciehp_handle_power_fault(p_slot); 670 pciehp_handle_power_fault(slot);
677 } 671 }
678 return IRQ_HANDLED; 672 return IRQ_HANDLED;
679} 673}
680 674
681static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value) 675int pciehp_get_max_link_speed(struct slot *slot, enum pci_bus_speed *value)
682{ 676{
683 struct controller *ctrl = slot->ctrl; 677 struct controller *ctrl = slot->ctrl;
684 enum pcie_link_speed lnk_speed; 678 enum pcie_link_speed lnk_speed;
@@ -709,7 +703,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
709 return retval; 703 return retval;
710} 704}
711 705
712static int hpc_get_max_lnk_width(struct slot *slot, 706int pciehp_get_max_lnk_width(struct slot *slot,
713 enum pcie_link_width *value) 707 enum pcie_link_width *value)
714{ 708{
715 struct controller *ctrl = slot->ctrl; 709 struct controller *ctrl = slot->ctrl;
@@ -759,7 +753,7 @@ static int hpc_get_max_lnk_width(struct slot *slot,
759 return retval; 753 return retval;
760} 754}
761 755
762static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value) 756int pciehp_get_cur_link_speed(struct slot *slot, enum pci_bus_speed *value)
763{ 757{
764 struct controller *ctrl = slot->ctrl; 758 struct controller *ctrl = slot->ctrl;
765 enum pcie_link_speed lnk_speed = PCI_SPEED_UNKNOWN; 759 enum pcie_link_speed lnk_speed = PCI_SPEED_UNKNOWN;
@@ -791,7 +785,7 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
791 return retval; 785 return retval;
792} 786}
793 787
794static int hpc_get_cur_lnk_width(struct slot *slot, 788int pciehp_get_cur_lnk_width(struct slot *slot,
795 enum pcie_link_width *value) 789 enum pcie_link_width *value)
796{ 790{
797 struct controller *ctrl = slot->ctrl; 791 struct controller *ctrl = slot->ctrl;
@@ -842,30 +836,6 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
842 return retval; 836 return retval;
843} 837}
844 838
845static void pcie_release_ctrl(struct controller *ctrl);
846static struct hpc_ops pciehp_hpc_ops = {
847 .power_on_slot = hpc_power_on_slot,
848 .power_off_slot = hpc_power_off_slot,
849 .set_attention_status = hpc_set_attention_status,
850 .get_power_status = hpc_get_power_status,
851 .get_attention_status = hpc_get_attention_status,
852 .get_latch_status = hpc_get_latch_status,
853 .get_adapter_status = hpc_get_adapter_status,
854
855 .get_max_bus_speed = hpc_get_max_lnk_speed,
856 .get_cur_bus_speed = hpc_get_cur_lnk_speed,
857 .get_max_lnk_width = hpc_get_max_lnk_width,
858 .get_cur_lnk_width = hpc_get_cur_lnk_width,
859
860 .query_power_fault = hpc_query_power_fault,
861 .green_led_on = hpc_set_green_led_on,
862 .green_led_off = hpc_set_green_led_off,
863 .green_led_blink = hpc_set_green_led_blink,
864
865 .release_ctlr = pcie_release_ctrl,
866 .check_lnk_status = hpc_check_lnk_status,
867};
868
869int pcie_enable_notification(struct controller *ctrl) 839int pcie_enable_notification(struct controller *ctrl)
870{ 840{
871 u16 cmd, mask; 841 u16 cmd, mask;
@@ -930,23 +900,16 @@ static int pcie_init_slot(struct controller *ctrl)
930 if (!slot) 900 if (!slot)
931 return -ENOMEM; 901 return -ENOMEM;
932 902
933 slot->hp_slot = 0;
934 slot->ctrl = ctrl; 903 slot->ctrl = ctrl;
935 slot->bus = ctrl->pci_dev->subordinate->number;
936 slot->device = ctrl->slot_device_offset + slot->hp_slot;
937 slot->hpc_ops = ctrl->hpc_ops;
938 slot->number = ctrl->first_slot;
939 mutex_init(&slot->lock); 904 mutex_init(&slot->lock);
940 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); 905 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
941 list_add(&slot->slot_list, &ctrl->slot_list); 906 ctrl->slot = slot;
942 return 0; 907 return 0;
943} 908}
944 909
945static void pcie_cleanup_slot(struct controller *ctrl) 910static void pcie_cleanup_slot(struct controller *ctrl)
946{ 911{
947 struct slot *slot; 912 struct slot *slot = ctrl->slot;
948 slot = list_first_entry(&ctrl->slot_list, struct slot, slot_list);
949 list_del(&slot->slot_list);
950 cancel_delayed_work(&slot->work); 913 cancel_delayed_work(&slot->work);
951 flush_scheduled_work(); 914 flush_scheduled_work();
952 flush_workqueue(pciehp_wq); 915 flush_workqueue(pciehp_wq);
@@ -957,7 +920,7 @@ static inline void dbg_ctrl(struct controller *ctrl)
957{ 920{
958 int i; 921 int i;
959 u16 reg16; 922 u16 reg16;
960 struct pci_dev *pdev = ctrl->pci_dev; 923 struct pci_dev *pdev = ctrl->pcie->port;
961 924
962 if (!pciehp_debug) 925 if (!pciehp_debug)
963 return; 926 return;
@@ -980,7 +943,7 @@ static inline void dbg_ctrl(struct controller *ctrl)
980 (unsigned long long)pci_resource_start(pdev, i)); 943 (unsigned long long)pci_resource_start(pdev, i));
981 } 944 }
982 ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap); 945 ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
983 ctrl_info(ctrl, " Physical Slot Number : %d\n", ctrl->first_slot); 946 ctrl_info(ctrl, " Physical Slot Number : %d\n", PSN(ctrl));
984 ctrl_info(ctrl, " Attention Button : %3s\n", 947 ctrl_info(ctrl, " Attention Button : %3s\n",
985 ATTN_BUTTN(ctrl) ? "yes" : "no"); 948 ATTN_BUTTN(ctrl) ? "yes" : "no");
986 ctrl_info(ctrl, " Power Controller : %3s\n", 949 ctrl_info(ctrl, " Power Controller : %3s\n",
@@ -1014,10 +977,7 @@ struct controller *pcie_init(struct pcie_device *dev)
1014 dev_err(&dev->device, "%s: Out of memory\n", __func__); 977 dev_err(&dev->device, "%s: Out of memory\n", __func__);
1015 goto abort; 978 goto abort;
1016 } 979 }
1017 INIT_LIST_HEAD(&ctrl->slot_list);
1018
1019 ctrl->pcie = dev; 980 ctrl->pcie = dev;
1020 ctrl->pci_dev = pdev;
1021 ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); 981 ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP);
1022 if (!ctrl->cap_base) { 982 if (!ctrl->cap_base) {
1023 ctrl_err(ctrl, "Cannot find PCI Express capability\n"); 983 ctrl_err(ctrl, "Cannot find PCI Express capability\n");
@@ -1029,11 +989,6 @@ struct controller *pcie_init(struct pcie_device *dev)
1029 } 989 }
1030 990
1031 ctrl->slot_cap = slot_cap; 991 ctrl->slot_cap = slot_cap;
1032 ctrl->first_slot = slot_cap >> 19;
1033 ctrl->slot_device_offset = 0;
1034 ctrl->num_slots = 1;
1035 ctrl->hpc_ops = &pciehp_hpc_ops;
1036 mutex_init(&ctrl->crit_sect);
1037 mutex_init(&ctrl->ctrl_lock); 992 mutex_init(&ctrl->ctrl_lock);
1038 init_waitqueue_head(&ctrl->queue); 993 init_waitqueue_head(&ctrl->queue);
1039 dbg_ctrl(ctrl); 994 dbg_ctrl(ctrl);
@@ -1089,7 +1044,7 @@ abort:
1089 return NULL; 1044 return NULL;
1090} 1045}
1091 1046
1092void pcie_release_ctrl(struct controller *ctrl) 1047void pciehp_release_ctrl(struct controller *ctrl)
1093{ 1048{
1094 pcie_shutdown_notification(ctrl); 1049 pcie_shutdown_notification(ctrl);
1095 pcie_cleanup_slot(ctrl); 1050 pcie_cleanup_slot(ctrl);
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 02e24d63b3ee..21733108adde 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -63,27 +63,27 @@ static int __ref pciehp_add_bridge(struct pci_dev *dev)
63int pciehp_configure_device(struct slot *p_slot) 63int pciehp_configure_device(struct slot *p_slot)
64{ 64{
65 struct pci_dev *dev; 65 struct pci_dev *dev;
66 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 66 struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate;
67 int num, fn; 67 int num, fn;
68 struct controller *ctrl = p_slot->ctrl; 68 struct controller *ctrl = p_slot->ctrl;
69 69
70 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0)); 70 dev = pci_get_slot(parent, PCI_DEVFN(0, 0));
71 if (dev) { 71 if (dev) {
72 ctrl_err(ctrl, "Device %s already exists " 72 ctrl_err(ctrl, "Device %s already exists "
73 "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev), 73 "at %04x:%02x:00, cannot hot-add\n", pci_name(dev),
74 pci_domain_nr(parent), p_slot->bus, p_slot->device); 74 pci_domain_nr(parent), parent->number);
75 pci_dev_put(dev); 75 pci_dev_put(dev);
76 return -EINVAL; 76 return -EINVAL;
77 } 77 }
78 78
79 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0)); 79 num = pci_scan_slot(parent, PCI_DEVFN(0, 0));
80 if (num == 0) { 80 if (num == 0) {
81 ctrl_err(ctrl, "No new device found\n"); 81 ctrl_err(ctrl, "No new device found\n");
82 return -ENODEV; 82 return -ENODEV;
83 } 83 }
84 84
85 for (fn = 0; fn < 8; fn++) { 85 for (fn = 0; fn < 8; fn++) {
86 dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, fn)); 86 dev = pci_get_slot(parent, PCI_DEVFN(0, fn));
87 if (!dev) 87 if (!dev)
88 continue; 88 continue;
89 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 89 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
@@ -111,19 +111,18 @@ int pciehp_unconfigure_device(struct slot *p_slot)
111 int j; 111 int j;
112 u8 bctl = 0; 112 u8 bctl = 0;
113 u8 presence = 0; 113 u8 presence = 0;
114 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; 114 struct pci_bus *parent = p_slot->ctrl->pcie->port->subordinate;
115 u16 command; 115 u16 command;
116 struct controller *ctrl = p_slot->ctrl; 116 struct controller *ctrl = p_slot->ctrl;
117 117
118 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:%02x\n", 118 ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
119 __func__, pci_domain_nr(parent), p_slot->bus, p_slot->device); 119 __func__, pci_domain_nr(parent), parent->number);
120 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &presence); 120 ret = pciehp_get_adapter_status(p_slot, &presence);
121 if (ret) 121 if (ret)
122 presence = 0; 122 presence = 0;
123 123
124 for (j = 0; j < 8; j++) { 124 for (j = 0; j < 8; j++) {
125 struct pci_dev* temp = pci_get_slot(parent, 125 struct pci_dev* temp = pci_get_slot(parent, PCI_DEVFN(0, j));
126 (p_slot->device << 3) | j);
127 if (!temp) 126 if (!temp)
128 continue; 127 continue;
129 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) { 128 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index c83113646223..cb5cae3e0205 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2776,7 +2776,15 @@ static void *intel_alloc_coherent(struct device *hwdev, size_t size,
2776 2776
2777 size = PAGE_ALIGN(size); 2777 size = PAGE_ALIGN(size);
2778 order = get_order(size); 2778 order = get_order(size);
2779 flags &= ~(GFP_DMA | GFP_DMA32); 2779
2780 if (!iommu_no_mapping(hwdev))
2781 flags &= ~(GFP_DMA | GFP_DMA32);
2782 else if (hwdev->coherent_dma_mask < dma_get_required_mask(hwdev)) {
2783 if (hwdev->coherent_dma_mask < DMA_BIT_MASK(32))
2784 flags |= GFP_DMA;
2785 else
2786 flags |= GFP_DMA32;
2787 }
2780 2788
2781 vaddr = (void *)__get_free_pages(flags, order); 2789 vaddr = (void *)__get_free_pages(flags, order);
2782 if (!vaddr) 2790 if (!vaddr)
@@ -3216,6 +3224,33 @@ static int __init init_iommu_sysfs(void)
3216} 3224}
3217#endif /* CONFIG_PM */ 3225#endif /* CONFIG_PM */
3218 3226
3227/*
3228 * Here we only respond to action of unbound device from driver.
3229 *
3230 * Added device is not attached to its DMAR domain here yet. That will happen
3231 * when mapping the device to iova.
3232 */
3233static int device_notifier(struct notifier_block *nb,
3234 unsigned long action, void *data)
3235{
3236 struct device *dev = data;
3237 struct pci_dev *pdev = to_pci_dev(dev);
3238 struct dmar_domain *domain;
3239
3240 domain = find_domain(pdev);
3241 if (!domain)
3242 return 0;
3243
3244 if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through)
3245 domain_remove_one_dev_info(domain, pdev);
3246
3247 return 0;
3248}
3249
3250static struct notifier_block device_nb = {
3251 .notifier_call = device_notifier,
3252};
3253
3219int __init intel_iommu_init(void) 3254int __init intel_iommu_init(void)
3220{ 3255{
3221 int ret = 0; 3256 int ret = 0;
@@ -3240,7 +3275,7 @@ int __init intel_iommu_init(void)
3240 * Check the need for DMA-remapping initialization now. 3275 * Check the need for DMA-remapping initialization now.
3241 * Above initialization will also be used by Interrupt-remapping. 3276 * Above initialization will also be used by Interrupt-remapping.
3242 */ 3277 */
3243 if (no_iommu || swiotlb || dmar_disabled) 3278 if (no_iommu || dmar_disabled)
3244 return -ENODEV; 3279 return -ENODEV;
3245 3280
3246 iommu_init_mempool(); 3281 iommu_init_mempool();
@@ -3261,13 +3296,17 @@ int __init intel_iommu_init(void)
3261 "PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n"); 3296 "PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n");
3262 3297
3263 init_timer(&unmap_timer); 3298 init_timer(&unmap_timer);
3264 force_iommu = 1; 3299#ifdef CONFIG_SWIOTLB
3300 swiotlb = 0;
3301#endif
3265 dma_ops = &intel_dma_ops; 3302 dma_ops = &intel_dma_ops;
3266 3303
3267 init_iommu_sysfs(); 3304 init_iommu_sysfs();
3268 3305
3269 register_iommu(&intel_iommu_ops); 3306 register_iommu(&intel_iommu_ops);
3270 3307
3308 bus_register_notifier(&pci_bus_type, &device_nb);
3309
3271 return 0; 3310 return 0;
3272} 3311}
3273 3312
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6edecff0b419..4e4c295a049f 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -513,7 +513,11 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
513 else if (state == PCI_D2 || dev->current_state == PCI_D2) 513 else if (state == PCI_D2 || dev->current_state == PCI_D2)
514 udelay(PCI_PM_D2_DELAY); 514 udelay(PCI_PM_D2_DELAY);
515 515
516 dev->current_state = state; 516 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
517 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
518 if (dev->current_state != state && printk_ratelimit())
519 dev_info(&dev->dev, "Refused to change power state, "
520 "currently in D%d\n", dev->current_state);
517 521
518 /* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT 522 /* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT
519 * INTERFACE SPECIFICATION, REV. 1.2", a device transitioning 523 * INTERFACE SPECIFICATION, REV. 1.2", a device transitioning
@@ -2542,10 +2546,10 @@ int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
2542 2546
2543/** 2547/**
2544 * pci_set_vga_state - set VGA decode state on device and parents if requested 2548 * pci_set_vga_state - set VGA decode state on device and parents if requested
2545 * @dev the PCI device 2549 * @dev: the PCI device
2546 * @decode - true = enable decoding, false = disable decoding 2550 * @decode: true = enable decoding, false = disable decoding
2547 * @command_bits PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY 2551 * @command_bits: PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY
2548 * @change_bridge - traverse ancestors and change bridges 2552 * @change_bridge: traverse ancestors and change bridges
2549 */ 2553 */
2550int pci_set_vga_state(struct pci_dev *dev, bool decode, 2554int pci_set_vga_state(struct pci_dev *dev, bool decode,
2551 unsigned int command_bits, bool change_bridge) 2555 unsigned int command_bits, bool change_bridge)
@@ -2719,17 +2723,6 @@ int __attribute__ ((weak)) pci_ext_cfg_avail(struct pci_dev *dev)
2719 return 1; 2723 return 1;
2720} 2724}
2721 2725
2722static int __devinit pci_init(void)
2723{
2724 struct pci_dev *dev = NULL;
2725
2726 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
2727 pci_fixup_device(pci_fixup_final, dev);
2728 }
2729
2730 return 0;
2731}
2732
2733static int __init pci_setup(char *str) 2726static int __init pci_setup(char *str)
2734{ 2727{
2735 while (str) { 2728 while (str) {
@@ -2767,8 +2760,6 @@ static int __init pci_setup(char *str)
2767} 2760}
2768early_param("pci", pci_setup); 2761early_param("pci", pci_setup);
2769 2762
2770device_initcall(pci_init);
2771
2772EXPORT_SYMBOL(pci_reenable_device); 2763EXPORT_SYMBOL(pci_reenable_device);
2773EXPORT_SYMBOL(pci_enable_device_io); 2764EXPORT_SYMBOL(pci_enable_device_io);
2774EXPORT_SYMBOL(pci_enable_device_mem); 2765EXPORT_SYMBOL(pci_enable_device_mem);
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 10c0e62bd5a8..40c3cc5d1caf 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/sched.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/errno.h> 22#include <linux/errno.h>
22#include <linux/pm.h> 23#include <linux/pm.h>
@@ -52,7 +53,7 @@ static struct pci_error_handlers aer_error_handlers = {
52 53
53static struct pcie_port_service_driver aerdriver = { 54static struct pcie_port_service_driver aerdriver = {
54 .name = "aer", 55 .name = "aer",
55 .port_type = PCIE_ANY_PORT, 56 .port_type = PCIE_RC_PORT,
56 .service = PCIE_PORT_SERVICE_AER, 57 .service = PCIE_PORT_SERVICE_AER,
57 58
58 .probe = aer_probe, 59 .probe = aer_probe,
@@ -318,6 +319,8 @@ static int __init aer_service_init(void)
318{ 319{
319 if (pcie_aer_disable) 320 if (pcie_aer_disable)
320 return -ENXIO; 321 return -ENXIO;
322 if (!pci_msi_enabled())
323 return -ENXIO;
321 return pcie_port_service_register(&aerdriver); 324 return pcie_port_service_register(&aerdriver);
322} 325}
323 326
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index f289ca9bf18d..5b7056cec00c 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -303,9 +303,6 @@ static void pcie_get_aspm_reg(struct pci_dev *pdev,
303 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 303 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
304 pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &reg32); 304 pci_read_config_dword(pdev, pos + PCI_EXP_LNKCAP, &reg32);
305 info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10; 305 info->support = (reg32 & PCI_EXP_LNKCAP_ASPMS) >> 10;
306 /* 00b and 10b are defined as "Reserved". */
307 if (info->support == PCIE_LINK_STATE_L1)
308 info->support = 0;
309 info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12; 306 info->latency_encoding_l0s = (reg32 & PCI_EXP_LNKCAP_L0SEL) >> 12;
310 info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15; 307 info->latency_encoding_l1 = (reg32 & PCI_EXP_LNKCAP_L1EL) >> 15;
311 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16); 308 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
@@ -659,8 +656,10 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
659 free_link_state(link); 656 free_link_state(link);
660 657
661 /* Recheck latencies and configure upstream links */ 658 /* Recheck latencies and configure upstream links */
662 pcie_update_aspm_capable(root); 659 if (parent_link) {
663 pcie_config_aspm_path(parent_link); 660 pcie_update_aspm_capable(root);
661 pcie_config_aspm_path(parent_link);
662 }
664out: 663out:
665 mutex_unlock(&aspm_lock); 664 mutex_unlock(&aspm_lock);
666 up_read(&pci_bus_sem); 665 up_read(&pci_bus_sem);
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 6df5c984a791..f635e476d632 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -30,7 +30,6 @@ MODULE_DESCRIPTION(DRIVER_DESC);
30MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
31 31
32/* global data */ 32/* global data */
33static const char device_name[] = "pcieport-driver";
34 33
35static int pcie_portdrv_restore_config(struct pci_dev *dev) 34static int pcie_portdrv_restore_config(struct pci_dev *dev)
36{ 35{
@@ -262,7 +261,7 @@ static struct pci_error_handlers pcie_portdrv_err_handler = {
262}; 261};
263 262
264static struct pci_driver pcie_portdriver = { 263static struct pci_driver pcie_portdriver = {
265 .name = (char *)device_name, 264 .name = "pcieport",
266 .id_table = &port_pci_ids[0], 265 .id_table = &port_pci_ids[0],
267 266
268 .probe = pcie_portdrv_probe, 267 .probe = pcie_portdrv_probe,
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6099facecd79..245d2cdb4765 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -670,6 +670,25 @@ static void __devinit quirk_vt8235_acpi(struct pci_dev *dev)
670} 670}
671DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_vt8235_acpi); 671DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_vt8235_acpi);
672 672
673/*
674 * TI XIO2000a PCIe-PCI Bridge erroneously reports it supports fast back-to-back:
675 * Disable fast back-to-back on the secondary bus segment
676 */
677static void __devinit quirk_xio2000a(struct pci_dev *dev)
678{
679 struct pci_dev *pdev;
680 u16 command;
681
682 dev_warn(&dev->dev, "TI XIO2000a quirk detected; "
683 "secondary bus fast back-to-back transfers disabled\n");
684 list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) {
685 pci_read_config_word(pdev, PCI_COMMAND, &command);
686 if (command & PCI_COMMAND_FAST_BACK)
687 pci_write_config_word(pdev, PCI_COMMAND, command & ~PCI_COMMAND_FAST_BACK);
688 }
689}
690DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XIO2000A,
691 quirk_xio2000a);
673 692
674#ifdef CONFIG_X86_IO_APIC 693#ifdef CONFIG_X86_IO_APIC
675 694
@@ -990,7 +1009,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX,
990 1009
991static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev) 1010static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev)
992{ 1011{
993 /* set SBX00 SATA in IDE mode to AHCI mode */ 1012 /* set SBX00/Hudson-2 SATA in IDE mode to AHCI mode */
994 u8 tmp; 1013 u8 tmp;
995 1014
996 pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp); 1015 pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp);
@@ -1009,8 +1028,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk
1009DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); 1028DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode);
1010DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 1029DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
1011DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 1030DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode);
1012DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SATA_IDE, quirk_amd_ide_mode); 1031DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
1013DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_SB900_SATA_IDE, quirk_amd_ide_mode); 1032DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode);
1014 1033
1015/* 1034/*
1016 * Serverworks CSB5 IDE does not fully support native mode 1035 * Serverworks CSB5 IDE does not fully support native mode
@@ -2572,6 +2591,19 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
2572 } 2591 }
2573 pci_do_fixups(dev, start, end); 2592 pci_do_fixups(dev, start, end);
2574} 2593}
2594
2595static int __init pci_apply_final_quirks(void)
2596{
2597 struct pci_dev *dev = NULL;
2598
2599 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
2600 pci_fixup_device(pci_fixup_final, dev);
2601 }
2602
2603 return 0;
2604}
2605
2606fs_initcall_sync(pci_apply_final_quirks);
2575#else 2607#else
2576void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {} 2608void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {}
2577#endif 2609#endif
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 706f82d8111f..c54526b206b5 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -205,43 +205,6 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
205 return ret; 205 return ret;
206} 206}
207 207
208#if 0
209int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
210{
211 struct pci_bus *bus = dev->bus;
212 struct resource *res = dev->resource + resno;
213 unsigned int type_mask;
214 int i, ret = -EBUSY;
215
216 type_mask = IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH;
217
218 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
219 struct resource *r = bus->resource[i];
220 if (!r)
221 continue;
222
223 /* type_mask must match */
224 if ((res->flags ^ r->flags) & type_mask)
225 continue;
226
227 ret = request_resource(r, res);
228
229 if (ret == 0)
230 break;
231 }
232
233 if (ret) {
234 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
235 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
236 } else if (resno < PCI_BRIDGE_RESOURCES) {
237 pci_update_resource(dev, resno);
238 }
239
240 return ret;
241}
242EXPORT_SYMBOL_GPL(pci_assign_resource_fixed);
243#endif
244
245/* Sort resources by alignment */ 208/* Sort resources by alignment */
246void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) 209void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
247{ 210{