All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v5 2/2] phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
Date: Tue, 03 Nov 2026 20:03:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-195954@kernel.org> (raw)
In-Reply-To: <20261103195007.9721-3-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] phy: airoha: use of devm_phy_optional_get() for required qp_phy
- [Medium] phy: airoha: G3_ANA_PXP_JCPLL_SSC_EN not cleared on init or deinit
- [Low] phy: airoha: misuse of dev_err_probe() in an7583_pcie_phy_init()
- [Low] phy: airoha: unused FREQ_LOCK_MAX_ATTEMPT macro and MAINTAINERS order
--

commit 2954f920d212f21a88edba191990e99091d7cd13
Author: Christian Marangi <ansuelsmth@gmail.com>

phy: airoha: add support for AN7583 Gen3 PCIe PHY driver

This commit adds a new PHY driver for the Gen3 PCIe port on the Airoha
AN7583 SoC, implementing its register map and calibration sequence.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 93abbb315065d..fb88a25ce0381 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -788,6 +788,14 @@ F:	Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml
>  F:	drivers/phy/phy-airoha-pcie-regs.h
>  F:	drivers/phy/phy-airoha-pcie.c
>  
> +AIROHA AN7583 PCIE PHY DRIVER
> +M:	Christian Marangi <ansuelsmth@gmail.com>
> +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
> +F:	drivers/phy/airoha/phy-an7583-pcie-regs.h
> +F:	drivers/phy/airoha/phy-an7583-pcie.c
> +
>  AIROHA SOUND DRIVER
>  M:	Christian Marangi <ansuelsmth@gmail.com>
>  L:	linux-sound@vger.kernel.org
[ ... ]
> diff --git a/drivers/phy/airoha/phy-an7583-pcie.c b/drivers/phy/airoha/phy-an7583-pcie.c
> new file mode 100644
> index 0000000000000..f3c42654895f8
> --- /dev/null
> +++ b/drivers/phy/airoha/phy-an7583-pcie.c
> @@ -0,0 +1,823 @@
[ ... ]
> +#include "phy-an7583-pcie-regs.h"
> +
> +#define FREQ_LOCK_MAX_ATTEMPT	50

[Severity: Low]
This isn't a bug, but FREQ_LOCK_MAX_ATTEMPT is defined in
drivers/phy/airoha/phy-an7583-pcie.c without being referenced anywhere in
the driver. Also, in MAINTAINERS, AIROHA AN7583 PCIE PHY DRIVER is placed
after AIROHA PCIE PHY DRIVER; should FREQ_LOCK_MAX_ATTEMPT be dropped and
the MAINTAINERS entry be placed in alphabetical order before AIROHA
ETHERNET DRIVER?

[ ... ]
> +static void an7583_pcie_phy_init_jcpll(struct an7583_pcie_phy *pcie_phy)
> +{
> +	regmap_set_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN);
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_EN);
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SPARE_H,
> +			   G3_ANA_PXP_JCPLL_SPARE_L,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SPARE_L, 0x20));
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_RST_DLY,
> +			G3_ANA_PXP_JCPLL_PLL_RSTB);
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA, 0x0));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA1,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA1, 0x0));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_PERIOD,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_PERIOD, 0x0));
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			  G3_ANA_PXP_JCPLL_SSC_PHASE_INI);
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			  G3_ANA_PXP_JCPLL_SSC_TRI_EN);
[ ... ]
> +static void an7583_pcie_phy_init_ssc_jcpll(struct an7583_pcie_phy *pcie_phy)
> +{
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA, 0x106));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA1,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA1, 0x106));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_PERIOD,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_PERIOD, 0x31B));
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			G3_ANA_PXP_JCPLL_SSC_PHASE_INI);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			G3_ANA_PXP_JCPLL_SSC_EN);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SDM_IFM,
> +			G3_ANA_PXP_JCPLL_SDM_IFM);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SDM_HREN,
> +			G3_ANA_PXP_JCPLL_SDM_HREN);
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_RST_DLY,
> +			  G3_ANA_PXP_JCPLL_SDM_DI_EN);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			G3_ANA_PXP_JCPLL_SSC_TRI_EN);
> +}
[ ... ]
> +static int an7583_pcie_phy_deinit(struct an7583_pcie_phy *pcie_phy)
> +{
> +	/* Disable RX CDR/PR */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_SS_DA_XPON_PWDB_0,
> +			  G3_PMA_DA_XPON_CDR_PR_PWDB);
> +
> +	/* Disable TX PLL output/enable */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_TXPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_TXPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_TXPLL_EN |
> +			  G3_PMA_FORCE_DA_PXP_TXPLL_EN);
> +
> +	/* Disable JCPLL output/enable */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN |
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_EN);
> +
> +	/* Assert PHY resets */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_SW_RST_SET,
> +			  G3_PMA_SW_TX_FIFO_RST_N |
> +			  G3_PMA_SW_ALLPCS_RST_N |
> +			  G3_PMA_SW_PMA_RST_N |
> +			  G3_PMA_SW_TX_RST_N |
> +			  G3_PMA_SW_RX_FIFO_RST_N |
> +			  G3_PMA_SW_XFI_RXPCS_RST_N |
> +			  G3_PMA_SW_REF_RST_N |
> +			  G3_PMA_SW_RX_RST_N);
> +
> +	/* Disable TX analog blocks */
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_TX_CKLDO_EN,
> +			  G3_ANA_PXP_TX_CKLDO_EN |
> +			  G3_ANA_PXP_TX_DMEDGEGEN_EN);
> +
> +	return 0;
> +}

