From patchwork Sun Jul 14 22:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 812873 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 8DDE5130A58 for ; Sun, 14 Jul 2024 22:53:54 +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=1720997636; cv=none; b=Ejqezwo/w/9YlhzzEwWUfb8OSp035Z0DuIDz6tGx0g9EWR54Vae8/7fQbqdNuIUQSJnwdI3Zz+O/nZwEbyDt3XFuJTbgS5LK65SJcV9QeBmOLu3PKJsdbtayY+ISbT0sXLE/ZbW3gBHfJTxn5RZgGizQRGHhcqE5C/7Dmtunk3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720997636; c=relaxed/simple; bh=iYI1KOvw94wnIMS8FI79AwEMjOsLCg7Kzx1l6dqHV1w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uHrKyg5Fe77dpjDishJKb9BNc0w4bGubczAZB1LXnjO/sAYiv/bsss7gdyPoSWzP1KgfKq2wtK0qJe/5nb9gLf0rvHdLfphuJhd34vNhjHohrzsw7CZZU6ZtyRFDwCRsefJgwSx0Nl00Uc1W0vzlf9n4FThHEBTQdp9ipLQLD68= 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=OaazSMqC; 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="OaazSMqC" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4266f535e82so24684705e9.1 for ; Sun, 14 Jul 2024 15:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720997633; x=1721602433; 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=MI2MH/h15Gsz7mc65cDWKHx+IlGAYagBQoxwo/Wd/mo=; b=OaazSMqCQ3NoXH8qDFtsCOazI24K+V8nKDEv/GnufbXMvp2kv58Yen8Z0scXJXAzsr xH4BuFh5on7DXpqXI7tSjgYq20xXd3LksUpvU3HUTKK7k9ob7anVAO2jJlJ6xn5GdEM5 o3akeyHxPnVEgTZsEugLp0cKIjilsawU80/xSz8yJ0afCAqwddz6HkEbPt+C7h/OYlkz bCXh/JsuYFNbKjbyTA4Nvt122ZxGOUWVyg0SAeo40Eq28I/kjqf8pgIwZ5jd2gJ9nqw+ ZulSH91gmzYN1zfuTt+bBsWyzMfJMNFmZ586PBzE7NYeipJvTUpkv3aeGhf4E54kKQET LEQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720997633; x=1721602433; 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=MI2MH/h15Gsz7mc65cDWKHx+IlGAYagBQoxwo/Wd/mo=; b=G19QFj9H5gdiL/DViXW8fgQRi0mtae6Uqi2JgRCJj6EPvJ9Zda3P/BOfDOuw3xlgpM OcE36ItuJE4s57PWRtgFfeG+Orn5/V5vZG7iqvlHkvk8MXDoyxAt4iwWrQUJcFowLMXw bZ1qn6lvTXxrfTlz2cjRrIRJo+iCHB5OiBfNT3Bmdxskqaa2mZ0bYhlAflJj0YQ8ww8W 5pybRETje07FFl9FnNw5XWt45UDIiBr6UuBJ4C8HGlU7ywgsT243pvDChzMbe3u+TYa/ fcaXlznHK/PtWx9JrEwKc6A1aMJebuUVm1PAX3cfYBkZRw54I1LEdcEFle/+f9Oed65/ luXQ== X-Forwarded-Encrypted: i=1; AJvYcCU4KtxBU9F5hCdCsSDwI6hMIXRUMtrzoYvmupYCVgQP49c0OEaa8kyx9/Pob30/c7Vp1/IEr73AHPOaBBl93rcmFDeZ5i9UzMg6t8HIbg== X-Gm-Message-State: AOJu0Yz6kEaRzR0x5+Xt9L2bNYL1V+U4t3RoaaEgT3bywgPcvvWAguGz yY6tpFoo7eyiijLE5fH21TVQRvTbvF+AyuEzT2LJFlt8XOvf6AP8oxltl0uYUOM= X-Google-Smtp-Source: AGHT+IEysSdUKxeJskaRsDHM4PnZM/pkXEmRsm6QU3mdlwpWsYGntp5CbVnOrGZjCgS2SX/mqCIDbw== X-Received: by 2002:a05:600c:1587:b0:426:5e91:3920 with SMTP id 5b1f17b1804b1-426708f1df1mr137832735e9.29.1720997632879; Sun, 14 Jul 2024 15:53:52 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279dae34casm40632445e9.0.2024.07.14.15.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 15:53:52 -0700 (PDT) From: Bryan O'Donoghue Date: Sun, 14 Jul 2024 23:53:58 +0100 Subject: [PATCH 1/2] media: qcom: camss: Remove use_count guard in stop_streaming Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240714-linux-next-24-07-13-camss-fixes-v1-1-8f8954bc8c85@linaro.org> References: <20240714-linux-next-24-07-13-camss-fixes-v1-0-8f8954bc8c85@linaro.org> In-Reply-To: <20240714-linux-next-24-07-13-camss-fixes-v1-0-8f8954bc8c85@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 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. 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") 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/media/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) ret = v4l2_subdev_call(subdev, video, s_stream, 0); - 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 streaming.\n"); - return; - } - if (ret) { dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); return; From patchwork Sun Jul 14 22:53:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 812561 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 7516F13D28F for ; Sun, 14 Jul 2024 22:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720997638; cv=none; b=TxJ4WF6iyUGFJ4BBNrcOAG/dB9LTAWfku2uA48WVFuMBPEOI/1GKGVzUfPw/IRPQmVLAFdSs6CNsBb5Zjtw5VJflW2nYoCVehDBg+i9+PKR23D9bXIeJ7Q2vVgJcyVdKvFjUQ5mIPKWz1IyJNBGWES/FBy8U+KshptubCRMBD0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720997638; c=relaxed/simple; bh=XFGhcwTu/Mz6wrqwi1h5k63gW/YSFiytfhyYe9UGJXc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b/rK50DbziUJeHTuVgBlYBh0U3Njk7KjKNmiqLvpP8aINb6LsM04Q26lasiIp/qGqF9Make+KM7bILgm0gB57g3wuB8YOGzZxm/oFHumntVrw/6CA5FNQH/jbbRvcFmHY9hlMFtZo6ivByfeKgAf28Bei/5SM1cCOOsynuIs9GE= 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=aoJgT2xo; arc=none smtp.client-ip=209.85.128.47 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="aoJgT2xo" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4272738eb9eso26858055e9.3 for ; Sun, 14 Jul 2024 15:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720997634; x=1721602434; 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=HzeclMxKxNLzIyOYlAy8CqRPm2NMzdjyMjfNK8U4cd4=; b=aoJgT2xog0Zf3aw7opTnF63IFwPTKch3CF1EpNyz27Sb5RfIM0EICNENqsEYmuDZOa 9EdhxSUTJ3hXhyfSK89PEb3bKstJX19Nmv9wJxXsM4t8QY9+1Wt5RvDsQ2E3BYXyELk+ FmWfmO+D0WKylCYR7YQbeT60NfF4x0CXb41JUA/wRaXG1mwusYNRwoCRoNoKVgzCK5pU LftI0OFNSek0nYFrrO175Emy4VJYFeEEatuHPpAjLKE234fM0ib6L86WRGV8xnHXlPhL Bwwg6brCnYs30yvnVpzJfxTj8epgAoZuicqdEn0SCdNCMBjr1/8ZsSeTLoZfM0hpGhn5 DkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720997634; x=1721602434; 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=HzeclMxKxNLzIyOYlAy8CqRPm2NMzdjyMjfNK8U4cd4=; b=HfFsN+jEchna7sBZEvAWShP5fwn8AuZGxaEg7xeMzcKMzXYI4heBvAyvPEK8nIPC+/ IduIaqgDMRM86+CgOr0MGrA08VL1SPEsTg2u4msYaogO8PWpSq+j+drZh7oc1HFHpVVZ HYSpjGW5Etm8Xda0M+tgvHErsXlqhMhmOSPjS9KLITioVrPLuQxaId7g9gC0CslUsBQZ PnBeqSZvOX3NxFVkdBnN/ZC7ti74SX407BZd0uuG1yVoheNsof9j8JFBlolctwxElC+Q rlLr+KSQ8IffhEGjjM12HzSLB70OAJxOiFtUStd80BhgbrDTJzEuk+LGqzQLZYtq8rRk L5nA== X-Forwarded-Encrypted: i=1; AJvYcCX7Qwgv2kgJliW4NEp+tiLWwTTTkJ3nfN/ue14WhLiLQc+QyWsQQvQS/lU5u8LGzl6PrDrTPBClfPw9ajEzQHgGEFqLMe8wi1EgW8+qOw== X-Gm-Message-State: AOJu0YyeEnZcvkVP2HMM1kIHUr260JMNH9qa4fXADUf6Ri2OCHi2Vn2I ubIF1KVienFB24SL7H1DBGzCbQbc/fSR1JGi02Z1sj0rSLj33ogdwaUkEboShOU= X-Google-Smtp-Source: AGHT+IG85V00IMooWyrtdiKFFfGK6QkfieuC3gLw5Jf+m2YrK3JSLDsYd7PsB4evQgrl4Jn0mVna4A== X-Received: by 2002:a05:600c:2284:b0:426:5e91:391e with SMTP id 5b1f17b1804b1-426707f81a5mr109514495e9.26.1720997633942; Sun, 14 Jul 2024 15:53:53 -0700 (PDT) Received: from [127.0.1.1] ([176.61.106.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279dae34casm40632445e9.0.2024.07.14.15.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 15:53:53 -0700 (PDT) From: Bryan O'Donoghue Date: Sun, 14 Jul 2024 23:53:59 +0100 Subject: [PATCH 2/2] media: qcom: camss: Fix ordering of pm_runtime_enable Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240714-linux-next-24-07-13-camss-fixes-v1-2-8f8954bc8c85@linaro.org> References: <20240714-linux-next-24-07-13-camss-fixes-v1-0-8f8954bc8c85@linaro.org> In-Reply-To: <20240714-linux-next-24-07-13-camss-fixes-v1-0-8f8954bc8c85@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 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. Fixes: 02afa816dbbf ("media: camss: Add basic runtime PM support") Signed-off-by: Bryan O'Donoghue Reported-by: Johan Hovold Tested-by: Johan Hovold --- 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/platform/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) v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev); + pm_runtime_enable(dev); + num_subdevs = camss_of_parse_ports(camss); if (num_subdevs < 0) { ret = num_subdevs; @@ -2323,8 +2325,6 @@ static int camss_probe(struct platform_device *pdev) } } - pm_runtime_enable(dev); - return 0; 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);