From patchwork Thu Feb 22 11:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp191547dyb; Thu, 22 Feb 2024 03:39:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXw4Qg6d4fSl0ljnUeOjgTfb1mAWIWz94eWAdbLDPxqc+HI2j8eDSkTzpDGelhQdXjGgGC710EWj5K1xlmPoXwdp7UgIA== X-Google-Smtp-Source: AGHT+IHufBap1DUMKeO53MFwnIGLLmQVwOHnQdOrG6ATY66PxBywli9SHsaQEIklMr2tHBq3HTF+ X-Received: by 2002:a05:622a:40a:b0:42c:7ca2:8ab2 with SMTP id n10-20020a05622a040a00b0042c7ca28ab2mr27714013qtx.48.1708601985860; Thu, 22 Feb 2024 03:39:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708601985; cv=pass; d=google.com; s=arc-20160816; b=aV7La13UJMN6iWrFymSLA46zNLLm1kcBR7Sj1af5DaVXVdU7eXS7eLOegRCrqqf+rP TKhL7qqr/xrE8l2SptNmruH/UuOMQTw94prWm8sj4cpD6cV5NCq3vIICbalOzyLeI3OP Zu54+tpo/Jm5eTkMVguEp8Ww2hATVq9WgqBfnGyjQ0u8EvVg/MM87TAOfGc0ymo6EhK5 opQV7K2YFhzgfV9ysTJdBSp+w9Ak4STFL2c/+eMB+/fVHnCl24bdPr6eVgUA8bXli6sL bX/H+6yFcry13LBztkJlUuUZT9hZrkc5jFQ0fXR3iyvyzgNTW2BZ8t5WRC9lccjPiBo/ 8DvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Vlbz21goACtx1c8zMXtgD7uoZ9QnG6VdgKVSgHpupv8=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=Dnf0/v+7RVlbIMSXh6xezyB76estHc6DYho7tASeScLk/G4iijgIiu0yilQJpuvUBW yl1lbONdZ5mo8hPSFjlAONIDclHqQdOUztP2ttZOv51Zn1V3Twi/GeP+yBFyeFnZ/pov 6ojU9UQjWxwo79d1C9qv53MTZbDtaErfZPYvQlLF2a0bFaWLkHn+RFaat9CdyJHK7cd9 LZm4XP7hTHtffC71wAZzz5WAzFfoag5Ge421HNypFyliZDQQOLmETcVtwF5uxXqBzaPY ICJxGWVKr72haTMstoqEpDecSybdm5fh3XXJ248rRCWWj0UkKxarlfcn/Vg/qMb6O6k+ 8yUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WtlcC9am; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p9-20020ac87409000000b0042e286668fbsi5237243qtq.246.2024.02.22.03.39.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WtlcC9am; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 957A41C235DF for ; Thu, 22 Feb 2024 11:39:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C210E5811A; Thu, 22 Feb 2024 11:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="WtlcC9am" Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE9B856471; Thu, 22 Feb 2024 11:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.142 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601639; cv=none; b=UlJALKChW7b+AR1pM+qNepFcS9/vPdNUZMVB8wgb9tzJrJEgFn/m6JrP5zYOi0fxb7b0IytBfpk3Ohl4SRbWG8aOiflbcziQd1tajIbk5nosZDiUFbc+5O6peYhVQ1jrIZUdly53OUoiA4tdTfhC9O4IsCV09ToVJS1hYxeQHC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601639; c=relaxed/simple; bh=/GtmPjLiq5+SagkrfDQAkAZP5XRkWs7T9sGKIVhkkz4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Qo7sSWTGa5/6ESs+jIpER050MymYdiU0sBVLo2xfbUCRFMmPRS66NHAmHFXa+iYqgM3xtQDehEc71wiuGMBLDHTL7fNHSk52n4M0qmlU/QheDQruuenx70rZHPhaMmPEE7yEv87N1xN9FY0mlJbzkwcdorL9UfrZLObthY7/4WM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=WtlcC9am; arc=none smtp.client-ip=198.47.19.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXk50027853; Thu, 22 Feb 2024 05:33:46 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601626; bh=Vlbz21goACtx1c8zMXtgD7uoZ9QnG6VdgKVSgHpupv8=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=WtlcC9amfGGCuR1WryWRG8vcT8UQA4iOk70DW9csiMHCyI5cwdZ/Rp7cLPJfN43+i owusU6Vw+I15sXQC5Mc2JEq+sWU42S/88MxS+rJzLeN0ai/BMQuxfwGpXzVMf86Iyj yheibmUbAhRe6TyZq+du3OSEEuWi8I0CmmjPP5ps= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXkVR014493 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:46 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 22 Feb 2024 05:33:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 22 Feb 2024 05:33:46 -0600 Received: from localhost (jluthra.dhcp.ti.com [172.24.227.217]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 41MBXi5B091622; Thu, 22 Feb 2024 05:33:45 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:37 +0530 Subject: [PATCH RFC 21/21] media: ti: j721e-csi2rx: Submit all available buffers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240222-multistream-v1-21-1837ed916eeb@ti.com> References: <20240222-multistream-v1-0-1837ed916eeb@ti.com> In-Reply-To: <20240222-multistream-v1-0-1837ed916eeb@ti.com> To: Tomi Valkeinen , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil , Vaishnav Achath , Maxime Ripard , Rob Herring , Krzysztof Kozlowski , Conor Dooley CC: , , , Vignesh Raghavendra , Aradhya Bhatia , Devarsh Thakkar , Changhuang Liang , Jack Zhu , Julien Massot , Jayshri Pawar , Jai Luthra X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3577; i=j-luthra@ti.com; h=from:subject:message-id; bh=/GtmPjLiq5+SagkrfDQAkAZP5XRkWs7T9sGKIVhkkz4=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDuro/ycwjO5PCLQrJiQETtI9R/Rz8V16qhH NGhUvuH9NSJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw7gAKCRBD3pH5JJpx RcEsEACXdlnzSwdPg09vRskjpB2V19aq2bTmJA5wMNKnsdqtyZms6Bks+K2NFIVccg7T1/kzOsW 21J9BXbvl9kotNHmiC9Dym6GGPX8PwSeER9ta/k67oEp+jcLqNYx013SDvmirXcBYKYrDjOb+ZK PyW8Aey4CRxqsLVo84BfWikCJuU6HNIE2puO47t+iTEm106GAwZLJpPDLJZjUfHd5FmEtJmwf07 GxK7+RFUfzaOkwgbNmg7qYMuL+UkMEBqONYDlMSopQhewlpGij1rsIVGsW5vLCcW1Dojq4WiPJj oItB+ePyFD9u5TGgSQM4oFeKZyDR5txG2VSuVbEkMlBWW6c/UVSIaNZppxUfDusr2DaOwYkpeJp LdfnNLEY75vdjHWlStzsNncC7n2ndrX3uHAs92XKsV8o7aXsfrHxOpl/xC/DbaPTVPVPMqt3Oce bTgrBXsX0fwr+um1f15uqHeXlGeDbEEtfBptF0zYPGutkfVdgDc1VcA5VP3NCHIVd7XCAIDinUT sNZWmtKUL5gU2x1/2bfEP7/C41y05IfuKLnqaTs4oTrkvp4QI7E1dA1+XZJiBo31NlTnxOuqKf+ 1s0zeZJK7Mk5e9BZ4FbNOSASxr64396RCo+TiU7XyvcpM2NKQ79DAybYUEbEzsIEDqPSXEY39rh +8lm46CyNyVOlnA== X-Developer-Key: i=j-luthra@ti.com; a=openpgp; fpr=4DE0D818E5D575E8D45AAFC543DE91F9249A7145 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599035755528112 X-GMAIL-MSGID: 1791599035755528112 We already make sure to submit all available buffers to DMA in each DMA completion callback. Move that logic in a separate function, and use it during stream start as well, as most application queue all their buffers before stream on. Signed-off-by: Jai Luthra --- .../media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index 0b9e0852da9f..a682db099e6c 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -666,6 +666,27 @@ static int ti_csi2rx_drain_dma(struct ti_csi2rx_ctx *ctx) return ret; } +static int ti_csi2rx_dma_submit_pending(struct ti_csi2rx_ctx *ctx) +{ + struct ti_csi2rx_dma *dma = &ctx->dma; + struct ti_csi2rx_buffer *buf; + int ret = 0; + + /* If there are more buffers to process then start their transfer. */ + while (!list_empty(&dma->queue)) { + buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); + ret = ti_csi2rx_start_dma(ctx, buf); + if (ret) { + dev_err(ctx->csi->dev, + "Failed to queue the next buffer for DMA\n"); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + break; + } + list_move_tail(&buf->list, &dma->submitted); + } + return ret; +} + static void ti_csi2rx_dma_callback(void *param) { struct ti_csi2rx_buffer *buf = param; @@ -686,18 +707,7 @@ static void ti_csi2rx_dma_callback(void *param) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); list_del(&buf->list); - /* If there are more buffers to process then start their transfer. */ - while (!list_empty(&dma->queue)) { - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - - if (ti_csi2rx_start_dma(ctx, buf)) { - dev_err(ctx->csi->dev, - "Failed to queue the next buffer for DMA\n"); - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - } else { - list_move_tail(&buf->list, &dma->submitted); - } - } + ti_csi2rx_dma_submit_pending(ctx); if (list_empty(&dma->submitted)) dma->state = TI_CSI2RX_DMA_IDLE; @@ -906,7 +916,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) struct ti_csi2rx_ctx *ctx = vb2_get_drv_priv(vq); struct ti_csi2rx_dev *csi = ctx->csi; struct ti_csi2rx_dma *dma = &ctx->dma; - struct ti_csi2rx_buffer *buf; struct v4l2_subdev_krouting *routing; struct v4l2_subdev_route *route = NULL; struct media_pad *remote_pad; @@ -972,16 +981,13 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) ctx->sequence = 0; spin_lock_irqsave(&dma->lock, flags); - buf = list_entry(dma->queue.next, struct ti_csi2rx_buffer, list); - ret = ti_csi2rx_start_dma(ctx, buf); + ret = ti_csi2rx_dma_submit_pending(ctx); if (ret) { - dev_err(csi->dev, "Failed to start DMA: %d\n", ret); spin_unlock_irqrestore(&dma->lock, flags); - goto err_pipeline; + goto err_dma; } - list_move_tail(&buf->list, &dma->submitted); dma->state = TI_CSI2RX_DMA_ACTIVE; spin_unlock_irqrestore(&dma->lock, flags); @@ -995,7 +1001,6 @@ static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count) err_dma: ti_csi2rx_stop_dma(ctx); -err_pipeline: video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_CNTL); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx));