Received: by 10.223.185.116 with SMTP id b49csp1720241wrg; Thu, 22 Feb 2018 01:53:20 -0800 (PST) X-Google-Smtp-Source: AH8x225XBW5XZy0qXvu6y7wVkG9npVP6PJmaae0LsRvVnW3tdRdfD0tzyb6DXs1Ub/IXCZExlrXX X-Received: by 10.98.79.90 with SMTP id d87mr6320957pfb.41.1519293200068; Thu, 22 Feb 2018 01:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519293200; cv=none; d=google.com; s=arc-20160816; b=DEbjPQpVwUHJxDaNJtNdNEoqvlmboB3H79zFc4WXgdhivM0Ha5eEGLziyx//xfSKV+ Nvt+JR/kbL3TR+Yu/+7oIfpEfYdqX4djjfdPR+QU7/ig4arAqZ/LhJ0eHmiHgCDsYguI O34dNZQ4NzLukkiiyqhDfmXgf1ntF3O6Oa1hhn1NZ8OT1j5z9yNKSu38yTIirUOJItk3 /kFOtN+wuFCfguA94+3gBFrLYUcL4oI3ueuvmW0q4lQZl4jesSbHWTEmP2t29B/HT/DJ +KFP/2GQTGvyr8MMN/7Fd2lywo+E1iXkfiIXUi3GpUqE8b9krUQjHVsn+AiQItPZTVK+ qbqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=9+zJ4a35MEnIsjxV2YsH8qQkeqt5OeEI6gecCeNyEWY=; b=LZM/6egIBWJk+6uc5vZtEzQvtqrHJCeUXnuExBKu7widfg2a/5amOHZwAFjF45Qaaj +OaLw1EebuzXcpY+df8pyenXK23rcVVgNlxi0KtqmjfJdi30RwmRcEh9FIfsJYuIQH0Z XKDogzrjZ6rcdll4WOAF6ZDyhoBWH38EIIc6ByAOmAdOyFYPTRIdibMh24+7hnqytXj2 FyP0mxgfkv/E9GPDQ80eLBbKCN7yU8Je+xmSdJ7vpUDH3VB2fRnNZ/IZoGO0G/62O+VW 4GZPtHAGHmuUrIA172P2dT+aABA6tK/0vsAmoK4JoENQ8uu8QVsxICHv7FwunkJIse6Q zrsA== ARC-Authentication-Results: i=1; mx.google.com; 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 p12-v6si1072602pll.191.2018.02.22.01.53.06; Thu, 22 Feb 2018 01:53:20 -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; 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 S1753321AbeBVJvM (ORCPT + 99 others); Thu, 22 Feb 2018 04:51:12 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:44676 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753198AbeBVJuQ (ORCPT ); Thu, 22 Feb 2018 04:50:16 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1M9moGI014094; Thu, 22 Feb 2018 10:49:38 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2g9bpk3nx2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 22 Feb 2018 10:49:38 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 602CD3A; Thu, 22 Feb 2018 09:49:36 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C8EAD503E; Thu, 22 Feb 2018 09:49:36 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 22 Feb 2018 10:49:36 +0100 Received: from localhost (10.201.23.73) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 22 Feb 2018 10:49:36 +0100 From: Hugues Fruchet To: Maxime Coquelin , Alexandre Torgue , Mauro Carvalho Chehab , "Hans Verkuil" CC: , , , Benjamin Gaignard , Yannick Fertre , Hugues Fruchet Subject: [PATCH v2] media: stm32-dcmi: rework overrun/error case Date: Thu, 22 Feb 2018 10:49:33 +0100 Message-ID: <1519292973-19808-1-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.73] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-22_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not stop/restart dma on overrun or errors. Dma will be restarted on current frame transfer completion. Frame transfer completion is ensured even if overrun or error occurs by DCMI continuous capture mode which restarts data transfer at next frame sync. Do no warn on overrun while in irq thread, this slows down system and lead to more overrun errors. Use a counter instead and log errors at stop streaming. Signed-off-by: Hugues Fruchet --- version 2: - Minor: remove extra line at end of dcmi_stop_streaming() drivers/media/platform/stm32/stm32-dcmi.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 5de18ad..536c0d5 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -160,6 +160,7 @@ struct stm32_dcmi { dma_cookie_t dma_cookie; u32 misr; int errors_count; + int overrun_count; int buffers_count; }; @@ -373,23 +374,9 @@ static irqreturn_t dcmi_irq_thread(int irq, void *arg) } if ((dcmi->misr & IT_OVR) || (dcmi->misr & IT_ERR)) { - /* - * An overflow or an error has been detected, - * stop current DMA transfert & restart it - */ - dev_warn(dcmi->dev, "%s: Overflow or error detected\n", - __func__); - dcmi->errors_count++; - dev_dbg(dcmi->dev, "Restarting capture after DCMI error\n"); - - spin_unlock_irq(&dcmi->irqlock); - dmaengine_terminate_all(dcmi->dma_chan); - - if (dcmi_start_capture(dcmi)) - dev_err(dcmi->dev, "%s: Cannot restart capture on overflow or error\n", - __func__); - return IRQ_HANDLED; + if (dcmi->misr & IT_OVR) + dcmi->overrun_count++; } spin_unlock_irq(&dcmi->irqlock); @@ -572,6 +559,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) dcmi->sequence = 0; dcmi->errors_count = 0; + dcmi->overrun_count = 0; dcmi->buffers_count = 0; dcmi->active = NULL; @@ -682,8 +670,13 @@ static void dcmi_stop_streaming(struct vb2_queue *vq) clk_disable(dcmi->mclk); - dev_dbg(dcmi->dev, "Stop streaming, errors=%d buffers=%d\n", - dcmi->errors_count, dcmi->buffers_count); + if (dcmi->errors_count) + dev_warn(dcmi->dev, "Some errors found while streaming: errors=%d (overrun=%d), buffers=%d\n", + dcmi->errors_count, dcmi->overrun_count, + dcmi->buffers_count); + dev_dbg(dcmi->dev, "Stop streaming, errors=%d (overrun=%d), buffers=%d\n", + dcmi->errors_count, dcmi->overrun_count, + dcmi->buffers_count); } static const struct vb2_ops dcmi_video_qops = { -- 1.9.1