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 3/4] phy: apple: atc: Add initial M3 series support
Date: Sun, 08 Nov 2026 15:56:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-203866@kernel.org> (raw)
In-Reply-To: <20261108-t8122-phy-v1-3-c2783b2a53a8@chaosmail.tech>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] phy: apple: atc: missing power off on RCAL1 timeout in
  atcphy_configure()
- [Low] phy: apple: atc: missing @hw kernel-doc entry in struct
  apple_atcphy
--

commit 70e818649e5b1dc004594c72a6012be4bd8cf369
Author: Sasha Finkelstein <k@chaosmail.tech>

phy: apple: atc: Add initial M3 series support

This commit adds initial USB and Thunderbolt PHY support for the Apple
M3 series (t8122).

> diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c
> index 45f1280a6faa3..256a084996469 100644
> --- a/drivers/phy/apple/atc.c
> +++ b/drivers/phy/apple/atc.c

[ ... ]

> @@ -599,9 +647,10 @@ struct apple_atcphy {
>  		struct apple_tunable *lane_usb4[2];
>  	} tunables;
>  
> +	const struct atcphy_hw *hw;
>  	enum atcphy_mode mode;
> -	bool swap_lanes;
>  	int dp_link_rate;
> +	bool swap_lanes;
>  	bool pipehandler_up;
>  
>  	struct {

[Severity: Low]
struct apple_atcphy has a kernel-doc comment block, so adding hw without
a matching @hw entry triggers a W=1 kernel-doc warning (and later commit
"phy: apple: atc: Add T8122 DisplayPort support" also leaves @hw
undocumented).

[ ... ]

> +static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode)
> +{
> +	int ret = 0;
> +	u32 reg;
> +
> +	lockdep_assert_held(&atcphy->lock);
> +
> +	if (mode == APPLE_ATCPHY_MODE_OFF) {
> +		ret = atcphy_power_off(atcphy);
> +		atcphy->mode = mode;
> +		return ret;
> +	}
> +
> +	ret = atcphy_power_on(atcphy);
> +	if (ret)
> +		return ret;
> +
> +	atcphy_apply_tunables(atcphy, mode);
> +	atcphy->hw->configure_post_tunable(atcphy, mode);
>  
>  	/* Setup AUX channel if DP altmode is requested */
>  	if (atcphy_modes[mode].enable_dp_aux)
>  		atcphy_enable_dp_aux(atcphy);
>  
>  	/* Enable clocks and configure lanes */
> -	core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_PCLK_EN);
> -	core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_REFCLK_EN);
> +	if (atcphy->hw->gen == ATCPHY_GENERATION_T8103) {
> +		core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_PCLK_EN);
> +		core_set32(atcphy, CIO3PLL_CLK_CTRL, CIO3PLL_CLK_REFCLK_EN);
> +	}
>  	atcphy_configure_lanes(atcphy, mode);
>  
>  	/* Take the USB3 PHY out of reset */
>  	core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N);
> +	/*
> +	 * NOTE: Not what macos does, it takes the phy out of reset right before writing to
> +	 * ACIOPHY_CFG0_COMMON_SMALL does lane configuration with phy out of reset, and the poll is
> +	 * right after AUS_COMMON_SHIM_BLK_BIAS_REG write. Does not seem to matter, but if something
> +	 * does not work, consider re-ordering things to macos order.
> +	 */
> +	if (atcphy->hw->gen == ATCPHY_GENERATION_T8122 &&
> +	    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);
> +		if (ret) {
> +			dev_err(atcphy->dev, "Failed to wait for RCAL1 done\n");
> +			return ret;
> +		}
> +	}

[Severity: Medium]
Should this error path call atcphy_power_off(atcphy) before returning?

When readl_poll_timeout() fails here, the PHY has already been powered
on and taken out of reset (ATCPHY_POWER_PHY_RESET_N), while atcphy->mode
remains APPLE_ATCPHY_MODE_OFF.  Because teardown in
atcphy_usb3_power_off() and atcphy_mux_set() (for TYPEC_STATE_SAFE) only
powers down the PHY when atcphy->mode != APPLE_ATCPHY_MODE_OFF, the PHY
and DP AUX stay powered on after disconnect and ATCPHY_POWER_PHY_RESET_N
remains deasserted when tunables are applied on the next connection.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-t8122-phy-v1-0-c2783b2a53a8@chaosmail.tech?part=3

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

  reply	other threads:[~2026-11-08 15:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-08 15:43 [PATCH 0/4] phy: apple: atc: Add M3 support Sasha Finkelstein
2026-11-08 15:43 ` [PATCH 1/4] dt-bindings: phy: atcphy: Add M3 series Sasha Finkelstein
2026-11-08 15:43 ` [PATCH 2/4] soc: apple: tunable: Allow passing NULL to tunable_apply Sasha Finkelstein
2026-11-08 15:48   ` Sven Peter
2026-11-08 15:43 ` [PATCH 3/4] phy: apple: atc: Add initial M3 series support Sasha Finkelstein
2026-11-08 15:56   ` sashiko-bot [this message]
2026-11-08 18:15   ` Sven Peter
2026-11-08 18:17   ` Sven Peter
2026-11-08 18:21     ` Sasha Finkelstein
2026-11-08 18:25       ` Sven Peter
2026-11-08 23:32   ` kernel test robot
2026-11-08 15:43 ` [PATCH 4/4] phy: apple: atc: Add T8122 DisplayPort support Sasha Finkelstein
2026-11-08 16:03   ` 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-203866@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