From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 07/11] drm/mediatek: mtk_dp: Add support for PHY from devicetree
Date: Thu, 09 Jul 2026 10:55:57 +0000 [thread overview]
Message-ID: <20260709105558.9096C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709103431.46616-8-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Double unregister of the PHY platform device in the error path of `mtk_dp_register_phy()`.
- [High] `phy_power_on()` is called before `phy_init()` during eDP probe on new devicetrees.
--
--- Patch [7]: [PATCH v3 07/11] drm/mediatek: mtk_dp: Add support for PHY from devicetree ---
commit 325a8fa9ebb5392753c0df0c9aa94be702f67e6e
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
drm/mediatek: mtk_dp: Add support for PHY from devicetree
This commit adds support for passing a displayport PHY handle from the
devicetree. It introduces a check for the phys property to support newer
configurations while maintaining legacy fallback behavior.
> diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
> index b4cb1996a3314..cabfc833c0a80 100644
> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
[ ... ]
> @@ -2754,6 +2775,7 @@ static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
> return dev_err_probe(dev, ret,
> "Failed to add phy unregister devm action");
>
> + /* PHY calibration data is in mtk_dp only for legacy devicetree */
> mtk_dp_get_calibration_data(mtk_dp);
>
> mtk_dp->phy = devm_phy_get(&mtk_dp->phy_dev->dev, "dp");
[Severity: High]
Could this error path trigger a double-free of the PHY platform device?
In mtk_dp_register_phy(), we register a devres action to unregister the
platform device via mtk_dp_unregister_pdevs(). If devm_phy_get() fails
and we return an error (like -EPROBE_DEFER), the explicit call to
platform_device_unregister() in the error path will free the device. When
the devres cleanup runs later, it will execute mtk_dp_unregister_pdevs()
and call platform_device_unregister() a second time on the same pointer.
[ ... ]
> @@ -2857,9 +2884,18 @@ static int mtk_dp_probe(struct platform_device *pdev)
> "Failed to register audio driver\n");
> }
>
> - ret = mtk_dp_register_phy(mtk_dp);
> - if (ret)
> - return ret;
> + if (!mtk_dp->legacy_regoff) {
> + mtk_dp->phy = devm_phy_get(dev, NULL);
> + if (IS_ERR(mtk_dp->phy))
> + return dev_err_probe(dev, PTR_ERR(mtk_dp->phy),
> + "Failed to get phy\n");
> +
> + mtk_dp->phy_dev = NULL;
[Severity: High]
Are we calling phy_power_on() before phy_init() for eDP displays on new
devicetrees?
During mtk_dp_probe() for eDP connectors, the driver calls
mtk_dp_power_enable() to read the EDID before the bridge is attached.
With the new PHY model, this executes phy_power_on(mtk_dp->phy):
mtk_dp_probe()
mtk_dp_power_enable()
phy_power_on(mtk_dp->phy);
However, phy_init() is not called until mtk_dp_bridge_attach() via
mtk_dp_poweron(). Violating the PHY API contract by powering on before
initialization can cause hardware initialization failures, as clocks
or regulators managed by phy_init() are not yet enabled.
> + } else {
> + ret = mtk_dp_register_phy(mtk_dp);
> + if (ret)
> + return ret;
> + }
>
> mtk_dp->bridge.of_node = dev->of_node;
> mtk_dp->bridge.type = mtk_dp->data->bridge_type;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709103431.46616-1-angelogioacchino.delregno@collabora.com?part=7
next prev parent reply other threads:[~2026-07-09 10:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 10:34 [PATCH v3 00/11] drm: MediaTek DisplayPort cleanups and MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 01/11] dt-bindings: display: mediatek: dp: Deprecate nvmem efuse data AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 02/11] dt-bindings: display: mediatek: dp: Add compatible for MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 03/11] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration AngeloGioacchino Del Regno
2026-07-09 10:46 ` sashiko-bot
2026-07-09 11:10 ` AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 04/11] drm/mediatek: mtk_dp: Clarify SMC eDP/DP video unmute commands AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 05/11] drm/mediatek: mtk_dp: Rework register offsets for proper PHY usage AngeloGioacchino Del Regno
2026-07-09 10:34 ` [PATCH v3 06/11] drm/mediatek: mtk_dp: Use PHY API for PHY power sequences AngeloGioacchino Del Regno
2026-07-09 11:00 ` sashiko-bot
2026-07-09 10:34 ` [PATCH v3 07/11] drm/mediatek: mtk_dp: Add support for PHY from devicetree AngeloGioacchino Del Regno
2026-07-09 10:55 ` sashiko-bot [this message]
2026-07-09 10:34 ` [PATCH v3 08/11] drm/mediatek: mtk_dp: Move max link rate to SoC specific data AngeloGioacchino Del Regno
2026-07-09 10:47 ` sashiko-bot
2026-07-09 10:34 ` [PATCH v3 09/11] drm/mediatek: mtk_dp: Add support for HotPlug Detection in DP AUX AngeloGioacchino Del Regno
2026-07-09 10:49 ` sashiko-bot
2026-07-09 10:34 ` [PATCH v3 10/11] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC AngeloGioacchino Del Regno
2026-07-09 10:51 ` sashiko-bot
2026-07-09 10:34 ` [PATCH v3 11/11] drm/mediatek: mtk_dp: Clarify XTAL freq and Debounce registers AngeloGioacchino Del Regno
2026-07-09 10:42 ` 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=20260709105558.9096C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.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.