From nobody Wed Dec 17 15:32:50 2025 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 6AFE413D502 for ; Tue, 16 Jul 2024 22:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721167990; cv=none; b=Ppd/jf+gYK+3BHIsa+VUI3Oq3OrQwqIqHuxjPEgFDcDubiIBy3qdWwgHuHlFRKzzp4MpuLwOzvafKC39XSAqKVT1zdwWaQkpFgUTLIv4zfBQn7MAwf5l1gOvOjN5eIXyJpz22WK5dveUP8iip2HvnICrQDM8O7CTBE3vlC40OlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721167990; c=relaxed/simple; bh=kezXaT3v6LZXlObjaJmSDpR0VCdvNGV2dck36xLGu9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q5C6gSLHBvBr/1cvUbTDES3MOKYr/aSUeXDwSQrYlVLgOGBjP2mgJP0Mti/hG6LL0pE14n4BSomxBWP7gj7st/53rK5nNVgCKCtLm3nCLRTp6DoWmUsIsIP0BhxTLGuibnKUiz7aNqtMHP6cfSGkGKhB4e0vOqaPsaDXZmDUE88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=muyZ68k0; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="muyZ68k0" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2eede876fcbso40728191fa.2 for ; Tue, 16 Jul 2024 15:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721167986; x=1721772786; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=rXxJu7W4ql54UYL0JTMsFKchNv7XNstoFoH6eTpHkCk=; b=muyZ68k08p/8rs5/4bea7a7oDg2V8WFy5+9lwPJELXJFCFRvLqqzvJDPU4szrzhphO xfoxoktPVVTjk8AY5yaak8MMa8XmoC7ddRj6yZ6u1FmZr9p5ISDgMSpDcgQtCUM/cWeQ 9rMCv/AV1MqAJZdN8vWEG4FEdEUXaPa46Qfyyx41zeI3SdMxaWDCxPZuEr8tGC/QbAPX +G2AbqxkCqUTJhpzJ6rx4Hjh3ctqYPxsynM+NT4eHpAG1yNJzgpBJCJmIpHB+TBOJzM9 Rx/jEJZibKicMy01LL3vcQN5CJYuHuspIUffAPLIE00tWZAi7faKHwmPsy0zxF5REwRS Gyfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721167986; x=1721772786; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rXxJu7W4ql54UYL0JTMsFKchNv7XNstoFoH6eTpHkCk=; b=vbtHA2s/8VfDorl/QQLE8TWgVxlV7IN8ngwuARJAocEI4Rz03YeEChLc69F9Fm2OcD ZLRbXdITEF4jhBOxNRDytI3GhQxfA7jCfvPxufTTLTScBrDEdYM0nB8dxzIFopCXjbCO 7cSuKDZS/gjeNNZTd0qUNIGry4EVG2sdSuA/ha/rtPmKOf0zCTaYJSwpYP46MNvJMY+4 GzooJqxMlbBNWQbo/uuoGMTsrQTRw2mD1zSIL8YzcvB4NGwFCWCarS0eU4wS1e2kAf00 0piKxfZDRL6thRjYIQtg82vJx8XPi4CfTNuwAQQJuM0aEPVcSz3keMeQphlkYMftLH9L VpeQ== X-Forwarded-Encrypted: i=1; AJvYcCUoUaOZ3tmXFYFqboSmy0MkUc651gqwnE7FtN9ta6V4ar0pAIDp8DfjiyhmP93CKvOXOxTy3UqkEH1VWRG2IuxqUbpIcqyOzPi0q3Vf X-Gm-Message-State: AOJu0Ywms7oYYkxaqZqE2vLU+ILkl4a+chMVbyBzbvc5U7+PP2gi2mGX oUvZh1VxHhwmqanf/EyipqIQH44Z4tPr3Elwgc3kRnlX5CYN/QY+iSWZ3HcAUOo= X-Google-Smtp-Source: AGHT+IFzUHyuPnjpUGz0IiohdSN62RZaXgipj8QdfEilZoZBDmtYvGzyUHXTF3ThfgoYDkCfoEFz6g== X-Received: by 2002:a05:651c:4ca:b0:2ee:8ce9:3037 with SMTP id 38308e7fff4ca-2eef41d8b29mr28242261fa.37.1721167986188; Tue, 16 Jul 2024 15:13:06 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b268a28ddsm5582997a12.71.2024.07.16.15.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 15:13:05 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 16 Jul 2024 23:13:24 +0100 Subject: [PATCH v2 1/2] media: qcom: camss: Remove use_count guard in stop_streaming Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240716-linux-next-24-07-13-camss-fixes-v2-1-e60c9f6742f2@linaro.org> References: <20240716-linux-next-24-07-13-camss-fixes-v2-0-e60c9f6742f2@linaro.org> In-Reply-To: <20240716-linux-next-24-07-13-camss-fixes-v2-0-e60c9f6742f2@linaro.org> To: Robert Foss , Todor Tomov , Mauro Carvalho Chehab , Hans Verkuil , Hans Verkuil , Milen Mitkov Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Johan Hovold , Bryan O'Donoghue , stable@vger.kernel.org X-Mailer: b4 0.15-dev-13183 The use_count check was introduced so that multiple concurrent Raw Data Interfaces RDIs could be driven by different virtual channels VCs on the CSIPHY input driving the video pipeline. This is an invalid use of use_count though as use_count pertains to the number of times a video entity has been opened by user-space not the number of active streams. If use_count and stream-on count don't agree then stop_streaming() will break as is currently the case and has become apparent when using CAMSS with libcamera's released softisp 0.3. The use of use_count like this is a bit hacky and right now breaks regular usage of CAMSS for a single stream case. As an example the "qcam" application in libcamera will fail with an -EBUSY result on stream stop and cannot then subsequently be restarted. The kernel log for this fault looks like this: [ 1265.509831] WARNING: CPU: 5 PID: 919 at drivers/media/common/videobuf2/v= ideobuf2-core.c:2183 __vb2_queue_cancel+0x230/0x2c8 [videobuf2_common] ... [ 1265.510630] Call trace: [ 1265.510636] __vb2_queue_cancel+0x230/0x2c8 [videobuf2_common] [ 1265.510648] vb2_core_streamoff+0x24/0xcc [videobuf2_common] [ 1265.510660] vb2_ioctl_streamoff+0x5c/0xa8 [videobuf2_v4l2] [ 1265.510673] v4l_streamoff+0x24/0x30 [videodev] [ 1265.510707] __video_do_ioctl+0x190/0x3f4 [videodev] [ 1265.510732] video_usercopy+0x304/0x8c4 [videodev] [ 1265.510757] video_ioctl2+0x18/0x34 [videodev] [ 1265.510782] v4l2_ioctl+0x40/0x60 [videodev] ... [ 1265.510944] videobuf2_common: driver bug: stop_streaming operation is le= aving buffer 0 in active state [ 1265.511175] videobuf2_common: driver bug: stop_streaming operation is le= aving buffer 1 in active state [ 1265.511398] videobuf2_common: driver bug: stop_streaming operation is le= aving buffer 2 in active st One CAMSS specific way to handle multiple VCs on the same RDI might be: - Reference count each pipeline enable for CSIPHY, CSID, VFE and RDIx. - The video buffers are already associated with msm_vfeN_rdiX so release video buffers when told to do so by stop_streaming. - Only release the power-domains for the CSIPHY, CSID and VFE when their internal refcounts drop. Either way refusing to release video buffers based on use_count is erroneous and should be reverted. The silicon enabling code for selecting VCs is perfectly fine. Its a "known missing feature" that concurrent VCs won't work with CAMSS right now. Initial testing with this code didn't show an error but, SoftISP and "real" usage with Google Hangouts breaks the upstream code pretty quickly, we need to do a partial revert and take another pass at VCs. This commit partially reverts commit 89013969e232 ("media: camss: sm8250: Pipeline starting and stopping for multiple virtual channels") Fixes: 89013969e232 ("media: camss: sm8250: Pipeline starting and stopping = for multiple virtual channels") Reported-by: Johan Hovold Closes: https://lore.kernel.org/lkml/ZoVNHOTI0PKMNt4_@hovoldconsulting.com/ Tested-by: Johan Hovold Cc: Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss-video.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index cd72feca618c..3b8fc31d957c 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -297,12 +297,6 @@ static void video_stop_streaming(struct vb2_queue *q) =20 ret =3D v4l2_subdev_call(subdev, video, s_stream, 0); =20 - if (entity->use_count > 1) { - /* Don't stop if other instances of the pipeline are still running */ - dev_dbg(video->camss->dev, "Video pipeline still used, don't stop strea= ming.\n"); - return; - } - if (ret) { dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); return; --=20 2.45.2 From nobody Wed Dec 17 15:32:50 2025 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 09C121411EB for ; Tue, 16 Jul 2024 22:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721167990; cv=none; b=IvAdDOKEFplNweYsUSg5inb7RKbhOyyx5QAP0GFN/6tCZwm9Gjlpj4DgTKnIilpyH/EATIbFeR7XXtDadQ6XXBV9SGWNf6/lqACP92w7I8rm4t0FJ4KT+ONCFl9IwUEgsQFKB2gVbU0MmJrFfV7hxRqUBE/2y8/4N1e652h7POI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721167990; c=relaxed/simple; bh=XMtSAnQLUPLTjEcZ9/jJuTztPkljj4KBCEwVdIRm9FQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IYavNCCwSWA4zqqe5sLK3ocgs9s0ykLihCP40DP7kFkvcS1qnCqWkyoSfyWZgaiwvaqq2ShrMITF5lGEtdjEzb+JcXOGJ4tyIi/noqHAaDrl17fWSwx14XbvDohAQtzVrDDASzZzpsDS4rymsQBXZNFuQJc4gNJry0ZSs/lqJYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FjmQLgMj; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FjmQLgMj" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-58b447c519eso8037163a12.3 for ; Tue, 16 Jul 2024 15:13:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721167987; x=1721772787; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=N37H6kLbkNAIPuExxunsB7bhPLTHsDDj/8KnxxdH8yw=; b=FjmQLgMjigIdM1J3dcOZykVf0m/v3rTlS5b8bZ/rbCa1+m6MqBp91Ybu/YUBW8fR6I wUgnXFEJeMW1qSXGMCyCZ6XxFykfQe/7Bhxn0VihsmXD1aENdk/JqBocGb2xtsSEP04L 0ppImgesB9rCJv2Xu6elhVNxOAOPEY2B3vd3H9DZiUIH8wf30LOFQywn5pDGFgTr1bgs NB3PrQuuIqu8OCykSm8mfckpi/QtWy40QincLyLT4Q80v8/OkrDeWj7MsPtfPNCnG07S 6Ka53AhIpqvv1a18CulBy3nRV4GBtIB/2vX1hkaYzflc4C7HobqrP5jvKAcYMg2WAApN oM1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721167987; x=1721772787; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N37H6kLbkNAIPuExxunsB7bhPLTHsDDj/8KnxxdH8yw=; b=aVrwfC+MDKLaaJ6x2UE7bKM01vuFN2Bx3RvaDsL4lEINDpSxGvPci3pvraUCZEqQpq Bn3BAwzmwLvKuD2H8rHeIdNok4sObbXR3EnIItjSNXl0hNRbw6ifpo4C/nAabQHvzzt4 PNA7ucb5dMu26ojQLy/jCx81YY4Se1SY77rQOJmvEAdzKbVhefiHVJjJrqg8YEqEMOA6 e68sEffbnbjjpbVYoyo2gMWyxgZb82vxZOmzZpMSkKRT3WVvDwIwLKSno+TOTigao84f U/Fuqf2B/OvPtzYpQp9wWN+NaRGTHOzREUiFZFopCjm78qg3/m8UWn/ONRm+t4mQPc71 jhpg== X-Forwarded-Encrypted: i=1; AJvYcCUsclifrbAvS6KuaszPG+dS950Mq6/N0ac/dmvC7eKmw6vMNGIq5xGWNLCZviXbnf/o2yr8f0vgO76JrN98Ru8RmuruobqxzmVGQtp9 X-Gm-Message-State: AOJu0YwSiMROkMZviyfhs65GOJIgykRLtSbk14vYjddDyZ1tLqGclySc O9fyrM13eI/CUwQ+tS4gjQXVuy5fhJaUbZ+KLoBpodTAY3t2+k0laBhX9ifvFcI= X-Google-Smtp-Source: AGHT+IG+MADQTpWKslhKvuJZKyGIHvh1adrMraY/f13ntQtqMtGVpyG6NOKMVQVgZZdl1PITC4I3bw== X-Received: by 2002:a50:a6d7:0:b0:58c:74ae:24ee with SMTP id 4fb4d7f45d1cf-59ef06b97fcmr1807973a12.38.1721167987397; Tue, 16 Jul 2024 15:13:07 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b268a28ddsm5582997a12.71.2024.07.16.15.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 15:13:07 -0700 (PDT) From: Bryan O'Donoghue Date: Tue, 16 Jul 2024 23:13:25 +0100 Subject: [PATCH v2 2/2] media: qcom: camss: Fix ordering of pm_runtime_enable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240716-linux-next-24-07-13-camss-fixes-v2-2-e60c9f6742f2@linaro.org> References: <20240716-linux-next-24-07-13-camss-fixes-v2-0-e60c9f6742f2@linaro.org> In-Reply-To: <20240716-linux-next-24-07-13-camss-fixes-v2-0-e60c9f6742f2@linaro.org> To: Robert Foss , Todor Tomov , Mauro Carvalho Chehab , Hans Verkuil , Hans Verkuil , Milen Mitkov Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Johan Hovold , Bryan O'Donoghue , stable@vger.kernel.org X-Mailer: b4 0.15-dev-13183 pm_runtime_enable() should happen prior to vfe_get() since vfe_get() calls pm_runtime_resume_and_get(). This is a basic race condition that doesn't show up for most users so is not widely reported. If you blacklist qcom-camss in modules.d and then subsequently modprobe the module post-boot it is possible to reliably show this error up. The kernel log for this error looks like this: qcom-camss ac5a000.camss: Failed to power up pipeline: -13 Fixes: 02afa816dbbf ("media: camss: Add basic runtime PM support") Reported-by: Johan Hovold Closes: https://lore.kernel.org/lkml/ZoVNHOTI0PKMNt4_@hovoldconsulting.com/ Tested-by: Johan Hovold Cc: Signed-off-by: Bryan O'Donoghue --- drivers/media/platform/qcom/camss/camss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index 51b1d3550421..d64985ca6e88 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -2283,6 +2283,8 @@ static int camss_probe(struct platform_device *pdev) =20 v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev); =20 + pm_runtime_enable(dev); + num_subdevs =3D camss_of_parse_ports(camss); if (num_subdevs < 0) { ret =3D num_subdevs; @@ -2323,8 +2325,6 @@ static int camss_probe(struct platform_device *pdev) } } =20 - pm_runtime_enable(dev); - return 0; =20 err_register_subdevs: @@ -2332,6 +2332,7 @@ static int camss_probe(struct platform_device *pdev) err_v4l2_device_unregister: v4l2_device_unregister(&camss->v4l2_dev); v4l2_async_nf_cleanup(&camss->notifier); + pm_runtime_disable(dev); err_genpd_cleanup: camss_genpd_cleanup(camss); =20 --=20 2.45.2