Commit 1d854908 authored by Linus Torvalds's avatar Linus Torvalds

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
parents f56c3196 444ee9bd
...@@ -44,7 +44,6 @@ extern bool pciehp_poll_mode; ...@@ -44,7 +44,6 @@ extern bool pciehp_poll_mode;
extern int pciehp_poll_time; extern int pciehp_poll_time;
extern bool pciehp_debug; extern bool pciehp_debug;
extern bool pciehp_force; extern bool pciehp_force;
extern struct workqueue_struct *pciehp_wq;
#define dbg(format, arg...) \ #define dbg(format, arg...) \
do { \ do { \
...@@ -78,6 +77,7 @@ struct slot { ...@@ -78,6 +77,7 @@ struct slot {
struct hotplug_slot *hotplug_slot; struct hotplug_slot *hotplug_slot;
struct delayed_work work; /* work for button event */ struct delayed_work work; /* work for button event */
struct mutex lock; struct mutex lock;
struct workqueue_struct *wq;
}; };
struct event_info { struct event_info {
......
...@@ -42,7 +42,6 @@ bool pciehp_debug; ...@@ -42,7 +42,6 @@ bool pciehp_debug;
bool pciehp_poll_mode; bool pciehp_poll_mode;
int pciehp_poll_time; int pciehp_poll_time;
bool pciehp_force; bool pciehp_force;
struct workqueue_struct *pciehp_wq;
#define DRIVER_VERSION "0.4" #define DRIVER_VERSION "0.4"
#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" #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,18 +339,13 @@ static int __init pcied_init(void)
{ {
int retval = 0; int retval = 0;
pciehp_wq = alloc_workqueue("pciehp", 0, 0);
if (!pciehp_wq)
return -ENOMEM;
pciehp_firmware_init(); pciehp_firmware_init();
retval = pcie_port_service_register(&hpdriver_portdrv); retval = pcie_port_service_register(&hpdriver_portdrv);
dbg("pcie_port_service_register = %d\n", retval); dbg("pcie_port_service_register = %d\n", retval);
info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
if (retval) { if (retval)
destroy_workqueue(pciehp_wq);
dbg("Failure to register service\n"); dbg("Failure to register service\n");
}
return retval; return retval;
} }
...@@ -359,7 +353,6 @@ static void __exit pcied_cleanup(void) ...@@ -359,7 +353,6 @@ static void __exit pcied_cleanup(void)
{ {
dbg("unload_pciehpd()\n"); dbg("unload_pciehpd()\n");
pcie_port_service_unregister(&hpdriver_portdrv); pcie_port_service_unregister(&hpdriver_portdrv);
destroy_workqueue(pciehp_wq);
info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
} }
......
...@@ -49,7 +49,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) ...@@ -49,7 +49,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
info->p_slot = p_slot; info->p_slot = p_slot;
INIT_WORK(&info->work, interrupt_event_handler); INIT_WORK(&info->work, interrupt_event_handler);
queue_work(pciehp_wq, &info->work); queue_work(p_slot->wq, &info->work);
return 0; return 0;
} }
...@@ -344,7 +344,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) ...@@ -344,7 +344,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
kfree(info); kfree(info);
goto out; goto out;
} }
queue_work(pciehp_wq, &info->work); queue_work(p_slot->wq, &info->work);
out: out:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
} }
...@@ -377,7 +377,7 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -377,7 +377,7 @@ static void handle_button_press_event(struct slot *p_slot)
if (ATTN_LED(ctrl)) if (ATTN_LED(ctrl))
pciehp_set_attention_status(p_slot, 0); pciehp_set_attention_status(p_slot, 0);
queue_delayed_work(pciehp_wq, &p_slot->work, 5*HZ); queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
break; break;
case BLINKINGOFF_STATE: case BLINKINGOFF_STATE:
case BLINKINGON_STATE: case BLINKINGON_STATE:
...@@ -439,7 +439,7 @@ static void handle_surprise_event(struct slot *p_slot) ...@@ -439,7 +439,7 @@ static void handle_surprise_event(struct slot *p_slot)
else else
p_slot->state = POWERON_STATE; p_slot->state = POWERON_STATE;
queue_work(pciehp_wq, &info->work); queue_work(p_slot->wq, &info->work);
} }
static void interrupt_event_handler(struct work_struct *work) static void interrupt_event_handler(struct work_struct *work)
......
...@@ -773,23 +773,32 @@ static void pcie_shutdown_notification(struct controller *ctrl) ...@@ -773,23 +773,32 @@ static void pcie_shutdown_notification(struct controller *ctrl)
static int pcie_init_slot(struct controller *ctrl) static int pcie_init_slot(struct controller *ctrl)
{ {
struct slot *slot; struct slot *slot;
char name[32];
slot = kzalloc(sizeof(*slot), GFP_KERNEL); slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot) if (!slot)
return -ENOMEM; return -ENOMEM;
snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
slot->wq = alloc_workqueue(name, 0, 0);
if (!slot->wq)
goto abort;
slot->ctrl = ctrl; slot->ctrl = ctrl;
mutex_init(&slot->lock); mutex_init(&slot->lock);
INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
ctrl->slot = slot; ctrl->slot = slot;
return 0; return 0;
abort:
kfree(slot);
return -ENOMEM;
} }
static void pcie_cleanup_slot(struct controller *ctrl) static void pcie_cleanup_slot(struct controller *ctrl)
{ {
struct slot *slot = ctrl->slot; struct slot *slot = ctrl->slot;
cancel_delayed_work(&slot->work); cancel_delayed_work(&slot->work);
flush_workqueue(pciehp_wq); destroy_workqueue(slot->wq);
kfree(slot); kfree(slot);
} }
......
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
extern bool shpchp_poll_mode; extern bool shpchp_poll_mode;
extern int shpchp_poll_time; extern int shpchp_poll_time;
extern bool shpchp_debug; extern bool shpchp_debug;
extern struct workqueue_struct *shpchp_wq;
extern struct workqueue_struct *shpchp_ordered_wq;
#define dbg(format, arg...) \ #define dbg(format, arg...) \
do { \ do { \
...@@ -91,6 +89,7 @@ struct slot { ...@@ -91,6 +89,7 @@ struct slot {
struct list_head slot_list; struct list_head slot_list;
struct delayed_work work; /* work for button event */ struct delayed_work work; /* work for button event */
struct mutex lock; struct mutex lock;
struct workqueue_struct *wq;
u8 hp_slot; u8 hp_slot;
}; };
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
bool shpchp_debug; bool shpchp_debug;
bool shpchp_poll_mode; bool shpchp_poll_mode;
int shpchp_poll_time; int shpchp_poll_time;
struct workqueue_struct *shpchp_wq;
struct workqueue_struct *shpchp_ordered_wq;
#define DRIVER_VERSION "0.4" #define DRIVER_VERSION "0.4"
#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" #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,6 +127,14 @@ static int init_slots(struct controller *ctrl)
slot->device = ctrl->slot_device_offset + i; slot->device = ctrl->slot_device_offset + i;
slot->hpc_ops = ctrl->hpc_ops; slot->hpc_ops = ctrl->hpc_ops;
slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i); slot->number = ctrl->first_slot + (ctrl->slot_num_inc * i);
snprintf(name, sizeof(name), "shpchp-%d", slot->number);
slot->wq = alloc_workqueue(name, 0, 0);
if (!slot->wq) {
retval = -ENOMEM;
goto error_info;
}
mutex_init(&slot->lock); mutex_init(&slot->lock);
INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work); INIT_DELAYED_WORK(&slot->work, shpchp_queue_pushbutton_work);
...@@ -148,7 +154,7 @@ static int init_slots(struct controller *ctrl) ...@@ -148,7 +154,7 @@ static int init_slots(struct controller *ctrl)
if (retval) { if (retval) {
ctrl_err(ctrl, "pci_hp_register failed with error %d\n", ctrl_err(ctrl, "pci_hp_register failed with error %d\n",
retval); retval);
goto error_info; goto error_slotwq;
} }
get_power_status(hotplug_slot, &info->power_status); get_power_status(hotplug_slot, &info->power_status);
...@@ -160,6 +166,8 @@ static int init_slots(struct controller *ctrl) ...@@ -160,6 +166,8 @@ static int init_slots(struct controller *ctrl)
} }
return 0; return 0;
error_slotwq:
destroy_workqueue(slot->wq);
error_info: error_info:
kfree(info); kfree(info);
error_hpslot: error_hpslot:
...@@ -180,8 +188,7 @@ void cleanup_slots(struct controller *ctrl) ...@@ -180,8 +188,7 @@ void cleanup_slots(struct controller *ctrl)
slot = list_entry(tmp, struct slot, slot_list); slot = list_entry(tmp, struct slot, slot_list);
list_del(&slot->slot_list); list_del(&slot->slot_list);
cancel_delayed_work(&slot->work); cancel_delayed_work(&slot->work);
flush_workqueue(shpchp_wq); destroy_workqueue(slot->wq);
flush_workqueue(shpchp_ordered_wq);
pci_hp_deregister(slot->hotplug_slot); pci_hp_deregister(slot->hotplug_slot);
} }
} }
...@@ -364,25 +371,12 @@ static struct pci_driver shpc_driver = { ...@@ -364,25 +371,12 @@ static struct pci_driver shpc_driver = {
static int __init shpcd_init(void) static int __init shpcd_init(void)
{ {
int retval = 0; int retval;
shpchp_wq = alloc_ordered_workqueue("shpchp", 0);
if (!shpchp_wq)
return -ENOMEM;
shpchp_ordered_wq = alloc_ordered_workqueue("shpchp_ordered", 0);
if (!shpchp_ordered_wq) {
destroy_workqueue(shpchp_wq);
return -ENOMEM;
}
retval = pci_register_driver(&shpc_driver); retval = pci_register_driver(&shpc_driver);
dbg("%s: pci_register_driver = %d\n", __func__, retval); dbg("%s: pci_register_driver = %d\n", __func__, retval);
info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
if (retval) {
destroy_workqueue(shpchp_ordered_wq);
destroy_workqueue(shpchp_wq);
}
return retval; return retval;
} }
...@@ -390,8 +384,6 @@ static void __exit shpcd_cleanup(void) ...@@ -390,8 +384,6 @@ static void __exit shpcd_cleanup(void)
{ {
dbg("unload_shpchpd()\n"); dbg("unload_shpchpd()\n");
pci_unregister_driver(&shpc_driver); pci_unregister_driver(&shpc_driver);
destroy_workqueue(shpchp_ordered_wq);
destroy_workqueue(shpchp_wq);
info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
} }
......
...@@ -51,7 +51,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) ...@@ -51,7 +51,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
info->p_slot = p_slot; info->p_slot = p_slot;
INIT_WORK(&info->work, interrupt_event_handler); INIT_WORK(&info->work, interrupt_event_handler);
queue_work(shpchp_wq, &info->work); queue_work(p_slot->wq, &info->work);
return 0; return 0;
} }
...@@ -453,7 +453,7 @@ void shpchp_queue_pushbutton_work(struct work_struct *work) ...@@ -453,7 +453,7 @@ void shpchp_queue_pushbutton_work(struct work_struct *work)
kfree(info); kfree(info);
goto out; goto out;
} }
queue_work(shpchp_ordered_wq, &info->work); queue_work(p_slot->wq, &info->work);
out: out:
mutex_unlock(&p_slot->lock); mutex_unlock(&p_slot->lock);
} }
...@@ -501,7 +501,7 @@ static void handle_button_press_event(struct slot *p_slot) ...@@ -501,7 +501,7 @@ static void handle_button_press_event(struct slot *p_slot)
p_slot->hpc_ops->green_led_blink(p_slot); p_slot->hpc_ops->green_led_blink(p_slot);
p_slot->hpc_ops->set_attention_status(p_slot, 0); p_slot->hpc_ops->set_attention_status(p_slot, 0);
queue_delayed_work(shpchp_wq, &p_slot->work, 5*HZ); queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
break; break;
case BLINKINGOFF_STATE: case BLINKINGOFF_STATE:
case BLINKINGON_STATE: case BLINKINGON_STATE:
......
...@@ -82,4 +82,4 @@ endchoice ...@@ -82,4 +82,4 @@ endchoice
config PCIE_PME config PCIE_PME
def_bool y def_bool y
depends on PCIEPORTBUS && PM_RUNTIME && EXPERIMENTAL && ACPI depends on PCIEPORTBUS && PM_RUNTIME && ACPI
...@@ -630,6 +630,7 @@ static void aer_recover_work_func(struct work_struct *work) ...@@ -630,6 +630,7 @@ static void aer_recover_work_func(struct work_struct *work)
continue; continue;
} }
do_recovery(pdev, entry.severity); do_recovery(pdev, entry.severity);
pci_dev_put(pdev);
} }
} }
#endif #endif
......
...@@ -771,6 +771,9 @@ void pcie_clear_aspm(struct pci_bus *bus) ...@@ -771,6 +771,9 @@ void pcie_clear_aspm(struct pci_bus *bus)
{ {
struct pci_dev *child; struct pci_dev *child;
if (aspm_force)
return;
/* /*
* Clear any ASPM setup that the firmware has carried out on this bus * Clear any ASPM setup that the firmware has carried out on this bus
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment