From: sashiko-bot@kernel.org
To: "Atanas Filipov" <atanas.filipov@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
media-ci@linuxtv.org
Subject: Re: [PATCH v2 04/10] media: qcom: cam-icc: add the Titan camera NoC driver
Date: Fri, 04 Dec 2026 08:27:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-249393@kernel.org> (raw)
In-Reply-To: <20261204075339.4077387-5-atanas.filipov@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [High] media: qcom: cam-icc: Kconfig under MEDIA_SUPPORT stalls
icc_sync_state()
- [High] media: qcom: cam-icc: drop OPP votes while camnoc_axi stays at
400 MHz
- [Medium] media: qcom: cam-icc: qcom_cam_icc_remove() leaks enabled
clocks on unbind
- [Medium] media: qcom: cam-icc: partial clock/OPP failure breaks
icc_set_bw() rollback
- [Medium] media: qcom: cam-icc: unbalanced disable_irq() in
qcom_cam_icc_resume()
- [Medium] media: qcom: cam-icc: unchecked match data in
qcom_cam_icc_probe()
- [Medium] media: qcom: cam-icc: SBM IRQ left unmasked across runtime PM
transitions
- [Medium] media: qcom: cam-icc: wrong IRQ clear order and unmask during
RPM_RESUMING
--
commit 28878b8cb1373ee083c9daeccda766f64646eb4a
Author: Atanas Filipov <atanas.filipov@oss.qualcomm.com>
media: qcom: cam-icc: add the Titan camera NoC driver
This commit adds an interconnect provider driver for the Qualcomm Titan
camera NoC, scaling AXI and AHB clocks and rail OPP levels from aggregated
bandwidth votes while configuring static QoS and error interrupts on runtime
resume.
> diff --git a/drivers/media/platform/qcom/cam-icc/Kconfig b/drivers/media/platform/qcom/cam-icc/Kconfig
> new file mode 100644
> index 0000000000000..8fae973ce1b0c
> --- /dev/null
> +++ b/drivers/media/platform/qcom/cam-icc/Kconfig
> @@ -0,0 +1,14 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +config QCOM_CAM_ICC
> + tristate "Qualcomm Titan camera NoC core driver"
> + depends on ARCH_QCOM || COMPILE_TEST
> + depends on COMMON_CLK && PM
> + depends on INTERCONNECT
> + select PM_OPP
> + default ARCH_QCOM
[Severity: High]
Can nesting QCOM_CAM_ICC under MEDIA_SUPPORT prevent icc_sync_state() from
ever completing?
This Kconfig file is sourced inside MEDIA_SUPPORT, MEDIA_PLATFORM_SUPPORT,
and MEDIA_PLATFORM_DRIVERS, so default ARCH_QCOM has no effect when
CONFIG_MEDIA_SUPPORT=n and limits the driver to at most =m when
CONFIG_MEDIA_SUPPORT=m (as in arm64 defconfig). Because qcom_cam_icc_driver
sets .sync_state = icc_sync_state, any boot where the camera NoC DT node has
#interconnect-cells enabled but this driver is not built in or loaded leaves
icc_sync_state() below providers_count. That permanently pins boot floor
bandwidth constraints across every interconnect provider on the SoC,
breaking low-power scaling and system suspend.
> diff --git a/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
> new file mode 100644
> index 0000000000000..dbfccdb30da3e
> --- /dev/null
> +++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
[ ... ]
> +static int qcom_cam_icc_set_axi_rate(struct qcom_cam_icc *camnoc, u64 rate)
> +{
> + unsigned long freq = min_t(u64, rate, ULONG_MAX);
> + struct dev_pm_opp *opp;
> + int ret;
> +
> + if (!rate) {
> + ret = clk_set_min_rate(camnoc->axi_clk, 0);
> + if (ret)
> + return ret;
> +
> + ret = clk_set_rate(camnoc->axi_clk, 0);
> + if (ret)
> + return ret;
> +
> + return dev_pm_opp_set_opp(camnoc->dev, NULL);
> + }
[Severity: High]
Can dev_pm_opp_set_opp(camnoc->dev, NULL) drop the rail voltage while
camnoc_axi is still running at 400 MHz on SA8775P?
Unlike SM8250 and SC7280, ftbl_cam_cc_camnoc_axi_clk_src in
drivers/clk/qcom/camcc-sa8775p.c has no 19.2 MHz XO entry and only a single
400 MHz entry, so clk_set_rate(camnoc->axi_clk, 0) rounds up to 400 MHz and
leaves cam_cc_camnoc_axi_clk enabled at 400 MHz. Calling
dev_pm_opp_set_opp(camnoc->dev, NULL) while the device is runtime-active
immediately lowers SA8775P_MMCX and SA8775P_MXC below their required
rpmhpd_opp_svs_l1 corner.
On the next qcom_cam_icc_runtime_resume(), clk_bulk_prepare_enable() also
restores the parked 400 MHz RCG configuration via clk_rcg2_shared_enable()
and writes QoS and IRQ registers before any client votes bandwidth to raise
those rails, risking bus errors or hardware hangs.
[ ... ]
> +static int qcom_cam_icc_update(struct qcom_cam_icc *camnoc)
> +{
> + struct icc_node *ahb = camnoc->icc_data->nodes[camnoc->data->ahb_id];
> + unsigned long ahb_rate;
> + u64 rate;
> + int ret;
> +
> + rate = qcom_cam_icc_axi_rate(camnoc);
> + ahb_rate = (ahb && (ahb->avg_bw || ahb->peak_bw)) ? QCOM_CAM_ICC_AHB_RATE : 0;
> + if (rate == camnoc->axi_rate && ahb_rate == camnoc->ahb_rate)
> + return 0;
> +
> + if (rate != camnoc->axi_rate) {
> + ret = qcom_cam_icc_set_axi_rate(camnoc, rate);
> + if (ret)
> + return ret;
> +
> + camnoc->axi_rate = rate;
> + }
> +
> + if (ahb_rate != camnoc->ahb_rate) {
> + ret = clk_set_min_rate(camnoc->ahb_clk, ahb_rate);
> + if (ret)
> + return ret;
> +
> + ret = clk_set_rate(camnoc->ahb_clk, ahb_rate);
> + if (ret)
> + return ret;
> +
> + camnoc->ahb_rate = ahb_rate;
> + }
[Severity: Medium]
Can a partial clock or OPP failure leave hardware clock state out of sync
with camnoc->axi_rate and camnoc->ahb_rate and defeat icc_set_bw() rollback?
In qcom_cam_icc_set_axi_rate() when !rate, if clk_set_rate() or
dev_pm_opp_set_opp() fails after clk_set_min_rate(0) succeeds, axi_clk is
already lowered while camnoc->axi_rate keeps the old frequency. The same
mismatch occurs if clk_set_rate() fails after clk_set_min_rate() for ahb_clk
here or for axi_clk in qcom_cam_icc_config_clks().
When icc_set_bw() rolls back a failed apply_constraints() by restoring the
previous bandwidths and calling provider->set() again, the early check
rate == camnoc->axi_rate && ahb_rate == camnoc->ahb_rate returns 0 and skips
restoring the modified clock state.
[ ... ]
> +static void qcom_cam_icc_irq_init(struct qcom_cam_icc *camnoc)
> +{
> + const struct qcom_cam_icc_data *data = camnoc->data;
> + size_t i;
> +
> + writel(data->sbm->clear_val, camnoc->base + data->sbm->clear_reg);
> +
> + for (i = 0; i < data->num_irq_errs; i++) {
> + const struct qcom_cam_icc_irq_err *err = &data->irq_errs[i];
> +
> + writel(1, camnoc->base + err->base + err->clear_off);
> + writel(err->enable_val, camnoc->base + err->base + err->enable_off);
> + }
> +
> + if (data->err_logger) {
> + writel(1, camnoc->base + data->err_logger->base + QCOM_CAM_ICC_ERL_ERRCLR);
> + writel(QCOM_CAM_ICC_ERL_MAINCTL_STALL_EN | QCOM_CAM_ICC_ERL_MAINCTL_FAULT_EN,
> + camnoc->base + data->err_logger->base + QCOM_CAM_ICC_ERL_MAINCTL);
> + }
> +
> + writel(camnoc->irq_mask, camnoc->base + data->sbm->enable_reg);
> +}
[Severity: Medium]
Is data->sbm->clear_reg cleared too early here, and can unmasking
data->sbm->enable_reg during RPM_RESUMING wedge the error interrupt?
Unlike qcom_cam_icc_irq(), this clears data->sbm->clear_reg before clearing
err->clear_off and QCOM_CAM_ICC_ERL_ERRCLR. If a stale error persists
across runtime suspend while the shared top GDSC stays powered, the SBM can
re-latch before the individual sources are cleared.
In addition, qcom_cam_icc_irq_init() runs inside qcom_cam_icc_runtime_resume()
while rpm_resume() still has runtime_status set to RPM_RESUMING. If an
interrupt fires before rpm_resume() transitions to RPM_ACTIVE,
qcom_cam_icc_irq() sees pm_runtime_get_if_active() <= 0 and returns IRQ_NONE
without clearing the latched status, which leaves a rising-edge interrupt
line asserted high and silences future error interrupts until the next
suspend/resume cycle.
[ ... ]
> +static int qcom_cam_icc_runtime_suspend(struct device *dev)
> +{
> + struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
> +
> + clk_bulk_disable_unprepare(camnoc->num_clks, camnoc->clks);
> + icc_set_bw(camnoc->hf_path, 0, 0);
> + icc_set_bw(camnoc->cfg_path, 0, 0);
> +
> + return 0;
> +}
[Severity: Medium]
Can leaving SBM interrupts unmasked in qcom_cam_icc_runtime_suspend() drop
and wedge edge-triggered camera NoC error interrupts?
qcom_cam_icc_runtime_suspend() disables clocks without masking
data->sbm->enable_reg (or the per-source error enables) and without
synchronizing with the threaded qcom_cam_icc_irq() handler. If an error
fires during suspend, or while suspended with the shared TITAN_TOP_GDSC held
on by another consumer such as cci0 or cci1, the threaded handler bails out:
CPU0 CPU1
rpm_suspend()
runtime_status = RPM_SUSPENDING
qcom_cam_icc_runtime_suspend()
clk_bulk_disable_unprepare()
<hardirq> -> wakes qcom_cam_icc_irq()
qcom_cam_icc_irq()
pm_runtime_get_if_active() -> 0
return IRQ_NONE <-- status uncleared
Because the interrupt is rising-edge triggered, leaving the SBM status
uncleared keeps the line latched high and suppresses further error
interrupts (and leaves the error logger stalled if STALL_EN triggered) until
the next runtime resume re-runs qcom_cam_icc_irq_init().
[ ... ]
> +static int qcom_cam_icc_resume(struct device *dev)
> +{
> + struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = pm_runtime_force_resume(dev);
> + if (ret)
> + return ret;
> +
> + enable_irq(camnoc->irq);
> +
> + return 0;
> +}
[Severity: Medium]
Does returning early when pm_runtime_force_resume() fails leave camnoc->irq
permanently disabled?
qcom_cam_icc_suspend() calls disable_irq(camnoc->irq), and even on callback
failure pm_runtime_force_resume() marks the device suspended and re-enables
runtime PM before system resume proceeds. Skipping enable_irq(camnoc->irq)
leaves the IRQ disable depth unbalanced across subsequent runtime resumes.
Calling enable_irq(camnoc->irq) unconditionally is safe because the device
remains suspended on error and qcom_cam_icc_irq() checks
pm_runtime_get_if_active() <= 0.
[ ... ]
> + camnoc->dev = dev;
> + camnoc->data = device_get_match_data(dev);
> +
> + camnoc->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(camnoc->base))
> + return PTR_ERR(camnoc->base);
> +
> + camnoc->num_clks = devm_clk_bulk_get_all(dev, &camnoc->clks);
> + if (camnoc->num_clks < 0)
> + return dev_err_probe(dev, camnoc->num_clks, "failed to get clocks\n");
> +
> + camnoc->axi_clk = devm_clk_get(dev, camnoc->data->rate_clk);
[Severity: Medium]
Can device_get_match_data() return NULL here and cause a NULL pointer
dereference?
If a platform device is bound to qcom-cam-icc without matching
qcom_cam_icc_of_match (for example via sysfs driver_override and bind),
camnoc->data is NULL and dereferencing camnoc->data->rate_clk oopses in
devm_clk_get(). Checking if (!camnoc->data) and returning -ENODEV avoids
the crash.
[ ... ]
> + ret = qcom_cam_icc_irq_request(pdev, camnoc);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to request the interrupt\n");
> +
> + ret = devm_pm_runtime_enable(dev);
> + if (ret)
> + return ret;
> +
> + ret = qcom_cam_icc_icc_init(camnoc);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to register the interconnect provider\n");
> +
> + return 0;
> +}
> +
> +static void qcom_cam_icc_remove(struct platform_device *pdev)
> +{
> + struct qcom_cam_icc *camnoc = platform_get_drvdata(pdev);
> +
> + icc_provider_deregister(&camnoc->provider);
> + icc_nodes_remove(&camnoc->provider);
> +}
[Severity: Medium]
Can unbinding the driver while the device is RPM_ACTIVE leak enabled clocks
and detach power domains while clocks are still running?
During unbind, __device_release_driver() resumes the device with
pm_runtime_get_sync() and calls pm_runtime_put_sync(). If the device stays
RPM_ACTIVE (for example because userspace set power/control to on, or an
in-flight qcom_cam_icc_irq() holds pm_runtime_get_if_active()),
qcom_cam_icc_remove() returns without synchronizing IRQ teardown or
suspending the device.
Because devm_pm_runtime_enable() is registered after
qcom_cam_icc_irq_request(), LIFO devres teardown runs pm_runtime_disable()
before free_irq() without calling qcom_cam_icc_runtime_suspend(). Later
devres callbacks then detach the power domains while clocks are active, and
devm_clk_bulk_release_all() puts the handles without disabling or
unpreparing them, permanently leaking prepare_count and enable_count on
camnoc->clks.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204075339.4077387-1-atanas.filipov@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-12-04 8:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 7:53 [PATCH v2 00/10] Add the Qualcomm Titan camera NoC interconnect provider Atanas Filipov
2026-12-04 7:53 ` [PATCH v2 01/10] dt-bindings: interconnect: add the Qualcomm SM8250 Titan camera NoC Atanas Filipov
2026-12-04 8:01 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 02/10] dt-bindings: interconnect: add the Qualcomm SC7280 " Atanas Filipov
2026-12-04 8:04 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 03/10] dt-bindings: interconnect: add the Qualcomm SA8775P " Atanas Filipov
2026-12-04 8:04 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 04/10] media: qcom: cam-icc: add the Titan camera NoC driver Atanas Filipov
2026-12-04 8:27 ` sashiko-bot [this message]
2026-12-04 7:53 ` [PATCH v2 05/10] media: qcom: cam-icc: add the SM8250 data Atanas Filipov
2026-12-04 8:16 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 06/10] media: qcom: cam-icc: add the SC7280 data Atanas Filipov
2026-12-04 7:53 ` [PATCH v2 07/10] media: qcom: cam-icc: add the SA8775P data Atanas Filipov
2026-12-04 8:19 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 08/10] arm64: dts: qcom: sm8250: add the Titan camera NoC node Atanas Filipov
2026-12-04 8:25 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 09/10] arm64: dts: qcom: sc7280: " Atanas Filipov
2026-12-04 8:30 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 10/10] arm64: dts: qcom: sa8775p: " Atanas Filipov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-249393@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=atanas.filipov@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox