From patchwork Thu Jun 20 14:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 13706793 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E50A2128372 for ; Fri, 21 Jun 2024 04:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945211; cv=none; b=Tph/H/a+c/lmSRk7v89Xwt9oh2J0oTLzirH/owRQY1i6ZqFPYLYkKzga8fF2T8wdH4pO6bAsUfdya+ZSC4oIVaDSPIRKvwp5uLmqBWrwdj5WqyPETo/fgzc+hRa0tntT29c2esnnLdOy282vb7Dpx31NHoD2QVVlSCLJ7Ekc8Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945211; c=relaxed/simple; bh=R8NdDkdLHuAJuu5DqtuYnvDxeUNZJtW9Joc8RZ7NcFU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CSHeCq039G5W6hv9U39+6sEAgmLYkL6NoiFYo8XH9235fqcKK2txBNfPyt/BEB8UVaC9Fw58cytty2zx/z7ipwqw4dWwTJjTsBvZMNsx1lNOgZVYWwFb4dfM6mSPalls6PtTCMcpFCz2xNXWUSjCI3AzpqD3BJ8TFvTk6h0eWpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=k7TKxjIa; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="k7TKxjIa" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-707040e3018so1143679a12.1 for ; Thu, 20 Jun 2024 21:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718945209; x=1719550009; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NFw8MXYGxMp7L3cI809OeU/qg49sBCBLTir7UDQywWA=; b=k7TKxjIas4fZ1idculBVHTekb/bq7S7+3TpGODMU4oOzTCG/S5VArp1FKn8dN34ylw vOeNIjsdlhuMYr5A81Wg7SaozNFgP8usDMUjuqBH3+PcJep7XmEaikvIucMW/eQ70jo3 SLzR641GjFyX3O8/0i7fCj51bv5WjnRrd2OlA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718945209; x=1719550009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NFw8MXYGxMp7L3cI809OeU/qg49sBCBLTir7UDQywWA=; b=FKdwGrdjz9BjGzOJ51rT2L4OS7w0e7uzelIY4fEutx/M3VRVsTsQTmtXWJiN3tV/7d z4RCNj9h/hbNXoCrmhagrjln6Gu8wSrZ2K5I2LYI4WSEjV6cl+ITuDsLHwbe0ewC95iX 9gCdFZ9dhTwanavVfEksbv35hipNkwazwMsN4JHcTLt7cViQUJQobQyRXjN8FcAae/ZK gwZw4u+vBQCl4M7/x/uAh6kxs02twdyVXfT3LZPV7OpsHGv+jEop0TqLkAQ4y+yomiUG Rh7WXWBHxD22IeKJ5ak1kS9s9J/FEGHN1yDOY/Zvj/YYMv8qbzaPEIeRZKFo1/h8bChs 3wKw== X-Forwarded-Encrypted: i=1; AJvYcCU3Dxi2s7aIoisqnWKTdTRnKjQl//+gJuFymfLHqC6AHz/rPfQSnxugYId24IbtL9vgmAOoX1MX8jfM8AZsYUc/RPgzoHr8nK9N+EE= X-Gm-Message-State: AOJu0YzaW9aFsoPpS4+r/i678r7SSlbXihJ4xF7GK44891baV4maAAT0 lSwYm5EMPTqrVUvwTXlofUHuq0yB+NVqgQCZ3E2ihF6fUuCWS5SrLqyxLxa3Vg== X-Google-Smtp-Source: AGHT+IGGosIMTTEw+hzlCiXlOi3rnGUIGOyZxC4WoKJX3kiPR+CzNCJgS7NRP7b1zjwEU/GvUpWcrA== X-Received: by 2002:a05:6a21:3288:b0:1b4:da55:e1be with SMTP id adf61e73a8af0-1bcbb4172cdmr9568050637.14.1718945209235; Thu, 20 Jun 2024 21:46:49 -0700 (PDT) Received: from mstaudt.tok.corp.google.com ([2401:fa00:8f:203:3c9:e095:f93c:9c3c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9ebbb5aa5sm4780755ad.271.2024.06.20.21.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 21:46:48 -0700 (PDT) From: Max Staudt To: Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab Cc: Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda , Max Staudt Subject: [PATCH v1 1/3] staging: media: ipu3: Drop superfluous check in imgu_vb2_stop_streaming() Date: Thu, 20 Jun 2024 23:45:41 +0900 Message-ID: <20240620145820.3910239-2-mstaudt@chromium.org> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog In-Reply-To: <20240620145820.3910239-1-mstaudt@chromium.org> References: <20240620145820.3910239-1-mstaudt@chromium.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The check for imgu_all_nodes_streaming() seems superfluous, since imgu->streaming can only become true once imgu_all_nodes_streaming() has been true. Hence, checking for imgu->streaming == true should imply imgu_all_nodes_streaming(), and therefore suffice. Signed-off-by: Max Staudt --- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 3df58eb3e882..541556037c42 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -548,7 +548,7 @@ static void imgu_vb2_stop_streaming(struct vb2_queue *vq) mutex_lock(&imgu->streaming_lock); /* Was this the first node with streaming disabled? */ - if (imgu->streaming && imgu_all_nodes_streaming(imgu, node)) { + if (imgu->streaming) { /* Yes, really stop streaming now */ dev_dbg(dev, "IMGU streaming is ready to stop"); r = imgu_s_stream(imgu, false); From patchwork Thu Jun 20 14:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 13706794 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68BAC13699E for ; Fri, 21 Jun 2024 04:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945213; cv=none; b=mTZ3vDa399qyhpsXuBuvtQHYxxBoWS9B7N/mIPqNrK7AcTf8H1R5lp19cZAJN6CxBXS5FnI5cx/T2VCtBzKa5r5Kb3er32sgOiXI836/9YitAq0NTnk736wEH2e4ooRKdAM9NPYKQpwHturMt4R+xXiCKJFDyVI9uN7EFmC/Crk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945213; c=relaxed/simple; bh=eg31BoRkeTJON7zXV4K1jhgM/v2n2k+KGM9iQFc0N64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pzkXyDFDWIcHTL5+m37WS2hRZPLNdtVUHB3tNLCORAjBlOSWfQoh/d/Xqog9CcLr59t+h+a7QgShPM5F+YALGD5HW4a3TP9ngCEjO4230MwkrrYGcwZvvUwjEYAyH63WwDhBwf9FYgISvqnCfx0x+aiuzNQG0jps2oQajJrg+Xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=gypKUVDQ; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="gypKUVDQ" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1f6fabe9da3so13471275ad.0 for ; Thu, 20 Jun 2024 21:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718945212; x=1719550012; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Qs6kToBk8YjSTiZsPQaIgz5b7g4VfXjvffstHMdxZFU=; b=gypKUVDQI7Ffbl1Wnu5kXb6vzVS7KgCFDOg35Gvy3gOBUINWAXQs1iw6d3VvzEAi+m GQqiTDnctqGGfcHg/1x5jvz73sFrhJUH4+jIG8mgC4uJdhcr9HJzVWjw+x9Tz0sC6aIS r1v0OK7YXl3hutUpZJXjrCWMOimuDKiwaAafI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718945212; x=1719550012; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qs6kToBk8YjSTiZsPQaIgz5b7g4VfXjvffstHMdxZFU=; b=LmKFM5o8jBytBGlOcGq8s18szuWtffqxoS267J+mPobEvzuxEAPgIpV2QsQZ944dYF ahZjmF1YrOC99OckynsutdBZ13ytV35igmGI5U6UmMmHsb/PGp/7T4kfsq8MXNCzde84 q2fpNEmRjuQuMHC7r+LBdsPQOJnOSDzMwdhr7lvbTkUr/4UHCaotDGu9lvI2IWb8OGO2 BZ5bo7991htrTwVP7uWyfRM5ALm4xBKeTHYu6K/yqg+wYez3S5oslLvWggYb1iZ5l/Rf 0qFQg33HWrho/tGw/Ck4Keq2b9IbmNPJ873J27uEBjzYFFtFW3EbJofEspFuxXC2izPU oCEw== X-Forwarded-Encrypted: i=1; AJvYcCUTLHHdzhcoIfFhuYHy5UGX8ovOgg3CMxSxIIiCCuh+oYud00hSCBGGMiyumgYQO8TuVSG5aDjMzUBmJbV5P4dd+ZfQkTQ9TF0bGTE= X-Gm-Message-State: AOJu0YxchHIiHdPsCsv6fIWUtnb9GXMzjqjjfxlTUwcO/ROnKjEqImiJ NP+5WhC2ocv4YxXncyXlUjgKRTzeXp6JUOFVZuIex5KhZQKP4jw2wVEQ7qjbHA== X-Google-Smtp-Source: AGHT+IGBWYpF1pYJ9+icaGVYwbZfvFF5d0o4lVQn5+tcG9E+8MIgi+4DUMl+GZROA3IqIr4GWwFgNA== X-Received: by 2002:a17:902:ecd0:b0:1f9:eb2e:d32 with SMTP id d9443c01a7336-1f9eb2e0ffamr10912895ad.22.1718945211680; Thu, 20 Jun 2024 21:46:51 -0700 (PDT) Received: from mstaudt.tok.corp.google.com ([2401:fa00:8f:203:3c9:e095:f93c:9c3c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9ebbb5aa5sm4780755ad.271.2024.06.20.21.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 21:46:51 -0700 (PDT) From: Max Staudt To: Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab Cc: Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda , Max Staudt Subject: [PATCH v1 2/3] staging: media: ipu3: Return buffers outside of needless locking Date: Thu, 20 Jun 2024 23:45:42 +0900 Message-ID: <20240620145820.3910239-3-mstaudt@chromium.org> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog In-Reply-To: <20240620145820.3910239-1-mstaudt@chromium.org> References: <20240620145820.3910239-1-mstaudt@chromium.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In imgu_vb2_start_streaming()'s error path, imgu_return_all_buffers() is outside the streaming_lock and after the call to video_device_pipeline_stop(). Let's apply the same order in imgu_vb2_stop_streaming() as well. Signed-off-by: Max Staudt --- drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 541556037c42..3ff390b04e1a 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -556,10 +556,10 @@ static void imgu_vb2_stop_streaming(struct vb2_queue *vq) imgu->streaming = false; } - imgu_return_all_buffers(imgu, node, VB2_BUF_STATE_ERROR); mutex_unlock(&imgu->streaming_lock); video_device_pipeline_stop(&node->vdev); + imgu_return_all_buffers(imgu, node, VB2_BUF_STATE_ERROR); } /******************** v4l2_ioctl_ops ********************/ From patchwork Thu Jun 20 14:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 13706795 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBDB213D615 for ; Fri, 21 Jun 2024 04:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945216; cv=none; b=bLx9vw06iiUqTpNAbPNqa2ECkzAdsD+J+Jo+QhcQ4vlNWHINm1hIeqJMtZfZ9n/qSSwa9Kz9HVU0w5bnxA3hV9fUnXffq24ikqmVV2rBW8mIPhpRK9WaM+IjlPlpz54XB9UjtnJzo1trD7g7mAf/w7e2tq2y9cKyYdVvz0vq4PQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718945216; c=relaxed/simple; bh=16MhtMxKDZcpnZf3ioCOy4a13qt3L50A9IKwXb5/1Ts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mduzvPB6DuFWDelRE8WAh1bRTIRsa/s+/LdyF+0lM2DpdnlgDfAgyb93VtoYjjeAv+Ijoafne4N00wm5Wet18hqCMAVnYvCOvRR1VDHLjyENolxFVnlsfbODkx9YvekcR44GWui6+n5E/m1iXPkPZKSRa2BZV0XHV4IP0GNgvgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=famBotpb; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="famBotpb" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f99fe4dc5aso13446685ad.0 for ; Thu, 20 Jun 2024 21:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1718945214; x=1719550014; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LSAH0M+p9QRAU7e73G9yxB5HQZ3+B+UK81pFfBELJCU=; b=famBotpbRQSNGOMQlo6EMShOfHLsaKFlbHNVBjMiqXi+aEv58eD8J3yaauUo96228F U2aIvXO9rmkkrT98FqwSXoNuFX/OK9AWXuZQt0N7rHHMhJiTclvDe99KMSVlu1JptFS4 wmsr1YAN/If1y15dxUmjeBnVj2TQZvq2Po4ms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718945214; x=1719550014; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LSAH0M+p9QRAU7e73G9yxB5HQZ3+B+UK81pFfBELJCU=; b=KxPD1l1RY+jDObqlovlD/XUd2FxniasAljr19sHDfDL5YOc6zjgYiykq69M28wJV8j 1iIML680DpaCTV/m7wGyf1ZS28XTrtxB/uaEo53AuLMcqMze4kkDU1cpNRzgmqwX0hsS ntpAeNkvj3x9P+nHhUkImKwMHDXSnV+w1pi8qTylHyv40Sa/+Jz3XfWi7JVtA8/etPmX 5oVmK9HT8TVmM/OaJ0jTtt1tUmb8ju5zTu68H1GBoM8fM1ulRWIwHCnqtozXvYxBwn1d L1iTIR3XglMhFhv42hc1Hc6h6rAwk78SaE/QrXcSodmkzWZg50f0N+JKQHJ8oOmCEKmp Gymw== X-Forwarded-Encrypted: i=1; AJvYcCV6KPv3UGO3k94v2fFZOz5kMdNRfXClAgUS2Wme/bzsk9mKh80E1E97PtX0gTLlfqrFhOjbDWqaxEQk4Jm0MRu+vy/J5X1qrwW0NqE= X-Gm-Message-State: AOJu0Yyuh2qBrv7+QlQ4JpMinEZbcEprLWyr9SbC/cch41T2dKicbaoP vsigwTNXRhEqiaBAFsR7oD8peY7tGttlyENAYFY1Pr9SN4pKKQRjPLjdTXCj7w== X-Google-Smtp-Source: AGHT+IEtoZcjZRs4Z2hN3BH58jpAvugCjNxXZr2Faov/subK0weBwx3axbvKSoceK3U++yd30EP7Yw== X-Received: by 2002:a17:903:1cf:b0:1f7:3379:1c71 with SMTP id d9443c01a7336-1f9aa3ebf53mr82891885ad.27.1718945214189; Thu, 20 Jun 2024 21:46:54 -0700 (PDT) Received: from mstaudt.tok.corp.google.com ([2401:fa00:8f:203:3c9:e095:f93c:9c3c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9ebbb5aa5sm4780755ad.271.2024.06.20.21.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 21:46:53 -0700 (PDT) From: Max Staudt To: Sakari Ailus , Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab Cc: Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Ribalda , Max Staudt Subject: [PATCH v1 3/3] staging: media: ipu3: Stop streaming in inverse order of starting Date: Thu, 20 Jun 2024 23:45:43 +0900 Message-ID: <20240620145820.3910239-4-mstaudt@chromium.org> X-Mailer: git-send-email 2.45.2.627.g7a2c4fd464-goog In-Reply-To: <20240620145820.3910239-1-mstaudt@chromium.org> References: <20240620145820.3910239-1-mstaudt@chromium.org> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 imgu_vb2_stop_streaming() did not order shutdown items in the inverse order and count of what imgu_vb2_start_streaming() does. Consequently, v6.7's new WARN_ON in call_s_stream() started screaming because it was called multiple times on the entire pipe, yet it should only be called when the pipe is interrupted by any first node being taken offline. This reorders streamoff to be the inverse of streamon, and uses analogous conditions to decide when and how often to call additional teardown functions. v4l2_subdev_call(s_stream, 0) remains outside the streaming_lock, analogously to imgu_vb2_start_streaming(). Signed-off-by: Max Staudt Reviewed-by: Bingbu Cao --- drivers/staging/media/ipu3/ipu3-v4l2.c | 36 +++++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index 3ff390b04e1a..e7aee7e3db5b 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -535,29 +535,51 @@ static void imgu_vb2_stop_streaming(struct vb2_queue *vq) container_of(vq, struct imgu_video_device, vbq); int r; unsigned int pipe; + bool stop_streaming = false; + /* Verify that the node had been setup with imgu_v4l2_node_setup() */ WARN_ON(!node->enabled); pipe = node->pipe; dev_dbg(dev, "Try to stream off node [%u][%u]", pipe, node->id); - imgu_pipe = &imgu->imgu_pipe[pipe]; - r = v4l2_subdev_call(&imgu_pipe->imgu_sd.subdev, video, s_stream, 0); - if (r) - dev_err(&imgu->pci_dev->dev, - "failed to stop subdev streaming\n"); + /* + * When the first node of a streaming setup is stopped, the entire + * pipeline needs to stop before individual nodes are disabled. + * Perform the inverse of the initial setup. + * + * Part 1 - s_stream on the entire pipeline + */ mutex_lock(&imgu->streaming_lock); - /* Was this the first node with streaming disabled? */ if (imgu->streaming) { /* Yes, really stop streaming now */ dev_dbg(dev, "IMGU streaming is ready to stop"); r = imgu_s_stream(imgu, false); if (!r) imgu->streaming = false; + stop_streaming = true; } - mutex_unlock(&imgu->streaming_lock); + /* Part 2 - s_stream on subdevs + * + * If we call s_stream multiple times, Linux v6.7's call_s_stream() + * WARNs and aborts. Thus, disable all pipes at once, and only once. + */ + if (stop_streaming) { + for_each_set_bit(pipe, imgu->css.enabled_pipes, + IMGU_MAX_PIPE_NUM) { + imgu_pipe = &imgu->imgu_pipe[pipe]; + + r = v4l2_subdev_call(&imgu_pipe->imgu_sd.subdev, + video, s_stream, 0); + if (r) + dev_err(&imgu->pci_dev->dev, + "failed to stop subdev streaming\n"); + } + } + + /* Part 3 - individual node teardown */ video_device_pipeline_stop(&node->vdev); imgu_return_all_buffers(imgu, node, VB2_BUF_STATE_ERROR); }