aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBhaktipriya Shridhar <bhaktipriya96@gmail.com>2016-07-02 06:47:31 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-07-08 14:02:57 -0400
commit5612e191ca1f88e16c48bb373d90d1508196aa95 (patch)
tree38588187920b4e01a065981a6ea175536b3b3c15
parent0423ff9bd4193dd9fd4dd2ef1a6698fc80fa17ec (diff)
[media] hdpvr: Remove deprecated create_singlethread_workqueue
The workqueue "workqueue" is involved in transmitting hdpvr buffers. It has a single work item(&dev->worker) 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 hdpvr_device_release() 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>
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c10
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-video.c6
-rw-r--r--drivers/media/usb/hdpvr/hdpvr.h2
3 files changed, 5 insertions, 13 deletions
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index 08f0ca7aa012..a61d8fd63c12 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -310,10 +310,6 @@ static int hdpvr_probe(struct usb_interface *interface,
310 init_waitqueue_head(&dev->wait_buffer); 310 init_waitqueue_head(&dev->wait_buffer);
311 init_waitqueue_head(&dev->wait_data); 311 init_waitqueue_head(&dev->wait_data);
312 312
313 dev->workqueue = create_singlethread_workqueue("hdpvr_buffer");
314 if (!dev->workqueue)
315 goto error;
316
317 dev->options = hdpvr_default_options; 313 dev->options = hdpvr_default_options;
318 314
319 if (default_video_input < HDPVR_VIDEO_INPUTS) 315 if (default_video_input < HDPVR_VIDEO_INPUTS)
@@ -404,9 +400,7 @@ reg_fail:
404#endif 400#endif
405error: 401error:
406 if (dev) { 402 if (dev) {
407 /* Destroy single thread */ 403 flush_work(&dev->worker);
408 if (dev->workqueue)
409 destroy_workqueue(dev->workqueue);
410 /* this frees allocated memory */ 404 /* this frees allocated memory */
411 hdpvr_delete(dev); 405 hdpvr_delete(dev);
412 } 406 }
@@ -427,7 +421,7 @@ static void hdpvr_disconnect(struct usb_interface *interface)
427 mutex_unlock(&dev->io_mutex); 421 mutex_unlock(&dev->io_mutex);
428 v4l2_device_disconnect(&dev->v4l2_dev); 422 v4l2_device_disconnect(&dev->v4l2_dev);
429 msleep(100); 423 msleep(100);
430 flush_workqueue(dev->workqueue); 424 flush_work(&dev->worker);
431 mutex_lock(&dev->io_mutex); 425 mutex_lock(&dev->io_mutex);
432 hdpvr_cancel_queue(dev); 426 hdpvr_cancel_queue(dev);
433 mutex_unlock(&dev->io_mutex); 427 mutex_unlock(&dev->io_mutex);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index ba7f02270c83..2a3a8b470555 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -316,7 +316,7 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
316 dev->status = STATUS_STREAMING; 316 dev->status = STATUS_STREAMING;
317 317
318 INIT_WORK(&dev->worker, hdpvr_transmit_buffers); 318 INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
319 queue_work(dev->workqueue, &dev->worker); 319 schedule_work(&dev->worker);
320 320
321 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, 321 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
322 "streaming started\n"); 322 "streaming started\n");
@@ -350,7 +350,7 @@ static int hdpvr_stop_streaming(struct hdpvr_device *dev)
350 wake_up_interruptible(&dev->wait_buffer); 350 wake_up_interruptible(&dev->wait_buffer);
351 msleep(50); 351 msleep(50);
352 352
353 flush_workqueue(dev->workqueue); 353 flush_work(&dev->worker);
354 354
355 mutex_lock(&dev->io_mutex); 355 mutex_lock(&dev->io_mutex);
356 /* kill the still outstanding urbs */ 356 /* kill the still outstanding urbs */
@@ -1123,7 +1123,7 @@ static void hdpvr_device_release(struct video_device *vdev)
1123 1123
1124 hdpvr_delete(dev); 1124 hdpvr_delete(dev);
1125 mutex_lock(&dev->io_mutex); 1125 mutex_lock(&dev->io_mutex);
1126 destroy_workqueue(dev->workqueue); 1126 flush_work(&dev->worker);
1127 mutex_unlock(&dev->io_mutex); 1127 mutex_unlock(&dev->io_mutex);
1128 1128
1129 v4l2_device_unregister(&dev->v4l2_dev); 1129 v4l2_device_unregister(&dev->v4l2_dev);
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h
index 78e815441f95..a12e0af1d4e1 100644
--- a/drivers/media/usb/hdpvr/hdpvr.h
+++ b/drivers/media/usb/hdpvr/hdpvr.h
@@ -107,8 +107,6 @@ struct hdpvr_device {
107 /* waitqueue for data */ 107 /* waitqueue for data */
108 wait_queue_head_t wait_data; 108 wait_queue_head_t wait_data;
109 /**/ 109 /**/
110 struct workqueue_struct *workqueue;
111 /**/
112 struct work_struct worker; 110 struct work_struct worker;
113 /* current stream owner */ 111 /* current stream owner */
114 struct v4l2_fh *owner; 112 struct v4l2_fh *owner;