diff options
| -rw-r--r-- | Documentation/ABI/testing/sysfs-bus-pci | 21 | ||||
| -rw-r--r-- | arch/ia64/pci/fixup.c | 4 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci-hotplug.c | 3 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci_of_scan.c | 3 | ||||
| -rw-r--r-- | arch/sparc/kernel/pci.c | 3 | ||||
| -rw-r--r-- | arch/x86/pci/fixup.c | 4 | ||||
| -rw-r--r-- | drivers/block/nvme-core.c | 11 | ||||
| -rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 3 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpci_hotplug_pci.c | 3 | ||||
| -rw-r--r-- | drivers/pci/hotplug/cpqphp_ctrl.c | 3 | ||||
| -rw-r--r-- | drivers/pci/hotplug/pciehp_pci.c | 3 | ||||
| -rw-r--r-- | drivers/pci/hotplug/rpadlpar_core.c | 3 | ||||
| -rw-r--r-- | drivers/pci/hotplug/shpchp_pci.c | 3 | ||||
| -rw-r--r-- | drivers/pci/pci-acpi.c | 8 | ||||
| -rw-r--r-- | drivers/pci/pci-driver.c | 33 | ||||
| -rw-r--r-- | drivers/pci/pci-sysfs.c | 40 | ||||
| -rw-r--r-- | drivers/pci/pci.c | 21 | ||||
| -rw-r--r-- | drivers/pci/pci.h | 2 | ||||
| -rw-r--r-- | drivers/pci/probe.c | 4 | ||||
| -rw-r--r-- | drivers/pci/setup-bus.c | 4 | ||||
| -rw-r--r-- | drivers/pcmcia/cardbus.c | 3 | ||||
| -rw-r--r-- | include/linux/pci.h | 17 |
22 files changed, 154 insertions, 45 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index ab8d76dfaa80..6615fda0abfb 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci | |||
| @@ -250,3 +250,24 @@ Description: | |||
| 250 | valid. For example, writing a 2 to this file when sriov_numvfs | 250 | valid. For example, writing a 2 to this file when sriov_numvfs |
| 251 | is not 0 and not 2 already will return an error. Writing a 10 | 251 | is not 0 and not 2 already will return an error. Writing a 10 |
| 252 | when the value of sriov_totalvfs is 8 will return an error. | 252 | when the value of sriov_totalvfs is 8 will return an error. |
| 253 | |||
| 254 | What: /sys/bus/pci/devices/.../driver_override | ||
| 255 | Date: April 2014 | ||
| 256 | Contact: Alex Williamson <alex.williamson@redhat.com> | ||
| 257 | Description: | ||
| 258 | This file allows the driver for a device to be specified which | ||
| 259 | will override standard static and dynamic ID matching. When | ||
| 260 | specified, only a driver with a name matching the value written | ||
| 261 | to driver_override will have an opportunity to bind to the | ||
| 262 | device. The override is specified by writing a string to the | ||
| 263 | driver_override file (echo pci-stub > driver_override) and | ||
| 264 | may be cleared with an empty string (echo > driver_override). | ||
| 265 | This returns the device to standard matching rules binding. | ||
| 266 | Writing to driver_override does not automatically unbind the | ||
| 267 | device from its current driver or make any attempt to | ||
| 268 | automatically load the specified driver. If no driver with a | ||
| 269 | matching name is currently loaded in the kernel, the device | ||
| 270 | will not bind to any driver. This also allows devices to | ||
| 271 | opt-out of driver binding using a driver_override name such as | ||
| 272 | "none". Only a single driver may be specified in the override, | ||
| 273 | there is no support for parsing delimiters. | ||
diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c index eee069a0b539..1fe9aa5068ea 100644 --- a/arch/ia64/pci/fixup.c +++ b/arch/ia64/pci/fixup.c | |||
| @@ -49,9 +49,7 @@ static void pci_fixup_video(struct pci_dev *pdev) | |||
| 49 | * type BRIDGE, or CARDBUS. Host to PCI controllers use | 49 | * type BRIDGE, or CARDBUS. Host to PCI controllers use |
| 50 | * PCI header type NORMAL. | 50 | * PCI header type NORMAL. |
| 51 | */ | 51 | */ |
| 52 | if (bridge | 52 | if (bridge && (pci_is_bridge(bridge))) { |
| 53 | &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE) | ||
| 54 | ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) { | ||
| 55 | pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, | 53 | pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, |
| 56 | &config); | 54 | &config); |
| 57 | if (!(config & PCI_BRIDGE_CTL_VGA)) | 55 | if (!(config & PCI_BRIDGE_CTL_VGA)) |
diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c index c1e17ae68a08..5b789177aa29 100644 --- a/arch/powerpc/kernel/pci-hotplug.c +++ b/arch/powerpc/kernel/pci-hotplug.c | |||
| @@ -98,8 +98,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus) | |||
| 98 | max = bus->busn_res.start; | 98 | max = bus->busn_res.start; |
| 99 | for (pass = 0; pass < 2; pass++) { | 99 | for (pass = 0; pass < 2; pass++) { |
| 100 | list_for_each_entry(dev, &bus->devices, bus_list) { | 100 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 101 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 101 | if (pci_is_bridge(dev)) |
| 102 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 103 | max = pci_scan_bridge(bus, dev, | 102 | max = pci_scan_bridge(bus, dev, |
| 104 | max, pass); | 103 | max, pass); |
| 105 | } | 104 | } |
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 83c26d829991..059e244484fe 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c | |||
| @@ -362,8 +362,7 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus, | |||
| 362 | 362 | ||
| 363 | /* Now scan child busses */ | 363 | /* Now scan child busses */ |
| 364 | list_for_each_entry(dev, &bus->devices, bus_list) { | 364 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 365 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 365 | if (pci_is_bridge(dev)) { |
| 366 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | ||
| 367 | of_scan_pci_bridge(dev); | 366 | of_scan_pci_bridge(dev); |
| 368 | } | 367 | } |
| 369 | } | 368 | } |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index 1555bbcae1ee..857ad77df9c0 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
| @@ -543,8 +543,7 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm, | |||
| 543 | printk("PCI: dev header type: %x\n", | 543 | printk("PCI: dev header type: %x\n", |
| 544 | dev->hdr_type); | 544 | dev->hdr_type); |
| 545 | 545 | ||
| 546 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 546 | if (pci_is_bridge(dev)) |
| 547 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 548 | of_scan_pci_bridge(pbm, child, dev); | 547 | of_scan_pci_bridge(pbm, child, dev); |
| 549 | } | 548 | } |
| 550 | } | 549 | } |
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index ef334a003f3c..b5e60268d93f 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c | |||
| @@ -338,9 +338,7 @@ static void pci_fixup_video(struct pci_dev *pdev) | |||
| 338 | * type BRIDGE, or CARDBUS. Host to PCI controllers use | 338 | * type BRIDGE, or CARDBUS. Host to PCI controllers use |
| 339 | * PCI header type NORMAL. | 339 | * PCI header type NORMAL. |
| 340 | */ | 340 | */ |
| 341 | if (bridge | 341 | if (bridge && (pci_is_bridge(bridge))) { |
| 342 | && ((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE) | ||
| 343 | || (bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) { | ||
| 344 | pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, | 342 | pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, |
| 345 | &config); | 343 | &config); |
| 346 | if (!(config & PCI_BRIDGE_CTL_VGA)) | 344 | if (!(config & PCI_BRIDGE_CTL_VGA)) |
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 7c64fa756cce..a842c71dcc21 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c | |||
| @@ -2775,6 +2775,16 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 2775 | return result; | 2775 | return result; |
| 2776 | } | 2776 | } |
| 2777 | 2777 | ||
| 2778 | static void nvme_reset_notify(struct pci_dev *pdev, bool prepare) | ||
| 2779 | { | ||
| 2780 | struct nvme_dev *dev = pci_get_drvdata(pdev); | ||
| 2781 | |||
| 2782 | if (prepare) | ||
| 2783 | nvme_dev_shutdown(dev); | ||
| 2784 | else | ||
| 2785 | nvme_dev_resume(dev); | ||
| 2786 | } | ||
| 2787 | |||
| 2778 | static void nvme_shutdown(struct pci_dev *pdev) | 2788 | static void nvme_shutdown(struct pci_dev *pdev) |
| 2779 | { | 2789 | { |
| 2780 | struct nvme_dev *dev = pci_get_drvdata(pdev); | 2790 | struct nvme_dev *dev = pci_get_drvdata(pdev); |
| @@ -2839,6 +2849,7 @@ static const struct pci_error_handlers nvme_err_handler = { | |||
| 2839 | .link_reset = nvme_link_reset, | 2849 | .link_reset = nvme_link_reset, |
| 2840 | .slot_reset = nvme_slot_reset, | 2850 | .slot_reset = nvme_slot_reset, |
| 2841 | .resume = nvme_error_resume, | 2851 | .resume = nvme_error_resume, |
| 2852 | .reset_notify = nvme_reset_notify, | ||
| 2842 | }; | 2853 | }; |
| 2843 | 2854 | ||
| 2844 | /* Move to pci_ids.h later */ | 2855 | /* Move to pci_ids.h later */ |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index bb945e33b1ec..75e178330215 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
| @@ -515,8 +515,7 @@ static void enable_slot(struct acpiphp_slot *slot) | |||
| 515 | if (PCI_SLOT(dev->devfn) != slot->device) | 515 | if (PCI_SLOT(dev->devfn) != slot->device) |
| 516 | continue; | 516 | continue; |
| 517 | 517 | ||
| 518 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 518 | if (pci_is_bridge(dev)) { |
| 519 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { | ||
| 520 | max = pci_scan_bridge(bus, dev, max, pass); | 519 | max = pci_scan_bridge(bus, dev, max, pass); |
| 521 | if (pass && dev->subordinate) { | 520 | if (pass && dev->subordinate) { |
| 522 | check_hotplug_bridge(slot, dev); | 521 | check_hotplug_bridge(slot, dev); |
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c index b238a1a28372..f6ef64c2ccb5 100644 --- a/drivers/pci/hotplug/cpci_hotplug_pci.c +++ b/drivers/pci/hotplug/cpci_hotplug_pci.c | |||
| @@ -289,8 +289,7 @@ int cpci_configure_slot(struct slot *slot) | |||
| 289 | list_for_each_entry(dev, &parent->devices, bus_list) | 289 | list_for_each_entry(dev, &parent->devices, bus_list) |
| 290 | if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn)) | 290 | if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn)) |
| 291 | continue; | 291 | continue; |
| 292 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 292 | if (pci_is_bridge(dev)) |
| 293 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | ||
| 294 | pci_hp_add_bridge(dev); | 293 | pci_hp_add_bridge(dev); |
| 295 | 294 | ||
| 296 | 295 | ||
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 11845b796799..f593585f2784 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c | |||
| @@ -709,7 +709,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz | |||
| 709 | temp = temp->next; | 709 | temp = temp->next; |
| 710 | } | 710 | } |
| 711 | 711 | ||
| 712 | temp->next = max->next; | 712 | if (temp) |
| 713 | temp->next = max->next; | ||
| 713 | } | 714 | } |
| 714 | 715 | ||
| 715 | max->next = NULL; | 716 | max->next = NULL; |
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c index 1b533060ce65..b6cb1df67097 100644 --- a/drivers/pci/hotplug/pciehp_pci.c +++ b/drivers/pci/hotplug/pciehp_pci.c | |||
| @@ -62,8 +62,7 @@ int pciehp_configure_device(struct slot *p_slot) | |||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | list_for_each_entry(dev, &parent->devices, bus_list) | 64 | list_for_each_entry(dev, &parent->devices, bus_list) |
| 65 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 65 | if (pci_is_bridge(dev)) |
| 66 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | ||
| 67 | pci_hp_add_bridge(dev); | 66 | pci_hp_add_bridge(dev); |
| 68 | 67 | ||
| 69 | pci_assign_unassigned_bridge_resources(bridge); | 68 | pci_assign_unassigned_bridge_resources(bridge); |
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c index 4fcdeedda31b..7660232ef460 100644 --- a/drivers/pci/hotplug/rpadlpar_core.c +++ b/drivers/pci/hotplug/rpadlpar_core.c | |||
| @@ -157,8 +157,7 @@ static void dlpar_pci_add_bus(struct device_node *dn) | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | /* Scan below the new bridge */ | 159 | /* Scan below the new bridge */ |
| 160 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 160 | if (pci_is_bridge(dev)) |
| 161 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 162 | of_scan_pci_bridge(dev); | 161 | of_scan_pci_bridge(dev); |
| 163 | 162 | ||
| 164 | /* Map IO space for child bus, which may or may not succeed */ | 163 | /* Map IO space for child bus, which may or may not succeed */ |
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c index 18209ebc0979..9202d133485c 100644 --- a/drivers/pci/hotplug/shpchp_pci.c +++ b/drivers/pci/hotplug/shpchp_pci.c | |||
| @@ -64,8 +64,7 @@ int shpchp_configure_device(struct slot *p_slot) | |||
| 64 | list_for_each_entry(dev, &parent->devices, bus_list) { | 64 | list_for_each_entry(dev, &parent->devices, bus_list) { |
| 65 | if (PCI_SLOT(dev->devfn) != p_slot->device) | 65 | if (PCI_SLOT(dev->devfn) != p_slot->device) |
| 66 | continue; | 66 | continue; |
| 67 | if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) || | 67 | if (pci_is_bridge(dev)) |
| 68 | (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) | ||
| 69 | pci_hp_add_bridge(dev); | 68 | pci_hp_add_bridge(dev); |
| 70 | } | 69 | } |
| 71 | 70 | ||
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index f49abef88485..ca4927ba8433 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
| @@ -309,13 +309,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev) | |||
| 309 | bool check_children; | 309 | bool check_children; |
| 310 | u64 addr; | 310 | u64 addr; |
| 311 | 311 | ||
| 312 | /* | 312 | check_children = pci_is_bridge(pci_dev); |
| 313 | * pci_is_bridge() is not suitable here, because pci_dev->subordinate | ||
| 314 | * is set only after acpi_pci_find_device() has been called for the | ||
| 315 | * given device. | ||
| 316 | */ | ||
| 317 | check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE | ||
| 318 | || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS; | ||
| 319 | /* Please ref to ACPI spec for the syntax of _ADR */ | 313 | /* Please ref to ACPI spec for the syntax of _ADR */ |
| 320 | addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); | 314 | addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); |
| 321 | return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr, | 315 | return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr, |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index ff236ed4f5cf..837d71f5390b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
| @@ -236,6 +236,13 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, | |||
| 236 | return NULL; | 236 | return NULL; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | static const struct pci_device_id pci_device_id_any = { | ||
| 240 | .vendor = PCI_ANY_ID, | ||
| 241 | .device = PCI_ANY_ID, | ||
| 242 | .subvendor = PCI_ANY_ID, | ||
| 243 | .subdevice = PCI_ANY_ID, | ||
| 244 | }; | ||
| 245 | |||
| 239 | /** | 246 | /** |
| 240 | * pci_match_device - Tell if a PCI device structure has a matching PCI device id structure | 247 | * pci_match_device - Tell if a PCI device structure has a matching PCI device id structure |
| 241 | * @drv: the PCI driver to match against | 248 | * @drv: the PCI driver to match against |
| @@ -249,18 +256,30 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv, | |||
| 249 | struct pci_dev *dev) | 256 | struct pci_dev *dev) |
| 250 | { | 257 | { |
| 251 | struct pci_dynid *dynid; | 258 | struct pci_dynid *dynid; |
| 259 | const struct pci_device_id *found_id = NULL; | ||
| 260 | |||
| 261 | /* When driver_override is set, only bind to the matching driver */ | ||
| 262 | if (dev->driver_override && strcmp(dev->driver_override, drv->name)) | ||
| 263 | return NULL; | ||
| 252 | 264 | ||
| 253 | /* Look at the dynamic ids first, before the static ones */ | 265 | /* Look at the dynamic ids first, before the static ones */ |
| 254 | spin_lock(&drv->dynids.lock); | 266 | spin_lock(&drv->dynids.lock); |
| 255 | list_for_each_entry(dynid, &drv->dynids.list, node) { | 267 | list_for_each_entry(dynid, &drv->dynids.list, node) { |
| 256 | if (pci_match_one_device(&dynid->id, dev)) { | 268 | if (pci_match_one_device(&dynid->id, dev)) { |
| 257 | spin_unlock(&drv->dynids.lock); | 269 | found_id = &dynid->id; |
| 258 | return &dynid->id; | 270 | break; |
| 259 | } | 271 | } |
| 260 | } | 272 | } |
| 261 | spin_unlock(&drv->dynids.lock); | 273 | spin_unlock(&drv->dynids.lock); |
| 262 | 274 | ||
| 263 | return pci_match_id(drv->id_table, dev); | 275 | if (!found_id) |
| 276 | found_id = pci_match_id(drv->id_table, dev); | ||
| 277 | |||
| 278 | /* driver_override will always match, send a dummy id */ | ||
| 279 | if (!found_id && dev->driver_override) | ||
| 280 | found_id = &pci_device_id_any; | ||
| 281 | |||
| 282 | return found_id; | ||
| 264 | } | 283 | } |
| 265 | 284 | ||
| 266 | struct drv_dev_and_id { | 285 | struct drv_dev_and_id { |
| @@ -600,14 +619,14 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev) | |||
| 600 | { | 619 | { |
| 601 | pci_fixup_device(pci_fixup_resume, pci_dev); | 620 | pci_fixup_device(pci_fixup_resume, pci_dev); |
| 602 | 621 | ||
| 603 | if (!pci_is_bridge(pci_dev)) | 622 | if (!pci_has_subordinate(pci_dev)) |
| 604 | pci_enable_wake(pci_dev, PCI_D0, false); | 623 | pci_enable_wake(pci_dev, PCI_D0, false); |
| 605 | } | 624 | } |
| 606 | 625 | ||
| 607 | static void pci_pm_default_suspend(struct pci_dev *pci_dev) | 626 | static void pci_pm_default_suspend(struct pci_dev *pci_dev) |
| 608 | { | 627 | { |
| 609 | /* Disable non-bridge devices without PM support */ | 628 | /* Disable non-bridge devices without PM support */ |
| 610 | if (!pci_is_bridge(pci_dev)) | 629 | if (!pci_has_subordinate(pci_dev)) |
| 611 | pci_disable_enabled_device(pci_dev); | 630 | pci_disable_enabled_device(pci_dev); |
| 612 | } | 631 | } |
| 613 | 632 | ||
| @@ -737,7 +756,7 @@ static int pci_pm_suspend_noirq(struct device *dev) | |||
| 737 | 756 | ||
| 738 | if (!pci_dev->state_saved) { | 757 | if (!pci_dev->state_saved) { |
| 739 | pci_save_state(pci_dev); | 758 | pci_save_state(pci_dev); |
| 740 | if (!pci_is_bridge(pci_dev)) | 759 | if (!pci_has_subordinate(pci_dev)) |
| 741 | pci_prepare_to_sleep(pci_dev); | 760 | pci_prepare_to_sleep(pci_dev); |
| 742 | } | 761 | } |
| 743 | 762 | ||
| @@ -991,7 +1010,7 @@ static int pci_pm_poweroff_noirq(struct device *dev) | |||
| 991 | return error; | 1010 | return error; |
| 992 | } | 1011 | } |
| 993 | 1012 | ||
| 994 | if (!pci_dev->state_saved && !pci_is_bridge(pci_dev)) | 1013 | if (!pci_dev->state_saved && !pci_has_subordinate(pci_dev)) |
| 995 | pci_prepare_to_sleep(pci_dev); | 1014 | pci_prepare_to_sleep(pci_dev); |
| 996 | 1015 | ||
| 997 | /* | 1016 | /* |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index b7333fa5f80d..84c350994b06 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
| @@ -514,6 +514,45 @@ static struct device_attribute sriov_numvfs_attr = | |||
| 514 | sriov_numvfs_show, sriov_numvfs_store); | 514 | sriov_numvfs_show, sriov_numvfs_store); |
| 515 | #endif /* CONFIG_PCI_IOV */ | 515 | #endif /* CONFIG_PCI_IOV */ |
| 516 | 516 | ||
| 517 | static ssize_t driver_override_store(struct device *dev, | ||
| 518 | struct device_attribute *attr, | ||
| 519 | const char *buf, size_t count) | ||
| 520 | { | ||
| 521 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 522 | char *driver_override, *old = pdev->driver_override, *cp; | ||
| 523 | |||
| 524 | if (count > PATH_MAX) | ||
| 525 | return -EINVAL; | ||
| 526 | |||
| 527 | driver_override = kstrndup(buf, count, GFP_KERNEL); | ||
| 528 | if (!driver_override) | ||
| 529 | return -ENOMEM; | ||
| 530 | |||
| 531 | cp = strchr(driver_override, '\n'); | ||
| 532 | if (cp) | ||
| 533 | *cp = '\0'; | ||
| 534 | |||
| 535 | if (strlen(driver_override)) { | ||
| 536 | pdev->driver_override = driver_override; | ||
| 537 | } else { | ||
| 538 | kfree(driver_override); | ||
| 539 | pdev->driver_override = NULL; | ||
| 540 | } | ||
| 541 | |||
| 542 | kfree(old); | ||
| 543 | |||
| 544 | return count; | ||
| 545 | } | ||
| 546 | |||
| 547 | static ssize_t driver_override_show(struct device *dev, | ||
| 548 | struct device_attribute *attr, char *buf) | ||
| 549 | { | ||
| 550 | struct pci_dev *pdev = to_pci_dev(dev); | ||
| 551 | |||
| 552 | return sprintf(buf, "%s\n", pdev->driver_override); | ||
| 553 | } | ||
| 554 | static DEVICE_ATTR_RW(driver_override); | ||
| 555 | |||
| 517 | static struct attribute *pci_dev_attrs[] = { | 556 | static struct attribute *pci_dev_attrs[] = { |
| 518 | &dev_attr_resource.attr, | 557 | &dev_attr_resource.attr, |
| 519 | &dev_attr_vendor.attr, | 558 | &dev_attr_vendor.attr, |
| @@ -539,6 +578,7 @@ static struct attribute *pci_dev_attrs[] = { | |||
| 539 | #ifdef CONFIG_OF | 578 | #ifdef CONFIG_OF |
| 540 | &dev_attr_devspec.attr, | 579 | &dev_attr_devspec.attr, |
| 541 | #endif | 580 | #endif |
| 581 | &dev_attr_driver_override.attr, | ||
| 542 | NULL, | 582 | NULL, |
| 543 | }; | 583 | }; |
| 544 | 584 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 39012831867e..f988bb18eba5 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
| @@ -3305,8 +3305,27 @@ static void pci_dev_unlock(struct pci_dev *dev) | |||
| 3305 | pci_cfg_access_unlock(dev); | 3305 | pci_cfg_access_unlock(dev); |
| 3306 | } | 3306 | } |
| 3307 | 3307 | ||
| 3308 | /** | ||
| 3309 | * pci_reset_notify - notify device driver of reset | ||
| 3310 | * @dev: device to be notified of reset | ||
| 3311 | * @prepare: 'true' if device is about to be reset; 'false' if reset attempt | ||
| 3312 | * completed | ||
| 3313 | * | ||
| 3314 | * Must be called prior to device access being disabled and after device | ||
| 3315 | * access is restored. | ||
| 3316 | */ | ||
| 3317 | static void pci_reset_notify(struct pci_dev *dev, bool prepare) | ||
| 3318 | { | ||
| 3319 | const struct pci_error_handlers *err_handler = | ||
| 3320 | dev->driver ? dev->driver->err_handler : NULL; | ||
| 3321 | if (err_handler && err_handler->reset_notify) | ||
| 3322 | err_handler->reset_notify(dev, prepare); | ||
| 3323 | } | ||
| 3324 | |||
| 3308 | static void pci_dev_save_and_disable(struct pci_dev *dev) | 3325 | static void pci_dev_save_and_disable(struct pci_dev *dev) |
| 3309 | { | 3326 | { |
| 3327 | pci_reset_notify(dev, true); | ||
| 3328 | |||
| 3310 | /* | 3329 | /* |
| 3311 | * Wake-up device prior to save. PM registers default to D0 after | 3330 | * Wake-up device prior to save. PM registers default to D0 after |
| 3312 | * reset and a simple register restore doesn't reliably return | 3331 | * reset and a simple register restore doesn't reliably return |
| @@ -3328,6 +3347,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev) | |||
| 3328 | static void pci_dev_restore(struct pci_dev *dev) | 3347 | static void pci_dev_restore(struct pci_dev *dev) |
| 3329 | { | 3348 | { |
| 3330 | pci_restore_state(dev); | 3349 | pci_restore_state(dev); |
| 3350 | pci_reset_notify(dev, false); | ||
| 3331 | } | 3351 | } |
| 3332 | 3352 | ||
| 3333 | static int pci_dev_reset(struct pci_dev *dev, int probe) | 3353 | static int pci_dev_reset(struct pci_dev *dev, int probe) |
| @@ -3344,6 +3364,7 @@ static int pci_dev_reset(struct pci_dev *dev, int probe) | |||
| 3344 | 3364 | ||
| 3345 | return rc; | 3365 | return rc; |
| 3346 | } | 3366 | } |
| 3367 | |||
| 3347 | /** | 3368 | /** |
| 3348 | * __pci_reset_function - reset a PCI device function | 3369 | * __pci_reset_function - reset a PCI device function |
| 3349 | * @dev: PCI device to reset | 3370 | * @dev: PCI device to reset |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fe233a3099cf..0601890db22d 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
| @@ -77,7 +77,7 @@ static inline void pci_wakeup_event(struct pci_dev *dev) | |||
| 77 | pm_wakeup_event(&dev->dev, 100); | 77 | pm_wakeup_event(&dev->dev, 100); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static inline bool pci_is_bridge(struct pci_dev *pci_dev) | 80 | static inline bool pci_has_subordinate(struct pci_dev *pci_dev) |
| 81 | { | 81 | { |
| 82 | return !!(pci_dev->subordinate); | 82 | return !!(pci_dev->subordinate); |
| 83 | } | 83 | } |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 52d05e054cd8..36f1fd174b07 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -1225,6 +1225,7 @@ static void pci_release_dev(struct device *dev) | |||
| 1225 | pci_release_of_node(pci_dev); | 1225 | pci_release_of_node(pci_dev); |
| 1226 | pcibios_release_device(pci_dev); | 1226 | pcibios_release_device(pci_dev); |
| 1227 | pci_bus_put(pci_dev->bus); | 1227 | pci_bus_put(pci_dev->bus); |
| 1228 | kfree(pci_dev->driver_override); | ||
| 1228 | kfree(pci_dev); | 1229 | kfree(pci_dev); |
| 1229 | } | 1230 | } |
| 1230 | 1231 | ||
| @@ -1680,8 +1681,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) | |||
| 1680 | 1681 | ||
| 1681 | for (pass=0; pass < 2; pass++) | 1682 | for (pass=0; pass < 2; pass++) |
| 1682 | list_for_each_entry(dev, &bus->devices, bus_list) { | 1683 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 1683 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 1684 | if (pci_is_bridge(dev)) |
| 1684 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 1685 | max = pci_scan_bridge(bus, dev, max, pass); | 1685 | max = pci_scan_bridge(bus, dev, max, pass); |
| 1686 | } | 1686 | } |
| 1687 | 1687 | ||
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index d9fdcea4412a..fd9b545c3cf5 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
| @@ -1716,9 +1716,7 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus) | |||
| 1716 | 1716 | ||
| 1717 | down_read(&pci_bus_sem); | 1717 | down_read(&pci_bus_sem); |
| 1718 | list_for_each_entry(dev, &bus->devices, bus_list) | 1718 | list_for_each_entry(dev, &bus->devices, bus_list) |
| 1719 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 1719 | if (pci_is_bridge(dev) && pci_has_subordinate(dev)) |
| 1720 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 1721 | if (dev->subordinate) | ||
| 1722 | __pci_bus_size_bridges(dev->subordinate, | 1720 | __pci_bus_size_bridges(dev->subordinate, |
| 1723 | &add_list); | 1721 | &add_list); |
| 1724 | up_read(&pci_bus_sem); | 1722 | up_read(&pci_bus_sem); |
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 8bde61952d20..4fe4cc4ae19a 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c | |||
| @@ -78,8 +78,7 @@ int __ref cb_alloc(struct pcmcia_socket *s) | |||
| 78 | max = bus->busn_res.start; | 78 | max = bus->busn_res.start; |
| 79 | for (pass = 0; pass < 2; pass++) | 79 | for (pass = 0; pass < 2; pass++) |
| 80 | list_for_each_entry(dev, &bus->devices, bus_list) | 80 | list_for_each_entry(dev, &bus->devices, bus_list) |
| 81 | if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | 81 | if (pci_is_bridge(dev)) |
| 82 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) | ||
| 83 | max = pci_scan_bridge(bus, dev, max, pass); | 82 | max = pci_scan_bridge(bus, dev, max, pass); |
| 84 | 83 | ||
| 85 | /* | 84 | /* |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 5dbd15422b55..4eb99966570e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
| @@ -365,6 +365,7 @@ struct pci_dev { | |||
| 365 | #endif | 365 | #endif |
| 366 | phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */ | 366 | phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */ |
| 367 | size_t romlen; /* Length of ROM if it's not from the BAR */ | 367 | size_t romlen; /* Length of ROM if it's not from the BAR */ |
| 368 | char *driver_override; /* Driver name to force a match */ | ||
| 368 | }; | 369 | }; |
| 369 | 370 | ||
| 370 | static inline struct pci_dev *pci_physfn(struct pci_dev *dev) | 371 | static inline struct pci_dev *pci_physfn(struct pci_dev *dev) |
| @@ -477,6 +478,19 @@ static inline bool pci_is_root_bus(struct pci_bus *pbus) | |||
| 477 | return !(pbus->parent); | 478 | return !(pbus->parent); |
| 478 | } | 479 | } |
| 479 | 480 | ||
| 481 | /** | ||
| 482 | * pci_is_bridge - check if the PCI device is a bridge | ||
| 483 | * @dev: PCI device | ||
| 484 | * | ||
| 485 | * Return true if the PCI device is bridge whether it has subordinate | ||
| 486 | * or not. | ||
| 487 | */ | ||
| 488 | static inline bool pci_is_bridge(struct pci_dev *dev) | ||
| 489 | { | ||
| 490 | return dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || | ||
| 491 | dev->hdr_type == PCI_HEADER_TYPE_CARDBUS; | ||
| 492 | } | ||
| 493 | |||
| 480 | static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) | 494 | static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) |
| 481 | { | 495 | { |
| 482 | dev = pci_physfn(dev); | 496 | dev = pci_physfn(dev); |
| @@ -603,6 +617,9 @@ struct pci_error_handlers { | |||
| 603 | /* PCI slot has been reset */ | 617 | /* PCI slot has been reset */ |
| 604 | pci_ers_result_t (*slot_reset)(struct pci_dev *dev); | 618 | pci_ers_result_t (*slot_reset)(struct pci_dev *dev); |
| 605 | 619 | ||
| 620 | /* PCI function reset prepare or completed */ | ||
| 621 | void (*reset_notify)(struct pci_dev *dev, bool prepare); | ||
| 622 | |||
| 606 | /* Device driver may resume normal operations */ | 623 | /* Device driver may resume normal operations */ |
| 607 | void (*resume)(struct pci_dev *dev); | 624 | void (*resume)(struct pci_dev *dev); |
| 608 | }; | 625 | }; |
