Devicetree
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: sashiko-reviews@lists.linux.dev
Cc: conor+dt@kernel.org, dri-devel@lists.freedesktop.org,
	robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 11/12] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC
Date: Thu, 9 Jul 2026 14:17:02 +0200	[thread overview]
Message-ID: <cf19aa15-9253-40c3-b86b-c803b3deed84@collabora.com> (raw)
In-Reply-To: <20260709121111.23CC71F000E9@smtp.kernel.org>

On 7/9/26 14:11, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> 
> New issues:
> - [High] Flawed hardware reset sequence and register mask conflict for the new IP (hwip_v1p4) in mtk_dp_encoder_reset().
> - [High] Uninitialized calibration data is applied to PHY registers on MT8196 if a legacy device tree is used.
> 
> Pre-existing issues:
> - [High] Sleeping functions called from atomic context in bridge atomic callbacks.

None of those are valid, if you want more context, check below.

> --
> 
> --- Patch [11]: [PATCH v4 11/12] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC ---
> commit 21e6cb76ec5d736e41c62351d0dcc4f501bc644f
> Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> 
> drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC
> 
> Add support for MediaTek's Embedded DisplayPort (eDP) v1.5 IP as
> found in the MT8196 SoC and other variants, and enclose some of
> the new register writes in specific platform data booleans.
> 
>> --- a/drivers/gpu/drm/mediatek/mtk_dp_reg.h
>> +++ b/drivers/gpu/drm/mediatek/mtk_dp_reg.h
> [ ... ]
>> +#define REG_3FF8_DP_ENC_P0_3			0x1ff8
>> +#define ENC_PHY_STATE_RESET_ALL_MASK			GENMASK(7, 0)
>> +#define PHY_STATE_W_1_DP_ENC_P0_3			BIT(6)
>> +#define DP_ENCODER_DVO_ON_W_1				BIT(5)
>> +#define DP_ENCODER_PSR_XTAL_FREQ_MHZ_MASK		GENMASK(13, 9)
> 
> [ ... ]
> 
>> --- a/drivers/gpu/drm/mediatek/mtk_dp.c
>> +++ b/drivers/gpu/drm/mediatek/mtk_dp.c
> [ ... ]
>> +static void mtk_dp_encoder_reset(struct mtk_dp *mtk_dp)
>> +{
>>   	/* dp tx encoder reset all sw */
>>   	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
>>   			   DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0,
>>   			   DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0);
>>   
>> +	if (mtk_dp->data->hwip_v1p4) {
>> +		mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004, 0,
>> +				   DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0);
>> +		mtk_dp_update_bits(mtk_dp, REG_3FF8_DP_ENC_P0_3,
>> +				   ENC_PHY_STATE_RESET_ALL_MASK,
>> +				   ENC_PHY_STATE_RESET_ALL_MASK);
>> +	}
>> +
>>   	/* Wait for sw reset to complete */
>>   	usleep_range(1000, 5000);
>> -	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
>> -			   0, DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0);
>> +
>> +	if (!mtk_dp->data->hwip_v1p4)
>> +		mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
>> +				   0, DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0);
>> +}
> 
> [Severity: High]
> Does ENC_PHY_STATE_RESET_ALL_MASK overlap with functional state bits
> like PHY_STATE_W_1_DP_ENC_P0_3 and DP_ENCODER_DVO_ON_W_1 defined in
> mtk_dp_reg.h?
> 

That's trolling!!! :-P

Yes, and that's on purpose.

> Also, could the new hwip_v1p4 sequence in mtk_dp_encoder_reset() leave the
> encoder PHY stuck in reset? The code asserts ENC_PHY_STATE_RESET_ALL_MASK
> before the wait, but there does not appear to be a step to deassert it after
> the sleep finishes.
> 

It's ok, because it's auto-cleared by HW.

>> @@ -2860,7 +3079,8 @@ static int mtk_dp_register_phy(struct mtk_dp *mtk_dp)
> [ ... ]
>>   	/* PHY calibration data is in mtk_dp only for legacy devicetree */
>> -	mtk_dp_get_calibration_data(mtk_dp);
>> +	if (mtk_dp->data->efuse_fmt)
>> +		mtk_dp_get_calibration_data(mtk_dp);
>>   
>>   	mtk_dp->phy = devm_phy_get(&mtk_dp->phy_dev->dev, "dp");
> 
> [ ... ]
> 
>> @@ -1359,8 +1550,10 @@ static int mtk_dp_phy_configure(struct mtk_dp *mtk_dp,
> [ ... ]
>>   	/*
>>   	 * For legacy, deprecated strategy, set partial PHY calibration here.
>>   	 * New-style will set all PHY calibrations with phy ops instead.
>>   	 */
>>   	if (mtk_dp->phy_dev)
>>   		mtk_dp_set_calibration_data(mtk_dp);
> 
> [Severity: High]
> If a legacy device tree is used on an MT8196 device, could this configuration
> apply uninitialized zeros to the PHY hardware?

If a legacy device tree is used on MT8196, this MediaTek maintainer (me) needs
a big vacation :-D

This is an impossible scenario.

> 
> In mtk_dp_register_phy(), mtk_dp_get_calibration_data() is skipped because
> efuse_fmt is NULL for mt8196_edp_data. However, mtk_dp_phy_configure() will
> still call mtk_dp_set_calibration_data() if the legacy phy_dev was created,
> potentially writing an unpopulated cal_data array directly to the registers.
> 

The legacy phy_dev can't be created, unless the DT is very-very-very wrong, and
if it is, this driver can't get a magic 8 ball.

>> +static void mtk_dp_encoder_force_bias_power_on(struct mtk_dp *mtk_dp)
>> +{
> [ ... ]
>> +	/* Wait for the MCU to get LDO ready in PHYD */
>> +	msleep(50);
> [ ... ]
>> +}
> 
> [ ... ]
> 
>> @@ -2580,6 +2795,10 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,
> [ ... ]
>>   	/* SDP path reset sw*/
>>   	mtk_dp_sdp_path_reset(mtk_dp);
>>   
>> +	/* Make sure BIAS is powered on after reset even when disabled */
>> +	if (mtk_dp->data->force_pwr_states)
>> +		mtk_dp_encoder_force_bias_power_on(mtk_dp);
>> +
>>   	/* Ensure the sink is muted */
>>   	msleep(20);
>>   }
> 
> [Severity: High]
> This is a pre-existing issue, but does this introduce an additional sleeping
> function into an atomic context path?
> 
> Since mtk_dp_bridge_atomic_disable() operates in an atomic context during
> modesetting, calling mtk_dp_encoder_force_bias_power_on() uses msleep(50),
> which could result in kernel warnings or system instability.
> 

It's not atomic context....

  reply	other threads:[~2026-07-09 12:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:31 [PATCH v4 00/12] drm: MediaTek DisplayPort cleanups and MT8196 eDP AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 01/12] dt-bindings: display: mediatek: dp: Deprecate nvmem efuse data AngeloGioacchino Del Regno
2026-07-11 15:08   ` Krzysztof Kozlowski
2026-07-09 11:31 ` [PATCH v4 02/12] dt-bindings: display: mediatek: dp: Add compatible for MT8196 eDP AngeloGioacchino Del Regno
2026-07-11 15:08   ` Krzysztof Kozlowski
2026-07-09 11:31 ` [PATCH v4 03/12] drm/mediatek: mtk_dp: Call pm_runtime_put_sync() in removal path AngeloGioacchino Del Regno
2026-07-09 11:42   ` sashiko-bot
2026-07-09 11:31 ` [PATCH v4 04/12] drm/mediatek: mtk_dp: Fix hdmi codec and phy driver unregistration AngeloGioacchino Del Regno
2026-07-09 11:48   ` sashiko-bot
2026-07-09 11:31 ` [PATCH v4 05/12] drm/mediatek: mtk_dp: Clarify SMC eDP/DP video unmute commands AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 06/12] drm/mediatek: mtk_dp: Rework register offsets for proper PHY usage AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 07/12] drm/mediatek: mtk_dp: Use PHY API for PHY power sequences AngeloGioacchino Del Regno
2026-07-09 11:53   ` sashiko-bot
2026-07-09 11:31 ` [PATCH v4 08/12] drm/mediatek: mtk_dp: Add support for PHY from devicetree AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 09/12] drm/mediatek: mtk_dp: Move max link rate to SoC specific data AngeloGioacchino Del Regno
2026-07-09 11:53   ` sashiko-bot
2026-07-09 11:31 ` [PATCH v4 10/12] drm/mediatek: mtk_dp: Add support for HotPlug Detection in DP AUX AngeloGioacchino Del Regno
2026-07-09 12:00   ` sashiko-bot
2026-07-09 12:05     ` AngeloGioacchino Del Regno
2026-07-09 11:31 ` [PATCH v4 11/12] drm/mediatek: mtk_dp: Add support for eDP1.5 IPs and MT8196 SoC AngeloGioacchino Del Regno
2026-07-09 12:11   ` sashiko-bot
2026-07-09 12:17     ` AngeloGioacchino Del Regno [this message]
2026-07-09 11:31 ` [PATCH v4 12/12] drm/mediatek: mtk_dp: Clarify XTAL freq and Debounce registers AngeloGioacchino Del Regno
2026-07-09 11:57   ` 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=cf19aa15-9253-40c3-b86b-c803b3deed84@collabora.com \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox