Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp600700img; Fri, 22 Mar 2019 04:57:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqymP1rYH7Eg70pgr19qedHEUywoWgoau3lzlpZ7udyjrO8uPY4ho5XE/bPZ3pNUHnwfmmR9 X-Received: by 2002:a63:545f:: with SMTP id e31mr8321081pgm.409.1553255821547; Fri, 22 Mar 2019 04:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553255821; cv=none; d=google.com; s=arc-20160816; b=AMq083BtVN8sXDby5+qkA7YDbevbOtdlfX0mNZ2y6F90P+QmtVf9wHb409uiSWlCWJ R4loir2jsENcaWVq9sBLBm0SsZDFL/Gh/BwLF0lfHG9W1lANYad/q/3tTKnZQO1p1F+q Hqidisvgtn6E+E0INS/WIZecp9oTEhCt3k01hl/bJR2XlSO9tdds4rIgp2YyDHyiU59e fjrCqEu/96/RBpl1lEUChC6pXDOUd4VhxSMMqQ0i1pPxOhN2VbdBM/9JJW0IDQPI/uTJ 78XS5V4ohjBwSIcaU0mAl6mPhqPTsCnnKU0symuq41/BDFiO9r3+Q8y2kw3oH4CjY3Wh h/rg== 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=gGzXDgmRmSNGQcYX2UJYrjIxPVmp2bPtHG4Gq55OjmQ=; b=0Ng6g4w/AYsNT+oH5qAVy81L7kTY3QdxN4ya6UWIVfGel/myWAKwfSdovldjCfDVV8 WZTK8v5LdQgMt0EC8kfdM5TQP4bEBObA+khde4GqgVlvxiWyEdj1HEThRq1RFqCjB3oH xIaqcyh5FVXgVUaITXPoPYlkFxotAoGZcg5DlJO4HgfaZBd/cPjxUYDW1kiPUmfywv+c ge7pGtKw/iHig0InHSFy4LjviuvlOWXjuLaV6z8fp/BzvTNlFcqimkH7o9b9QjhETP0H wxO5WwExPNEAxrg4tTXMb5oSX3hnx/8JD3uCQ2KFf+dToTaDckNZTuudUxsshqXV+L8Z jFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I8hjtl2v; 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 e11si7377941plb.140.2019.03.22.04.56.47; Fri, 22 Mar 2019 04:57:01 -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=I8hjtl2v; 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 S1733258AbfCVL4J (ORCPT + 99 others); Fri, 22 Mar 2019 07:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:60744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732770AbfCVL4G (ORCPT ); Fri, 22 Mar 2019 07:56:06 -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 125F220850; Fri, 22 Mar 2019 11:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255764; bh=CbZh/J1RAUhTsnjU0qfYQiZOObREr5BYnslLU20AkHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8hjtl2v6M2WWW0zjcmPCR/cHBMuEQvxYtkSOZU5j9Pw3EbHXkdwcLdZaMVbZKb9V F6k5MRpWLe0t9QHkEVIGzX9cNRxXH2ifJ7WzrKAGxnph61tfLwFQA/3tiz537/a56b rvjmLzEGTLc4+ikSTAPFdvmPAKDi5Lxk9iRmshDc= 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.14 174/183] media: imx: csi: Disable CSI immediately after last EOF Date: Fri, 22 Mar 2019 12:16:42 +0100 Message-Id: <20190322111254.504396249@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@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.14-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 @@ -538,7 +538,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; @@ -555,7 +555,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); @@ -681,6 +684,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); @@ -688,8 +701,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] = {