All of lore.kernel.org
 help / color / mirror / Atom feed
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 04/10] media: qcom: cam-icc: add the Titan camera NoC driver
Date: Mon, 30 Nov 2026 11:18:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-240939@kernel.org> (raw)
In-Reply-To: <20261130104955.1288089-5-atanas.filipov@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] media: qcom: cam-icc: clk_set_rate_range() with ULONG_MAX
  prevents downscaling
- [Medium] media: qcom: cam-icc: PD_FLAG_DEV_LINK_ON leaks active
  reference on top GDSC
- [Medium] media: qcom: cam-icc: of_icc_xlate_onecell() drops
  interconnect path tags
- [Medium] media: qcom: cam-icc: premature drvdata and runtime PM enable
  in probe
- [Medium] media: qcom: cam-icc: race between qcom_cam_icc_irq() and
  force suspend
--

commit 99e6773ec5e7bf2c96781aedd0dc83a40d461f04
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 to scale the AXI/AHB clocks and power domain rail levels from
aggregated bandwidth votes, and to configure static QoS and error interrupts
on runtime resume.

> 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..beb0ee0cad7a4
> --- /dev/null
> +++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
> @@ -0,0 +1,635 @@

[ ... ]

> +static int qcom_cam_icc_set_axi_rate(struct qcom_cam_icc *camnoc, u64 rate)
> +{
> +	unsigned long freq = rate;
> +	struct dev_pm_opp *opp;
> +	int ret;
> +
> +	if (!rate) {
> +		ret = clk_set_rate_range(camnoc->axi_src, 0, ULONG_MAX);
> +		if (ret)
> +			return ret;
> +
> +		return dev_pm_opp_set_opp(camnoc->dev, NULL);
> +	}

[ ... ]

> +static int qcom_cam_icc_update(struct qcom_cam_icc *camnoc)
> +{
> +	struct icc_node *ahb = camnoc->icc_data->nodes[camnoc->data->ahb_id];
> +	const struct qcom_cam_icc_ahb_level *level;
> +	unsigned long ahb_rate;
> +	u64 rate;
> +	int ret;
> +
> +	rate = qcom_cam_icc_axi_rate(camnoc);
> +	level = qcom_cam_icc_ahb_level(camnoc, ahb ? ahb->peak_bw : 0);
> +	if (rate == camnoc->axi_rate && level == camnoc->ahb_level)
> +		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 (level != camnoc->ahb_level) {
> +		ahb_rate = level ? level->slow_ahb_rate : 0;
> +		ret = clk_set_rate_range(camnoc->ahb_src, ahb_rate, ULONG_MAX);

[Severity: High]
Does calling clk_set_rate_range() with max set to ULONG_MAX prevent
camnoc->axi_src and camnoc->ahb_src from ever scaling back down?

clk_set_rate_range() clamps clk->core->req_rate into [min, max] and passes
that clamped value to clk_core_set_rate_nolock(), which updates req_rate:

drivers/clk/clk.c:clk_set_rate_range_nolock() {
	...
	rate = clamp(clk->core->req_rate, min, max);
	ret = clk_core_set_rate_nolock(clk->core, rate);
	...
}

Once qcom_cam_icc_config_clks() or qcom_cam_icc_update() raises the minimum
frequency to R_high, req_rate becomes R_high.  When bandwidth votes later
drop to a lower OPP frequency R_low or 0, clamp(R_high, R_low, ULONG_MAX)
still evaluates to R_high, so the clock stays at R_high while
dev_pm_opp_set_opp() lowers or drops the voltage rail performance state,
undervolting the active AXI clock.

[ ... ]

> +static int qcom_cam_icc_icc_init(struct qcom_cam_icc *camnoc)
> +{
> +	const struct qcom_cam_icc_data *data = camnoc->data;
> +	struct icc_provider *provider = &camnoc->provider;
> +	struct icc_onecell_data *icc_data;
> +	size_t i, j;
> +	int ret;
> +
> +	icc_data = devm_kzalloc(camnoc->dev, struct_size(icc_data, nodes, data->num_ids),
> +				GFP_KERNEL);
> +	if (!icc_data)
> +		return -ENOMEM;
> +
> +	icc_data->num_nodes = data->num_ids;
> +	camnoc->icc_data = icc_data;
> +
> +	provider->dev = camnoc->dev;
> +	provider->set = qcom_cam_icc_icc_set;
> +	provider->aggregate = qcom_cam_icc_icc_aggregate;
> +	provider->get_bw = qcom_cam_icc_icc_get_bw;
> +	provider->xlate = of_icc_xlate_onecell;
> +	provider->data = icc_data;

[Severity: Medium]
Does using of_icc_xlate_onecell drop interconnect path tags?

The Titan camera NoC bindings define #interconnect-cells = <2>, where the
second cell is the path tag.  Because provider->xlate is set instead of
provider->xlate_extended, of_icc_get_from_provider() leaves src_data->tag
as 0, and of_icc_get_by_index() never applies the tag to paths starting at a
camera NoC port (including the downstream mmss_noc and mc_virt providers).

[ ... ]

> +static irqreturn_t qcom_cam_icc_irq(int irq, void *dev_id)
> +{
> +	struct qcom_cam_icc *camnoc = dev_id;
> +	const struct qcom_cam_icc_data *data = camnoc->data;
> +	u32 status, pending, enable;
> +	size_t i;
> +
> +	if (pm_runtime_get_if_active(camnoc->dev) <= 0)
> +		return IRQ_NONE;
> +
> +	status = readl(camnoc->base + data->sbm->status_reg);

[ ... ]

> +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);
> +
> +	return icc_set_bw(camnoc->cfg_path, 0, 0);
> +}

[ ... ]

> +static const struct dev_pm_ops qcom_cam_icc_pm_ops = {
> +	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> +	RUNTIME_PM_OPS(qcom_cam_icc_runtime_suspend, qcom_cam_icc_runtime_resume, NULL)
> +};

[Severity: Medium]
Can qcom_cam_icc_irq() race with pm_runtime_force_suspend() and access
camnoc->base after clocks and cfg_path are disabled?

CPU0                                    CPU1
qcom_cam_icc_irq()
  pm_runtime_get_if_active() > 0
                                        dpm_suspend()
                                          pm_runtime_force_suspend()
                                            qcom_cam_icc_runtime_suspend()
                                              clk_bulk_disable_unprepare(...)
                                              icc_set_bw(cfg_path, 0, 0)
  readl(camnoc->base + ...)  <-- unclocked MMIO access

pm_runtime_force_suspend() runs during dpm_suspend(), before
dpm_suspend_noirq() disables device interrupts, and invokes
qcom_cam_icc_runtime_suspend() regardless of the power.usage_count reference
taken by pm_runtime_get_if_active().

> +
> +static const char * const qcom_cam_icc_pd_names[] = { "top" };
> +
> +static const struct dev_pm_domain_attach_data qcom_cam_icc_pd_data = {
> +	.pd_names = qcom_cam_icc_pd_names,
> +	.num_pd_names = ARRAY_SIZE(qcom_cam_icc_pd_names),
> +	.pd_flags = PD_FLAG_DEV_LINK_ON,
> +};

[Severity: Medium]
Does PD_FLAG_DEV_LINK_ON leave the top GDSC powered on after probe?

PD_FLAG_DEV_LINK_ON passes DL_FLAG_RPM_ACTIVE to device_link_add(), which
calls pm_runtime_get_sync() on the top power domain under the assumption
that the consumer device will be set to RPM_ACTIVE during probe.  Because
qcom_cam_icc_probe() leaves camnoc->dev in RPM_SUSPENDED state, that active
supplier reference is never dropped when probe finishes, keeping the Titan
top GDSC powered on after boot until camnoc->dev goes through a runtime
resume and suspend cycle.

[ ... ]

> +	platform_set_drvdata(pdev, camnoc);
> +
> +	ret = qcom_cam_icc_pd_init(camnoc);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to attach the power domains\n");
> +
> +	ret = qcom_cam_icc_opp_init(camnoc);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to add the OPP table\n");
> +
> +	ret = devm_pm_runtime_enable(dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = qcom_cam_icc_irq_request(pdev, camnoc);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to request the interrupt\n");
> +
> +	ret = qcom_cam_icc_icc_init(camnoc);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to register the interconnect provider\n");

[Severity: Medium]
Can enabling runtime PM and publishing drvdata before
qcom_cam_icc_irq_request() leave error interrupts disabled on runtime
resume?

qcom_cam_icc_link() uses platform_get_drvdata(pdev) to check whether this
driver has finished probing before calling device_link_add() with
DL_FLAG_PM_RUNTIME, which can immediately runtime-resume camnoc->dev while
both devices are probing.  If runtime resume runs between
devm_pm_runtime_enable() and qcom_cam_icc_irq_request() (either via a
concurrent qcom_cam_icc_link() caller or via sysfs),
qcom_cam_icc_runtime_resume() -> qcom_cam_icc_irq_init() writes
camnoc->irq_mask to data->sbm->enable_reg while camnoc->irq_mask is still 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130104955.1288089-1-atanas.filipov@oss.qualcomm.com?part=4

  reply	other threads:[~2026-11-30 11:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 10:49 [PATCH 00/10] Add the Qualcomm Titan camera NoC interconnect provider Atanas Filipov
2026-11-30 10:49 ` [PATCH 01/10] dt-bindings: interconnect: add the Qualcomm SM8250 Titan camera NoC Atanas Filipov
2026-11-30 11:01   ` sashiko-bot
2026-11-30 10:49 ` [PATCH 02/10] dt-bindings: interconnect: add the Qualcomm SC7280 " Atanas Filipov
2026-11-30 10:57   ` sashiko-bot
2026-11-30 10:49 ` [PATCH 03/10] dt-bindings: interconnect: add the Qualcomm SA8775P " Atanas Filipov
2026-11-30 10:54   ` sashiko-bot
2026-11-30 10:49 ` [PATCH 04/10] media: qcom: cam-icc: add the Titan camera NoC driver Atanas Filipov
2026-11-30 11:18   ` sashiko-bot [this message]
2026-11-30 12:16   ` Bryan O'Donoghue
2026-11-30 12:59     ` Atanas Filipov
2026-11-30 13:22     ` Gjorgji Rosikopulos (Consultant)
2026-11-30 15:22       ` Bryan O'Donoghue
2026-11-30 10:49 ` [PATCH 05/10] media: qcom: cam-icc: add the SM8250 data Atanas Filipov
2026-11-30 10:49 ` [PATCH 06/10] media: qcom: cam-icc: add the SC7280 data Atanas Filipov
2026-11-30 10:49 ` [PATCH 07/10] media: qcom: cam-icc: add the SA8775P data Atanas Filipov
2026-11-30 10:57   ` sashiko-bot
2026-11-30 10:49 ` [PATCH 08/10] arm64: dts: qcom: sm8250: add the Titan camera NoC node Atanas Filipov
2026-11-30 10:49 ` [PATCH 09/10] arm64: dts: qcom: sc7280: " Atanas Filipov
2026-11-30 10:49 ` [PATCH 10/10] arm64: dts: qcom: sa8775p: " Atanas Filipov
2026-11-30 11:01   ` sashiko-bot

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-240939@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.