Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1453240pxb; Fri, 22 Oct 2021 00:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTG7gW338kCtXkd5ueSz6iOIqfoecFBkTJqdRbcjooADhIQvKXZbyqMPaLqP+NxKiH4S5Y X-Received: by 2002:a17:906:950a:: with SMTP id u10mr6834694ejx.306.1634889394840; Fri, 22 Oct 2021 00:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634889394; cv=none; d=google.com; s=arc-20160816; b=odT5MBQSPXL1emHUB9XEyVUVh2gQwKiqDOfLhazjduXNvrWccb7r4O++SOFe5h4Hd6 vKZkvDv/dVEb7ndZTaDPqSBENUWtBUoeYdyotWY7NjA8wbNSxcdWkkkGlQgloKufkUgK HBMlEu3ZVCE/u2wni9sRZbTXKAzfFOfiOhUXXvo9rkGm8e9TmAw0rx6uEXq8/7veb219 kQsNGd2w2I3PByJdx2CSqo4jeq/6bBFymTSWe7tWjFBNWEv+pW96rSN6yBwFCzQS859R 05SqO/cmHv5WTG5N8tElnJR/crk4nbiALooag/OP1lkYxUVnagQlTBEDBX6vYUl3pK1x uy3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=PaHG7KRxOVH4IVz0P3WilegqP1EkOWJD656XqTsOydw=; b=iyGs+c4aOnv2TmF5J0qY55znSVr0JFoSu1oXc5IGgHfsVRQwVuxvaMI0hAy0yMAVoN 9DI5At18kipUf6PeppSWD65z07vwG1TC0NjZMwy4TnNoq8LUHdrcwkY2PQQ0LuVNOHke T+MvvSJQ41EQcx8Ahf2pNV7O38sjYFH3F5KsdpXCgotFN8VOzNI61eo81kp6o3AsNWqb hQAYqxYeRInU+CghlnLU8/vvqpyAsWCFJDmg+tinV2zYCPjgXNmsBBXTq0wGlrly8VOm pAlj9ze67ekVnEUEgb9chRJDWk9fKsRrjY1PluZ+lxx778AtEmIqPbzNT8aJ6w76nbMR 0fkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=rlP71XSE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si9996275ejc.468.2021.10.22.00.56.12; Fri, 22 Oct 2021 00:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=rlP71XSE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232433AbhJVH4d (ORCPT + 99 others); Fri, 22 Oct 2021 03:56:33 -0400 Received: from esa.microchip.iphmx.com ([68.232.153.233]:55701 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232445AbhJVH4b (ORCPT ); Fri, 22 Oct 2021 03:56:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1634889254; x=1666425254; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gcb+lnpjPb51M6Oj/PPqswwgdjHYl153vJF1lo5rimE=; b=rlP71XSEiNPbp1yGWkJriJms5LKiq1SW+M6JLLUAbzp36vh9jxLTsY/7 79zSJYU/c9KgIbtgJ/rtNTdJ9zyRkmVbCoyHbS6+EcM6dghZHntoEfweg JP/xxEDqw39Cyli4U2MfYgrNA+IKS/+w0Jpx/6rh0QoYEdaDXah8jUkIH cd/5+yKuV1HMb2g+75WwtJHV+h/OD49CyZXhhEh5GYHtSk30k6a3F6GX1 k6344Iil1Y4U1A+WDDJAaEmlFg9cdiLcxtc8paJOzqwSzRtDHjfmcEakL AnPVln/RZJWR8PcLdv/EH4J/xJ3JsL99lq35r3I+ki1enk3z/fx57tadM Q==; IronPort-SDR: biDkLlip17oxnkF2jKE70Mfk0IlDOq8R3NLj8ilE2cQRdNS4Bq24W0uxAPUCL9psuWLR3458Rt D7QrP4ljohElJa79uRoZFTd1gCA/aWlIIpBRQfLfGJDsaS645SStzD/KGCvW1na04dbClcs6s4 Lplk5sqyvn5xWtHNgNiFJNMRjsFlEmyyUb0tCWz5tc6Y+swLsA7TAYPvErNgNOVhJ4+W4lYo1J P52aT3d3aadhHBz8FWi3E8aWEpuPEMXhFoahW7+DQaMzHra3paIYm5MTFdjE+6JKhFFZ2k16Pc rbbL4+SX16zZ1FBKsuzx9DwM X-IronPort-AV: E=Sophos;i="5.87,172,1631602800"; d="scan'208";a="149141211" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Oct 2021 00:54:13 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 22 Oct 2021 00:54:13 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 22 Oct 2021 00:54:09 -0700 From: Eugen Hristev To: , , , CC: , , , , , Eugen Hristev Subject: [PATCH 08/21] media: atmel: atmel-isc-base: use streaming status when queueing buffers Date: Fri, 22 Oct 2021 10:52:34 +0300 Message-ID: <20211022075247.518880-9-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022075247.518880-1-eugen.hristev@microchip.com> References: <20211022075247.518880-1-eugen.hristev@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During experiments with libcamera, it looks like vb2_is_streaming returns true before our start streaming is called. Order of operations is streamon -> queue -> start_streaming ISC would have started the DMA immediately when a buffer is being added to the vbqueue if the queue is streaming. It is more safe to start the DMA after the start streaming of the driver is called. Thus, even if vb2queue is streaming, add the buffer to the dma queue of the driver instead of actually starting the DMA process, if the start streaming has not been called yet. Signed-off-by: Eugen Hristev --- drivers/media/platform/atmel/atmel-isc-base.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index f3e89a892373..6f14cc549543 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -442,12 +442,14 @@ static void isc_buffer_queue(struct vb2_buffer *vb) unsigned long flags; spin_lock_irqsave(&isc->dma_queue_lock, flags); - if (!isc->cur_frm && list_empty(&isc->dma_queue) && - vb2_is_streaming(vb->vb2_queue)) { + + if (!isc->cur_frm && list_empty(&isc->dma_queue) && !isc->stop) { isc->cur_frm = buf; isc_start_dma(isc); - } else + } else { list_add_tail(&buf->list, &isc->dma_queue); + } + spin_unlock_irqrestore(&isc->dma_queue_lock, flags); } @@ -1015,7 +1017,7 @@ static int isc_s_fmt_vid_cap(struct file *file, void *priv, { struct isc_device *isc = video_drvdata(file); - if (vb2_is_streaming(&isc->vb2_vidq)) + if (!isc->stop) return -EBUSY; return isc_set_fmt(isc, f); @@ -1537,7 +1539,7 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl) isc_update_awb_ctrls(isc); - if (vb2_is_streaming(&isc->vb2_vidq)) { + if (!isc->stop) { /* * If we are streaming, we can update profile to * have the new settings in place. @@ -1553,8 +1555,7 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl) } /* if we have autowhitebalance on, start histogram procedure */ - if (ctrls->awb == ISC_WB_AUTO && - vb2_is_streaming(&isc->vb2_vidq) && + if (ctrls->awb == ISC_WB_AUTO && !isc->stop && ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code)) isc_set_histogram(isc, true); @@ -1830,6 +1831,8 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) struct vb2_queue *q = &isc->vb2_vidq; int ret = 0; + isc->stop = true; + INIT_WORK(&isc->awb_work, isc_awb_work); ret = v4l2_device_register_subdev_nodes(&isc->v4l2_dev); -- 2.25.1