Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sasha Finkelstein" <k@chaosmail.tech>
Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v2 4/5] phy: apple: atc: Add T8122 DisplayPort support
Date: Sun, 22 Nov 2026 12:44:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-227933@kernel.org> (raw)
In-Reply-To: <20261122-t8122-phy-v2-4-8d5c8fdf31ba@chaosmail.tech>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] phy: apple: atc: missing RCAL1 poll for DP mode in
  atcphy_wait_rcal1_done_t8122()
- [Medium] phy: apple: atc: incomplete lane reconfiguration in
  atcphy_sw_set()
--

commit 82ef5fe4b6ea8a9fcb315bd8a7aac593736df7fc
Author: Ramzi Abdiche <abdicheramzi@gmail.com>

phy: apple: atc: Add T8122 DisplayPort support

This commit adds DisplayPort AUX and link setup support for T8122-family
Type-C PHYs and stops active DisplayPort lanes before changing cable
orientation.

> diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c
> index 398b2be5dd116..647093bb70f1b 100644
> --- a/drivers/phy/apple/atc.c
> +++ b/drivers/phy/apple/atc.c
[ ... ]
> @@ -1931,10 +2483,8 @@ static void atcphy_configure_post_tunable_t8103(struct apple_atcphy *atcphy, enu
>  	udelay(10);
>  }
>  
> -static void atcphy_configure_post_tunable_t8122(struct apple_atcphy *atcphy, enum atcphy_mode mode)
> +static void atcphy_power_on_common_t8122(struct apple_atcphy *atcphy)
>  {
> -	if (atcphy_modes[mode].pipehandler_state != ATCPHY_PIPEHANDLER_STATE_USB3)
> -		return;
>  	core_set32(atcphy, ACIOPHY_CFG0, ACIOPHY_CFG0_COMMON_SMALL);
>  	udelay(10);
>  	core_set32(atcphy, ACIOPHY_CFG0, ACIOPHY_CFG0_COMMON_SMALL_OV);

[Severity: Medium]
Should atcphy_wait_rcal1_done_t8122() also poll AUS_COMMON_DIG_RCAL1 when
DisplayPort is enabled?

With atcphy_hw_t8122.dp set in this patch,
atcphy_configure_post_tunable_t8122() calls atcphy_power_on_common_t8122()
whenever atcphy_modes[mode].enable_dp_aux is true, including in 4-lane
APPLE_ATCPHY_MODE_DP where pipehandler_state is
ATCPHY_PIPEHANDLER_STATE_DUMMY:

drivers/phy/apple/atc.c:atcphy_configure_post_tunable_t8122() {
	if (atcphy_modes[mode].pipehandler_state == ATCPHY_PIPEHANDLER_STATE_USB3 ||
	    (atcphy->hw->dp && atcphy_modes[mode].enable_dp_aux))
		atcphy_power_on_common_t8122(atcphy);
}

drivers/phy/apple/atc.c:atcphy_wait_rcal1_done_t8122() {
	...
	if (atcphy_modes[mode].pipehandler_state == ATCPHY_PIPEHANDLER_STATE_USB3) {
		ret = readl_poll_timeout(atcphy->regs.core + AUS_COMMON_DIG_RCAL1, reg,
					 (reg & AUS_COMMON_DIG_RCAL1_ALL_CODES_DONE), 10, 100000);
	...
}

Because atcphy_wait_rcal1_done_t8122() only checks for
ATCPHY_PIPEHANDLER_STATE_USB3, configuring APPLE_ATCPHY_MODE_DP powers on
the AUS common block and releases PHY reset without waiting for resistor
calibration to finish.

Also, the hunk introducing the new atcphy_configure_post_tunable_t8122()
that calls atcphy_power_on_common_t8122() and dereferences atcphy->hw->dp
was placed in the earlier commit "phy: apple: atc: Add initial M3 series
support", which breaks git bisect compilation at that commit.

[ ... ]

> @@ -2290,20 +2855,32 @@ static int atcphy_probe_rcdev(struct apple_atcphy *atcphy)
>  static int atcphy_sw_set(struct typec_switch_dev *sw, enum typec_orientation orientation)
>  {
>  	struct apple_atcphy *atcphy = typec_switch_get_drvdata(sw);
> +	bool swap_lanes;
> +	int ret;
>  
>  	guard(mutex)(&atcphy->lock);
>  
>  	switch (orientation) {
>  	case TYPEC_ORIENTATION_NONE:
> -		break;
> +		return 0;
>  	case TYPEC_ORIENTATION_NORMAL:
> -		atcphy->swap_lanes = false;
> +		swap_lanes = false;
>  		break;
>  	case TYPEC_ORIENTATION_REVERSE:
> -		atcphy->swap_lanes = true;
> +		swap_lanes = true;
>  		break;
> +	default:
> +		return -EINVAL;
>  	}
>  
> +	/* Cleanup needs the old lane configuration until shutdown succeeds. */
> +	if (swap_lanes != atcphy->swap_lanes && atcphy->hw->dp && atcphy->hw->dp->stop) {
> +		ret = atcphy->hw->dp->stop(atcphy);
> +		if (ret)
> +			return ret;
> +	}
> +	atcphy->swap_lanes = swap_lanes;
> +
>  	return 0;
>  }

[Severity: Medium]
If orientation changes while atcphy->mode != APPLE_ATCPHY_MODE_OFF, does
stopping only the DisplayPort link leave the PHY crossbar and lane modes
programmed for the old orientation?

atcphy_sw_set() updates atcphy->swap_lanes without reconfiguring the PHY or
resetting atcphy->mode, and atcphy_mux_set() skips atcphy_configure() when
atcphy->mode already matches target_mode:

drivers/phy/apple/atc.c:atcphy_mux_set() {
	...
	if (atcphy->mode == target_mode)
		return 0;

	...
	return atcphy_configure(atcphy, target_mode);
}

When atcphy_dp_set_rate_t8122() subsequently starts the DisplayPort link,
it selects PMA lanes from atcphy_get_mode_config() using the new
atcphy->swap_lanes value while aciophy_crossbar, aciophy_lane_mode,
ATCPHY_MISC_LANE_SWAP, and lane tunables remain configured for the previous
orientation, leaving DisplayPort and USB3 non-functional.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-t8122-phy-v2-0-8d5c8fdf31ba@chaosmail.tech?part=4

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

  reply	other threads:[~2026-11-22 12:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 12:27 [PATCH v2 0/5] phy: apple: atc: Add M3 support Sasha Finkelstein
2026-11-22 12:27 ` [PATCH v2 1/5] dt-bindings: phy: atcphy: Add M3 series Sasha Finkelstein
2026-11-22 12:27 ` [PATCH v2 2/5] soc: apple: tunable: Allow passing NULL to tunable_apply Sasha Finkelstein
2026-11-22 12:27 ` [PATCH v2 3/5] phy: apple: atc: Add initial M3 series support Sasha Finkelstein
2026-11-22 12:35   ` sashiko-bot
2026-11-22 12:28 ` [PATCH v2 4/5] phy: apple: atc: Add T8122 DisplayPort support Sasha Finkelstein
2026-11-22 12:44   ` sashiko-bot [this message]
     [not found] ` <20261122-t8122-phy-v2-5-8d5c8fdf31ba@chaosmail.tech>
2026-11-22 12:35   ` [PATCH v2 5/5] phy: apple: atc: Split generation-specific code 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-227933@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=k@chaosmail.tech \
    --cc=linux-phy@lists.infradead.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