net: phy: Add driver for Motorcomm Quad 2.5GbE phy
Subsystems (4)
PATCH v15 1/1 net: phy: Add driver for Motorcomm Quad 2.5GbE phy
Add support for Motorcomm YT8824 quad-port 2.5G PHY to the existing motorcomm driver, using the phy_package helpers for the shared top extended register space.
It also adds a new exported phylib helper, genphy_c45_template_testmode().
--- drivers/net/phy/Kconfig | 3 +- drivers/net/phy/motorcomm.c | 1585 ++++++++++++++++++++++++++++++++++- drivers/net/phy/phy-c45.c | 55 ++ include/linux/phy.h | 1 + include/uapi/linux/mdio.h | 12 + 5 files changed, 1653 insertions(+), 3 deletions(-)
drivers/net/phy/Kconfig +2 -1
@@ -361,9 +361,10 @@ config MICROSEMI_PHY config MOTORCOMM_PHY tristate "Motorcomm PHYs" + select PHY_PACKAGE help Enables support for Motorcomm network PHYs. - Currently supports YT85xx Gigabit Ethernet PHYs. + Currently supports YT85xx Gigabit Ethernet PHYs and YT8824 4 * 2.5G PHY. config NATIONAL_PHY tristate "National Semiconductor PHYs"
drivers/net/phy/motorcomm.c +1583 -2
1,662 lines not on this page · raw message
drivers/net/phy/phy-c45.c +55 -0
61 lines not on this page · raw message
include/linux/phy.h +1 -0
@@ -2357,6 +2357,7 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable, int speed);int genphy_c45_pma_resume (struct phy_device *phydev);int genphy_c45_pma_suspend (struct phy_device *phydev);int genphy_c45_fast_retrain (struct phy_device *phydev,bool enable); +int genphy_c45_template_testmode (struct phy_device *phydev,int test_mode);int genphy_c45_plca_get_cfg (struct phy_device *phydev,struct phy_plca_cfg *plca_cfg); int genphy_c45_plca_set_cfg(struct phy_device *phydev,
include/uapi/linux/mdio.h +12 -0
@@ -63,6 +63,7 @@/* Media-dependent registers. */ #define MDIO_PMA_10GBT_SWAPPOL 130/* 10GBASE-T pair swap & polarity */ #define MDIO_PMA_10GBT_TXPWR 131/* 10GBASE-T TX power control */ +#define MDIO_PMA_10GBT_TESTMODE 132/* Test mode control */ #define MDIO_PMA_10GBT_SNR 133/* 10GBASE-T SNR margin, lane A. * Lanes B-D are numbered 134-136. */ #define MDIO_PMA_10GBR_FSRT_CSR 147/* 10GBASE-R fast retrain status and control */
@@ -320,6 +321,17 @@/* PMA 10GBASE-R Fast Retrain status and control register. */ #define MDIO_PMA_10GBR_FSRT_ENABLE 0x0001/* Fast retrain enable */ +/* PMA 10GBASE-T Template Test Mode Register*/ +#define MDIO_PMA_10GBT_TESTMODE_MASK 0xE000/* Template test mode */ +#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0000/* Template Normal */ +#define MDIO_PMA_10GBT_TESTMODE_1 0x2000/* Template TestMode1 */ +#define MDIO_PMA_10GBT_TESTMODE_2 0x4000/* Template TestMode2 */ +#define MDIO_PMA_10GBT_TESTMODE_3 0x6000/* Template TestMode3 */ +#define MDIO_PMA_10GBT_TESTMODE_4 0x8000/* Template TestMode4 */ +#define MDIO_PMA_10GBT_TESTMODE_5 0xa000/* Template TestMode5 */ +#define MDIO_PMA_10GBT_TESTMODE_6 0xc000/* Template TestMode6 */ +#define MDIO_PMA_10GBT_TESTMODE_7 0xe000/* Template TestMode7 */ +/* PCS 10GBASE-R/-T status register 1. */ #define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001/* Block lock attained */
Signature · 1 line
2.25.1
Hi Kyle
Quoted 5 lines · Kyle Switch
Add support for Motorcomm YT8824 quad-port 2.5G PHY to the existing motorcomm driver, using the
phy_packagehelpers for the shared top extended register space.
It also adds a new exported phylib helper,genphy_c45_template_testmode().
[...]
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4482
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+/** +* yt8824_resume() - resume the hardware +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_resume (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret =0 ;
No need to zero-init
Quoted 75 lines
drivers/net/phy/motorcomm.c +75
-0+ +mutex_lock (&priv->shared_lock); + ret =yt8824_power_on (phydev); +mutex_unlock (&priv->shared_lock); + +return ret; +} + +/** +* yt8824_power_down() - set utp power down. +* @phydev: a pointer to a &struct phy_device +* +* NOTE: need WA like softreset +* +* Returns: 0 or negative errno code +*/ +static int yt8824_power_down (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret; +int r; + +if (priv->interface_mode ==PHY_INTERFACE_MODE_INTERNAL ) { +/* invalid test mode */ + ret =yt8824_utp_invalid_test_mode_paged (phydev); +if (ret <0 ) + goto retry; +/* utp power down */ + ret =yt8824_utp_power_down (phydev); +if (ret <0 ) + goto retry; +/* normal mode */ + ret =yt8824_utp_normal_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + }else { +/* invalid test mode */ + ret =yt8824_utp_invalid_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + +/* sds isolation */ + ret =yt8824_sds_isolate_paged (phydev); +if (ret <0 ) + goto retry; + +/* utp power down */ + ret =yt8824_utp_power_down (phydev); +if (ret <0 ) + goto retry; + +/* normal mode */ + ret =yt8824_utp_normal_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + +/* sds soft reset and disable isolation */ + ret =yt8824_sds_isolate_and_softreset_paged (phydev); +if (ret <0 ) + goto retry; + } +return 0 ; + +retry: +/* +* If the PHY down operation succeeds but the subsequent operation +* fails, revert to the default state. +*/ + r =yt8824_utp_power_on (phydev); +if (ret >=0 && r <0 ) + ret = r; + ret =yt8824_restore_working_status (phydev, ret); +return ret; +} +
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4567
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+/** +* yt8824_suspend() - suspend the hardware +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_suspend (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret =0 ;
No need to zero-initialize it
Quoted 35 lines
drivers/net/phy/motorcomm.c +35
-0+ +mutex_lock (&priv->shared_lock); + ret =yt8824_power_down (phydev); +mutex_unlock (&priv->shared_lock); + +return ret; +} + +/** +* yt8824_config_aneg() - config negotiation +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_config_aneg (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int phy_ctrl =0 ; +int ret =0 ; + +mutex_lock (&priv->shared_lock); + ret =phy8824_page_write_with_lock (phydev,YT8824_RSSR_UTP_SPACE ); +if (ret <0 ) + goto err; + +if (linkmode_test_bit (ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + phydev->advertising)) + phy_ctrl =MDIO_AN_10GBT_CTRL_ADV2_5G ; + + ret =phy_modify_mmd_changed (phydev,MDIO_MMD_AN , +MDIO_AN_10GBT_CTRL , +MDIO_AN_10GBT_CTRL_ADV2_5G , + phy_ctrl); +if (ret <0 ) + goto err;
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4612
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+ + ret =__genphy_config_aneg (phydev, ret); + +err: +mutex_unlock (&priv->shared_lock); +return ret; +} + +/** +* yt8824_phy_package_probe_once() - init phy packet for phy8824.
^^ package ?
Quoted 5 lines
+ * @phydev: a pointer to a &struct
phy_device
+ *
+ * Returns: 0 or negative errno code
+ */drivers/net/phy/motorcomm.c +1
-0+static int yt8824_phy_package_probe_once (struct phy_device *phydev)
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4627
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +struct device_node *np =phy_package_get_node (phydev); +const char *interface_mode_name; + +/* Initialise shared lock for YT8824 */ +mutex_init (&priv->shared_lock); + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ; +if (!of_property_read_string (np,"motorcomm,interface-mode" , + &interface_mode_name)) {
I don't see that property documented anywhere in the bindings, and besides that the typical way we deal with quad PHYs is to have each MAC node use QSGMII / USXGMII as their phy-interface-mode. Any reason for needing that at the package level ?
Quoted 8 lines
drivers/net/phy/motorcomm.c +8
-0+if (!strcasecmp (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_USXGMII ))) { + priv->interface_mode =PHY_INTERFACE_MODE_USXGMII ; + }else if (!strcasecmp + (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_INTERNAL ))) { + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ; + }else {
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4645
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+return -EINVAL ; + } + }else { +phydev_warn (phydev,"%s, motorcomm,interface-mode missing in DTS.\n" , + __func__); + } + +return 0 ; +} +
Maxime>
Quoted 14 lines
include/uapi/linux/mdio.h +11
-0+/* PMA 10GBASE-T Template Test Mode Register*/ +#define MDIO_PMA_10GBT_TESTMODE_MASK 0xE000/* Template test mode */ +#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0000/* Template Normal */ +#define MDIO_PMA_10GBT_TESTMODE_1 0x2000/* Template TestMode1 */ +#define MDIO_PMA_10GBT_TESTMODE_2 0x4000/* Template TestMode2 */ +#define MDIO_PMA_10GBT_TESTMODE_3 0x6000/* Template TestMode3 */ +#define MDIO_PMA_10GBT_TESTMODE_4 0x8000/* Template TestMode4 */ +#define MDIO_PMA_10GBT_TESTMODE_5 0xa000/* Template TestMode5 */ +#define MDIO_PMA_10GBT_TESTMODE_6 0xc000/* Template TestMode6 */ +#define MDIO_PMA_10GBT_TESTMODE_7 0xe000/* Template TestMode7 */ +/* PCS 10GBASE-R/-T status register 1. */ #define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001/* Block lock attained */
Quoted 10 lines · Maxime Chevallier
Hi Kyle
Quoted 5 lines · Kyle Switch
Add support for Motorcomm YT8824 quad-port 2.5G PHY to the existing motorcomm driver, using the
phy_packagehelpers for the shared top extended register space.
It also adds a new exported phylib helper,genphy_c45_template_testmode().[...]
Quoted 11 lines
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4482
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+/** +* yt8824_resume() - resume the hardware +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_resume (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret =0 ;No need to zero-init
Ans: will be fixed in next version.
Quoted 79 lines
Quoted 79 lines
drivers/net/phy/motorcomm.c +78
-0+ +mutex_lock (&priv->shared_lock); + ret =yt8824_power_on (phydev); +mutex_unlock (&priv->shared_lock); + +return ret; +} + +/** +* yt8824_power_down() - set utp power down. +* @phydev: a pointer to a &struct phy_device +* +* NOTE: need WA like softreset +* +* Returns: 0 or negative errno code +*/ +static int yt8824_power_down (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret; +int r; + +if (priv->interface_mode ==PHY_INTERFACE_MODE_INTERNAL ) { +/* invalid test mode */ + ret =yt8824_utp_invalid_test_mode_paged (phydev); +if (ret <0 ) + goto retry; +/* utp power down */ + ret =yt8824_utp_power_down (phydev); +if (ret <0 ) + goto retry; +/* normal mode */ + ret =yt8824_utp_normal_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + }else { +/* invalid test mode */ + ret =yt8824_utp_invalid_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + +/* sds isolation */ + ret =yt8824_sds_isolate_paged (phydev); +if (ret <0 ) + goto retry; + +/* utp power down */ + ret =yt8824_utp_power_down (phydev); +if (ret <0 ) + goto retry; + +/* normal mode */ + ret =yt8824_utp_normal_test_mode_paged (phydev); +if (ret <0 ) + goto retry; + +/* sds soft reset and disable isolation */ + ret =yt8824_sds_isolate_and_softreset_paged (phydev); +if (ret <0 ) + goto retry; + } +return 0 ; + +retry: +/* +* If the PHY down operation succeeds but the subsequent operation +* fails, revert to the default state. +*/ + r =yt8824_utp_power_on (phydev); +if (ret >=0 && r <0 ) + ret = r; + ret =yt8824_restore_working_status (phydev, ret); +return ret; +} + +/** +* yt8824_suspend() - suspend the hardware +* @phydev: a pointer to a &struct phy_device
Quoted 8 lines
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4567
Quoted 7 lines
+ *
+ * Returns: 0 or negative errno code
+ */drivers/net/phy/motorcomm.c +4
-0+static int yt8824_suspend (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int ret =0 ;No need to zero-initialize it
Ans: will be fixed in next version.
Quoted 38 lines
Quoted 38 lines
drivers/net/phy/motorcomm.c +38
-0+ +mutex_lock (&priv->shared_lock); + ret =yt8824_power_down (phydev); +mutex_unlock (&priv->shared_lock); + +return ret; +} + +/** +* yt8824_config_aneg() - config negotiation +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_config_aneg (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int phy_ctrl =0 ; +int ret =0 ; + +mutex_lock (&priv->shared_lock); + ret =phy8824_page_write_with_lock (phydev,YT8824_RSSR_UTP_SPACE ); +if (ret <0 ) + goto err; + +if (linkmode_test_bit (ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + phydev->advertising)) + phy_ctrl =MDIO_AN_10GBT_CTRL_ADV2_5G ; + + ret =phy_modify_mmd_changed (phydev,MDIO_MMD_AN , +MDIO_AN_10GBT_CTRL , +MDIO_AN_10GBT_CTRL_ADV2_5G , + phy_ctrl); +if (ret <0 ) + goto err; + + ret =__genphy_config_aneg (phydev, ret); +
Quoted 9 lines
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4612
Quoted 7 lines
drivers/net/phy/motorcomm.c +7
-0+err: +mutex_unlock (&priv->shared_lock); +return ret; +} + +/** +* yt8824_phy_package_probe_once() - init phy packet for phy8824. ^^ package ?
Ans: will be fixed in next version.
Quoted 11 lines
Quoted 11 lines
+ * @phydev: a pointer to a &struct
phy_device
+ *
+ * Returns: 0 or negative errno code
+ */drivers/net/phy/motorcomm.c +7
-0+static int yt8824_phy_package_probe_once (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +struct device_node *np =phy_package_get_node (phydev); +const char *interface_mode_name; + +/* Initialise shared lock for YT8824 */
Quoted 8 lines
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4627
Quoted 4 lines
drivers/net/phy/motorcomm.c +4
-0+mutex_init (&priv->shared_lock); + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ; +if (!of_property_read_string (np,"motorcomm,interface-mode" , + &interface_mode_name)) {I don't see that property documented anywhere in the bindings, and besides that the typical way we deal with quad PHYs is to have each MAC node use QSGMII / USXGMII as their phy-interface-mode. Any reason for needing that at the package level ?
Ans: in the next version,we will add the corresponding dts.
The interface_mode here is used to indicate the current mode of the four ports,
which mainly includes two scenarios: 1. An independent external PHY 8824;
2. Four UTPs embedded in the switch. Different scenarios have somewhat
different processing logic for power down and power up, so an interface_mode
is defined separately here.
Quoted 35 lines
Quoted 10 lines
drivers/net/phy/motorcomm.c +8
-0+if (!strcasecmp (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_USXGMII ))) { + priv->interface_mode =PHY_INTERFACE_MODE_USXGMII ; + }else if (!strcasecmp + (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_INTERNAL ))) { + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ; + }else {drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4645
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+return -EINVAL ; + } + }else { +phydev_warn (phydev,"%s, motorcomm,interface-mode missing in DTS.\n" , + __func__); + } + +return 0 ; +} +Maxime>
Quoted 14 lines
include/uapi/linux/mdio.h +11
-0+/* PMA 10GBASE-T Template Test Mode Register*/ +#define MDIO_PMA_10GBT_TESTMODE_MASK 0xE000/* Template test mode */ +#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0000/* Template Normal */ +#define MDIO_PMA_10GBT_TESTMODE_1 0x2000/* Template TestMode1 */ +#define MDIO_PMA_10GBT_TESTMODE_2 0x4000/* Template TestMode2 */ +#define MDIO_PMA_10GBT_TESTMODE_3 0x6000/* Template TestMode3 */ +#define MDIO_PMA_10GBT_TESTMODE_4 0x8000/* Template TestMode4 */ +#define MDIO_PMA_10GBT_TESTMODE_5 0xa000/* Template TestMode5 */ +#define MDIO_PMA_10GBT_TESTMODE_6 0xc000/* Template TestMode6 */ +#define MDIO_PMA_10GBT_TESTMODE_7 0xe000/* Template TestMode7 */ +/* PCS 10GBASE-R/-T status register 1. */ #define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001/* Block lock attained */
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Critical: 0 · High: 0 · Medium: 2 · Low: 1
- [Medium] New, undocumented device-tree ABI for YT8824.
- [Medium] Lock-initialization race: priv->shared_lock is mutex_init()'d (motorcomm.c:4624) and priv->interface_mode published (4625) *after*…
- [Low] yt8824_restore_working_status()'s kernel-doc summary says "called to do store working status" while the function stores nothing: it…
--
net: phy: Add driver for Motorcomm Quad 2.5GbE phy
This adds support for the Motorcomm YT8824 quad-port 2.5G PHY to the existing motorcomm driver, sharing the top extended register space through the phy_package helpers. It also exports a new phylib helper, genphy_c45_template_testmode(), and adds the 10GBASE-T test mode register definitions to the uapi mdio header.
Quoted 4 lines
drivers/net/phy/motorcomm.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/phy/motorcomm.c +0
-0@@ -626,11 +722,1056 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
[ ... ]
Quoted 6 lines
drivers/net/phy/motorcomm.c +6
-0+/** +* yt8824_restore_working_status() - called to do store working status +* @phydev: a pointer to a &struct phy_device +* @ret: operation's return code +* +* Returns: 0 or negative errno code
drivers/net/phy/motorcomm.c static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) · line 903
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+*/ +static int yt8824_restore_working_status (struct phy_device *phydev,int ret) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +int r; + +/* configure normal test mode */ + r =yt8824_utp_normal_test_mode_paged (phydev); +if (ret >=0 && r <0 ) + ret = r;
[Severity: Low]
This isn't a bug, but the kernel-doc summary says "called to do store working status" while the body stores nothing. It calls yt8824_utp_normal_test_mode_paged() and, for the non-internal interface mode, yt8824_sds_isolate_and_softreset_paged(), so it restores the PHY to its working configuration. Should the summary say something like "restore the PHY working configuration"?
[ ... ]
Quoted 24 lines
drivers/net/phy/motorcomm.c +24
-0+/** +* yt8824_phy_package_probe_once() - init phy packet for phy8824. +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code +*/ +static int yt8824_phy_package_probe_once (struct phy_device *phydev) +{ +struct yt8824_shared_priv *priv =phy_package_get_priv (phydev); +struct device_node *np =phy_package_get_node (phydev); +const char *interface_mode_name; + +/* Initialise shared lock for YT8824 */ +mutex_init (&priv->shared_lock); + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ; +if (!of_property_read_string (np,"motorcomm,interface-mode" , + &interface_mode_name)) { +if (!strcasecmp (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_USXGMII ))) { + priv->interface_mode =PHY_INTERFACE_MODE_USXGMII ; + }else if (!strcasecmp + (interface_mode_name, +phy_modes (PHY_INTERFACE_MODE_INTERNAL ))) { + priv->interface_mode =PHY_INTERFACE_MODE_INTERNAL ;
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4644
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+ }else { +return -EINVAL ; + } + }else { +phydev_warn (phydev,"%s, motorcomm,interface-mode missing in DTS.\n" , + __func__); + } + +return 0 ; +}
[Severity: Medium]
Is there a device tree binding update planned for this? This introduces a new vendor property, motorcomm,interface-mode, read from the PHY package node, with the legal values fixed by phy_modes(PHY_INTERFACE_MODE_USXGMII) and phy_modes(PHY_INTERFACE_MODE_INTERNAL).
The only Motorcomm PHY schema, Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml, is not touched by this patch and lists only:
enum:
- ethernet-phy-id4f51.e91a
- ethernet-phy-id4f51.e91b
so there is no YT8824 compatible (ethernet-phy-id4f51.e8b8), no description of the package node layout, and no description of the new property. Without that, can dt_binding_check or dtbs_check validate boards using this part, and how do device tree authors know which node carries the property?
An in-tree example of a documented vendor property on a PHY package node is Documentation/devicetree/bindings/net/qcom,qca807x.yaml.
Quoted 6 lines
drivers/net/phy/motorcomm.c +6
-0+ +/** +* yt8824_probe() - phy8824 probe. +* @phydev: a pointer to a &struct phy_device +* +* Returns: 0 or negative errno code
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4660
Quoted 10 lines
drivers/net/phy/motorcomm.c +10
-0+*/ +static int yt8824_probe (struct phy_device *phydev) +{ +struct device *dev = &phydev->mdio.dev; +struct yt8824_shared_priv *shared_priv; +int ret; + + ret =devm_of_phy_package_join (dev, phydev,sizeof (*shared_priv)); +if (ret) +return ret;
[Severity: Medium]
Related to the binding question above: this call is unconditional, and of_phy_package_join() in drivers/net/phy/phy_package.c requires a specific, currently undocumented device tree topology:
if (!of_node_name_eq(package_node, "ethernet-phy-package")) {
ret = -EINVAL;It also requires the PHY to have an OF node and the package node to carry a reg property. Does a board that describes this part as four ordinary PHY nodes, or a non-OF system, then fail probe with -EINVAL and leave the ports unusable?
drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4669
Quoted 9 lines
drivers/net/phy/motorcomm.c +9
-0+ +if (phy_package_probe_once (phydev)) { + ret =yt8824_phy_package_probe_once (phydev); +if (ret) +return ret; + } + +return 0 ; +}
[Severity: Medium]
Can a sibling PHY of the same package use priv->shared_lock before it has been initialised?
phy_package_probe_once() is only an election:
drivers/net/phy/phy_package.c:__phy_package_set_once() {
...
return !test_and_set_bit(b, &shared->flags);
...
}It does not wait for the winner to finish, so:
CPU0 CPU1yt8824_probe()
phy_package_probe_once() -> true
yt8824_probe()
phy_package_probe_once() -> false
return 0
phy_probe()
yt8824_get_features()
mutex_lock(&priv->shared_lock);
yt8824_phy_package_probe_once()
mutex_init(&priv->shared_lock);
priv->interface_mode = ...;The shared priv is allocated zeroed by phy_package_join(), so CPU1 would lock a mutex that has not been through mutex_init() and would read priv->interface_mode as 0 (PHY_INTERFACE_MODE_NA), which selects the external SerDes paths in yt8824_config_init() and yt8824_restore_working_status().
dp83640_probe() wraps the same pattern in the package lock for this reason:
drivers/net/phy/dp83640.c:dp83640_probe() {
...
/* Ensure other PHY probes wait for shared clock initialization. */
phy_package_lock(phydev);
if (phy_package_probe_once(phydev))
dp83640_clock_init(clock);
phy_package_unlock(phydev);
...
}Would phy_package_lock()/phy_package_unlock() around the once-block here be appropriate too?
Note also that when the property parse returns -EINVAL, the once bit stays set, so no other port in the package will retry the shared initialisation.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260909074911.2378402-1-kyle.switch%40motor-comm.com