From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89002C43219 for ; Fri, 12 Nov 2021 14:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B25D60F39 for ; Fri, 12 Nov 2021 14:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235248AbhKLObG (ORCPT ); Fri, 12 Nov 2021 09:31:06 -0500 Received: from esa.microchip.iphmx.com ([68.232.154.123]:55248 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234988AbhKLObC (ORCPT ); Fri, 12 Nov 2021 09:31:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1636727291; x=1668263291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c7zR7YV+/NaEAUBvJ084GX1l4HCMOCQS7YcMiVzt3gE=; b=1XCgFME157ENP/MmsWg7M2tYj3BrJsyHR5Wqx6d7tCIbJXJJQyeADYa8 MdWukNphOGW7mOunVpmM7fakGdWzDcF8iDBXGdVHbo5bHChjIbs/xF/qY Kj8TaZ3L5bjJeoRlORKlHvL6SGMkFfOo6SqrNNLi23sctpmezR0eR2d6k 0rfdRK7s03OW8sxWikOo3IRA8EYuEG2ypEH6ah5yEg9I8fH8jB1s0psaB yo8kHblLaxiz+IlzfrArGXe3LKV24rE9NV0yA7UHOtYC0mClc8e/Uk5GF rSvrzfgni8ipLsqZlrFF59eERPFsZdgeTwcgXW3mpSnWBu5VxK9Sy4wvZ A==; IronPort-SDR: Fg1JGnFlYJezOOu5tk9FvQJXvNqOP6Sk4Fq1apqY+o6vjCauLz3KflIOV0nsN+moF1nPmJpuuf XkCc3e3r9x/LACk2nnIGyf4zvDcqYQ7RDhgDqGSeEr6FtPkyZGEaYXWUBaDNK9jK+0H5PuR40o GpmkEC532wn2RMzQtZFD6/A5DPO3DEMN+geUlmmSaItZUvVNOzLhhwne+XHozE4mwYlhGoZdju ptKRUL/UtSQeKFsEiEdUvBqGj3XJFIsTkURrG30clQ6o+GnQV/ftKfSCnp357Q4E6NQr08r+CW 0P82MT8F1D6/9vVvM9o+8R4J X-IronPort-AV: E=Sophos;i="5.87,229,1631602800"; d="scan'208";a="136387855" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Nov 2021 07:27:59 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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, 12 Nov 2021 07:27:58 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 12 Nov 2021 07:27:47 -0700 From: Eugen Hristev To: CC: , , , , , , , Eugen Hristev Subject: [PATCH v2 08/25] media: atmel: atmel-isc-base: use streaming status when queueing buffers Date: Fri, 12 Nov 2021 16:24:52 +0200 Message-ID: <20211112142509.2230884-9-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112142509.2230884-1-eugen.hristev@microchip.com> References: <20211112142509.2230884-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 26a6090f056c..e6c9071c04f0 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -441,12 +441,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); } @@ -1014,7 +1016,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); @@ -1536,7 +1538,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. @@ -1552,8 +1554,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); @@ -1829,6 +1830,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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4F84C433EF for ; Fri, 12 Nov 2021 14:32:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7429C60FE7 for ; Fri, 12 Nov 2021 14:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7429C60FE7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fAKjXmt+0vXBMCtES5XeU8jhT+kMNEiAl/ferNzeeAk=; b=GXq7Z8iITDxXOw BiEIyJ9odDl0AQCbzI0J17n/dsw64chwKjHeFuUPqIXbJaW3MYWyxB9Tkw1wnW29yMTtCRuXwsUqx ZjtS2UKzE8hqgFXTsSyLSU15UE/6oNPGshe9QOqmg2OtAcrnRwPAxB0gX63KDpD7WHYZxAVNrkIp0 1+C3Yad9rIdMmeyBsQ2WalpsSNg7/kvNCj7b5gsKFx2gpZlL6K7UhPpO7oZ34Yf3txh/y7WoUPdvm mA1IPhkLZWQHs/sG0UwS0vaDcLJEDnOF45JNduv1KSot3rDu7QvTkkLftZlGin/kDDT8HblWoiT8c ZdUzjknUjpo4veeGYmlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlXa7-00An0k-LQ; Fri, 12 Nov 2021 14:31:08 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlXXH-00AlZl-VK for linux-arm-kernel@lists.infradead.org; Fri, 12 Nov 2021 14:28:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1636727291; x=1668263291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c7zR7YV+/NaEAUBvJ084GX1l4HCMOCQS7YcMiVzt3gE=; b=1XCgFME157ENP/MmsWg7M2tYj3BrJsyHR5Wqx6d7tCIbJXJJQyeADYa8 MdWukNphOGW7mOunVpmM7fakGdWzDcF8iDBXGdVHbo5bHChjIbs/xF/qY Kj8TaZ3L5bjJeoRlORKlHvL6SGMkFfOo6SqrNNLi23sctpmezR0eR2d6k 0rfdRK7s03OW8sxWikOo3IRA8EYuEG2ypEH6ah5yEg9I8fH8jB1s0psaB yo8kHblLaxiz+IlzfrArGXe3LKV24rE9NV0yA7UHOtYC0mClc8e/Uk5GF rSvrzfgni8ipLsqZlrFF59eERPFsZdgeTwcgXW3mpSnWBu5VxK9Sy4wvZ A==; IronPort-SDR: Fg1JGnFlYJezOOu5tk9FvQJXvNqOP6Sk4Fq1apqY+o6vjCauLz3KflIOV0nsN+moF1nPmJpuuf XkCc3e3r9x/LACk2nnIGyf4zvDcqYQ7RDhgDqGSeEr6FtPkyZGEaYXWUBaDNK9jK+0H5PuR40o GpmkEC532wn2RMzQtZFD6/A5DPO3DEMN+geUlmmSaItZUvVNOzLhhwne+XHozE4mwYlhGoZdju ptKRUL/UtSQeKFsEiEdUvBqGj3XJFIsTkURrG30clQ6o+GnQV/ftKfSCnp357Q4E6NQr08r+CW 0P82MT8F1D6/9vVvM9o+8R4J X-IronPort-AV: E=Sophos;i="5.87,229,1631602800"; d="scan'208";a="136387855" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 12 Nov 2021 07:27:59 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) 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, 12 Nov 2021 07:27:58 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 12 Nov 2021 07:27:47 -0700 From: Eugen Hristev To: Subject: [PATCH v2 08/25] media: atmel: atmel-isc-base: use streaming status when queueing buffers Date: Fri, 12 Nov 2021 16:24:52 +0200 Message-ID: <20211112142509.2230884-9-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211112142509.2230884-1-eugen.hristev@microchip.com> References: <20211112142509.2230884-1-eugen.hristev@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211112_062812_124850_59198847 X-CRM114-Status: GOOD ( 17.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, jacopo@jmondi.org, linux-kernel@vger.kernel.org, sakari.ailus@iki.fi, laurent.pinchart@ideasonboard.com, Eugen Hristev , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 26a6090f056c..e6c9071c04f0 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -441,12 +441,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); } @@ -1014,7 +1016,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); @@ -1536,7 +1538,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. @@ -1552,8 +1554,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); @@ -1829,6 +1830,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel