[media] pvrusb2: Remove deprecated create_singlethread_workqueue

The workqueue "workqueue" is involved in polling the pvrusb2 hardware
(pvr2_hdw).

It has a single work item(&hdw->workpoll) and hence doesn't require
ordering. Also, it is not being used on a memory reclaim path.
Hence, the singlethreaded workqueue has been replaced with the use of
system_wq.

System workqueues have been able to handle high level of concurrency
for a long time now and hence it's not required to have a singlethreaded
workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
created with create_singlethread_workqueue(), system_wq allows multiple
work items to overlap executions even on the same CPU; however, a
per-cpu workqueue doesn't have any CPU locality or global ordering
guarantee unless the target CPU is explicitly specified and thus the
increase of local concurrency shouldn't make any difference.

Work item has been flushed in pvr2_hdw_destroy to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Bhaktipriya Shridhar 2016-07-16 05:32:34 -03:00 committed by Mauro Carvalho Chehab
parent 50d286470c
commit 29a3006e52
2 changed files with 7 additions and 17 deletions

View File

@ -170,7 +170,6 @@ struct pvr2_hdw {
const struct pvr2_device_desc *hdw_desc; const struct pvr2_device_desc *hdw_desc;
/* Kernel worker thread handling */ /* Kernel worker thread handling */
struct workqueue_struct *workqueue;
struct work_struct workpoll; /* Update driver state */ struct work_struct workpoll; /* Update driver state */
/* Video spigot */ /* Video spigot */

View File

@ -2624,7 +2624,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1; if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1;
hdw->name[cnt1] = 0; hdw->name[cnt1] = 0;
hdw->workqueue = create_singlethread_workqueue(hdw->name);
INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll);
pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s", pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s",
@ -2651,11 +2650,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
del_timer_sync(&hdw->decoder_stabilization_timer); del_timer_sync(&hdw->decoder_stabilization_timer);
del_timer_sync(&hdw->encoder_run_timer); del_timer_sync(&hdw->encoder_run_timer);
del_timer_sync(&hdw->encoder_wait_timer); del_timer_sync(&hdw->encoder_wait_timer);
if (hdw->workqueue) { flush_work(&hdw->workpoll);
flush_workqueue(hdw->workqueue);
destroy_workqueue(hdw->workqueue);
hdw->workqueue = NULL;
}
usb_free_urb(hdw->ctl_read_urb); usb_free_urb(hdw->ctl_read_urb);
usb_free_urb(hdw->ctl_write_urb); usb_free_urb(hdw->ctl_write_urb);
kfree(hdw->ctl_read_buffer); kfree(hdw->ctl_read_buffer);
@ -2712,11 +2707,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
{ {
if (!hdw) return; if (!hdw) return;
pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
if (hdw->workqueue) { flush_work(&hdw->workpoll);
flush_workqueue(hdw->workqueue);
destroy_workqueue(hdw->workqueue);
hdw->workqueue = NULL;
}
del_timer_sync(&hdw->quiescent_timer); del_timer_sync(&hdw->quiescent_timer);
del_timer_sync(&hdw->decoder_stabilization_timer); del_timer_sync(&hdw->decoder_stabilization_timer);
del_timer_sync(&hdw->encoder_run_timer); del_timer_sync(&hdw->encoder_run_timer);
@ -4443,7 +4434,7 @@ static void pvr2_hdw_quiescent_timeout(unsigned long data)
hdw->state_decoder_quiescent = !0; hdw->state_decoder_quiescent = !0;
trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent); trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent);
hdw->state_stale = !0; hdw->state_stale = !0;
queue_work(hdw->workqueue,&hdw->workpoll); schedule_work(&hdw->workpoll);
} }
@ -4454,7 +4445,7 @@ static void pvr2_hdw_decoder_stabilization_timeout(unsigned long data)
hdw->state_decoder_ready = !0; hdw->state_decoder_ready = !0;
trace_stbit("state_decoder_ready", hdw->state_decoder_ready); trace_stbit("state_decoder_ready", hdw->state_decoder_ready);
hdw->state_stale = !0; hdw->state_stale = !0;
queue_work(hdw->workqueue, &hdw->workpoll); schedule_work(&hdw->workpoll);
} }
@ -4465,7 +4456,7 @@ static void pvr2_hdw_encoder_wait_timeout(unsigned long data)
hdw->state_encoder_waitok = !0; hdw->state_encoder_waitok = !0;
trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok); trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok);
hdw->state_stale = !0; hdw->state_stale = !0;
queue_work(hdw->workqueue,&hdw->workpoll); schedule_work(&hdw->workpoll);
} }
@ -4477,7 +4468,7 @@ static void pvr2_hdw_encoder_run_timeout(unsigned long data)
hdw->state_encoder_runok = !0; hdw->state_encoder_runok = !0;
trace_stbit("state_encoder_runok",hdw->state_encoder_runok); trace_stbit("state_encoder_runok",hdw->state_encoder_runok);
hdw->state_stale = !0; hdw->state_stale = !0;
queue_work(hdw->workqueue,&hdw->workpoll); schedule_work(&hdw->workpoll);
} }
} }
@ -4991,7 +4982,7 @@ static void pvr2_hdw_state_sched(struct pvr2_hdw *hdw)
if (hdw->state_stale) return; if (hdw->state_stale) return;
hdw->state_stale = !0; hdw->state_stale = !0;
trace_stbit("state_stale",hdw->state_stale); trace_stbit("state_stale",hdw->state_stale);
queue_work(hdw->workqueue,&hdw->workpoll); schedule_work(&hdw->workpoll);
} }