[Severity: Medium]
When an7583_pcie_phy_init() runs, an7583_pcie_phy_init_ssc_jcpll() enables
JCPLL spread-spectrum clocking by setting G3_ANA_PXP_JCPLL_SSC_PHASE_INI
and G3_ANA_PXP_JCPLL_SSC_EN in REG_PXP_JCPLL_VCO_TCLVAR, and
G3_ANA_PXP_JCPLL_SSC_TRI_EN in REG_PXP_JCPLL_SSC_TRI_EN.

However, an7583_pcie_phy_deinit() does not clear these JCPLL SSC bits (in
contrast to airoha_pcie_phy_exit() in drivers/phy/phy-airoha-pcie.c, which
clears CSR_2L_PXP_JCPLL_SSC_PHASE_INI | CSR_2L_PXP_JCPLL_SSC_TRI_EN |
CSR_2L_PXP_JCPLL_SSC_EN), and Phase 1 in an7583_pcie_phy_init_jcpll() only
clears G3_ANA_PXP_JCPLL_SSC_PHASE_INI and G3_ANA_PXP_JCPLL_SSC_TRI_EN
without clearing G3_ANA_PXP_JCPLL_SSC_EN.

If the PHY is re-initialized after phy_exit() or after a failed phy_init()
attempt (or if the bootloader left JCPLL SSC enabled), will
G3_ANA_PXP_JCPLL_SSC_EN remain set during Phase 1 JCPLL and TXPLL
configuration when SSC is supposed to be disabled?

