linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bryan O'Donoghue" <bryan.odonoghue@linaro.org>
Cc: olteanv@gmail.com, neil.armstrong@linaro.org,
	devicetree@vger.kernel.org, media-ci@linuxtv.org,
	linux-clk@vger.kernel.org, linux-phy@lists.infradead.org,
	vkoul@kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v17 4/5] media: qcom: camss: Add support for PHY API devices
Date: Sun, 06 Sep 2026 14:32:32 +0000	[thread overview]
Message-ID: <20260906143233.523A21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260906-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v17-4-e2197a3e2551@linaro.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Selects a non-existent Kconfig symbol PHY_QCOM_MIPI_CSI2.
- [High] Hardware PHY state and resources are leaked on early probe and registration error paths.
- [Medium] Missing return value checks for phy_mipi_dphy_get_default_config_for_hsclk() and phy_set_mode() can lead to uninitialized PHY configuration.
--

commit cc3786ea5902bcb687c49374e8e8db29c5127496
Author: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

media: qcom: camss: Add support for PHY API devices

Add the ability to use a PHY pointer which interacts with the standard PHY
API. In the first instance the code will try to use the new PHY interface.
If no PHYs are present in the DT then the legacy method will be attempted.

> diff --git a/drivers/media/platform/qcom/camss/Kconfig b/drivers/media/platform/qcom/camss/Kconfig
> index 4eda48cb1adf0..1edc5e5a1829e 100644
> --- a/drivers/media/platform/qcom/camss/Kconfig
> +++ b/drivers/media/platform/qcom/camss/Kconfig
> @@ -7,3 +7,4 @@ config VIDEO_QCOM_CAMSS
>  	select VIDEO_V4L2_SUBDEV_API
>  	select VIDEOBUF2_DMA_SG
>  	select V4L2_FWNODE
> +	select PHY_QCOM_MIPI_CSI2

[Severity: High]
Does this select a nonexistent config symbol? Selecting a symbol that isn't
defined anywhere in the kernel causes a silent build dependency failure,
which will leave the required PHY infrastructure unbuilt.

[ ... ]

> diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
> index 539ac4888b608..e00748dd83b02 100644
> --- a/drivers/media/platform/qcom/camss/camss-csiphy.c
> +++ b/drivers/media/platform/qcom/camss/camss-csiphy.c

[ ... ]

> @@ -306,11 +308,88 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
> +	link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
> +
> +	if (link_freq < 0) {
> +		dev_err(dev,
> +			"Cannot get CSI2 transmitter's link frequency\n");
> +		return -EINVAL;
> +	}
> +
> +	phy_mipi_dphy_get_default_config_for_hsclk(link_freq, num_lanes, dphy_cfg);
> +
> +	phy_set_mode(csiphy->phy, PHY_MODE_MIPI_DPHY);
> +
> +	ret = phy_configure(csiphy->phy, &dphy_opts);

[Severity: Medium]
Should we check the return values of phy_mipi_dphy_get_default_config_for_hsclk()
and phy_set_mode() here? 

If link_freq evaluates to 0, it appears phy_mipi_dphy_get_default_config_for_hsclk()
could return -EINVAL and leave the output dphy_opts structure zero-filled. Passing
this uninitialized configuration directly to phy_configure() could lead to
erratic hardware behavior.

[ ... ]

> @@ -709,6 +788,56 @@ int msm_csiphy_subdev_init(struct camss *camss,
> +	ret = phy_init(csiphy->phy);
> +	if (ret)
> +		dev_err(dev, "%s init fail %d\n", csiphy->name, ret);
> +
> +done:
> +	return ret;
> +}

[ ... ]

> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 2123f6388e3d7..84097d82d99c9 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c

[ ... ]

> @@ -4832,14 +4890,21 @@ static int camss_init_subdevices(struct camss *camss)
>  	unsigned int i;
>  	int ret;
>  
> +	camss_detect_legacy_phy(camss);
> +
>  	for (i = 0; i < camss->res->csiphy_num; i++) {
> -		ret = msm_csiphy_subdev_init(camss, &camss->csiphy[i],
> -					     &res->csiphy_res[i],
> -					     res->csiphy_res[i].csiphy.id);
> +		if (!camss->legacy_phy) {
> +			ret = msm_csiphy_subdev_init(camss, i);
> +		} else {
> +			ret = msm_csiphy_subdev_init_legacy(camss,
> +							    &camss->csiphy[i],
> +							    &res->csiphy_res[i],
> +							    res->csiphy_res[i].csiphy.id);
> +		}
> +
>  		if (ret < 0) {
> -			dev_err(camss->dev,
> -				"Failed to init csiphy%d sub-device: %d\n",
> -				i, ret);
> +			dev_err(camss->dev, "csiphy %d init fail\n",
> +				res->csiphy_res[i].csiphy.id);
>  			return ret;
>  		}
>  	}

[Severity: High]
Does this error path leak the PHY initialization state?

When msm_csiphy_subdev_init() succeeds, it calls phy_init() to acquire the PHY.
If a subsequent iteration of this loop fails, or if a later initialization step
like camss_probe() fails, the code returns immediately or goes to an error label
without rolling back the previously initialized PHYs (which require phy_exit()).

Additionally, in msm_csiphy_register_entity() located in camss-csiphy.c:

	ret = csiphy_init_formats(sd, NULL);
	if (ret < 0) {
		dev_err(dev, "Failed to init format: %d\n", ret);
		return ret;
	}

A failure here returns early without calling phy_exit(). When the calling code
in camss_register_entities() rolls back, it decrements the index and skips this
failing entity, which seems to permanently leak its PHY initialization state.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260906-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v17-0-e2197a3e2551@linaro.org?part=4

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-09-06 14:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06 14:17 [PATCH v17 0/5] Add phy_get_by_of_node and devm helper Bryan O'Donoghue
2026-09-06 14:17 ` [PATCH v17 1/5] phy: core: Fix use-after-free in phy_get paths Bryan O'Donoghue
2026-09-06 14:17 ` [PATCH v17 2/5] phy: core: Add phy_get_by_of_node() Bryan O'Donoghue
2026-09-06 14:31   ` sashiko-bot
2026-09-06 14:17 ` [PATCH v17 3/5] phy: core: Add devm_phy_get_by_of_node() Bryan O'Donoghue
2026-09-06 14:17 ` [PATCH v17 4/5] media: qcom: camss: Add support for PHY API devices Bryan O'Donoghue
2026-09-06 14:32   ` sashiko-bot [this message]
2026-09-06 14:17 ` [PATCH v17 5/5] media: qcom: camss: Use data-lanes starting at 1 for new CSIPHY mode Bryan O'Donoghue
2026-09-06 14:28   ` sashiko-bot
2026-09-06 15:47   ` Nihal Kumar Gupta

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=20260906143233.523A21F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=media-ci@linuxtv.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).