diff options
author | Tejun Heo <tj@kernel.org> | 2010-10-18 02:31:02 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-10-18 02:31:02 -0400 |
commit | a827ea307b147aeb050803433b3f6842582c6ced (patch) | |
tree | d87c0e0b2acd5a966d402597e9d94af5c527118e /drivers/pci | |
parent | 7bf4a5ddc9fbff52855cad8d4d74bf5344fe8093 (diff) |
pciehp: update workqueue usage
* Rename pciehp_wq to pciehp_ordered_wq and add non-ordered pciehp_wq
which is used instead of the system workqueue. This is to remove
the use of flush_scheduled_work() which is deprecated and scheduled
for removal.
* With cmwq in place, there's no point in creating workqueues lazily.
Create both pciehp_wq and pciehp_ordered_wq upfront.
* Include workqueue.h from pciehp.h.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/pciehp.h | 2 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_core.c | 18 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_ctrl.c | 9 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_hpc.c | 20 |
4 files changed, 24 insertions, 25 deletions
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 73d513989263..838f571027b7 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/sched.h> /* signal_pending() */ | 36 | #include <linux/sched.h> /* signal_pending() */ |
37 | #include <linux/pcieport_if.h> | 37 | #include <linux/pcieport_if.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | #include <linux/workqueue.h> | ||
39 | 40 | ||
40 | #define MY_NAME "pciehp" | 41 | #define MY_NAME "pciehp" |
41 | 42 | ||
@@ -44,6 +45,7 @@ extern int pciehp_poll_time; | |||
44 | extern int pciehp_debug; | 45 | extern int pciehp_debug; |
45 | extern int pciehp_force; | 46 | extern int pciehp_force; |
46 | extern struct workqueue_struct *pciehp_wq; | 47 | extern struct workqueue_struct *pciehp_wq; |
48 | extern struct workqueue_struct *pciehp_ordered_wq; | ||
47 | 49 | ||
48 | #define dbg(format, arg...) \ | 50 | #define dbg(format, arg...) \ |
49 | do { \ | 51 | do { \ |
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index aa5f3ff629ff..7ac8358df8fd 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c | |||
@@ -43,6 +43,7 @@ int pciehp_poll_mode; | |||
43 | int pciehp_poll_time; | 43 | int pciehp_poll_time; |
44 | int pciehp_force; | 44 | int pciehp_force; |
45 | struct workqueue_struct *pciehp_wq; | 45 | struct workqueue_struct *pciehp_wq; |
46 | struct workqueue_struct *pciehp_ordered_wq; | ||
46 | 47 | ||
47 | #define DRIVER_VERSION "0.4" | 48 | #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>" | 49 | #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" |
@@ -340,18 +341,33 @@ static int __init pcied_init(void) | |||
340 | { | 341 | { |
341 | int retval = 0; | 342 | int retval = 0; |
342 | 343 | ||
344 | pciehp_wq = alloc_workqueue("pciehp", 0, 0); | ||
345 | if (!pciehp_wq) | ||
346 | return -ENOMEM; | ||
347 | |||
348 | pciehp_ordered_wq = alloc_ordered_workqueue("pciehp_ordered", 0); | ||
349 | if (!pciehp_ordered_wq) { | ||
350 | destroy_workqueue(pciehp_wq); | ||
351 | return -ENOMEM; | ||
352 | } | ||
353 | |||
343 | pciehp_firmware_init(); | 354 | pciehp_firmware_init(); |
344 | retval = pcie_port_service_register(&hpdriver_portdrv); | 355 | retval = pcie_port_service_register(&hpdriver_portdrv); |
345 | dbg("pcie_port_service_register = %d\n", retval); | 356 | dbg("pcie_port_service_register = %d\n", retval); |
346 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 357 | info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
347 | if (retval) | 358 | if (retval) { |
359 | destroy_workqueue(pciehp_ordered_wq); | ||
360 | destroy_workqueue(pciehp_wq); | ||
348 | dbg("Failure to register service\n"); | 361 | dbg("Failure to register service\n"); |
362 | } | ||
349 | return retval; | 363 | return retval; |
350 | } | 364 | } |
351 | 365 | ||
352 | static void __exit pcied_cleanup(void) | 366 | static void __exit pcied_cleanup(void) |
353 | { | 367 | { |
354 | dbg("unload_pciehpd()\n"); | 368 | dbg("unload_pciehpd()\n"); |
369 | destroy_workqueue(pciehp_ordered_wq); | ||
370 | destroy_workqueue(pciehp_wq); | ||
355 | pcie_port_service_unregister(&hpdriver_portdrv); | 371 | pcie_port_service_unregister(&hpdriver_portdrv); |
356 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); | 372 | info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); |
357 | } | 373 | } |
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 8f58148be044..085dbb5fc168 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
35 | #include <linux/workqueue.h> | ||
36 | #include "../pci.h" | 35 | #include "../pci.h" |
37 | #include "pciehp.h" | 36 | #include "pciehp.h" |
38 | 37 | ||
@@ -50,7 +49,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type) | |||
50 | info->p_slot = p_slot; | 49 | info->p_slot = p_slot; |
51 | INIT_WORK(&info->work, interrupt_event_handler); | 50 | INIT_WORK(&info->work, interrupt_event_handler); |
52 | 51 | ||
53 | schedule_work(&info->work); | 52 | queue_work(pciehp_wq, &info->work); |
54 | 53 | ||
55 | return 0; | 54 | return 0; |
56 | } | 55 | } |
@@ -345,7 +344,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work) | |||
345 | kfree(info); | 344 | kfree(info); |
346 | goto out; | 345 | goto out; |
347 | } | 346 | } |
348 | queue_work(pciehp_wq, &info->work); | 347 | queue_work(pciehp_ordered_wq, &info->work); |
349 | out: | 348 | out: |
350 | mutex_unlock(&p_slot->lock); | 349 | mutex_unlock(&p_slot->lock); |
351 | } | 350 | } |
@@ -378,7 +377,7 @@ static void handle_button_press_event(struct slot *p_slot) | |||
378 | if (ATTN_LED(ctrl)) | 377 | if (ATTN_LED(ctrl)) |
379 | pciehp_set_attention_status(p_slot, 0); | 378 | pciehp_set_attention_status(p_slot, 0); |
380 | 379 | ||
381 | schedule_delayed_work(&p_slot->work, 5*HZ); | 380 | queue_delayed_work(pciehp_wq, &p_slot->work, 5*HZ); |
382 | break; | 381 | break; |
383 | case BLINKINGOFF_STATE: | 382 | case BLINKINGOFF_STATE: |
384 | case BLINKINGON_STATE: | 383 | case BLINKINGON_STATE: |
@@ -440,7 +439,7 @@ static void handle_surprise_event(struct slot *p_slot) | |||
440 | else | 439 | else |
441 | p_slot->state = POWERON_STATE; | 440 | p_slot->state = POWERON_STATE; |
442 | 441 | ||
443 | queue_work(pciehp_wq, &info->work); | 442 | queue_work(pciehp_ordered_wq, &info->work); |
444 | } | 443 | } |
445 | 444 | ||
446 | static void interrupt_event_handler(struct work_struct *work) | 445 | static 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 0cd42047d89b..50a23da5d24d 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c | |||
@@ -41,8 +41,6 @@ | |||
41 | #include "../pci.h" | 41 | #include "../pci.h" |
42 | #include "pciehp.h" | 42 | #include "pciehp.h" |
43 | 43 | ||
44 | static atomic_t pciehp_num_controllers = ATOMIC_INIT(0); | ||
45 | |||
46 | static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) | 44 | static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) |
47 | { | 45 | { |
48 | struct pci_dev *dev = ctrl->pcie->port; | 46 | struct pci_dev *dev = ctrl->pcie->port; |
@@ -805,8 +803,8 @@ static void pcie_cleanup_slot(struct controller *ctrl) | |||
805 | { | 803 | { |
806 | struct slot *slot = ctrl->slot; | 804 | struct slot *slot = ctrl->slot; |
807 | cancel_delayed_work(&slot->work); | 805 | cancel_delayed_work(&slot->work); |
808 | flush_scheduled_work(); | ||
809 | flush_workqueue(pciehp_wq); | 806 | flush_workqueue(pciehp_wq); |
807 | flush_workqueue(pciehp_ordered_wq); | ||
810 | kfree(slot); | 808 | kfree(slot); |
811 | } | 809 | } |
812 | 810 | ||
@@ -912,16 +910,6 @@ struct controller *pcie_init(struct pcie_device *dev) | |||
912 | /* Disable sotfware notification */ | 910 | /* Disable sotfware notification */ |
913 | pcie_disable_notification(ctrl); | 911 | pcie_disable_notification(ctrl); |
914 | 912 | ||
915 | /* | ||
916 | * If this is the first controller to be initialized, | ||
917 | * initialize the pciehp work queue | ||
918 | */ | ||
919 | if (atomic_add_return(1, &pciehp_num_controllers) == 1) { | ||
920 | pciehp_wq = create_singlethread_workqueue("pciehpd"); | ||
921 | if (!pciehp_wq) | ||
922 | goto abort_ctrl; | ||
923 | } | ||
924 | |||
925 | ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", | 913 | ctrl_info(ctrl, "HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", |
926 | pdev->vendor, pdev->device, pdev->subsystem_vendor, | 914 | pdev->vendor, pdev->device, pdev->subsystem_vendor, |
927 | pdev->subsystem_device); | 915 | pdev->subsystem_device); |
@@ -941,11 +929,5 @@ void pciehp_release_ctrl(struct controller *ctrl) | |||
941 | { | 929 | { |
942 | pcie_shutdown_notification(ctrl); | 930 | pcie_shutdown_notification(ctrl); |
943 | pcie_cleanup_slot(ctrl); | 931 | pcie_cleanup_slot(ctrl); |
944 | /* | ||
945 | * If this is the last controller to be released, destroy the | ||
946 | * pciehp work queue | ||
947 | */ | ||
948 | if (atomic_dec_and_test(&pciehp_num_controllers)) | ||
949 | destroy_workqueue(pciehp_wq); | ||
950 | kfree(ctrl); | 932 | kfree(ctrl); |
951 | } | 933 | } |