Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp635612img; Fri, 22 Mar 2019 05:37:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8+QC96eVCz1hyjcmtXtSiWv5oNTUdu7iGbozvifgXjE1hr+MqhGZ2aEDfULN4oRCJPSRB X-Received: by 2002:a63:3f8b:: with SMTP id m133mr8551274pga.91.1553258235722; Fri, 22 Mar 2019 05:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553258235; cv=none; d=google.com; s=arc-20160816; b=I/vQ9XZbSPP/XoMcrhHDLXB5mSwpD+Gbs2Qko57ohEQsJBzKLsZpI+F2/ashnTVxHs TOxdhLkYqekJXPtG/xagY/xbFmjcR5rcn3wyFoOOlsS6UTo9xpGw7/Z1s0bDo48nD4jf jfnoQcsic45jOZpRYa5p9YKUUO+9F+ZPexAgCyvdCewdTUO4SzHLShvbDvjkecgzpxaw bAGzXCZSVr7Sa4tGp3hFthJfZi8WeUdxMndIMiIgAPgErKV5D9ID8kag3q4u6FQUWIou SXpWzHhwEYKRAhbzdStwcVeripzp74cEohytKJbYBkFN3lsZUkYpT0hOl0ja4+02i9Ug jz2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YcGHF26Lh7IZUIPImzn4eN0hE9YlfZb6QLaMiPn+N3A=; b=tE9VR4r7h99CnpnBBlHoiMla03s0wFJj9VoN6Tyqqj54Q4ykyWKrZuLfp6JCYZCrCD jYBx/NEuElsVGFpeqnWd35hfrsHcG+HV+MnbHz0JSMcQls5cD9v7nxxhbGeVsXWgTX4U pWrlzxZi7cySjaMoeHUYh5mflmJMg19Jx4zahaoNf+EyTcxaklxr5X6ilc2a5uZE9ydi CnEeiql3keZ52puQJXw+OZSnhg9BJpYaGPzJazUDfyUXkKr95zyqobm60jdjH9vL97FP 2Tp3ATUYiN509enMv5lszzO3FE6sgFAkrUGUgB6JBwDG6kjR53d0Gv/iz52BPdG7zt9c bDCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSqlWctK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25si367075pgm.137.2019.03.22.05.36.58; Fri, 22 Mar 2019 05:37:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LSqlWctK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389162AbfCVMLW (ORCPT + 99 others); Fri, 22 Mar 2019 08:11:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:49614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388974AbfCVMLR (ORCPT ); Fri, 22 Mar 2019 08:11:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4492F21929; Fri, 22 Mar 2019 12:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256676; bh=PqLDeqflfWhk7KQEx88ZVrLd9Vu5hpFZPnQENufHlH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSqlWctK3puHXXPVH+yUgksU2wctf24nAv1UtJjW7ah4sFh2v9niitAHctBy6NTsQ k8E5X2qZ++M/XHgrZIe6GXvUiURbBAQNZCtT9EV1SCf8NLr3bbbnHjSNNJj4V7cFvz pFr/1Xi8Uy36dmhAyGOBv3IYBmZ7EloCbIXMmeag= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ga=C3=ABl=20PORTAY?= , Steve Longerbeam , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.19 267/280] media: imx: csi: Disable CSI immediately after last EOF Date: Fri, 22 Mar 2019 12:17:00 +0100 Message-Id: <20190322111345.323945164@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steve Longerbeam commit 2e0fe66e0a136252f4d89dbbccdcb26deb867eb8 upstream. Disable the CSI immediately after receiving the last EOF before stream off (and thus before disabling the IDMA channel). Do this by moving the wait for EOF completion into a new function csi_idmac_wait_last_eof(). This fixes a complete system hard lockup on the SabreAuto when streaming from the ADV7180, by repeatedly sending a stream off immediately followed by stream on: while true; do v4l2-ctl -d4 --stream-mmap --stream-count=3; done Eventually this either causes the system lockup or EOF timeouts at all subsequent stream on, until a system reset. The lockup occurs when disabling the IDMA channel at stream off. Disabling the CSI before disabling the IDMA channel appears to be a reliable fix for the hard lockup. Fixes: 4a34ec8e470cb ("[media] media: imx: Add CSI subdev driver") Reported-by: Gaƫl PORTAY Signed-off-by: Steve Longerbeam Cc: stable@vger.kernel.org # for 4.13 and up Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/imx/imx-media-csi.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -626,7 +626,7 @@ out_put_ipu: return ret; } -static void csi_idmac_stop(struct csi_priv *priv) +static void csi_idmac_wait_last_eof(struct csi_priv *priv) { unsigned long flags; int ret; @@ -643,7 +643,10 @@ static void csi_idmac_stop(struct csi_pr &priv->last_eof_comp, msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT)); if (ret == 0) v4l2_warn(&priv->sd, "wait last EOF timeout\n"); +} +static void csi_idmac_stop(struct csi_priv *priv) +{ devm_free_irq(priv->dev, priv->eof_irq, priv); devm_free_irq(priv->dev, priv->nfb4eof_irq, priv); @@ -755,6 +758,16 @@ idmac_stop: static void csi_stop(struct csi_priv *priv) { + if (priv->dest == IPU_CSI_DEST_IDMAC) + csi_idmac_wait_last_eof(priv); + + /* + * Disable the CSI asap, after syncing with the last EOF. + * Doing so after the IDMA channel is disabled has shown to + * create hard system-wide hangs. + */ + ipu_csi_disable(priv->csi); + if (priv->dest == IPU_CSI_DEST_IDMAC) { csi_idmac_stop(priv); @@ -762,8 +775,6 @@ static void csi_stop(struct csi_priv *pr if (priv->fim) imx_media_fim_set_stream(priv->fim, NULL, false); } - - ipu_csi_disable(priv->csi); } static const struct csi_skip_desc csi_skip[12] = {