[PATCH v2 2/2] [media] cx25821: Remove deprecated create_singlethread_workqueue

2016-07-25 Thread Bhaktipriya Shridhar
The workqueue "_irq_audio_queues" runs the audio upstream handler.
It has a single work item(>_audio_work_entry) 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.

The work item has been flushed in cx25821_stop_upstream_audio() to ensure
that nothing is pending when the driver is disconnected.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 Changes in v2:
-Flushed work item and updated the commit description to reflect
 the same.

 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 14 ++
 drivers/media/pci/cx25821/cx25821.h|  1 -
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c 
b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 05bd957..7c8edb6 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -242,8 +242,7 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
dev->_audioframe_count = 0;
dev->_audiofile_status = END_OF_FILE;

-   destroy_workqueue(dev->_irq_audio_queues);
-   dev->_irq_audio_queues = NULL;
+   flush_work(>_audio_work_entry);

kfree(dev->_audiofilename);
 }
@@ -446,8 +445,7 @@ static int cx25821_audio_upstream_irq(struct cx25821_dev 
*dev, int chan_num,

dev->_audioframe_index = dev->_last_index_irq;

-   queue_work(dev->_irq_audio_queues,
-  >_audio_work_entry);
+   schedule_work(>_audio_work_entry);
}

if (dev->_is_first_audio_frame) {
@@ -639,14 +637,6 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, 
int channel_select)

/* Work queue */
INIT_WORK(>_audio_work_entry, cx25821_audioups_handler);
-   dev->_irq_audio_queues =
-   create_singlethread_workqueue("cx25821_audioworkqueue");
-
-   if (!dev->_irq_audio_queues) {
-   printk(KERN_DEBUG
-   pr_fmt("ERROR: create_singlethread_workqueue() for 
Audio FAILED!\n"));
-   return -ENOMEM;
-   }

dev->_last_index_irq = 0;
dev->_audio_is_running = 0;
diff --git a/drivers/media/pci/cx25821/cx25821.h 
b/drivers/media/pci/cx25821/cx25821.h
index a513b68..c813d88 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -294,7 +294,6 @@ struct cx25821_dev {
u32 audio_upstream_riscbuf_size;
u32 audio_upstream_databuf_size;
int _audioframe_index;
-   struct workqueue_struct *_irq_audio_queues;
struct work_struct _audio_work_entry;
char *input_audiofilename;

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/2] [media] cx25821: Drop Freeing of Workqueue

2016-07-25 Thread Bhaktipriya Shridhar
Workqueues shouldn't be freed. destroy_workqueue should be used instead.
destroy_workqueue safely destroys a workqueue and ensures that all pending
work items are done before destroying the workqueue.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 Changes in v2: None

 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c 
b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 68dbc2d..05bd957 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -242,7 +242,7 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
dev->_audioframe_count = 0;
dev->_audiofile_status = END_OF_FILE;

-   kfree(dev->_irq_audio_queues);
+   destroy_workqueue(dev->_irq_audio_queues);
dev->_irq_audio_queues = NULL;

kfree(dev->_audiofilename);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] Remove improper workqueue usage

2016-07-25 Thread Bhaktipriya Shridhar
This patch set fixes the improper usage of the workqueue API.
This includes dropping the freeing of workqueue and removing the
deprecated create_singlethread_workqueue instance.

Bhaktipriya Shridhar (2):
  [media] cx25821: Drop Freeing of Workqueue
  [media] cx25821: Remove deprecated create_singlethread_workqueue

 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 14 ++
 drivers/media/pci/cx25821/cx25821.h|  1 -
 2 files changed, 2 insertions(+), 13 deletions(-)

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] [media] ad9389b: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue work_queue is involved in EDID (Extended Display
Identification Data) handling.

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

>edid_handler is a self requeueing work item and it has been
been sync cancelled in ad9389b_remove() to ensure that nothing is
pending when the driver is disconnected.

The unused label err_unreg has also been dropped.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 Changes in v2:
-Fixes kbuild warning: label 'err_unreg' defined but not used.

 drivers/media/i2c/ad9389b.c | 22 --
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 0462f46..5fd2350 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -98,7 +98,6 @@ struct ad9389b_state {
struct ad9389b_state_edid edid;
/* Running counter of the number of detected EDIDs (for debugging) */
unsigned edid_detect_counter;
-   struct workqueue_struct *work_queue;
struct delayed_work edid_handler; /* work entry */
 };

@@ -843,8 +842,7 @@ static void ad9389b_edid_handler(struct work_struct *work)
v4l2_dbg(1, debug, sd, "%s: edid read failed\n", 
__func__);
ad9389b_s_power(sd, false);
ad9389b_s_power(sd, true);
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
return;
}
}
@@ -933,8 +931,7 @@ static void ad9389b_update_monitor_present_status(struct 
v4l2_subdev *sd)
ad9389b_setup(sd);
ad9389b_notify_monitor_detect(sd);
state->edid.read_retries = EDID_MAX_RETRIES;
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
} else if (!(status & MASK_AD9389B_HPD_DETECT)) {
v4l2_dbg(1, debug, sd, "%s: hotplug not detected\n", __func__);
state->have_monitor = false;
@@ -1065,8 +1062,7 @@ static bool ad9389b_check_edid_status(struct v4l2_subdev 
*sd)
ad9389b_wr(sd, 0xc9, 0xf);
ad9389b_wr(sd, 0xc4, state->edid.segments);
state->edid.read_retries = EDID_MAX_RETRIES;
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
return false;
}

@@ -1170,13 +1166,6 @@ static int ad9389b_probe(struct i2c_client *client, 
const struct i2c_device_id *
goto err_entity;
}

-   state->work_queue = create_singlethread_workqueue(sd->name);
-   if (state->work_queue == NULL) {
-   v4l2_err(sd, "could not create workqueue\n");
-   err = -ENOMEM;
-   goto err_unreg;
-   }
-
INIT_DELAYED_WORK(>edid_handler, ad9389b_edid_handler);
state->dv_timings = dv1080p60;

@@ -1187,8 +1176,6 @@ static int ad9389b_probe(struct i2c_client *client, const 
struct i2c_device_id *
  client->addr << 1, client->adapter->name);
return 0;

-err_unreg:
-   i2c_unregister_device(state->edid_i2c_client);
 err_entity:
media_entity_cleanup(>entity);
 err_hdl:
@@ -1211,9 +1198,8 @@ static int ad9389b_remove(struct i2c_client *client)
ad9389b_s_stream(sd, false);
ad9389b_s_audio_stream(sd, false);
ad9389b_init_setup(sd);
-   cancel_delayed_work(>edid_handler);
+   cancel_delayed_work_sync(>edid_handler);
i2c_unregister_device(state->edid_i2c_client);
-   destroy_workqueue(state->work_queue);
v4l2_device_unregister_subdev(sd);
media_entity_cleanup(>entity);
v4l2_ctrl_handler_free(sd->ctrl_handler);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] ad9389b: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue work_queue is involved in EDID (Extended Display
Identification Data) handling.

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

>edid_handler is a self requeueing work item and it has been
been sync cancelled in ad9389b_remove() to ensure that nothing is
pending when the driver is disconnected.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/i2c/ad9389b.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c
index 0462f46..1ac552d 100644
--- a/drivers/media/i2c/ad9389b.c
+++ b/drivers/media/i2c/ad9389b.c
@@ -98,7 +98,6 @@ struct ad9389b_state {
struct ad9389b_state_edid edid;
/* Running counter of the number of detected EDIDs (for debugging) */
unsigned edid_detect_counter;
-   struct workqueue_struct *work_queue;
struct delayed_work edid_handler; /* work entry */
 };

@@ -843,8 +842,7 @@ static void ad9389b_edid_handler(struct work_struct *work)
v4l2_dbg(1, debug, sd, "%s: edid read failed\n", 
__func__);
ad9389b_s_power(sd, false);
ad9389b_s_power(sd, true);
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
return;
}
}
@@ -933,8 +931,7 @@ static void ad9389b_update_monitor_present_status(struct 
v4l2_subdev *sd)
ad9389b_setup(sd);
ad9389b_notify_monitor_detect(sd);
state->edid.read_retries = EDID_MAX_RETRIES;
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
} else if (!(status & MASK_AD9389B_HPD_DETECT)) {
v4l2_dbg(1, debug, sd, "%s: hotplug not detected\n", __func__);
state->have_monitor = false;
@@ -1065,8 +1062,7 @@ static bool ad9389b_check_edid_status(struct v4l2_subdev 
*sd)
ad9389b_wr(sd, 0xc9, 0xf);
ad9389b_wr(sd, 0xc4, state->edid.segments);
state->edid.read_retries = EDID_MAX_RETRIES;
-   queue_delayed_work(state->work_queue,
-  >edid_handler, EDID_DELAY);
+   schedule_delayed_work(>edid_handler, EDID_DELAY);
return false;
}

@@ -1170,13 +1166,6 @@ static int ad9389b_probe(struct i2c_client *client, 
const struct i2c_device_id *
goto err_entity;
}

-   state->work_queue = create_singlethread_workqueue(sd->name);
-   if (state->work_queue == NULL) {
-   v4l2_err(sd, "could not create workqueue\n");
-   err = -ENOMEM;
-   goto err_unreg;
-   }
-
INIT_DELAYED_WORK(>edid_handler, ad9389b_edid_handler);
state->dv_timings = dv1080p60;

