Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2412405imu; Thu, 17 Jan 2019 13:47:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YZAj6YegTkvSp/zEcjKhuFz7pQ+kLzRr9U6qks6eYNyXnBEfBqWIAXS59KuQQTRP0Yx6d X-Received: by 2002:a62:7792:: with SMTP id s140mr16635145pfc.26.1547761631938; Thu, 17 Jan 2019 13:47:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547761631; cv=none; d=google.com; s=arc-20160816; b=pHcKdSDCuvfPMDUHfQp5cz/wXyZ8AknE71Tt23Aw1NorcHe6Z5otCnStncLGsIMu/p XBw2R5fvwTWZ9Zd9tpWAT5wH7KHIq4xgXIfALRxn2Yee7OX7aEGalB0lb9gjIbTJnBTZ AF34NhOaIMCPsV3O/lmhRyptDKByX7T7KXY+XHdCa4YuP0u4GDiYww9NKS5SF59u1bk0 4Kptx0JABUtzbPkJujz9HRv/2L7mAeGjD6h8RxNDYs9A+rUWORlav4eLjAJ/PXEul//3 czGMtPC31WEAkoY0d6uC+0V3O37HADZUe7BdjAb/jZYH+7U6iOqGIN1tt56G+qc38e9F VTCQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1CeHF8JpPX+3eBjpFQ299XD9B5rV/dSfOnnUNODOxhY=; b=u+yaJpMBLAhcSaifntJ+IectDxsb41T0xYDxjT+W2kyIaavdbqxGyQd0KlhmcF599A 4+LJNqFZ1grkhgLdFJwv7KFIdYWcrNAFXS7GW1VwolcZ31JELAJIcSnoCP/YiWSCBxdu 9K5bFdB8oin0N2mEQa0Tkr1mLD8eCmuZyeT7hi8lvsAd13tm6i839xswKK43nrbjEz7x nq32q4qTkkI7YrkBCn5tl/hJODsxG0Mqh5osy9CkVMpfe9jT7HrztWPSnkoRqMrL0o+P dUSVeoC2DHbJ01hP4x+eKVx4CASBk8t8pPRBfaILyjaI26xdd5sp6ZZSVfCk26eUkbYs q7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eMdgydE7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si2625091pge.444.2019.01.17.13.46.54; Thu, 17 Jan 2019 13:47:11 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=eMdgydE7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727960AbfAQUth (ORCPT + 99 others); Thu, 17 Jan 2019 15:49:37 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43806 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbfAQUte (ORCPT ); Thu, 17 Jan 2019 15:49:34 -0500 Received: by mail-pl1-f195.google.com with SMTP id gn14so5264589plb.10; Thu, 17 Jan 2019 12:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1CeHF8JpPX+3eBjpFQ299XD9B5rV/dSfOnnUNODOxhY=; b=eMdgydE7Iw65oq7L/45dJkOe9F8CNQRLTfSnT4y/hz4V8+FwhMwnNzuRln1evETzdD RC85He0XamYQzoho4I4iXC00s6JOI8OL1MQUOPl9HazubvC6k6MIfJ890B4ju0GE7VNp uZucUan5vr4kiCa6pcQZHJ8G6xN0O5qRrbFv9mGWxR+2FdCPJeZNYdbCT9N9h0ssUunQ izf0nASJMDx92V1O5fNdPerE/Awb9iPAAfcCYO0KWqqqvymSqGQ5gmbzFWbkEfq112y0 VA5zQqbMZZbyL3fZBuJsCo6bIfAp0PDAoLhPL7FprnTGCste4B8P++m8m+SjwR/S7tbJ 9stw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1CeHF8JpPX+3eBjpFQ299XD9B5rV/dSfOnnUNODOxhY=; b=Tazzi4sgVbRYn8ETRcPiGNvWxlBzWyPDwmYSo/qjeN8hPyahC1t6KzAbwOBPsPFTTM lA7eiSv7fB80J7O9DoXv9Yq+qDboyatM0N8RGbvzbdlmNWo9xniqI5rSWlTa8S5hWcXK uXPc8CMiJhjl7WRYlLvGbKnir+/5dsC/Ad6pxnqRrROrguLW6D+9H5jImxHYceCi7Tj5 5C8U1JGxPhfnGYm1MoHinI7XXBDk20dp5p2nFQwUINqaoCSLLx7chMkM3KEwmWe56Qbn WzDlBNqGnEipksxLno0cL+owFZ24lIBgudPqDcmfiprw0kpQWY4ibO1nvV6QVrGFTGJs HTQw== X-Gm-Message-State: AJcUukc3sN6S7BP6WLxzbpaCnc/pVbZ92Tly4AHH/x0vljBMsgvTRnqd /8QVga0iczZmRYQbdP6CjnEoPpVqs9M= X-Received: by 2002:a17:902:f082:: with SMTP id go2mr16475317plb.115.1547758172910; Thu, 17 Jan 2019 12:49:32 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id b68sm4007481pfg.160.2019.01.17.12.49.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Jan 2019 12:49:32 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , stable@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/2] media: imx: prpencvf: Disable CSI immediately after last EOF Date: Thu, 17 Jan 2019 12:49:12 -0800 Message-Id: <20190117204912.28456-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117204912.28456-1-slongerbeam@gmail.com> References: <20190117204912.28456-1-slongerbeam@gmail.com> 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 The CSI must be disabled immediately after receiving the last EOF before stream off (and thus before disabling the IDMA channel). This can be accomplished by moving upstream stream off to just after receiving the last EOF completion in prp_stop(). For symmetry also move upstream stream on to end of prp_start(). 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 -d1 --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: f0d9c8924e2c3 ("[media] media: imx: Add IC subdev drivers") Reported-by: Gaƫl PORTAY Signed-off-by: Steve Longerbeam Cc: stable@vger.kernel.org --- Changes in v2: - Add Fixes: and Cc: stable --- drivers/staging/media/imx/imx-ic-prpencvf.c | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 33ada6612fee..f53cdb608528 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -707,12 +707,23 @@ static int prp_start(struct prp_priv *priv) goto out_free_nfb4eof_irq; } + /* start upstream */ + ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 1); + ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0; + if (ret) { + v4l2_err(&ic_priv->sd, + "upstream stream on failed: %d\n", ret); + goto out_free_eof_irq; + } + /* start the EOF timeout timer */ mod_timer(&priv->eof_timeout_timer, jiffies + msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT)); return 0; +out_free_eof_irq: + devm_free_irq(ic_priv->dev, priv->eof_irq, priv); out_free_nfb4eof_irq: devm_free_irq(ic_priv->dev, priv->nfb4eof_irq, priv); out_unsetup: @@ -744,6 +755,12 @@ static void prp_stop(struct prp_priv *priv) if (ret == 0) v4l2_warn(&ic_priv->sd, "wait last EOF timeout\n"); + /* stop upstream */ + ret = v4l2_subdev_call(priv->src_sd, video, s_stream, 0); + if (ret && ret != -ENOIOCTLCMD) + v4l2_warn(&ic_priv->sd, + "upstream stream off failed: %d\n", ret); + devm_free_irq(ic_priv->dev, priv->eof_irq, priv); devm_free_irq(ic_priv->dev, priv->nfb4eof_irq, priv); @@ -1174,15 +1191,6 @@ static int prp_s_stream(struct v4l2_subdev *sd, int enable) if (ret) goto out; - /* start/stop upstream */ - ret = v4l2_subdev_call(priv->src_sd, video, s_stream, enable); - ret = (ret && ret != -ENOIOCTLCMD) ? ret : 0; - if (ret) { - if (enable) - prp_stop(priv); - goto out; - } - update_count: priv->stream_count += enable ? 1 : -1; if (priv->stream_count < 0) -- 2.17.1