From patchwork Thu Feb 22 11:31:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 204714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp195271dyb; Thu, 22 Feb 2024 03:48:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpF1/1LIFYmH8JqFEg5fu32gaYBo1nAjy8rAD8MO6Rwi8LdUilRWOJREIrBQtMIOGdVYI+5l9fOiqFNNG22Rrf3jKExw== X-Google-Smtp-Source: AGHT+IGTCFJFvTq+a281qVhApsh7tG2l3SNT2NK/AYqemugKJQY1asfdF9Cc52zvu2SeAyOYmhhS X-Received: by 2002:aa7:dd02:0:b0:565:43e7:7b5f with SMTP id i2-20020aa7dd02000000b0056543e77b5fmr853592edv.5.1708602492711; Thu, 22 Feb 2024 03:48:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602492; cv=pass; d=google.com; s=arc-20160816; b=um5C3TNm7BdJN1guIarw+9gR7gtlTgINf6DPERVzqQW1XWgNIzdiPUPvUDuEIYkLRZ 4D7Yc3ied6uXutCFWvRuDs9/8NesFjR+G88x56V/LMZ0u7XS6zPYx9Y+z3x0sDiX89kJ pfYEMXYWB8wkjwj8PLFEWAqVAC++RS/xeu0HAypF8jstrXDBinVdDPUy58hK4dUyLV46 oCpQ0IR737doX0uNsJi6aiYPAVnWl3c4LEO7hsxHKn9iyfqZBPKuyrkA1NlpKCGCLuJO yMr1eRSfnQ8fyDdtg4FSKqfGg5xCK68Ro3IVr3pN443o3VLion1h7HHaDPIgcfsDdvM4 CDyQ== 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=h4Cf3SOkx3K5Auy7bEc25EsHCsaRMY7o1BWV1atNTG4=; fh=7Ze5xPQXuwRxFNHD2ILqwMPZ5wjg3PcSuREjIh8VhDo=; b=xaCoknkyMbwz2Fyujd8RXPlQdqFUiy73/CG7rnEU0IY3sP3NrrMKCAgFeNtwOMrdOD u6gym9jlh0dxYdPwKstRyhgZyRU47yssy/J4+9koMH95VXs5zm9uyhJQr4IlA4cVdGA9 kxhYNlhdJAwiwi1hiim2C/4poUaNvgxc4vnxTc8i50xGC1z/JZZKVrl12kH7cNLNHNci suOXZ0LCXZf9G9Cx3io06oxDjmIdmrsLdgNTXsVtW2Vw5lrqj+4WT52lfirs/oLNRVlj rb00GRe5EAfYWRUp8L2Njcy7rPkYLUloQECiIpifgoizt5cCcwCWmHqQBY/gptpbL9++ vjUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="kMqR/1EM"; 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-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a509356000000b00563cfa60977si5286471eda.360.2024.02.22.03.48.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:48:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="kMqR/1EM"; 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-76433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76433-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 06D561F29A6B for ; Thu, 22 Feb 2024 11:39:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7FF757894; Thu, 22 Feb 2024 11:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kMqR/1EM" 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 4395F5646A; Thu, 22 Feb 2024 11:33:56 +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=1708601638; cv=none; b=mi1Ve1womNP0/LtDzgpY36zaFLUNCIIYNpkttnSxTxLSgYAJ4HqqaqimsJCGbFpI/gAezr4pDlEuGzy2GR2DbXixu0sqhvym8uRtSBxQuNuLlXcBP4YIPNxUK/6ovL48pXCmrjXf96KBP0HLsqlC0V/YTowPwQG2TRncRKypm3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708601638; c=relaxed/simple; bh=UHhcmDEpCe+fIBZF6t/hU6vqn9E2M2zqDvurAxx6H4c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=ZcutceKj2MWJSVaO8An4H6IykPmEZbK5yDFsAjWYN8TBh++qO7D2+yS91TFoHgwU9WocHpV70J+NILSeXEA23VQtjipdGUh+VyQGw9tzjDZ/8ihvpdw43keKmcd4mHcJP+zZtP1DZk2MKvrVS9WLHgJFw/Qp0BME4KgxVhHcAkw= 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=kMqR/1EM; 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 41MBXif6027847; Thu, 22 Feb 2024 05:33:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1708601624; bh=h4Cf3SOkx3K5Auy7bEc25EsHCsaRMY7o1BWV1atNTG4=; h=From:Date:Subject:References:In-Reply-To:To:CC; b=kMqR/1EMKXtPJF73iXF9EFR+Y8migT5oWQly0ShGGHk1tNyazg2dN9pf3i90iyyyq MlNY9Nxjw8/m/6Nfw8hCpWTvBVNgdY1Dzl43o5c2/Q4ASpnH9U7E3wUdrkOPm4+hJE +8Vp404BBqusysKBxjmaXPvmjJI0syFNGZby7PWU= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 41MBXiVH014442 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Feb 2024 05:33:44 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE102.ent.ti.com (10.64.6.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:44 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE110.ent.ti.com (10.64.6.31) 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:44 -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 41MBXhGP091587; Thu, 22 Feb 2024 05:33:43 -0600 From: Jai Luthra Date: Thu, 22 Feb 2024 17:01:36 +0530 Subject: [PATCH RFC 20/21] SQUASH: media: ti: j721e-csi2rx: Assert pixel reset before stopping last stream 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-20-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=1832; i=j-luthra@ti.com; h=from:subject:message-id; bh=UHhcmDEpCe+fIBZF6t/hU6vqn9E2M2zqDvurAxx6H4c=; b=owEBbQKS/ZANAwAIAUPekfkkmnFFAcsmYgBl1zDtxulJ5vwh1hk7rUtv04y9hAoMjlAfOaM/I 946Exq1leuJAjMEAAEIAB0WIQRN4NgY5dV16NRar8VD3pH5JJpxRQUCZdcw7QAKCRBD3pH5JJpx RXT2EADGCihGFKE4jnCo389SggQfrAJRxINhD00hY+I8PSgr5Q8Dphg/C/Wjb8E0bPcqoebJLhs EWC+WB2CDiGO/GxMyeZiMxOHqVWOJeRXDEBaZzkaOzu0wCg8tb31WopXSrBvz9e7IcsTM6ilVSV mp7hlpiXzCofr/F/lAY3TWkKzkzgF3Ix8j6lZiO9l4JiMzduDQT4FlRcP1sV3Ay+mq5gxsbJnjQ fSpo9m3cO+YgY9p4+qhhekjagSAD/NG4QZ6TTdeYCnC0CBgb/6qRaznGv0EEIhilw6MCpkqGgME m/oBtaHC+lEViiolUOvsTOjv4Pm5aKRNhUC7YMMyET0H00qy8lSBbnd5bvib4W6icXUJd0Lz2TX Vlo/d0mx7s68KFtd+0E3uN77ni1AyR+uBZzW3qTZOq2Hf4pt/s9RBKG2DS59+cI0kMHmThgbUZZ T7iRcIKMgAHoA38iBktZToF+UC8VmAN6pqY9qVcQWLtGVNWz0BI24ZtuVkCL2DjEzpRcNY38jmn l1Xp0bhXL0dEwm3RwfvQbWYxYINVSalySZt4zFTmy0eVw6kNaly2Xfdw3FF3H6GVUJ3adN8hp17 9iFu2Z1XJgwv2Vr6xwCxqOa5T5LbU8Q37F79vnGJ/rztw/v8PbUycns2T8lQiYQm9HUYqjsjqje eMNosTG92fZifng== 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: 1791599567234613416 X-GMAIL-MSGID: 1791599567234613416 With multi-stream support, make sure pixel reset is only asserted when last-stream is stopped. We assert this before stopping the stream to prevent issues with module unload/reload. As the device's power domain cannot be cleanly switched off by the firmware if stale data is present on the PSI-L endpoint, which can happen if source was streaming but we pulling data out through DMA. Signed-off-by: Jai Luthra --- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c index c2d47507b3a7..0b9e0852da9f 100644 --- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c @@ -560,8 +560,10 @@ static void ti_csi2rx_setup_shim(struct ti_csi2rx_ctx *ctx) fmt = find_format_by_fourcc(ctx->v_fmt.fmt.pix.pixelformat); /* De-assert the pixel interface reset. */ - reg = SHIM_CNTL_PIX_RST; - writel(reg, csi->shim + SHIM_CNTL); + if (!csi->enable_count) { + reg = SHIM_CNTL_PIX_RST; + writel(reg, csi->shim + SHIM_CNTL); + } reg = SHIM_DMACNTX_EN; reg |= FIELD_PREP(SHIM_DMACNTX_FMT, fmt->csi_dt); @@ -1008,9 +1010,11 @@ static void ti_csi2rx_stop_streaming(struct vb2_queue *vq) struct ti_csi2rx_dev *csi = ctx->csi; int ret; - video_device_pipeline_stop(&ctx->vdev); + /* assert pixel reset to prevent stale data on stopping last stream */ + if (csi->enable_count == 1) + writel(0, csi->shim + SHIM_CNTL); - writel(0, csi->shim + SHIM_CNTL); + video_device_pipeline_stop(&ctx->vdev); writel(0, csi->shim + SHIM_DMACNTX(ctx->idx)); ret = v4l2_subdev_disable_streams(&csi->subdev,