Received: by 10.223.176.5 with SMTP id f5csp926721wra; Wed, 7 Feb 2018 09:43:10 -0800 (PST) X-Google-Smtp-Source: AH8x2257OoIaDEs2fd3lAvZC9a0mL6BjTEoctTPNjVmnd1OLc+1lcqB9s5sjoDIFGSq653S/Gibi X-Received: by 2002:a17:902:d917:: with SMTP id c23-v6mr6880033plz.231.1518025390372; Wed, 07 Feb 2018 09:43:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518025390; cv=none; d=google.com; s=arc-20160816; b=AfQx3xak1MTPrgOyGZsZ+3pkTcLldf0HdLuPRJW9wzTBE15nwW0EuDFiOWtEMEyDHn SdTnZ2H0bXMRS+t1glUcoND6azg8/p6jRv3HuEMlC2QeFO99DVBUljvihVzWUWK4Uu9j SQY1T5kP9LQpHBh+ka3P3xgu+OeMwVAZJWoQuvfiDjefthi7WLCKkOtZCQiJGpvrwTz1 ayujDE14o81eTFAlpX265faDl0xmmq1erkHBDQZAoHIIYa4ijZsHLUBx0M5TOyQ6VB7n IvRl5p1GZRG8zDXWgf09ad5Y0fnAkr63X/4rY5kD8rqLSZSetP/PLdiEbbkPU6qEFCcc baCw== 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=043XVWtLfXIih4+VuhraTxesCMCczlYjjVokgtiaZq0=; b=IH5O7vPj+GSyudfMBqLR1BKyI1Gq7pI3sKmqwimiR/8kjENpNBkFrYirQYP+oXkYiw p384ZLt8fIVH++A4xO03ttD6Kam2Val+gWcbvZTCppIXpaaJtc8su7c0qwy4SlXu0vV+ Qxprr+njbDN/rOXu7ttDBD4S+KUZdBQw2JOnv4SK/JXQIzqiC8xx60rXY62tlSe3MBmy 18sUN2dU1Afz46pKY0hiPPuvF6haATlsL9fuM0YupYhBjAKebb4RaOJqzRu3YZGc53EG 0vpLoxAjqCBSneAHESmyMHR0F2KXaVJa2qPE4brecJ0ZKDd3ULJGFssZ5LnYoTb9D3p5 WJ9g== 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 x14si854359pgt.208.2018.02.07.09.42.55; Wed, 07 Feb 2018 09:43:10 -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 S1754049AbeBGRmO (ORCPT + 99 others); Wed, 7 Feb 2018 12:42:14 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:8561 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753733AbeBGRmM (ORCPT ); Wed, 7 Feb 2018 12:42:12 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w17HdOqN029957; Wed, 7 Feb 2018 18:41:50 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2fxmgpmw30-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 07 Feb 2018 18:41:50 +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 9BC7631; Wed, 7 Feb 2018 17:41:49 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 669185A83; Wed, 7 Feb 2018 17:41:49 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 7 Feb 2018 18:41:49 +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; Wed, 7 Feb 2018 18:41:48 +0100 From: Hugues Fruchet To: Maxime Coquelin , Alexandre Torgue , Mauro Carvalho Chehab , "Hans Verkuil" CC: , , , , "Benjamin Gaignard" , Yannick Fertre , Hugues Fruchet Subject: [PATCH] media: stm32-dcmi: rework overrun/error case Date: Wed, 7 Feb 2018 18:41:46 +0100 Message-ID: <1518025306-3386-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-07_05:,, 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 --- drivers/media/platform/stm32/stm32-dcmi.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 4a75756..ab555d4 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); @@ -574,6 +561,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; @@ -684,8 +672,14 @@ 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