提交 18b5dc2e 编写于 作者: A Andy Walls 提交者: Mauro Carvalho Chehab

V4L/DVB (9721): cx18: Change to singlethreaded global work queue thread for deferable work

Change to singlethreaded global work queue thread for deferable work,
instead of the kernel default multithreaded work queue.  This ensures
execution of deferable work is always in the proper order, so caputred buffers
don't get reordered.
Signed-off-by: NAndy Walls <awalls@radix.net>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 ee2d64f5
...@@ -56,6 +56,9 @@ struct cx18 *cx18_cards[CX18_MAX_CARDS]; ...@@ -56,6 +56,9 @@ struct cx18 *cx18_cards[CX18_MAX_CARDS];
/* Protects cx18_cards_active */ /* Protects cx18_cards_active */
DEFINE_SPINLOCK(cx18_cards_lock); DEFINE_SPINLOCK(cx18_cards_lock);
/* Queue for deferrable IRQ handling work for all cx18 cards in system */
struct workqueue_struct *cx18_work_queue;
/* add your revision and whatnot here */ /* add your revision and whatnot here */
static struct pci_device_id cx18_pci_tbl[] __devinitdata = { static struct pci_device_id cx18_pci_tbl[] __devinitdata = {
{PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418, {PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418,
...@@ -920,6 +923,13 @@ int cx18_init_on_first_open(struct cx18 *cx) ...@@ -920,6 +923,13 @@ int cx18_init_on_first_open(struct cx18 *cx)
return 0; return 0;
} }
static void cx18_cancel_epu_work_orders(struct cx18 *cx)
{
int i;
for (i = 0; i < CX18_MAX_EPU_WORK_ORDERS; i++)
cancel_work_sync(&cx->epu_work_order[i].work);
}
static void cx18_remove(struct pci_dev *pci_dev) static void cx18_remove(struct pci_dev *pci_dev)
{ {
struct cx18 *cx = pci_get_drvdata(pci_dev); struct cx18 *cx = pci_get_drvdata(pci_dev);
...@@ -937,7 +947,7 @@ static void cx18_remove(struct pci_dev *pci_dev) ...@@ -937,7 +947,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
cx18_halt_firmware(cx); cx18_halt_firmware(cx);
flush_scheduled_work(); cx18_cancel_epu_work_orders(cx);
cx18_streams_cleanup(cx, 1); cx18_streams_cleanup(cx, 1);
...@@ -981,8 +991,17 @@ static int module_start(void) ...@@ -981,8 +991,17 @@ static int module_start(void)
printk(KERN_INFO "cx18: Debug value must be >= 0 and <= 511!\n"); printk(KERN_INFO "cx18: Debug value must be >= 0 and <= 511!\n");
} }
cx18_work_queue = create_singlethread_workqueue("cx18");
if (cx18_work_queue == NULL) {
printk(KERN_ERR
"cx18: Unable to create work hander thread\n");
return -ENOMEM;
}
if (pci_register_driver(&cx18_pci_driver)) { if (pci_register_driver(&cx18_pci_driver)) {
printk(KERN_ERR "cx18: Error detecting PCI card\n"); printk(KERN_ERR "cx18: Error detecting PCI card\n");
destroy_workqueue(cx18_work_queue);
cx18_work_queue = NULL;
return -ENODEV; return -ENODEV;
} }
printk(KERN_INFO "cx18: End initialization\n"); printk(KERN_INFO "cx18: End initialization\n");
...@@ -995,11 +1014,15 @@ static void module_cleanup(void) ...@@ -995,11 +1014,15 @@ static void module_cleanup(void)
pci_unregister_driver(&cx18_pci_driver); pci_unregister_driver(&cx18_pci_driver);
destroy_workqueue(cx18_work_queue);
cx18_work_queue = NULL;
for (i = 0; i < cx18_cards_active; i++) { for (i = 0; i < cx18_cards_active; i++) {
if (cx18_cards[i] == NULL) if (cx18_cards[i] == NULL)
continue; continue;
kfree(cx18_cards[i]); kfree(cx18_cards[i]);
} }
} }
module_init(module_start); module_init(module_start);
......
...@@ -486,6 +486,7 @@ extern struct cx18 *cx18_cards[]; ...@@ -486,6 +486,7 @@ extern struct cx18 *cx18_cards[];
extern int cx18_cards_active; extern int cx18_cards_active;
extern int cx18_first_minor; extern int cx18_first_minor;
extern spinlock_t cx18_cards_lock; extern spinlock_t cx18_cards_lock;
extern struct workqueue_struct *cx18_work_queue;
/*==============Prototypes==================*/ /*==============Prototypes==================*/
......
...@@ -409,7 +409,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu) ...@@ -409,7 +409,7 @@ void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu)
*/ */
submit = epu_cmd_irq(cx, order, stale); submit = epu_cmd_irq(cx, order, stale);
if (submit > 0) { if (submit > 0) {
schedule_work(&order->work); queue_work(cx18_work_queue, &order->work);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册