Skip to contentSkip to conversation

ad9389b: Remove deprecated create_singlethread_workqueue

PATCH Superseded Bhaktipriya Shridhar 3 participants 4 messages Jul 16, 2016 – Jul 18, 2016 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ad9389b: Remove deprecated create_singlethread_workqueue

The workqueue work_queue is involved in EDID (Extended Display Identification Data) handling.

It has a single work item(&state->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.

&state->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.

---
 drivers/media/i2c/ad9389b.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/media/i2c/ad9389b.c +4 -16
index 0462f46..1ac552d 100644
@@ -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,
-					   &state->edid_handler, EDID_DELAY);
+			schedule_delayed_work(&state->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,
-				   &state->edid_handler, EDID_DELAY);
+		schedule_delayed_work(&state->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,
-				   &state->edid_handler, EDID_DELAY);
+		schedule_delayed_work(&state->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(&state->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(&state->edid_handler);
+	cancel_delayed_work_sync(&state->edid_handler);
 	i2c_unregister_device(state->edid_i2c_client);
-	destroy_workqueue(state->work_queue);
 	v4l2_device_unregister_subdev(sd);
 	media_entity_cleanup(&sd->entity);
 	v4l2_ctrl_handler_free(sd->ctrl_handler);

--
2.1.4

#1 lore raw
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi,

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.7-rc7 next-20160715]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Bhaktipriya-Shridhar/ad9389b-Remove-deprecated-create_singlethread_workqueue/20160716-174501
base:   git://linuxtv.org/media_tree.git master
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64

All warnings (new ones prefixed by >>):

drivers/media/i2c/ad9389b.c: In function 'ad9389b_probe':

>> drivers/media/i2c/ad9389b.c:1179:1: warning: label 'err_unreg' defined but not used [-Wunused-label]
    err_unreg:
    ^

vim +/err_unreg +1179 drivers/media/i2c/ad9389b.c

117a55b6 Hans Verkuil 2012-07-18  1163  	if (state->edid_i2c_client == NULL) {
117a55b6 Hans Verkuil 2012-07-18  1164  		v4l2_err(sd, "failed to register edid i2c client\n");
6ec735df Wei Yongjun  2013-05-13  1165  		err = -ENOMEM;
117a55b6 Hans Verkuil 2012-07-18  1166  		goto err_entity;
117a55b6 Hans Verkuil 2012-07-18  1167  	}
117a55b6 Hans Verkuil 2012-07-18  1168  
117a55b6 Hans Verkuil 2012-07-18  1169  	INIT_DELAYED_WORK(&state->edid_handler, ad9389b_edid_handler);
117a55b6 Hans Verkuil 2012-07-18  1170  	state->dv_timings = dv1080p60;
117a55b6 Hans Verkuil 2012-07-18  1171  
117a55b6 Hans Verkuil 2012-07-18  1172  	ad9389b_init_setup(sd);
117a55b6 Hans Verkuil 2012-07-18  1173  	ad9389b_set_isr(sd, true);
117a55b6 Hans Verkuil 2012-07-18  1174  
117a55b6 Hans Verkuil 2012-07-18  1175  	v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
117a55b6 Hans Verkuil 2012-07-18  1176  		  client->addr << 1, client->adapter->name);
117a55b6 Hans Verkuil 2012-07-18  1177  	return 0;
117a55b6 Hans Verkuil 2012-07-18  1178  
117a55b6 Hans Verkuil 2012-07-18 @1179  err_unreg:
117a55b6 Hans Verkuil 2012-07-18  1180  	i2c_unregister_device(state->edid_i2c_client);
117a55b6 Hans Verkuil 2012-07-18  1181  err_entity:
117a55b6 Hans Verkuil 2012-07-18  1182  	media_entity_cleanup(&sd->entity);
117a55b6 Hans Verkuil 2012-07-18  1183  err_hdl:
117a55b6 Hans Verkuil 2012-07-18  1184  	v4l2_ctrl_handler_free(&state->hdl);
117a55b6 Hans Verkuil 2012-07-18  1185  	return err;
117a55b6 Hans Verkuil 2012-07-18  1186  }

117a55b6 Hans Verkuil 2012-07-18 1187

:::::: The code at line 1179 was first introduced by commit
:::::: 117a55b69d36a19028d1c59a737ad1246a0a75ad [media] ad9389b: driver for the Analog Devices AD9389B video encoder

:::::: TO: Hans Verkuil <[email protected]> :::::: CC: Mauro Carvalho Chehab <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw

PATCH v2 1/1 ad9389b: Remove deprecated create_singlethread_workqueue

In reply to Bhaktipriya Shridhar

The workqueue work_queue is involved in EDID (Extended Display Identification Data) handling.

It has a single work item(&state->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.

&state->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.

---
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(-)
drivers/media/i2c/ad9389b.c +4 -18
index 0462f46..5fd2350 100644
@@ -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,
-					   &state->edid_handler, EDID_DELAY);
+			schedule_delayed_work(&state->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,
-				   &state->edid_handler, EDID_DELAY);
+		schedule_delayed_work(&state->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,
-				   &state->edid_handler, EDID_DELAY);
+		schedule_delayed_work(&state->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(&state->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(&sd->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(&state->edid_handler);
+	cancel_delayed_work_sync(&state->edid_handler);
 	i2c_unregister_device(state->edid_i2c_client);
-	destroy_workqueue(state->work_queue);
 	v4l2_device_unregister_subdev(sd);
 	media_entity_cleanup(&sd->entity);
 	v4l2_ctrl_handler_free(sd->ctrl_handler);

--
2.1.4

Acked-by on v2 1/1
#3 lore raw
Quoted 8 lines · Bhaktipriya Shridhar

The workqueue work_queue is involved in EDID (Extended Display Identification Data) handling.

It has a single work item(&state->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.

Quoted 7 lines

&state->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.

Thanks.

Signature · 1 line
tejun