From nobody Thu Dec 18 05:17:28 2025 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 8D5511494B0 for ; Mon, 29 Jul 2024 12:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722256939; cv=none; b=AKF3rZdCQXfaQg6RDXcRqPtciyyZtx27HZwnGxIY1XS/7HefbMD3kWzwe5WxZ9eclxE46l4tEYP3u1DnSOVuUv816kbMvbEjeqkiar1EpO/1wl2O66tVYv7A4ENZJVDXYhMLteu1ze9c4W7WkNb3naxiNZP+6L6iN46de5RZ3VY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722256939; c=relaxed/simple; bh=Mt1qpwEwH+wt+ZY8OYQdkzU+fJoI85r05BtyNBAs70Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T68FekQ2sS9GflRbLT5u9NkBqPwjUa5x+DpT2XSMEuSCmhbZ/MQAzstkXB7AT+RvVDZRhUCYyY6BLuLTJxDMzEl1C8YMpv70io27l0UMa4ggfgep7QGeMYUlQagnKcVCIirKU20/quKfgNwLppRXwwvd16jpAx8UyYNEbJSjYf0= 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=njEOiG50; arc=none smtp.client-ip=209.85.221.43 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="njEOiG50" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3687f91af40so1512619f8f.0 for ; Mon, 29 Jul 2024 05:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722256936; x=1722861736; 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=I88Q8sziaG0l3nKnE0hWxJ2x8+a+rgX5/qNIMnrCJJs=; b=njEOiG508KcsguO6/L97ZAtCrmc0TYKysY5j+Ed7Ny2gj/xrGUIcn2cCtApaN1CK/x wzw/331+iGGlrmN0tSgus65OsF66dUQDptQAOGqWLp0bfEn7zy1aTT+RkLYwzY0puf7q k4thCNtsc9yi21+QB+pvsj70/CNCjqHQ0jIrPi1OpoVH/jp7bsXtOC4Fl2olqvDvm3RH qGLtFYf4KVvc4jOw2CP+eMjY88CGT1dhU30qBQHGEeePgDxe8GanGdV9t5ZbIAqYJFef 4rF7tiHlUgkLKMw7kAzTgh9TN7ywGBXHpF2Q7oK9g3miZTjsqLGO+t3J3/HvspohrzPL N+cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722256936; x=1722861736; 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=I88Q8sziaG0l3nKnE0hWxJ2x8+a+rgX5/qNIMnrCJJs=; b=adL2yFBnmTGVjfm597yag0xioRS64gFjdwszVVCmEpdS7TOUfc3t9HB4yUqcqCO2A/ +7wqJg71Opo54gDDnZp03hDcoCLImtRZT3jAZHdxttYpfLFpgTw4so2705cUh5vZn3E4 IAEPrOUCZ1uYYRf4DyrOwEJfkb/4cCwquciMb6yJFwhi6mtLnDcq4sftsckFdFGGBicQ Kt22aI0OK9cgQs1ICRAaBy91n/BhhJnhMrQUUTF2FfyW0fjQ57xIOjVPK2PhMuuuy61C vVlTsNztuO1KZKXe2rBevmgr0Sr3r0gGqaprIXAr7jJVPm1NUBtSGR2C/xzmIl3Yg0E7 YFeg== X-Forwarded-Encrypted: i=1; AJvYcCXFmuYOQlIABoA32KRZZ33Yq5aGeNdlcYRW6DQaDe1e2qTYRR/G1Q448RNzsDIXmgO0Df2cO7tz7Lf/RHyVeFTVB+9Wvx3QDGBxtOpH X-Gm-Message-State: AOJu0Ywef7PXT/dOUraeFKyUoDZjScb/PyRzGC5u+fOwSmBCTuNJKAuA oVWpyr1FSD4fTlDxWeJCzNvYZ7WZjHamwY5h6UODMMbQjh68OSywVPEvD5x9FB4= X-Google-Smtp-Source: AGHT+IHjgYkhEwH+b0aL+nKAjpYbsxmNb3nztzLzMIsrrw/HeyXfmalNOQ9Dbux1MPAVfv89NOGi1A== X-Received: by 2002:adf:f38f:0:b0:368:4e38:790c with SMTP id ffacd0b85a97d-36b5ceee06emr5091150f8f.14.1722256935742; Mon, 29 Jul 2024 05:42:15 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367c092esm12106275f8f.13.2024.07.29.05.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:42:15 -0700 (PDT) From: Bryan O'Donoghue Date: Mon, 29 Jul 2024 13:42:02 +0100 Subject: [PATCH v3 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: <20240729-linux-next-24-07-13-camss-fixes-v3-1-38235dc782c7@linaro.org> References: <20240729-linux-next-24-07-13-camss-fixes-v3-0-38235dc782c7@linaro.org> In-Reply-To: <20240729-linux-next-24-07-13-camss-fixes-v3-0-38235dc782c7@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. Stopping qcam results in the splat below, and then it cannot be started again and any attempts to do so fails with -EBUSY. [ 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 Reviewed-by: Vladimir Zapolskiy --- 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 Thu Dec 18 05:17:28 2025 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 984A1148836 for ; Mon, 29 Jul 2024 12:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722256940; cv=none; b=SXKNKZrrsVKAbLGOvbIVlkEs8b78s+mqnZrNPICa5Yjd36eeNN21QIQoqw1oYffo3esIpsin3eIWjbbC9cEQA10Oavyk7a76xw/XpSiKJZUAz0yybxat++96+kQ2lK7t2raMCPtaN0ozv9YAGMzjmxyoK1bnMU19Ou7RE6P9v0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722256940; c=relaxed/simple; bh=XMtSAnQLUPLTjEcZ9/jJuTztPkljj4KBCEwVdIRm9FQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RhsrDXOcFu15Zv9A+xj7pKvwacHUuoVqlMzz6uGxe/07OSwK6Bw0ArMoqCDGKyrEvecCZe4+batj0ByIPe0VV5pEgEMgYw/awi0EenocCtBVxqZLNYWqAy6aIAJ2UdhAHrKb0cwGOCekxUbcclWxNHcL8AiPRj3qi1QiRwWQ5CY= 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=zdIdYL+5; arc=none smtp.client-ip=209.85.128.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="zdIdYL+5" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4281abc64dfso9330895e9.3 for ; Mon, 29 Jul 2024 05:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722256937; x=1722861737; 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=zdIdYL+5faQpUDJZwI9HxYaAMurA7BiYm+TksSWvmQGV+37eD/VWOMxc71Z/GNIJY7 6T808NtQfItXKarLR2yWJg63UioqK9129dtyXa2TKxQflgtmr1k66YSpdKhkrpwBdzk6 /nA4cGBVgwe3DDGTTHD51/whL66ZH4wXzuB0OsuGVlulJGO1A7TbcIjxiCqm9uy86O4c d+TRsVLkhIvauVLiGi19uEI4FDWl0vDR4S0nAOf4dmSh3qu/7C9tHZF1/8xk2eItr5dX Xx8SmFfGQHCKrW667KKG76uYtFtU3KjgI/TnE/VzYKoQCduOjarIbPh+PZGCmViZezrM 4+3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722256937; x=1722861737; 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=sWzIdTWbXiBKqbXEz6GilMtyFpRmgu2vQJE4bRZKbtUMNXg1qkVsXS9GRBqGsIjMfF h5qJ9G5Vd5dSZMCHRzf6VTVnDYTiqU0C2vMEqnn8ZKbVFrfnw0n2leAY3zIY5LuWeev2 aeQaW1tCzlh++DwwrQ0Dc8Ix2fAbtXjGfH68qLzw6MOLOQXI+pNTcqtPo+2byyIN9h/8 SDrQmzteuvynXwhcZxKx3fYvUHm9+AxZ+6y1tB8mNn9pN407c4VHllWmX73o+p+XcnGF 1J+9HVVG3PW4YiFQR+cKnF2WpFkV+nd/jnnVLDYnY+WGX4Ma3+13HiW/9NClnwNvr2zD xBNw== X-Forwarded-Encrypted: i=1; AJvYcCXaBMfy5FUkQwBcx1U2MGPVsvFpAuAMGaJ5+QLX0qmSxKXvlelSiwr9cNS0OskkdBMC0Ixrwtz2XdmBnaaVRa2p5sz7ZEbpuBQ3tueo X-Gm-Message-State: AOJu0YzhaH25Sc1bAdbhwQTH4XNIc/oQzbRgZxlMwY56/iFuE8Uz5tNi lTx8zN0Klp6fCCHHHT/4dHlSS6ts9yIbCjC2QDzyIPhay8GpJYeTr4xAbCpUc+E= X-Google-Smtp-Source: AGHT+IFd9o55Nf2Yjsmn3MKtdq05hMAb79DL3MCHg9LTvgi6dSD5URw35jk1cVD61sFRmsWeY6X4Hw== X-Received: by 2002:a05:6000:1a53:b0:367:9851:4f22 with SMTP id ffacd0b85a97d-36b5d0cc08cmr4558101f8f.58.1722256936868; Mon, 29 Jul 2024 05:42:16 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367c092esm12106275f8f.13.2024.07.29.05.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:42:16 -0700 (PDT) From: Bryan O'Donoghue Date: Mon, 29 Jul 2024 13:42:03 +0100 Subject: [PATCH v3 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: <20240729-linux-next-24-07-13-camss-fixes-v3-2-38235dc782c7@linaro.org> References: <20240729-linux-next-24-07-13-camss-fixes-v3-0-38235dc782c7@linaro.org> In-Reply-To: <20240729-linux-next-24-07-13-camss-fixes-v3-0-38235dc782c7@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 Reviewed-by: Konrad Dybcio --- 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