media: qcom: camss: Fix ordering of pm_runtime_enable

commit a151766bd3 upstream.

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: 02afa816db ("media: camss: Add basic runtime PM support")
Reported-by: Johan Hovold <johan+linaro@kernel.org>
Closes: https://lore.kernel.org/lkml/ZoVNHOTI0PKMNt4_@hovoldconsulting.com/
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Konrad Dybcio <konradybcio@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Bryan O'Donoghue 2024-07-29 13:42:03 +01:00 committed by Greg Kroah-Hartman
parent c2218a82f7
commit ea3a6938cb

View File

@ -1665,6 +1665,8 @@ static int camss_probe(struct platform_device *pdev)
v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev); v4l2_async_nf_init(&camss->notifier, &camss->v4l2_dev);
pm_runtime_enable(dev);
num_subdevs = camss_of_parse_ports(camss); num_subdevs = camss_of_parse_ports(camss);
if (num_subdevs < 0) { if (num_subdevs < 0) {
ret = num_subdevs; ret = num_subdevs;
@ -1701,8 +1703,6 @@ static int camss_probe(struct platform_device *pdev)
} }
} }
pm_runtime_enable(dev);
return 0; return 0;
err_register_subdevs: err_register_subdevs:
@ -1710,6 +1710,7 @@ err_register_subdevs:
err_v4l2_device_unregister: err_v4l2_device_unregister:
v4l2_device_unregister(&camss->v4l2_dev); v4l2_device_unregister(&camss->v4l2_dev);
v4l2_async_nf_cleanup(&camss->notifier); v4l2_async_nf_cleanup(&camss->notifier);
pm_runtime_disable(dev);
err_genpd_cleanup: err_genpd_cleanup:
camss_genpd_cleanup(camss); camss_genpd_cleanup(camss);