]>
Commit | Line | Data |
---|---|---|
0f714131 GKH |
1 | From 83967993f2320575c0ab27a80bf1d7535909c2f4 Mon Sep 17 00:00:00 2001 |
2 | From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> | |
3 | Date: Fri, 18 May 2018 16:41:54 -0400 | |
4 | Subject: media: vsp1: Release buffers for each video node | |
5 | ||
6 | From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> | |
7 | ||
8 | commit 83967993f2320575c0ab27a80bf1d7535909c2f4 upstream. | |
9 | ||
10 | Commit 372b2b0399fc ("media: v4l: vsp1: Release buffers in | |
11 | start_streaming error path") introduced a helper to clean up buffers on | |
12 | error paths, but inadvertently changed the code such that only the | |
13 | output WPF buffers were cleaned, rather than the video node being | |
14 | operated on. | |
15 | ||
16 | Since then vsp1_video_cleanup_pipeline() has grown to perform both video | |
17 | node cleanup, as well as pipeline cleanup. Split the implementation into | |
18 | two distinct functions that perform the required work, so that each | |
19 | video node can release its buffers correctly on streamoff. The pipe | |
20 | cleanup that was performed in the vsp1_video_stop_streaming() (releasing | |
21 | the pipe->dl) is moved to the function for clarity. | |
22 | ||
23 | Fixes: 372b2b0399fc ("media: v4l: vsp1: Release buffers in start_streaming error path") | |
24 | ||
25 | Cc: stable@vger.kernel.org # v4.14+ | |
26 | Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> | |
27 | Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | |
28 | Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | |
29 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
30 | ||
31 | --- | |
32 | drivers/media/platform/vsp1/vsp1_video.c | 21 +++++++++++++-------- | |
33 | 1 file changed, 13 insertions(+), 8 deletions(-) | |
34 | ||
35 | --- a/drivers/media/platform/vsp1/vsp1_video.c | |
36 | +++ b/drivers/media/platform/vsp1/vsp1_video.c | |
37 | @@ -849,9 +849,8 @@ static int vsp1_video_setup_pipeline(str | |
38 | return 0; | |
39 | } | |
40 | ||
41 | -static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) | |
42 | +static void vsp1_video_release_buffers(struct vsp1_video *video) | |
43 | { | |
44 | - struct vsp1_video *video = pipe->output->video; | |
45 | struct vsp1_vb2_buffer *buffer; | |
46 | unsigned long flags; | |
47 | ||
48 | @@ -861,12 +860,18 @@ static void vsp1_video_cleanup_pipeline( | |
49 | vb2_buffer_done(&buffer->buf.vb2_buf, VB2_BUF_STATE_ERROR); | |
50 | INIT_LIST_HEAD(&video->irqqueue); | |
51 | spin_unlock_irqrestore(&video->irqlock, flags); | |
52 | +} | |
53 | + | |
54 | +static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) | |
55 | +{ | |
56 | + lockdep_assert_held(&pipe->lock); | |
57 | ||
58 | /* Release our partition table allocation */ | |
59 | - mutex_lock(&pipe->lock); | |
60 | kfree(pipe->part_table); | |
61 | pipe->part_table = NULL; | |
62 | - mutex_unlock(&pipe->lock); | |
63 | + | |
64 | + vsp1_dl_list_put(pipe->dl); | |
65 | + pipe->dl = NULL; | |
66 | } | |
67 | ||
68 | static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count) | |
69 | @@ -881,8 +886,9 @@ static int vsp1_video_start_streaming(st | |
70 | if (pipe->stream_count == pipe->num_inputs) { | |
71 | ret = vsp1_video_setup_pipeline(pipe); | |
72 | if (ret < 0) { | |
73 | - mutex_unlock(&pipe->lock); | |
74 | + vsp1_video_release_buffers(video); | |
75 | vsp1_video_cleanup_pipeline(pipe); | |
76 | + mutex_unlock(&pipe->lock); | |
77 | return ret; | |
78 | } | |
79 | ||
80 | @@ -932,13 +938,12 @@ static void vsp1_video_stop_streaming(st | |
81 | if (ret == -ETIMEDOUT) | |
82 | dev_err(video->vsp1->dev, "pipeline stop timeout\n"); | |
83 | ||
84 | - vsp1_dl_list_put(pipe->dl); | |
85 | - pipe->dl = NULL; | |
86 | + vsp1_video_cleanup_pipeline(pipe); | |
87 | } | |
88 | mutex_unlock(&pipe->lock); | |
89 | ||
90 | media_pipeline_stop(&video->video.entity); | |
91 | - vsp1_video_cleanup_pipeline(pipe); | |
92 | + vsp1_video_release_buffers(video); | |
93 | vsp1_video_pipeline_put(pipe); | |
94 | } | |
95 |