@@ -1211,9 +1200,8 @@ static int ad9389b_remove(struct i2c_client *client)
ad9389b_s_stream(sd, false);
ad9389b_s_audio_stream(sd, false);
ad9389b_init_setup(sd);
-   cancel_delayed_work(>edid_handler);
+   cancel_delayed_work_sync(>edid_handler);
i2c_unregister_device(state->edid_i2c_client);
-   destroy_workqueue(state->work_queue);
v4l2_device_unregister_subdev(sd);
media_entity_cleanup(>entity);
v4l2_ctrl_handler_free(sd->ctrl_handler);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [media] cx25821: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "_irq_audio_queues" runs the audio upstream handler.
It has a single work item(>_audio_work_entry) 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.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 11 +--
 drivers/media/pci/cx25821/cx25821.h|  1 -
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c 
b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 05bd957..1a86dff 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -446,8 +446,7 @@ static int cx25821_audio_upstream_irq(struct cx25821_dev 
*dev, int chan_num,

dev->_audioframe_index = dev->_last_index_irq;

-   queue_work(dev->_irq_audio_queues,
-  >_audio_work_entry);
+   schedule_work(>_audio_work_entry);
}

if (dev->_is_first_audio_frame) {
@@ -639,14 +638,6 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, 
int channel_select)

/* Work queue */
INIT_WORK(>_audio_work_entry, cx25821_audioups_handler);
-   dev->_irq_audio_queues =
-   create_singlethread_workqueue("cx25821_audioworkqueue");
-
-   if (!dev->_irq_audio_queues) {
-   printk(KERN_DEBUG
-   pr_fmt("ERROR: create_singlethread_workqueue() for 
Audio FAILED!\n"));
-   return -ENOMEM;
-   }

dev->_last_index_irq = 0;
dev->_audio_is_running = 0;
diff --git a/drivers/media/pci/cx25821/cx25821.h 
b/drivers/media/pci/cx25821/cx25821.h
index a513b68..c813d88 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -294,7 +294,6 @@ struct cx25821_dev {
u32 audio_upstream_riscbuf_size;
u32 audio_upstream_databuf_size;
int _audioframe_index;
-   struct workqueue_struct *_irq_audio_queues;
struct work_struct _audio_work_entry;
char *input_audiofilename;

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [media] cx25821: Drop Freeing of Workqueue

2016-07-16 Thread Bhaktipriya Shridhar
Workqueues shouldn't be freed. destroy_workqueue should be used instead.
destroy_workqueue safely destroys a workqueue and ensures that all pending
work items are done before destroying the workqueue.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx25821/cx25821-audio-upstream.c 
b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
index 68dbc2d..05bd957 100644
--- a/drivers/media/pci/cx25821/cx25821-audio-upstream.c
+++ b/drivers/media/pci/cx25821/cx25821-audio-upstream.c
@@ -242,7 +242,7 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
dev->_audioframe_count = 0;
dev->_audiofile_status = END_OF_FILE;

-   kfree(dev->_irq_audio_queues);
+   destroy_workqueue(dev->_irq_audio_queues);
dev->_irq_audio_queues = NULL;

kfree(dev->_audiofilename);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Remove improper workqueue usage

2016-07-16 Thread Bhaktipriya Shridhar
This patch set fixes the improper usage of the workqueue API.
This includes dropping the freeing of workqueue and removing the deprecated
create_singlethread_workqueue instance.

Bhaktipriya Shridhar (2):
  [media] cx25821: Drop Freeing of Workqueue
  [media] cx25821: Remove deprecated create_singlethread_workqueue

 drivers/media/pci/cx25821/cx25821-audio-upstream.c | 13 ++---
 drivers/media/pci/cx25821/cx25821.h|  1 -
 2 files changed, 2 insertions(+), 12 deletions(-)

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] gspca: finepix: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in streaming the camera data.
It has a single work item(>work_struct) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/finepix.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/gspca/finepix.c 
b/drivers/media/usb/gspca/finepix.c
index 52bdb56..ae9a55d 100644
--- a/drivers/media/usb/gspca/finepix.c
+++ b/drivers/media/usb/gspca/finepix.c
@@ -41,7 +41,6 @@ struct usb_fpix {
struct gspca_dev gspca_dev; /* !! must be the first item */

struct work_struct work_struct;
-   struct workqueue_struct *work_thread;
 };

 /* Delay after which claim the next frame. If the delay is too small,
@@ -226,9 +225,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
/* Again, reset bulk in endpoint */
usb_clear_halt(gspca_dev->dev, gspca_dev->urb[0]->pipe);

-   /* Start the workqueue function to do the streaming */
-   dev->work_thread = create_singlethread_workqueue(MODULE_NAME);
-   queue_work(dev->work_thread, >work_struct);
+   schedule_work(>work_struct);

return 0;
 }
@@ -241,9 +238,8 @@ static void sd_stop0(struct gspca_dev *gspca_dev)

/* wait for the work queue to terminate */
mutex_unlock(_dev->usb_lock);
-   destroy_workqueue(dev->work_thread);
+   flush_work(>work_struct);
mutex_lock(_dev->usb_lock);
-   dev->work_thread = NULL;
 }

 /* Table of supported USB devices */
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] gspca: jl2005bcd: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in streaming the camera data.
It has a single work item(>work_struct) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/jl2005bcd.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/gspca/jl2005bcd.c 
b/drivers/media/usb/gspca/jl2005bcd.c
index 5b481fa..ac295f0 100644
--- a/drivers/media/usb/gspca/jl2005bcd.c
+++ b/drivers/media/usb/gspca/jl2005bcd.c
@@ -45,7 +45,6 @@ struct sd {
const struct v4l2_pix_format *cap_mode;
/* Driver stuff */
struct work_struct work_struct;
-   struct workqueue_struct *work_thread;
u8 frame_brightness;
int block_size; /* block size of camera */
int vga;/* 1 if vga cam, 0 if cif cam */
@@ -477,9 +476,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
return -1;
}

-   /* Start the workqueue function to do the streaming */
-   sd->work_thread = create_singlethread_workqueue(MODULE_NAME);
-   queue_work(sd->work_thread, >work_struct);
+   schedule_work(>work_struct);

return 0;
 }
@@ -493,8 +490,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
/* wait for the work queue to terminate */
mutex_unlock(_dev->usb_lock);
/* This waits for sq905c_dostream to finish */
-   destroy_workqueue(dev->work_thread);
-   dev->work_thread = NULL;
+   flush_work(>work_struct);
mutex_lock(_dev->usb_lock);
 }

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] gspca: vicam: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in streaming the camera data.
It has a single work item(>work_struct) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/vicam.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index 103f6c4..8860510 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -47,7 +47,6 @@ MODULE_FIRMWARE(VICAM_FIRMWARE);
 struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
struct work_struct work_struct;
-   struct workqueue_struct *work_thread;
 };

 /* The vicam sensor has a resolution of 512 x 244, with I believe square
@@ -278,9 +277,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
if (ret < 0)
return ret;

-   /* Start the workqueue function to do the streaming */
-   sd->work_thread = create_singlethread_workqueue(MODULE_NAME);
-   queue_work(sd->work_thread, >work_struct);
+   schedule_work(>work_struct);

return 0;
 }
@@ -294,8 +291,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
/* wait for the work queue to terminate */
mutex_unlock(_dev->usb_lock);
/* This waits for vicam_dostream to finish */
-   destroy_workqueue(dev->work_thread);
-   dev->work_thread = NULL;
+   flush_work(>work_struct);
mutex_lock(_dev->usb_lock);

if (gspca_dev->present)
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] gspca: sonixj: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in updating the JPEG quality
of the gspca_dev. It has a single work item(>work) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/sonixj.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c
index fd1c870..d49d76e 100644
--- a/drivers/media/usb/gspca/sonixj.c
+++ b/drivers/media/usb/gspca/sonixj.c
@@ -54,7 +54,6 @@ struct sd {
u32 exposure;

struct work_struct work;
-   struct workqueue_struct *work_thread;

u32 pktsz;  /* (used by pkt_scan) */
u16 npkt;
@@ -2485,7 +2484,6 @@ static int sd_start(struct gspca_dev *gspca_dev)

sd->pktsz = sd->npkt = 0;
sd->nchg = sd->short_mark = 0;
-   sd->work_thread = create_singlethread_workqueue(MODULE_NAME);

return gspca_dev->usb_err;
 }
@@ -2569,12 +2567,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;

-   if (sd->work_thread != NULL) {
-   mutex_unlock(_dev->usb_lock);
-   destroy_workqueue(sd->work_thread);
-   mutex_lock(_dev->usb_lock);
-   sd->work_thread = NULL;
-   }
+   mutex_unlock(_dev->usb_lock);
+   flush_work(>work);
+   mutex_lock(_dev->usb_lock);
 }

 static void do_autogain(struct gspca_dev *gspca_dev)
@@ -2785,7 +2780,7 @@ marker_found:
new_qual = QUALITY_MAX;
if (new_qual != sd->quality) {
sd->quality = new_qual;
-   queue_work(sd->work_thread, >work);
+   schedule_work(>work);
}
}
} else {
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] pvrusb2: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
The workqueue "workqueue" is involved in polling the pvrusb2 hardware
(pvr2_hdw).

