Skip to contentSkip to conversation

media: vimc: streamer: if kthread_stop fails, ignore the error

PATCH In review Dafna Hirschfeld 2 participants 2 messages Jan 22, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 media: vimc: streamer: if kthread_stop fails, ignore the error

Ignore errors returned from kthread_stop since the vimc subdevices should still be notified that streaming stopped so they can release the memory for the streaming, and also kthread should be set to NULL. kthread_stop can return -EINTR in case the thread did not yet run. This can happen if userspace calls streamon and streamoff right after.

---
changes from v4: change dev_warn to dev_dbg, delete and add a empty lines Changes from v3: change the comment to explain when kthread fails changes since v2: add a comment explaning why we ignore the error Changes from v1: undo deletion of an empty line

 drivers/media/platform/vimc/vimc-streamer.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/vimc/vimc-streamer.c +7 -1
index cd6b55433c9e..9d2b1ff2ba45 100644
@@ -215,8 +215,14 @@ int vimc_streamer_s_stream(struct vimc_stream *stream,
 			return 0;
 
 		ret = kthread_stop(stream->kthread);
+		/*
+		 * kthread_stop returns -EINTR in cases when streamon was
+		 * immediately followed by streamoff, and the thread didn't had
+		 * a chance to run. Ignore errors to stop the stream in the
+		 * pipeline.
+		 */
 		if (ret)
-			return ret;
+			dev_dbg(ved->dev, "kthread_stop returned '%d'\n", ret);
 
 		stream->kthread = NULL;
 
Signature · 1 line
2.17.1
Acked-by on v5 1/1
#1 lore raw
Quoted 9 lines · Dafna Hirschfeld

Ignore errors returned from kthread_stop since the vimc subdevices should still be notified that streaming stopped so they can release the memory for the streaming, and also kthread should be set to NULL. kthread_stop can return -EINTR in case the thread did not yet run. This can happen if userspace calls streamon and streamoff right after.

Thanks
Helen

Quoted 30 lines

---
changes from v4: change dev_warn to dev_dbg, delete and add a empty lines Changes from v3: change the comment to explain when kthread fails changes since v2: add a comment explaning why we ignore the error Changes from v1: undo deletion of an empty line

 drivers/media/platform/vimc/vimc-streamer.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/vimc/vimc-streamer.c +7 -1
index cd6b55433c9e..9d2b1ff2ba45 100644
@@ -215,8 +215,14 @@ int vimc_streamer_s_stream(struct vimc_stream *stream,
 			return 0;
 
 		ret = kthread_stop(stream->kthread);
+		/*
+		 * kthread_stop returns -EINTR in cases when streamon was
+		 * immediately followed by streamoff, and the thread didn't had
+		 * a chance to run. Ignore errors to stop the stream in the
+		 * pipeline.
+		 */
 		if (ret)
-			return ret;
+			dev_dbg(ved->dev, "kthread_stop returned '%d'\n", ret);
 
 		stream->kthread = NULL;