aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-01-22 19:36:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-01-22 19:36:23 -0500
commit1d8549085377674224bf30a368284c391a3ce40e (patch)
treecfe79776ded693367600fd6d1d019a2cb59a0c5c /drivers/pci
parentf56c3196f251012de9b3ebaff55732a9074fdaae (diff)
parent444ee9bd3d0fa78317c6127c961af5accf50038b (diff)
Merge tag '3.8-pci-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI updates from Bjorn Helgaas: "The most important is a fix for a pciehp deadlock that occurs when unplugging a Thunderbolt adapter. We also applied the same fix to shpchp, removed CONFIG_EXPERIMENTAL dependencies, fixed a pcie_aspm=force problem, and fixed a refcount leak. Details: - Hotplug PCI: pciehp: Use per-slot workqueues to avoid deadlock PCI: shpchp: Make shpchp_wq non-ordered PCI: shpchp: Handle push button event asynchronously PCI: shpchp: Use per-slot workqueues to avoid deadlock - Power management PCI: Allow pcie_aspm=force even when FADT indicates it is unsupported - Misc PCI/AER: pci_get_domain_bus_and_slot() call missing required pci_dev_put() PCI: remove depends on CONFIG_EXPERIMENTAL" * tag '3.8-pci-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: PCI: remove depends on CONFIG_EXPERIMENTAL PCI: Allow pcie_aspm=force even when FADT indicates it is unsupported PCI: shpchp: Use per-slot workqueues to avoid deadlock PCI: shpchp: Handle push button event asynchronously PCI: shpchp: Make shpchp_wq non-ordered PCI/AER: pci_get_domain_bus_and_slot() call missing required pci_dev_put() PCI: pciehp: Use per-slot workqueues to avoid deadlock
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug/pciehp.h2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c11
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c8
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c11
-rw-r--r--drivers/pci/hotplug/shpchp.h3
-rw-r--r--drivers/pci/hotplug/shpchp_core.c36
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c6
-rw-r--r--drivers/pci/pcie/Kconfig2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c1
-rw-r--r--drivers/pci/pcie/aspm.c3
10 files changed, 40 insertions, 43 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 26ffd3e3fb74..2c113de94323 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -44,7 +44,6 @@ extern bool pciehp_poll_mode;
44extern int pciehp_poll_time; 44extern int pciehp_poll_time;
45extern bool pciehp_debug; 45extern bool pciehp_debug;
46extern bool pciehp_force; 46extern bool pciehp_force;
47extern struct workqueue_struct *pciehp_wq;
48 47
49#define dbg(format, arg...) \ 48#define dbg(format, arg...) \
50do { \ 49do { \
@@ -78,6 +77,7 @@ struct slot {
78 struct hotplug_slot *hotplug_slot; 77 struct hotplug_slot *hotplug_slot;
79 struct delayed_work work; /* work for button event */ 78 struct delayed_work work; /* work for button event */
80 struct mutex lock; 79 struct mutex lock;
80 struct workqueue_struct *wq;
81}; 81};
82 82
83struct event_info { 83struct event_info {
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 916bf4f53aba..939bd1d4b5b1 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -42,7 +42,6 @@ bool pciehp_debug;
42bool pciehp_poll_mode; 42bool pciehp_poll_mode;
43int pciehp_poll_time; 43int pciehp_poll_time;
44bool pciehp_force; 44bool pciehp_force;
45struct workqueue_struct *pciehp_wq;
46 45
47#define DRIVER_VERSION "0.4" 46#define DRIVER_VERSION "0.4"
48#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 47#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -340,18 +339,13 @@ static int __init pcied_init(void)
340{ 339{
341 int retval = 0; 340 int retval = 0;
342 341
343 pciehp_wq = alloc_workqueue("pciehp", 0, 0);
344 if (!pciehp_wq)
345 return -ENOMEM;
346
347 pciehp_firmware_init(); 342 pciehp_firmware_init();
348 retval = pcie_port_service_register(&hpdriver_portdrv); 343 retval = pcie_port_service_register(&hpdriver_portdrv);
349 dbg("pcie_port_service_register = %d\n", retval); 344 dbg("pcie_port_service_register = %d\n", retval);
350 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 345 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
351 if (retval) { 346 if (retval)
352 destroy_workqueue(pciehp_wq);
353 dbg("Failure to register service\n"); 347 dbg("Failure to register service\n");
354 } 348
355 return retval; 349 return retval;
356} 350}
357 351
@@ -359,7 +353,6 @@ static void __exit pcied_cleanup(void)
359{ 353{
360 dbg("unload_pciehpd()\n"); 354 dbg("unload_pciehpd()\n");
361 pcie_port_service_unregister(&hpdriver_portdrv); 355 pcie_port_service_unregister(&hpdriver_portdrv);
362 destroy_workqueue(pciehp_wq);
363 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 356 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
364} 357}
365 358
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 27f44295a657..38f018679175 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -49,7 +49,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
49 info->p_slot = p_slot; 49 info->p_slot = p_slot;
50 INIT_WORK(&info->work, interrupt_event_handler); 50 INIT_WORK(&info->work, interrupt_event_handler);
51 51
52 queue_work(pciehp_wq, &info->work); 52 queue_work(p_slot->wq, &info->work);
53 53
54 return 0; 54 return 0;
55} 55}
@@ -344,7 +344,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
344 kfree(info); 344 kfree(info);
345 goto out; 345 goto out;
346 } 346 }
347 queue_work(pciehp_wq, &info->work); 347 queue_work(p_slot->wq, &info->work);
348 out: 348 out:
349 mutex_unlock(&p_slot->lock); 349 mutex_unlock(&p_slot->lock);
350} 350}
@@ -377,7 +377,7 @@ static void handle_button_press_event(struct slot *p_slot)
377 if (ATTN_LED(ctrl)) 377 if (ATTN_LED(ctrl))
378 pciehp_set_attention_status(p_slot, 0); 378 pciehp_set_attention_status(p_slot, 0);
379 379
380 queue_delayed_work(pciehp_wq, &p_slot->work, 5*HZ); 380 queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
381 break; 381 break;
382 case BLINKINGOFF_STATE: 382 case BLINKINGOFF_STATE:
383 case BLINKINGON_STATE: 383 case BLINKINGON_STATE:
@@ -439,7 +439,7 @@ static void handle_surprise_event(struct slot *p_slot)
439 else 439 else
440 p_slot->state = POWERON_STATE; 440 p_slot->state = POWERON_STATE;
441 441
442 queue_work(pciehp_wq, &info->work); 442 queue_work(p_slot->wq, &info->work);
443} 443}
444 444
445static void interrupt_event_handler(struct work_struct *work) 445static void interrupt_event_handler(struct work_struct *work)
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 13b2eaf7ba43..5127f3f41821 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -773,23 +773,32 @@ static void pcie_shutdown_notification(struct controller *ctrl)
773static int pcie_init_slot(struct controller *ctrl) 773static int pcie_init_slot(struct controller *ctrl)
774{ 774{
775 struct slot *slot; 775 struct slot *slot;
776 char name[32];
776 777
777 slot = kzalloc(sizeof(*slot), GFP_KERNEL); 778 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
778 if (!slot) 779 if (!slot)
779 return -ENOMEM; 780 return -ENOMEM;
780 781
782 snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
783 slot->wq = alloc_workqueue(name, 0, 0);
784 if (!slot->wq)
785 goto abort;
786
781 slot->ctrl = ctrl; 787 slot->ctrl = ctrl;
782 mutex_init(&slot->lock); 788 mutex_init(&slot->lock);
783 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); 789 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
784 ctrl->slot = slot; 790 ctrl->slot = slot;
785 return 0; 791 return 0;
792abort:
793 kfree(slot);
794 return -ENOMEM;
786} 795}
787 796
788static void pcie_cleanup_slot(struct controller *ctrl) 797static void pcie_cleanup_slot(struct controller *ctrl)
789{ 798{
790 struct slot *slot = ctrl->slot; 799 struct slot *slot = ctrl->slot;
791 cancel_delayed_work(&slot->work); 800 cancel_delayed_work(&slot->work);
792 flush_workqueue(pciehp_wq); 801 destroy_workqueue(slot->wq);
793 kfree(slot); 802 kfree(slot);
794} 803}
795 804
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index ca64932e658b..b849f995075a 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -46,8 +46,6 @@
46extern bool shpchp_poll_mode; 46extern bool shpchp_poll_mode;
47extern int shpchp_poll_time; 47extern int shpchp_poll_time;
48extern bool shpchp_debug; 48extern bool shpchp_debug;
49extern struct workqueue_struct *shpchp_wq;
50extern struct workqueue_struct *shpchp_ordered_wq;
51 49
52#define dbg(format, arg...) \ 50#define dbg(format, arg...) \
53do { \ 51do { \
@@ -91,6 +89,7 @@ struct slot {
91 struct list_head slot_list; 89 struct list_head slot_list;
92 struct delayed_work work; /* work for button event */ 90 struct delayed_work work; /* work for button event */
93 struct mutex lock; 91 struct mutex lock;
92 struct workqueue_struct *wq;
94 u8 hp_slot; 93 u8 hp_slot;
95}; 94};
96 95
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index b6de307248e4..3100c52c837c 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -39,8 +39,6 @@
39bool shpchp_debug; 39bool shpchp_debug;
40bool shpchp_poll_mode; 40bool shpchp_poll_mode;
41int shpchp_poll_time; 41int shpchp_poll_time;
42struct workqueue_struct *shpchp_wq;
43struct workqueue_struct *shpchp_ordered_wq;
44 42
45#define DRIVER_VERSION "0.4" 43#define DRIVER_VERSION "0.4"
46#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 44#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -129,6 +127,14 @@ static int init_slots(struct controller *ctrl)
129 slot->device = ctrl->slot_device_offset + i; 127 slot->device = ctrl->slot_device_offset + i;
130 slot->hpc_ops = ctrl->hpc_ops; 128 slot->hpc_ops = ctrl->hpc_ops;
131 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i); 129 slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
130
131 snprintf(name, sizeof(name), "shpchp-%d", slot->number);
132 slot->wq = alloc_workqueue(name, 0, 0);
133 if (!slot->wq) {
134 retval = -ENOMEM;
135 goto error_info;
136 }
137
132 mutex_init(&slot->lock); 138 mutex_init(&slot->lock);
133 INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work); 139 INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work);
134 140
@@ -148,7 +154,7 @@ static int init_slots(struct controller *ctrl)
148 if (retval) { 154 if (retval) {
149 ctrl_err(ctrl, "pci_hp_register failed with error %d\n", 155 ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
150 retval); 156 retval);
151 goto error_info; 157 goto error_slotwq;
152 } 158 }
153 159
154 get_power_status(hotplug_slot, &info->power_status); 160 get_power_status(hotplug_slot, &info->power_status);
@@ -160,6 +166,8 @@ static int init_slots(struct controller *ctrl)
160 } 166 }
161 167
162 return 0; 168 return 0;
169error_slotwq:
170 destroy_workqueue(slot->wq);
163error_info: 171error_info:
164 kfree(info); 172 kfree(info);
165error_hpslot: 173error_hpslot:
@@ -180,8 +188,7 @@ void cleanup_slots(struct controller *ctrl)
180 slot = list_entry(tmp, struct slot, slot_list); 188 slot = list_entry(tmp, struct slot, slot_list);
181 list_del(&slot->slot_list); 189 list_del(&slot->slot_list);
182 cancel_delayed_work(&slot->work); 190 cancel_delayed_work(&slot->work);
183 flush_workqueue(shpchp_wq); 191 destroy_workqueue(slot->wq);
184 flush_workqueue(shpchp_ordered_wq);
185 pci_hp_deregister(slot->hotplug_slot); 192 pci_hp_deregister(slot->hotplug_slot);
186 } 193 }
187} 194}
@@ -364,25 +371,12 @@ static struct pci_driver shpc_driver = {
364 371
365static int __init shpcd_init(void) 372static int __init shpcd_init(void)
366{ 373{
367 int retval = 0; 374 int retval;
368
369 shpchp_wq = alloc_ordered_workqueue("shpchp", 0);
370 if (!shpchp_wq)
371 return -ENOMEM;
372
373 shpchp_ordered_wq = alloc_ordered_workqueue("shpchp_ordered", 0);
374 if (!shpchp_ordered_wq) {
375 destroy_workqueue(shpchp_wq);
376 return -ENOMEM;
377 }
378 375
379 retval = pci_register_driver(&shpc_driver); 376 retval = pci_register_driver(&shpc_driver);
380 dbg("%s: pci_register_driver = %d\n", __func__, retval); 377 dbg("%s: pci_register_driver = %d\n", __func__, retval);
381 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 378 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
382 if (retval) { 379
383 destroy_workqueue(shpchp_ordered_wq);
384 destroy_workqueue(shpchp_wq);
385 }
386 return retval; 380 return retval;
387} 381}
388 382
@@ -390,8 +384,6 @@ static void __exit shpcd_cleanup(void)
390{ 384{
391 dbg("unload_shpchpd()\n"); 385 dbg("unload_shpchpd()\n");
392 pci_unregister_driver(&shpc_driver); 386 pci_unregister_driver(&shpc_driver);
393 destroy_workqueue(shpchp_ordered_wq);
394 destroy_workqueue(shpchp_wq);
395 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 387 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
396} 388}
397 389
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index f9b5a52e4115..58499277903a 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -51,7 +51,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
51 info->p_slot = p_slot; 51 info->p_slot = p_slot;
52 INIT_WORK(&info->work, interrupt_event_handler); 52 INIT_WORK(&info->work, interrupt_event_handler);
53 53
54 queue_work(shpchp_wq, &info->work); 54 queue_work(p_slot->wq, &info->work);
55 55
56 return 0; 56 return 0;
57} 57}
@@ -453,7 +453,7 @@ void shpchp_queue_pushbutton_work(struct work_struct *work)
453 kfree(info); 453 kfree(info);
454 goto out; 454 goto out;
455 } 455 }
456 queue_work(shpchp_ordered_wq, &info->work); 456 queue_work(p_slot->wq, &info->work);
457 out: 457 out:
458 mutex_unlock(&p_slot->lock); 458 mutex_unlock(&p_slot->lock);
459} 459}
@@ -501,7 +501,7 @@ static void handle_button_press_event(struct slot *p_slot)
501 p_slot->hpc_ops->green_led_blink(p_slot); 501 p_slot->hpc_ops->green_led_blink(p_slot);
502 p_slot->hpc_ops->set_attention_status(p_slot, 0); 502 p_slot->hpc_ops->set_attention_status(p_slot, 0);
503 503
504 queue_delayed_work(shpchp_wq, &p_slot->work, 5*HZ); 504 queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
505 break; 505 break;
506 case BLINKINGOFF_STATE: 506 case BLINKINGOFF_STATE:
507 case BLINKINGON_STATE: 507 case BLINKINGON_STATE:
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index 6c8bc5809787..fde4a32a0295 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -82,4 +82,4 @@ endchoice
82 82
83config PCIE_PME 83config PCIE_PME
84 def_bool y 84 def_bool y
85 depends on PCIEPORTBUS && PM_RUNTIME && EXPERIMENTAL && ACPI 85 depends on PCIEPORTBUS && PM_RUNTIME && ACPI
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 421bbc5fee32..564d97f94b6c 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -630,6 +630,7 @@ static void aer_recover_work_func(struct work_struct *work)
630 continue; 630 continue;
631 } 631 }
632 do_recovery(pdev, entry.severity); 632 do_recovery(pdev, entry.severity);
633 pci_dev_put(pdev);
633 } 634 }
634} 635}
635#endif 636#endif
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index b52630b8eada..8474b6a4fc9b 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -771,6 +771,9 @@ void pcie_clear_aspm(struct pci_bus *bus)
771{ 771{
772 struct pci_dev *child; 772 struct pci_dev *child;
773 773
774 if (aspm_force)
775 return;
776
774 /* 777 /*
775 * Clear any ASPM setup that the firmware has carried out on this bus 778 * Clear any ASPM setup that the firmware has carried out on this bus
776 */ 779 */