It has a single work item(>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 <bhaktipriy...@gmail.com>
---
 drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h |  1 -
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c  | 23 +++
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
index 60141b1..23473a2 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw-internal.h
@@ -170,7 +170,6 @@ struct pvr2_hdw {
const struct pvr2_device_desc *hdw_desc;

/* Kernel worker thread handling */
-   struct workqueue_struct *workqueue;
struct work_struct workpoll; /* Update driver state */

/* Video spigot */
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c 
b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
index 83e9a3e..85e39ec 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
@@ -2624,7 +2624,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface 
*intf,
if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1;
hdw->name[cnt1] = 0;

-   hdw->workqueue = create_singlethread_workqueue(hdw->name);
INIT_WORK(>workpoll,pvr2_hdw_worker_poll);

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(>decoder_stabilization_timer);
del_timer_sync(>encoder_run_timer);
del_timer_sync(>encoder_wait_timer);
-   if (hdw->workqueue) {
-   flush_workqueue(hdw->workqueue);
-   destroy_workqueue(hdw->workqueue);
-   hdw->workqueue = NULL;
-   }
+   flush_work(>workpoll);
usb_free_urb(hdw->ctl_read_urb);
usb_free_urb(hdw->ctl_write_urb);
kfree(hdw->ctl_read_buffer);
@@ -2712,11 +2707,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
 {
if (!hdw) return;
pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
-   if (hdw->workqueue) {
-   flush_workqueue(hdw->workqueue);
-   destroy_workqueue(hdw->workqueue);
-   hdw->workqueue = NULL;
-   }
+   flush_work(>workpoll);
del_timer_sync(>quiescent_timer);
del_timer_sync(>decoder_stabilization_timer);
del_timer_sync(>encoder_run_timer);
@@ -4439,7 +4430,7 @@ static void pvr2_hdw_quiescent_timeout(unsigned long data)
hdw->state_decoder_quiescent = !0;
trace_stbit("state_decoder_quiescent",hdw->state_decoder_quiescent);
hdw->state_stale = !0;
-   queue_work(hdw->workqueue,>workpoll);
+   schedule_work(>workpoll);
 }


@@ -4450,7 +4441,7 @@ static void 
pvr2_hdw_decoder_stabilization_timeout(unsigned long data)
hdw->state_decoder_ready = !0;
trace_stbit("state_decoder_ready", hdw->state_decoder_ready);
hdw->state_stale = !0;
-   queue_work(hdw->workqueue, >workpoll);
+   schedule_work(>workpoll);
 }


@@ -4461,7 +4452,7 @@ static void pvr2_hdw_encoder_wait_timeout(unsigned long 
data)
hdw->state_encoder_waitok = !0;
trace_stbit("state_encoder_waitok",hdw->state_encoder_waitok);
hdw->state_stale = !0;
-   queue_work(hdw->workqueue,>workpoll);
+   schedule_work(>workpoll);
 }


@@ -4473,7 +4464,7 @@ static void pvr2_hdw_encoder_run_timeout(unsigned long 
data)
hdw->state_encoder_runok = !0;
trace_stbit("state_encoder_runok",hdw->state_encoder_runok);
hdw->state_stale = !0;
-   queue_work(hdw->workqueue,>workpoll);
+

[PATCH] [media] s5p-mfc: Remove deprecated create_singlethread_workqueue

2016-07-16 Thread Bhaktipriya Shridhar
alloc_workqueue replaces deprecated create_singlethread_workqueue().

The MFC device driver is a v4l2 driver which can encode/decode video
raw/elementary streams and has support for all popular video codecs.

The driver's watchdog_workqueue has been replaced with system_wq since
it queues a single work item, >watchdog_work, which calls for no
ordering requirement. The work item is involved in running the watchdog
timer and is not being used on a memory reclaim path.

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

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index b16466f..1bc27ec 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -152,7 +152,7 @@ static void s5p_mfc_watchdog(unsigned long arg)
 * error. Now it is time to kill all instances and
 * reset the MFC. */
mfc_err("Time out during waiting for HW\n");
-   queue_work(dev->watchdog_workqueue, >watchdog_work);
+   schedule_work(>watchdog_work);
}
dev->watchdog_timer.expires = jiffies +
msecs_to_jiffies(MFC_WATCHDOG_INTERVAL);
@@ -1238,7 +1238,6 @@ static int s5p_mfc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dev);

dev->hw_lock = 0;
-   dev->watchdog_workqueue = create_singlethread_workqueue(S5P_MFC_NAME);
INIT_WORK(>watchdog_work, s5p_mfc_watchdog_worker);
atomic_set(>watchdog_cnt, 0);
init_timer(>watchdog_timer);
@@ -1284,8 +1283,7 @@ static int s5p_mfc_remove(struct platform_device *pdev)
v4l2_info(>v4l2_dev, "Removing %s\n", pdev->name);

del_timer_sync(>watchdog_timer);
-   flush_workqueue(dev->watchdog_workqueue);
-   destroy_workqueue(dev->watchdog_workqueue);
+   flush_work(>watchdog_work);

video_unregister_device(dev->vfd_enc);
video_unregister_device(dev->vfd_dec);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] zc3xx: Remove deprecated create_singlethread_workqueue

2016-07-09 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in updating parameters for
transfers. It has a single work item(>work) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 Changes in v2:
-Added call to flush_work

 drivers/media/usb/gspca/zc3xx.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index c5d8ee6..5f7254d 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -53,7 +53,6 @@ struct sd {
struct v4l2_ctrl *jpegqual;

struct work_struct work;
-   struct workqueue_struct *work_thread;

u8 reg08;   /* webcam compression quality */

@@ -6826,8 +6825,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
return gspca_dev->usb_err;

/* Start the transfer parameters update thread */
-   sd->work_thread = create_singlethread_workqueue(KBUILD_MODNAME);
-   queue_work(sd->work_thread, >work);
+   schedule_work(>work);

return 0;
 }
@@ -6838,12 +6836,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;

-   if (sd->work_thread != NULL) {
-   mutex_unlock(_dev->usb_lock);
-   destroy_workqueue(sd->work_thread);
-   mutex_lock(_dev->usb_lock);
-   sd->work_thread = NULL;
-   }
+   mutex_unlock(_dev->usb_lock);
+   flush_work(>work);
+   mutex_lock(_dev->usb_lock);
if (!gspca_dev->present)
return;
send_unknown(gspca_dev, sd->sensor);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] zc3xx: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in updating parameters for
transfers. It has a single work item(>work) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/zc3xx.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index c5d8ee6..ebdfed4d6 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -53,7 +53,6 @@ struct sd {
struct v4l2_ctrl *jpegqual;

struct work_struct work;
-   struct workqueue_struct *work_thread;

u8 reg08;   /* webcam compression quality */

@@ -6826,8 +6825,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
return gspca_dev->usb_err;

/* Start the transfer parameters update thread */
-   sd->work_thread = create_singlethread_workqueue(KBUILD_MODNAME);
-   queue_work(sd->work_thread, >work);
+   schedule_work(>work);

return 0;
 }
@@ -6838,12 +6836,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;

-   if (sd->work_thread != NULL) {
-   mutex_unlock(_dev->usb_lock);
-   destroy_workqueue(sd->work_thread);
-   mutex_lock(_dev->usb_lock);
-   sd->work_thread = NULL;
-   }
+   mutex_unlock(_dev->usb_lock);
+   schedule_work(>work);
+   mutex_lock(_dev->usb_lock);
if (!gspca_dev->present)
return;
send_unknown(gspca_dev, sd->sensor);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] sn9c20x: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "work_thread" is involved in JPEG quality update.
It has a single work item(>work) 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 sd_stop0() to ensure that there are no
pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/usb/gspca/sn9c20x.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/gspca/sn9c20x.c 
b/drivers/media/usb/gspca/sn9c20x.c
index d0ee899..10269da 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -92,7 +92,6 @@ struct sd {
struct v4l2_ctrl *jpegqual;

struct work_struct work;
-   struct workqueue_struct *work_thread;

u32 pktsz;  /* (used by pkt_scan) */
u16 npkt;
@@ -2051,8 +2050,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
if (mode & MODE_JPEG) {
sd->pktsz = sd->npkt = 0;
sd->nchg = 0;
-   sd->work_thread =
-   create_singlethread_workqueue(KBUILD_MODNAME);
}

return gspca_dev->usb_err;
@@ -2070,12 +2067,9 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
 {
struct sd *sd = (struct sd *) gspca_dev;

-   if (sd->work_thread != NULL) {
-   mutex_unlock(_dev->usb_lock);
-   destroy_workqueue(sd->work_thread);
-   mutex_lock(_dev->usb_lock);
-   sd->work_thread = NULL;
-   }
+   mutex_unlock(_dev->usb_lock);
+   flush_work(>work);
+   mutex_lock(_dev->usb_lock);
 }

 static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum)
