]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/5.0.4/media-imx-csi-disable-csi-immediately-after-last-eof.patch
Linux 5.0.4
[thirdparty/kernel/stable-queue.git] / releases / 5.0.4 / media-imx-csi-disable-csi-immediately-after-last-eof.patch
CommitLineData
4888e11d
GKH
1From 2e0fe66e0a136252f4d89dbbccdcb26deb867eb8 Mon Sep 17 00:00:00 2001
2From: Steve Longerbeam <slongerbeam@gmail.com>
3Date: Mon, 21 Jan 2019 21:35:50 -0200
4Subject: media: imx: csi: Disable CSI immediately after last EOF
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9From: Steve Longerbeam <slongerbeam@gmail.com>
10
11commit 2e0fe66e0a136252f4d89dbbccdcb26deb867eb8 upstream.
12
13Disable the CSI immediately after receiving the last EOF before stream
14off (and thus before disabling the IDMA channel). Do this by moving the
15wait for EOF completion into a new function csi_idmac_wait_last_eof().
16
17This fixes a complete system hard lockup on the SabreAuto when streaming
18from the ADV7180, by repeatedly sending a stream off immediately followed
19by stream on:
20
21while true; do v4l2-ctl -d4 --stream-mmap --stream-count=3; done
22
23Eventually this either causes the system lockup or EOF timeouts at all
24subsequent stream on, until a system reset.
25
26The lockup occurs when disabling the IDMA channel at stream off. Disabling
27the CSI before disabling the IDMA channel appears to be a reliable fix for
28the hard lockup.
29
30Fixes: 4a34ec8e470cb ("[media] media: imx: Add CSI subdev driver")
31
32Reported-by: Gaƫl PORTAY <gael.portay@collabora.com>
33Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
34Cc: stable@vger.kernel.org # for 4.13 and up
35Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
36Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
37Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38
39---
40 drivers/staging/media/imx/imx-media-csi.c | 17 ++++++++++++++---
41 1 file changed, 14 insertions(+), 3 deletions(-)
42
43--- a/drivers/staging/media/imx/imx-media-csi.c
44+++ b/drivers/staging/media/imx/imx-media-csi.c
45@@ -629,7 +629,7 @@ out_put_ipu:
46 return ret;
47 }
48
49-static void csi_idmac_stop(struct csi_priv *priv)
50+static void csi_idmac_wait_last_eof(struct csi_priv *priv)
51 {
52 unsigned long flags;
53 int ret;
54@@ -646,7 +646,10 @@ static void csi_idmac_stop(struct csi_pr
55 &priv->last_eof_comp, msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT));
56 if (ret == 0)
57 v4l2_warn(&priv->sd, "wait last EOF timeout\n");
58+}
59
60+static void csi_idmac_stop(struct csi_priv *priv)
61+{
62 devm_free_irq(priv->dev, priv->eof_irq, priv);
63 devm_free_irq(priv->dev, priv->nfb4eof_irq, priv);
64
65@@ -758,6 +761,16 @@ idmac_stop:
66
67 static void csi_stop(struct csi_priv *priv)
68 {
69+ if (priv->dest == IPU_CSI_DEST_IDMAC)
70+ csi_idmac_wait_last_eof(priv);
71+
72+ /*
73+ * Disable the CSI asap, after syncing with the last EOF.
74+ * Doing so after the IDMA channel is disabled has shown to
75+ * create hard system-wide hangs.
76+ */
77+ ipu_csi_disable(priv->csi);
78+
79 if (priv->dest == IPU_CSI_DEST_IDMAC) {
80 csi_idmac_stop(priv);
81
82@@ -765,8 +778,6 @@ static void csi_stop(struct csi_priv *pr
83 if (priv->fim)
84 imx_media_fim_set_stream(priv->fim, NULL, false);
85 }
86-
87- ipu_csi_disable(priv->csi);
88 }
89
90 static const struct csi_skip_desc csi_skip[12] = {