> +
> +static int an7583_pcie_phy_init(struct phy *phy)
> +{
[ ... ]
> +	ret = phy_init(pcie_phy->qp_phy);
> +	if (ret) {
> +		an7583_pcie_phy_deinit(pcie_phy);
> +
> +		return dev_err_probe(pcie_phy->dev, ret, "failed to initialize QP phy\n");
> +	}

[Severity: Low]
Is dev_err_probe() appropriate inside the phy_ops .init callback
an7583_pcie_phy_init()?

Because an7583_pcie_phy_init() runs when a consumer PCIe controller driver
calls phy_init() after an7583_pcie_phy_probe() has already bound
pcie_phy->dev, calling dev_err_probe(pcie_phy->dev, ret, ...) will suppress
error messages completely if ret is -ENOMEM, or downgrade the message to
dev_dbg() and allocate pcie_phy->dev->p->deferred_probe_reason on an
already-bound device if ret is -EPROBE_DEFER. Should this use dev_err()
instead?

[ ... ]
> +static int an7583_pcie_phy_probe(struct platform_device *pdev)
> +{
> +	struct an7583_pcie_phy *pcie_phy;
> +	struct device *dev = &pdev->dev;
> +	struct phy_provider *provider;
> +
> +	pcie_phy = devm_kzalloc(dev, sizeof(*pcie_phy), GFP_KERNEL);
> +	if (!pcie_phy)
> +		return -ENOMEM;
> +
> +	pcie_phy->g3_ana = an7583_pcie_phy_regmap_init(pdev, "g3-ana");
> +	if (IS_ERR(pcie_phy->g3_ana))
> +		return dev_err_probe(dev, PTR_ERR(pcie_phy->g3_ana),
> +				     "Failed to initialize g3 ANA regmap\n");
> +
> +	pcie_phy->qp_phy = devm_phy_optional_get(dev, NULL);
> +	if (IS_ERR(pcie_phy->qp_phy))
> +		return dev_err_probe(dev, PTR_ERR(pcie_phy->qp_phy),
> +				     "Failed to get QP PCIe phy\n");

[Severity: Medium]
Should an7583_pcie_phy_probe() use devm_phy_get() instead of
devm_phy_optional_get() for pcie_phy->qp_phy?

In Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml,
phys is a required property because QPHY configuration is needed during the
PCIe PHY setup and calibration phase. With devm_phy_optional_get(dev, NULL),
a missing phys property or a disabled QPHY node in DeviceTree causes
_of_phy_get() to return ERR_PTR(-ENODEV), which devm_phy_optional_get()
turns into NULL. Both an7583_pcie_phy_probe() and phy_init(pcie_phy->qp_phy)
in an7583_pcie_phy_init() will then succeed silently without initializing
the required QPHY.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103195007.9721-1-ansuelsmth@gmail.com?part=2

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v5 2/2] phy: airoha: add support for AN7583 Gen3 PCIe PHY driver
Date: Tue, 03 Nov 2026 20:03:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-195954@kernel.org> (raw)
In-Reply-To: <20261103195007.9721-3-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] phy: airoha: use of devm_phy_optional_get() for required qp_phy
- [Medium] phy: airoha: G3_ANA_PXP_JCPLL_SSC_EN not cleared on init or deinit
- [Low] phy: airoha: misuse of dev_err_probe() in an7583_pcie_phy_init()
- [Low] phy: airoha: unused FREQ_LOCK_MAX_ATTEMPT macro and MAINTAINERS order
--

commit 2954f920d212f21a88edba191990e99091d7cd13
Author: Christian Marangi <ansuelsmth@gmail.com>

phy: airoha: add support for AN7583 Gen3 PCIe PHY driver

This commit adds a new PHY driver for the Gen3 PCIe port on the Airoha
AN7583 SoC, implementing its register map and calibration sequence.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 93abbb315065d..fb88a25ce0381 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -788,6 +788,14 @@ F:	Documentation/devicetree/bindings/phy/airoha,en7581-pcie-phy.yaml
>  F:	drivers/phy/phy-airoha-pcie-regs.h
>  F:	drivers/phy/phy-airoha-pcie.c
>  
> +AIROHA AN7583 PCIE PHY DRIVER
> +M:	Christian Marangi <ansuelsmth@gmail.com>
> +L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml
> +F:	drivers/phy/airoha/phy-an7583-pcie-regs.h
> +F:	drivers/phy/airoha/phy-an7583-pcie.c
> +
>  AIROHA SOUND DRIVER
>  M:	Christian Marangi <ansuelsmth@gmail.com>
>  L:	linux-sound@vger.kernel.org
[ ... ]
> diff --git a/drivers/phy/airoha/phy-an7583-pcie.c b/drivers/phy/airoha/phy-an7583-pcie.c
> new file mode 100644
> index 0000000000000..f3c42654895f8
> --- /dev/null
> +++ b/drivers/phy/airoha/phy-an7583-pcie.c
> @@ -0,0 +1,823 @@
[ ... ]
> +#include "phy-an7583-pcie-regs.h"
> +
> +#define FREQ_LOCK_MAX_ATTEMPT	50

[Severity: Low]
This isn't a bug, but FREQ_LOCK_MAX_ATTEMPT is defined in
drivers/phy/airoha/phy-an7583-pcie.c without being referenced anywhere in
the driver. Also, in MAINTAINERS, AIROHA AN7583 PCIE PHY DRIVER is placed
after AIROHA PCIE PHY DRIVER; should FREQ_LOCK_MAX_ATTEMPT be dropped and
the MAINTAINERS entry be placed in alphabetical order before AIROHA
ETHERNET DRIVER?

[ ... ]
> +static void an7583_pcie_phy_init_jcpll(struct an7583_pcie_phy *pcie_phy)
> +{
> +	regmap_set_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN);
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_EN);
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SPARE_H,
> +			   G3_ANA_PXP_JCPLL_SPARE_L,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SPARE_L, 0x20));
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_RST_DLY,
> +			G3_ANA_PXP_JCPLL_PLL_RSTB);
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA, 0x0));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA1,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA1, 0x0));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_PERIOD,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_PERIOD, 0x0));
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			  G3_ANA_PXP_JCPLL_SSC_PHASE_INI);
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			  G3_ANA_PXP_JCPLL_SSC_TRI_EN);
[ ... ]
> +static void an7583_pcie_phy_init_ssc_jcpll(struct an7583_pcie_phy *pcie_phy)
> +{
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA, 0x106));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			   G3_ANA_PXP_JCPLL_SSC_DELTA1,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_DELTA1, 0x106));
> +	regmap_update_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_DELTA,
> +			   G3_ANA_PXP_JCPLL_SSC_PERIOD,
> +			   FIELD_PREP(G3_ANA_PXP_JCPLL_SSC_PERIOD, 0x31B));
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			G3_ANA_PXP_JCPLL_SSC_PHASE_INI);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_VCO_TCLVAR,
> +			G3_ANA_PXP_JCPLL_SSC_EN);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SDM_IFM,
> +			G3_ANA_PXP_JCPLL_SDM_IFM);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SDM_HREN,
> +			G3_ANA_PXP_JCPLL_SDM_HREN);
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_RST_DLY,
> +			  G3_ANA_PXP_JCPLL_SDM_DI_EN);
> +	regmap_set_bits(pcie_phy->g3_ana, REG_PXP_JCPLL_SSC_TRI_EN,
> +			G3_ANA_PXP_JCPLL_SSC_TRI_EN);
> +}
[ ... ]
> +static int an7583_pcie_phy_deinit(struct an7583_pcie_phy *pcie_phy)
> +{
> +	/* Disable RX CDR/PR */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_SS_DA_XPON_PWDB_0,
> +			  G3_PMA_DA_XPON_CDR_PR_PWDB);
> +
> +	/* Disable TX PLL output/enable */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_TXPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_TXPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_TXPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_TXPLL_EN |
> +			  G3_PMA_FORCE_DA_PXP_TXPLL_EN);
> +
> +	/* Disable JCPLL output/enable */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_FORCE_DA_PXP_JCPLL_CKOUT_EN,
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_JCPLL_CKOUT_EN |
> +			  G3_PMA_FORCE_SEL_DA_PXP_JCPLL_EN |
> +			  G3_PMA_FORCE_DA_PXP_JCPLL_EN);
> +
> +	/* Assert PHY resets */
> +	regmap_clear_bits(pcie_phy->g3_pma, REG_SW_RST_SET,
> +			  G3_PMA_SW_TX_FIFO_RST_N |
> +			  G3_PMA_SW_ALLPCS_RST_N |
> +			  G3_PMA_SW_PMA_RST_N |
> +			  G3_PMA_SW_TX_RST_N |
> +			  G3_PMA_SW_RX_FIFO_RST_N |
> +			  G3_PMA_SW_XFI_RXPCS_RST_N |
> +			  G3_PMA_SW_REF_RST_N |
> +			  G3_PMA_SW_RX_RST_N);
> +
> +	/* Disable TX analog blocks */
> +	regmap_clear_bits(pcie_phy->g3_ana, REG_PXP_TX_CKLDO_EN,
> +			  G3_ANA_PXP_TX_CKLDO_EN |
> +			  G3_ANA_PXP_TX_DMEDGEGEN_EN);
> +
> +	return 0;
> +}

[Severity: Medium]
When an7583_pcie_phy_init() runs, an7583_pcie_phy_init_ssc_jcpll() enables
JCPLL spread-spectrum clocking by setting G3_ANA_PXP_JCPLL_SSC_PHASE_INI
and G3_ANA_PXP_JCPLL_SSC_EN in REG_PXP_JCPLL_VCO_TCLVAR, and
G3_ANA_PXP_JCPLL_SSC_TRI_EN in REG_PXP_JCPLL_SSC_TRI_EN.

However, an7583_pcie_phy_deinit() does not clear these JCPLL SSC bits (in
contrast to airoha_pcie_phy_exit() in drivers/phy/phy-airoha-pcie.c, which
clears CSR_2L_PXP_JCPLL_SSC_PHASE_INI | CSR_2L_PXP_JCPLL_SSC_TRI_EN |
CSR_2L_PXP_JCPLL_SSC_EN), and Phase 1 in an7583_pcie_phy_init_jcpll() only
clears G3_ANA_PXP_JCPLL_SSC_PHASE_INI and G3_ANA_PXP_JCPLL_SSC_TRI_EN
without clearing G3_ANA_PXP_JCPLL_SSC_EN.

If the PHY is re-initialized after phy_exit() or after a failed phy_init()
attempt (or if the bootloader left JCPLL SSC enabled), will
G3_ANA_PXP_JCPLL_SSC_EN remain set during Phase 1 JCPLL and TXPLL
configuration when SSC is supposed to be disabled?

> +
> +static int an7583_pcie_phy_init(struct phy *phy)
> +{
[ ... ]
> +	ret = phy_init(pcie_phy->qp_phy);
> +	if (ret) {
> +		an7583_pcie_phy_deinit(pcie_phy);
> +
> +		return dev_err_probe(pcie_phy->dev, ret, "failed to initialize QP phy\n");
> +	}

[Severity: Low]
Is dev_err_probe() appropriate inside the phy_ops .init callback
an7583_pcie_phy_init()?

Because an7583_pcie_phy_init() runs when a consumer PCIe controller driver
calls phy_init() after an7583_pcie_phy_probe() has already bound
pcie_phy->dev, calling dev_err_probe(pcie_phy->dev, ret, ...) will suppress
error messages completely if ret is -ENOMEM, or downgrade the message to
dev_dbg() and allocate pcie_phy->dev->p->deferred_probe_reason on an
already-bound device if ret is -EPROBE_DEFER. Should this use dev_err()
instead?

[ ... ]
> +static int an7583_pcie_phy_probe(struct platform_device *pdev)
> +{
> +	struct an7583_pcie_phy *pcie_phy;
> +	struct device *dev = &pdev->dev;
> +	struct phy_provider *provider;
> +
> +	pcie_phy = devm_kzalloc(dev, sizeof(*pcie_phy), GFP_KERNEL);
> +	if (!pcie_phy)
> +		return -ENOMEM;
> +
> +	pcie_phy->g3_ana = an7583_pcie_phy_regmap_init(pdev, "g3-ana");
> +	if (IS_ERR(pcie_phy->g3_ana))
> +		return dev_err_probe(dev, PTR_ERR(pcie_phy->g3_ana),
> +				     "Failed to initialize g3 ANA regmap\n");
> +
> +	pcie_phy->qp_phy = devm_phy_optional_get(dev, NULL);
> +	if (IS_ERR(pcie_phy->qp_phy))
> +		return dev_err_probe(dev, PTR_ERR(pcie_phy->qp_phy),
> +				     "Failed to get QP PCIe phy\n");

[Severity: Medium]
Should an7583_pcie_phy_probe() use devm_phy_get() instead of
devm_phy_optional_get() for pcie_phy->qp_phy?

In Documentation/devicetree/bindings/phy/airoha,an7583-pcie-gen3-phy.yaml,
phys is a required property because QPHY configuration is needed during the
PCIe PHY setup and calibration phase. With devm_phy_optional_get(dev, NULL),
a missing phys property or a disabled QPHY node in DeviceTree causes
_of_phy_get() to return ERR_PTR(-ENODEV), which devm_phy_optional_get()
turns into NULL. Both an7583_pcie_phy_probe() and phy_init(pcie_phy->qp_phy)
in an7583_pcie_phy_init() will then succeed silently without initializing
the required QPHY.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103195007.9721-1-ansuelsmth@gmail.com?part=2

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

  reply	other threads:[~2026-11-03 20:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 19:49 [PATCH v5 0/2] phy: airoha: add support for AN7583 PCIe PHY driver Christian Marangi
2026-11-03 19:49 ` Christian Marangi
2026-11-03 19:49 ` [PATCH v5 1/2] dt-bindings: phy: airoha: Document support for AN7583 Gen3 PCIe PHY Christian Marangi
2026-11-03 19:49   ` Christian Marangi
2026-11-03 19:58   ` sashiko-bot
2026-11-03 19:58     ` sashiko-bot
2026-11-04 16:35   ` Rob Herring (Arm)
2026-11-04 16:35     ` Rob Herring (Arm)
2026-11-03 19:50 ` [PATCH v5 2/2] phy: airoha: add support for AN7583 Gen3 PCIe PHY driver Christian Marangi
2026-11-03 19:50   ` Christian Marangi
2026-11-03 20:03   ` sashiko-bot [this message]
2026-11-03 20: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-195954@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 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.