@@ -2228,7 +,7 @@ static void transfer_check(struct gspca_dev *gspca_dev,
new_qual = sd->jpegqual->maximum;
if (new_qual != curqual) {
sd->jpegqual->cur.val = new_qual;
-   queue_work(sd->work_thread, >work);
+   schedule_work(>work);
}
}
} else {
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] hdpvr: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "workqueue" is involved in tranmitting hdpvr buffers.
It has a single work item(>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 <bhaktipriy...@gmail.com>
---
 drivers/media/usb/hdpvr/hdpvr-core.c  | 10 ++
 drivers/media/usb/hdpvr/hdpvr-video.c |  6 +++---
 drivers/media/usb/hdpvr/hdpvr.h   |  2 --
 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 08f0ca7..a61d8fd 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,
init_waitqueue_head(>wait_buffer);
init_waitqueue_head(>wait_data);

-   dev->workqueue = create_singlethread_workqueue("hdpvr_buffer");
-   if (!dev->workqueue)
-   goto error;
-
dev->options = hdpvr_default_options;

if (default_video_input < HDPVR_VIDEO_INPUTS)
@@ -404,9 +400,7 @@ reg_fail:
 #endif
 error:
if (dev) {
-   /* Destroy single thread */
-   if (dev->workqueue)
-   destroy_workqueue(dev->workqueue);
+   flush_work(>worker);
/* this frees allocated memory */
hdpvr_delete(dev);
}
@@ -427,7 +421,7 @@ static void hdpvr_disconnect(struct usb_interface 
*interface)
mutex_unlock(>io_mutex);
v4l2_device_disconnect(>v4l2_dev);
msleep(100);
-   flush_workqueue(dev->workqueue);
+   flush_work(>worker);
mutex_lock(>io_mutex);
hdpvr_cancel_queue(dev);
mutex_unlock(>io_mutex);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c 
b/drivers/media/usb/hdpvr/hdpvr-video.c
index ba7f022..2a3a8b4 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)
dev->status = STATUS_STREAMING;

INIT_WORK(>worker, hdpvr_transmit_buffers);
-   queue_work(dev->workqueue, >worker);
+   schedule_work(>worker);

v4l2_dbg(MSG_BUFFER, hdpvr_debug, >v4l2_dev,
"streaming started\n");
@@ -350,7 +350,7 @@ static int hdpvr_stop_streaming(struct hdpvr_device *dev)
wake_up_interruptible(>wait_buffer);
msleep(50);

-   flush_workqueue(dev->workqueue);
+   flush_work(>worker);

mutex_lock(>io_mutex);
/* kill the still outstanding urbs */
@@ -1123,7 +1123,7 @@ static void hdpvr_device_release(struct video_device 
*vdev)

hdpvr_delete(dev);
mutex_lock(>io_mutex);
-   destroy_workqueue(dev->workqueue);
+   flush_work(>worker);
mutex_unlock(>io_mutex);

v4l2_device_unregister(>v4l2_dev);
diff --git a/drivers/media/usb/hdpvr/hdpvr.h b/drivers/media/usb/hdpvr/hdpvr.h
index 78e8154..a12e0af 100644
--- a/drivers/media/usb/hdpvr/hdpvr.h
+++ b/drivers/media/usb/hdpvr/hdpvr.h
@@ -107,8 +107,6 @@ struct hdpvr_device {
/* waitqueue for data */
wait_queue_head_t   wait_data;
/**/
-   struct workqueue_struct *workqueue;
-   /**/
struct work_struct  worker;
/* current stream owner */
struct v4l2_fh  *owner;
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] adv7604: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "work_queues" enables hotplugging.
It has a single work item(>delayed_work_enable_hotplug) 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 sync cancelled in adv76xx_remove() to ensure
that there are no pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/i2c/adv7604.c | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index beb2841..010f24c 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -184,7 +184,6 @@ struct adv76xx_state {
u16 spa_port_a[2];
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
-   struct workqueue_struct *work_queues;
struct delayed_work delayed_work_enable_hotplug;
bool restart_stdi_once;

@@ -2130,8 +2129,7 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, 
struct v4l2_edid *edid)
}

/* enable hotplug after 100 ms */
-   queue_delayed_work(state->work_queues,
-   >delayed_work_enable_hotplug, HZ / 10);
+   schedule_delayed_work(>delayed_work_enable_hotplug, HZ / 10);
return 0;
 }

@@ -3182,14 +3180,6 @@ static int adv76xx_probe(struct i2c_client *client,
}
}

-   /* work queues */
-   state->work_queues = create_singlethread_workqueue(client->name);
-   if (!state->work_queues) {
-   v4l2_err(sd, "Could not create work queue\n");
-   err = -ENOMEM;
-   goto err_i2c;
-   }
-
INIT_DELAYED_WORK(>delayed_work_enable_hotplug,
adv76xx_delayed_work_enable_hotplug);

@@ -3225,7 +3215,6 @@ err_entity:
media_entity_cleanup(>entity);
 err_work_queues:
cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
 err_i2c:
adv76xx_unregister_clients(state);
 err_hdl:
@@ -3241,7 +3230,6 @@ static int adv76xx_remove(struct i2c_client *client)
struct adv76xx_state *state = to_state(sd);

cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
v4l2_async_unregister_subdev(sd);
media_entity_cleanup(>entity);
adv76xx_unregister_clients(to_state(sd));
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] tc358743: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "work_queues" enables hotplugging.
It has a single work item(>delayed_work_enable_hotplug) 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 sync cancelled in tc358743_remove() to ensure
that there are no pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/i2c/tc358743.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
index 6cf6d06..1e3a0dd 100644
--- a/drivers/media/i2c/tc358743.c
+++ b/drivers/media/i2c/tc358743.c
@@ -89,8 +89,6 @@ struct tc358743_state {
struct v4l2_ctrl *audio_sampling_rate_ctrl;
struct v4l2_ctrl *audio_present_ctrl;

-   /* work queues */
-   struct workqueue_struct *work_queues;
struct delayed_work delayed_work_enable_hotplug;

/* edid  */
@@ -425,8 +423,7 @@ static void tc358743_enable_edid(struct v4l2_subdev *sd)

/* Enable hotplug after 100 ms. DDC access to EDID is also enabled when
 * hotplug is enabled. See register DDC_CTL */
-   queue_delayed_work(state->work_queues,
-  >delayed_work_enable_hotplug, HZ / 10);
+   schedule_delayed_work(>delayed_work_enable_hotplug, HZ / 10);

tc358743_enable_interrupts(sd, true);
tc358743_s_ctrl_detect_tx_5v(sd);
@@ -1884,14 +1881,6 @@ static int tc358743_probe(struct i2c_client *client,
goto err_hdl;
}

-   /* work queues */
-   state->work_queues = create_singlethread_workqueue(client->name);
-   if (!state->work_queues) {
-   v4l2_err(sd, "Could not create work queue\n");
-   err = -ENOMEM;
-   goto err_hdl;
-   }
-
state->pad.flags = MEDIA_PAD_FL_SOURCE;
err = media_entity_pads_init(>entity, 1, >pad);
if (err < 0)
@@ -1940,7 +1929,6 @@ static int tc358743_probe(struct i2c_client *client,

 err_work_queues:
cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
mutex_destroy(>confctl_mutex);
 err_hdl:
media_entity_cleanup(>entity);
@@ -1954,7 +1942,6 @@ static int tc358743_remove(struct i2c_client *client)
struct tc358743_state *state = to_state(sd);

cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
v4l2_async_unregister_subdev(sd);
v4l2_device_unregister_subdev(sd);
mutex_destroy(>confctl_mutex);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [media] adv7842: Remove deprecated create_singlethread_workqueue

2016-07-02 Thread Bhaktipriya Shridhar
The workqueue "work_queues" enables hotplugging.
It has a single work item(>delayed_work_enable_hotplug) 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 sync cancelled in adv7842_remove() to ensure
that there are no pending tasks while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriy...@gmail.com>
---
 drivers/media/i2c/adv7842.c | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index ecaacb0..a18d28d 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -118,7 +118,6 @@ struct adv7842_state {
struct v4l2_fract aspect_ratio;
u32 rgb_quantization_range;
bool is_cea_format;
-   struct workqueue_struct *work_queues;
struct delayed_work delayed_work_enable_hotplug;
bool restart_stdi_once;
bool hdmi_port_a;
@@ -756,8 +755,7 @@ static int edid_write_vga_segment(struct v4l2_subdev *sd)
}

/* enable hotplug after 200 ms */
-   queue_delayed_work(state->work_queues,
-   >delayed_work_enable_hotplug, HZ / 5);
+   schedule_delayed_work(>delayed_work_enable_hotplug, HZ / 5);

return 0;
 }
@@ -855,8 +853,7 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, 
u8 port)
}

/* enable hotplug after 200 ms */
-   queue_delayed_work(state->work_queues,
-   >delayed_work_enable_hotplug, HZ / 5);
+   schedule_delayed_work(>delayed_work_enable_hotplug, HZ / 5);

return 0;
 }
@@ -3311,13 +3308,6 @@ static int adv7842_probe(struct i2c_client *client,
goto err_i2c;
}

-   /* work queues */
-   state->work_queues = create_singlethread_workqueue(client->name);
-   if (!state->work_queues) {
-   v4l2_err(sd, "Could not create work queue\n");
-   err = -ENOMEM;
-   goto err_i2c;
-   }

INIT_DELAYED_WORK(>delayed_work_enable_hotplug,
adv7842_delayed_work_enable_hotplug);
@@ -3339,7 +3329,6 @@ err_entity:
media_entity_cleanup(>entity);
 err_work_queues:
cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
 err_i2c:
adv7842_unregister_clients(sd);
 err_hdl:
@@ -3357,7 +3346,6 @@ static int adv7842_remove(struct i2c_client *client)
adv7842_irq_enable(sd, false);

cancel_delayed_work(>delayed_work_enable_hotplug);
-   destroy_workqueue(state->work_queues);
v4l2_device_unregister_subdev(sd);
media_entity_cleanup(>entity);
adv7842_unregister_clients(sd);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html