Skip to contentSkip to conversation

net: phy: Add driver for Motorcomm Quad 2.5GbE phy

PATCH Superseded Kyle Switch 5 participants 13 messages Sep 17 – Sep 23

Subsystems (5)

v20 of 29 Superseded Latest is v29 →

lore
Share & tools
lore
#0 lore raw

v20 cover net: phy: Add driver for Motorcomm Quad 2.5GbE phy

changes in v20:
patch 1: Add phy-mode description in properties in

	 motorcomm,yt8824.yaml

changes in v19:
patch 2: Replace the int type with the u16 type for test_mode. patch 3: 1) Merge yt8824_utp_normal_test_mode_paged() and

         yt8824_utp_invalid_test_mode_paged() into 
         yt8824_utp_set_template_test_mode().

2) Add a fatal error return when phy-mode is missing in the DTS.

changes in v18:
1. Split the template_testmode() into a small patch and optimize the implementation.
2. Optimize the definition and initialization of interface_mode by adopting the existing approach.

changes in v17:
patch 1: Remove redundant description.
Use phy-mode instead of motorcomm,interface to describe the interface.
Add the required checks.
patch 2: Use phy-mode to get interface mode.
Need return after init configuration is done to avoid falling into the error path.

changes in v16:
1. Add DTS documentation.
2. Fix redundant initialization.

changes in v14:
1. Refactor the error return path to preserve and return the initial error, rather than letting later errors mask it.

changes in v13:
1. Fix the lock release issue on the error path to prevent potential deadlock or resource leak.
2. Add a func yt8824_restore_defaults() to restore configuration on the error path,ensuring the hardware/device is left in a known good state upon failure.

changes in v12:
1. Refactor the yt8824_read_status() function to ensure proper state synchronization between hardware registers and the phy_device structure.

changes in v11:
1. Clean build_clang warning.

changes in v10:
1. Within the interface that swaps to the USXGMII reg space,the lock include shared_lock and mdio mutex must remain held throughout the entire operation and should only be released after all steps have completed.
2. Improve the template interface in phy-c45.c
3. Fix the handling of some failure paths.

changes in v9:
1. Add shared_lock mutex prevents UTPs from interfering with each other due to swapping reg space.

change in v8:
1. Clean up format warning.
2. Fix exception handling code logic based on Sashiko/Gemini.
3. Remove interrupt/handle function

changes in v7:
1. Refactor the using of mdio lock
In all cases of swapping to the USXGMII side interface, lock the MDIO bus at the beginning, switch to the UTP address space after the operation is completed, and then release the lock.The purpose of doing this is to ensure that it will not affect other UTPs operating in the UTP address space.
2. Rename YT8824_RSSR_FIBER_SPACE to YT8824_RSSR_USXGMII_SPACE.

changes in v6:
1. Add test mode helper in phy-c45.c
2. Refactor the using of swapping paged for utp and fiber

changes in v5:
1. Fix diffs issue which caused by unexpected whitespace.
2. Fix "exceeding 80 columns" warning.

changes in v4:
1. Remove motorcomm,yt8xxx.yaml, will update in other patch thread
2. Fix locking issue. Since every interface requires switching of space, the bus is already locked during the space switching process in phy_select_page(), other operations within the interface cannot be locked again before unlock in phy_restore_page().
3. Fix warning log identified during the inspection process using checkpatch.pl.
4. Fix the way of using common api in phy_package.c

changes in v3:
1. Using common apis defined in phy_package.c to handle shared top extend register space.
2. Add dts demo in motorcomm,yt8xxx.yaml.
3. Fix unnecessary redundant judgments.
4. Fix BMCR registers operation using magic number.
5. Rename function based on its approximate functionality.

changes in v2:
1. Remove duplicate code and replace it with existing api.

Kyle Switch (3):
dt-bindings: net: Document Motorcomm YT8824 PHY package
net: phy: Add support for Template Control register for PMA
net: phy: Add driver for Motorcomm Quad 2.5GbE phy

 .../bindings/net/motorcomm,yt8824.yaml        |   62 +
 drivers/net/phy/Kconfig                       |    3 +-
 drivers/net/phy/motorcomm.c                   | 1575 ++++++++++++++++-
 drivers/net/phy/phy-c45.c                     |   23 +
 include/linux/phy.h                           |    1 +
 include/uapi/linux/mdio.h                     |   12 +
 6 files changed, 1673 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
Signature · 1 line
2.25.1
#1 lore raw

PATCH v20 1/3 dt-bindings: net: Document Motorcomm YT8824 PHY package

Motorcomm YT8824 Ethernet PHY is PHY package of 4 PHY-s.

---
 .../bindings/net/motorcomm,yt8824.yaml        | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +62 -0
new file mode 100644
index 000000000000..9737364744a0
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MotorComm YT8824 Ethernet PHY
+
+maintainers:
+  - Kyle Switch <[email protected]>
+
+description:
+  Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.
+
+$ref: ethernet-phy-package.yaml#
+
+properties:
+  compatible:
+    enum:
+      - motorcomm,yt8824-package
+  phy-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [ internal, usxgmii ]
+
+required:
+  - compatible
+  - phy-mode
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy-package@0 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "motorcomm,yt8824-package";
+            reg = <9>;
+
+            phy-mode = "internal";
+
+            ethernet-phy@4 {
+                reg = <4>;
+            };
+
+            ethernet-phy@5 {
+                reg = <5>;
+            };
+
+            ethernet-phy@6 {
+                reg = <6>;
+            };
+
+            ethernet-phy@7 {
+                reg = <7>;
+            };
+        };
+    };
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH net-next v20 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dt-bindings: unit-address mismatch with reg property in example --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dt-bindings: unit-address mismatch with reg property in example
--

commit 21a69a542a09b6b2571122c2f9f0dadf390d6020
Author: Kyle Switch <[email protected]>

dt-bindings: net: Document Motorcomm YT8824 PHY package

This commit introduces device tree binding documentation for the Motorcomm YT8824 Ethernet PHY, describing it as a package of 4 PHYs.

Quoted 5 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +0 -0
new file mode 100644
index 0000000000000..9737364744a07

[ ... ]

Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml line 42

Quoted 11 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +11 -0
+examples:
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy-package@0 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "motorcomm,yt8824-package";
+            reg = <9>;

[Severity: Low]
Does this unit-address cause a validation warning during make dt_binding_check? The node name uses @0, but the reg property is assigned <9>. This mismatch typically triggers a unit_address_vs_reg warning from the dtc compiler.

Quoted 2 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +2 -0
+
+            phy-mode = "internal";
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH net-next v20 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package

In reply to Kyle Switch
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 2

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [Medium] The single example in the new binding is self-inconsistent and contradicts the semantics it inherits: the package node is named…
- [Medium] The binding redefines the standard, MAC-side property phy- mode on a PHY *package* node with its own type reference (`$ref:…
- [Medium] The package-level phy-mode enum is limited to [internal, usxgmii].
- [Low] The new binding file Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml is not…
- [Low] Concern (judged a false positive at end of series): the binding requires phy-mode on the package node and defines compatible…

--

dt-bindings: net: Document Motorcomm YT8824 PHY package

This adds a new binding for the Motorcomm YT8824, described as a PHY package containing four PHYs. The binding references ethernet-phy-package.yaml and adds a package-level phy-mode property with the values internal and usxgmii.

A few questions about the new schema below.

Quoted 6 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +0 -0
new file mode 100644
index 0000000000000..9737364744a07

Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml line 10

Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +10 -0
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/motorcomm,yt8824.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MotorComm YT8824 Ethernet PHY
+
+maintainers:
+  - Kyle Switch <[email protected]>

[Severity: Low]
Should MAINTAINERS gain an entry for this file? The MOTORCOMM PHY DRIVER section currently lists the binding literally:

MOTORCOMM PHY DRIVER
M: Frank <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
F: drivers/net/phy/motorcomm.c

That pattern does not match motorcomm,yt8824.yaml, and no other section matches it either, so get_maintainer.pl will not report the Motorcomm PHY maintainer for future changes to this file. Widening the existing entry to Documentation/devicetree/bindings/net/motorcomm,yt8*.yaml, or adding a new
F: line, would cover it.

Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml line 23

Quoted 13 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +13 -0
+
+description:
+  Motorcomm YT8824 Ethernet PHY is a PHY package of 4 PHYs.
+
+$ref: ethernet-phy-package.yaml#
+
+properties:
+  compatible:
+    enum:
+      - motorcomm,yt8824-package
+  phy-mode:
+    $ref: /schemas/types.yaml#/definitions/string
+    enum: [ internal, usxgmii ]

[Severity: Medium]
Is phy-mode the right property name here, and is internal a valid value for this device?

phy-mode is owned by ethernet-controller.yaml, as an alias of phy-connection-type, and internal is defined there as:

# There is not a standard bus between the MAC and the PHY, # something proprietary is being used to embed the PHY in the # MAC.
- internal

The YT8824 is a discrete package addressed over MDIO, so that definition does not appear to describe it. The driver added later in the series keys hardware bring-up off this value:

  drivers/net/phy/motorcomm.c:yt8824_config_init() {
      if (priv->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
          ret = yt8824_internal_config_init_paged(phydev);
      ...
  }

so the standard property name is being given a vendor-specific meaning that the schema does not state. The property is also added with no description and placed in required:, which freezes it as ABI.

The closest peer binding, qcom,qca807x.yaml (which also references ethernet-phy-package.yaml), uses a vendor-prefixed property with an explicit mode table instead:

qcom,package-mode:
description: |
PHY package can be configured in 3 mode following this table:

Would a described, vendor-prefixed property such as motorcomm,package-mode be a better fit than overloading phy-mode?

[Severity: Medium]
Separately, is usxgmii the correct wire format for this package?

If the four 2.5G ports are multiplexed onto a single 10G SerDes uplink, the kernel's interface mode for that format is 10g-qxgmii (PHY_INTERFACE_MODE_10G_QXGMII), and ethernet-controller.yaml lists the two as distinct values:

- usxgmii
- 10gbase-r
- 25gbase-r
- 10g-qxgmii

A MAC configured from phy-mode = "usxgmii" would program a single-channel USXGMII PCS, which would leave the remaining three ports without a channel.

If the chip instead exposes four independent USXGMII lanes, a single package-wide string cannot express which PHY sits on which lane, and the binding defines no property for that mapping. I could not determine the host topology from the series: the only SerDes setup for the non-internal mode is preamble padding in yt8824_extern_config_sds_init_paged(), which is consistent with either arrangement.

Could the description: state the host-side topology explicitly?

Quoted 9 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +9 -0
+
+required:
+  - compatible
+  - phy-mode
+  - reg
+
+unevaluatedProperties: false
+
+examples:

Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml line 42

Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +10 -0
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet-phy-package@0 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "motorcomm,yt8824-package";
+            reg = <9>;

[Severity: Medium]
Two things about this node.

First, the unit address is @0 while reg = <9>. Should the node be named ethernet-phy-package@9 so the unit address matches the first reg entry? As written, two YT8824 packages on the same bus would both be named ethernet-phy-package@0, which collides under the -Wunique_unit_address_if_enabled used by Documentation/devicetree/bindings/Makefile.

Second, is reg = <9> consistent with the meaning inherited from ethernet-phy-package.yaml?

reg:
minimum: 0
maximum: 31
description:
The base ID number for the PHY package. Commonly the ID of the first PHY in the PHY package.

Here all four members are at 4, 5, 6 and 7, i.e. below the declared base, and phylib only ever forms member addresses by adding an unsigned offset to the base:

  drivers/net/phy/phy_package.c:phy_package_address() {
      u8 base_addr = shared->base_addr;
      if (addr_offset >= PHY_MAX_ADDR - base_addr)
          return -EIO;
      return base_addr + addr_offset;

}

so no member of this example is reachable as base + offset.

The driver added later in the series treats the package reg as the absolute MDIO address of the shared top-extended register block, at offset 0:

  drivers/net/phy/motorcomm.c:ytphy_write_top_ext() {
      /*
       * The package base address is used here to read the top ext registers.
       * For example, in internal mode, the top ext address is fixed at 9;
       */
      ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
      ...
  }

If that is the intended meaning, should this binding add its own reg:
description overriding the base-ID wording? A DT author following the inherited text and writing reg = <4> would have of_phy_package_join() store 4 as base_addr, and the page-select and page-data writes above would then land on the member PHY at address 4 instead of the package register block.

Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml line 52

Quoted 10 lines
Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml new file +10 -0
+
+            phy-mode = "internal";
+
+            ethernet-phy@4 {
+                reg = <4>;
+            };
+
+            ethernet-phy@5 {
+                reg = <5>;
+            };

[ ... ]

For reference, the binding file is unchanged by the remaining two patches in the series, so nothing later adjusts the example or the phy-mode wording.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260917131441.3428554-1-kyle.switch%40motor-comm.com
maintainer
#4 lore raw

Re: [PATCH net-next v20 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package

Quoted 7 lines

MOTORCOMM PHY DRIVER
M: Frank <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
F: drivers/net/phy/motorcomm.c

Quoted 5 lines

That pattern does not match motorcomm,yt8824.yaml, and no other section matches it either, so get_maintainer.pl will not report the Motorcomm PHY maintainer for future changes to this file. Widening the existing entry to Documentation/devicetree/bindings/net/motorcomm,yt8*.yaml, or adding a new
F: line, would cover it.

Please do fix this.

Andrew

#5 lore raw

Re: [PATCH net-next v20 1/3] dt-bindings: net: Document Motorcomm YT8824 PHY package

Quoted 7 lines · Andrew Lunn
Quoted 7 lines

MOTORCOMM PHY DRIVER
M: Frank <[email protected]>
L: [email protected]
S: Maintained
F: Documentation/devicetree/bindings/net/motorcomm,yt8xxx.yaml
F: drivers/net/phy/motorcomm.c

Quoted 6 lines
Quoted 5 lines

That pattern does not match motorcomm,yt8824.yaml, and no other section matches it either, so get_maintainer.pl will not report the Motorcomm PHY maintainer for future changes to this file. Widening the existing entry to Documentation/devicetree/bindings/net/motorcomm,yt8*.yaml, or adding a new
F: line, would cover it.

Please do fix this.

Ans: okay, Another question I'd like to ask is whether all the risk issues

flagged by sashiko need to be resolved. Some of the flags may not actually

be bugs, and some that are clearly meaningful have been fixed

one after another previously, so what I want to know is whether everything

flagged by sashiko has to be cleared. Thank you.

Quoted 2 lines

Andrew

#6 lore raw

PATCH v20 2/3 net: phy: Add support for Template Control register for PMA

In reply to Kyle Switch

Add support for the 10GBASE-T PMA Template Test Mode register field, which allows selecting one of eight test modes (Normal and TestMode1..TestMode7) used for PHY validation.

---
 drivers/net/phy/phy-c45.c | 23 +++++++++++++++++++++++
 include/linux/phy.h       |  1 +
 include/uapi/linux/mdio.h | 12 ++++++++++++
 3 files changed, 36 insertions(+)
drivers/net/phy/phy-c45.c +23 -0
index 870920311f9a..c5f5753f7194 100644
@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)
 }
 EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);
 
+/**
+ * genphy_c45_template_testmode - configure template testmode registers
+ * @phydev: target phy_device struct
+ * @test_mode: testmode includes Normal to Test mode 7
+ *
+ * Description: Set template testmode include Normal to Test mode 7
+ *
+ * Return: 0 on success, or a negative error code on failure (e.g. register
+ * read/write error).
+ */
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
+{
+	u16 ctrl;
+
+	if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
+		return -EOPNOTSUPP;
+
+	ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);
+	return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+			      MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);
+
 /**
  * genphy_c45_plca_get_cfg - get PLCA configuration from standard registers
  * @phydev: target phy_device struct
include/linux/phy.h +1 -0
index 3d8afe6b7f1c..2db804b8fd4d 100644
@@ -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, u16 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
index 06f4bc3c20c7..353ca13c64fc 100644
@@ -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 GENMASK(15, 13) /* Template test mode */
+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */
+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */
+#define MDIO_PMA_10GBT_TESTMODE_2 0x2 /* Template TestMode2 */
+#define MDIO_PMA_10GBT_TESTMODE_3 0x3 /* Template TestMode3 */
+#define MDIO_PMA_10GBT_TESTMODE_4 0x4 /* Template TestMode4 */
+#define MDIO_PMA_10GBT_TESTMODE_5 0x5 /* Template TestMode5 */
+#define MDIO_PMA_10GBT_TESTMODE_6 0x6 /* Template TestMode6 */
+#define MDIO_PMA_10GBT_TESTMODE_7 0x7 /* 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
#7 lore raw

Re: [PATCH net-next v20 2/3] net: phy: Add support for Template Control register for PMA

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] uapi: testmode mask uses kernel-only GENMASK macro - [Low] net: phy: missing linux/bitfield.h…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] uapi: testmode mask uses kernel-only GENMASK macro
- [Low] net: phy: missing linux/bitfield.h include for FIELD_PREP
--

commit b5c025498496747ab794fc2b34dd0903358ffea9
Author: Kyle Switch <[email protected]>

net: phy: Add support for Template Control register for PMA

This commit adds support for the 10GBASE-T PMA Template Test Mode register field. It introduces configuration functions and macro definitions to allow selecting test modes used for PHY validation.

Quoted 4 lines
drivers/net/phy/phy-c45.c +0 -0
index 870920311f9a0..c5f5753f7194b 100644

[ ... ]

drivers/net/phy/phy-c45.c int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable) · line 1428

Quoted 8 lines
drivers/net/phy/phy-c45.c +8 -0
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
+{
+	u16 ctrl;
+
+	if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
+		return -EOPNOTSUPP;
+
+	ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);

[Severity: Low]
Does genphy_c45_template_testmode() rely on an implicit inclusion of linux/bitfield.h? Using FIELD_PREP without explicitly including its required header might lead to build failures if header dependencies change in the future or on certain architectures.

Quoted 4 lines
drivers/net/phy/phy-c45.c +4 -0
+	return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+			      MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);

[ ... ]

Quoted 4 lines
include/uapi/linux/mdio.h +0 -0
index 06f4bc3c20c71..353ca13c64fca 100644

[ ... ]

include/uapi/linux/mdio.h line 325

Quoted 6 lines
include/uapi/linux/mdio.h +2 -0
@@ -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 GENMASK(15, 13) /* Template test mode */

[Severity: High]
Can this macro break userspace compilation? GENMASK is a kernel-only construct, so defining a UAPI macro with it could cause a build regression for userspace applications that include linux/mdio.h and evaluate MDIO_PMA_10GBT_TESTMODE_MASK.

Quoted 2 lines
include/uapi/linux/mdio.h +2 -0
+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */
+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#8 lore raw

Re: [PATCH net-next v20 2/3] net: phy: Add support for Template Control register for PMA

In reply to Kyle Switch
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…

Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] DISCARDED (resolved later in the series):
genphy_c45_template_testmode() has no in-tree caller at this commit,…
- [Low] include/uapi/linux/mdio.h:325 defines the newly exported macro MDIO_PMA_10GBT_TESTMODE_MASK as GENMASK(15, 13).

--

net: phy: Add support for Template Control register for PMA

This adds a new phylib helper, genphy_c45_template_testmode(), which writes the 10GBASE-T PMA template test mode field, along with the register and field definitions in the exported mdio.h header. Eight values are defined, Normal plus TestMode1 through TestMode7.

Two small observations below.

Quoted 20 lines
drivers/net/phy/phy-c45.c +12 -0
index 870920311f9a0..c5f5753f7194b 100644
@@ -1408,6 +1408,29 @@ int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable)
 }
 EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain);
 
+/**
+ * genphy_c45_template_testmode - configure template testmode registers
+ * @phydev: target phy_device struct
+ * @test_mode: testmode includes Normal to Test mode 7
+ *
+ * Description: Set template testmode include Normal to Test mode 7
+ *
+ * Return: 0 on success, or a negative error code on failure (e.g. register
+ * read/write error).
+ */
+int genphy_c45_template_testmode(struct phy_device *phydev, u16 test_mode)
+{

drivers/net/phy/phy-c45.c int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable) · line 1432

Quoted 10 lines
drivers/net/phy/phy-c45.c +10 -0
+	u16 ctrl;
+
+	if (test_mode > MDIO_PMA_10GBT_TESTMODE_7)
+		return -EOPNOTSUPP;
+
+	ctrl = FIELD_PREP(MDIO_PMA_10GBT_TESTMODE_MASK, test_mode);
+	return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TESTMODE,
+			      MDIO_PMA_10GBT_TESTMODE_MASK, ctrl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_template_testmode);

[Severity: Low]
This isn't a bug, just a note for the record. At this commit genphy_c45_template_testmode() has no in-tree caller.

The following patch in the series, "net: phy: Add driver for Motorcomm Quad 2.5GbE phy", adds the consumers, for example in yt8824_utp_set_template_test_mode():

	return genphy_c45_template_testmode(phydev, test_mode);

along with uses of MDIO_PMA_10GBT_TESTMODE_1 and MDIO_PMA_10GBT_TESTMODE_NORMAL in yt8824_soft_reset() and yt8824_restore_working_status(), so the transient state resolves within the series.

Quoted 4 lines
include/uapi/linux/mdio.h +0 -0
index 06f4bc3c20c71..353ca13c64fca 100644

[ ... ]

include/uapi/linux/mdio.h line 325

Quoted 6 lines
include/uapi/linux/mdio.h +2 -0
@@ -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 GENMASK(15, 13) /* Template test mode */

[Severity: Low]
Can userspace expand this new mask? GENMASK() comes from the kernel-only include/linux/bits.h, and the exported header only pulls in:

	#include <linux/types.h>
	#include <linux/mii.h>

Neither uapi mii.h nor uapi ethtool.h defines GENMASK or BIT, so a userspace translation unit that includes <linux/mdio.h> and actually uses MDIO_PMA_10GBT_TESTMODE_MASK, for instance in a constant initializer, would fail to compile with GENMASK undeclared.

Would __GENMASK() from include/uapi/linux/bits.h, or a plain 0xe000, be preferable here?

The in-kernel user in phy-c45.c is unaffected, since it reaches GENMASK and FIELD_PREP through the in-kernel linux/mdio.h chain. Note the header already carries a few bare GENMASK() uses that predate this patch, so this is an existing wart in the file rather than newly broken userspace, but new uapi additions probably should not repeat it.

Quoted 2 lines
include/uapi/linux/mdio.h +2 -0
+#define MDIO_PMA_10GBT_TESTMODE_NORMAL 0x0 /* Template Normal */
+#define MDIO_PMA_10GBT_TESTMODE_1 0x1 /* Template TestMode1 */

[ ... ]

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260917131441.3428554-1-kyle.switch%40motor-comm.com
#9 lore raw

PATCH v20 3/3 net: phy: Add driver for Motorcomm Quad 2.5GbE phy

In reply to Kyle Switch

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.

---
 drivers/net/phy/Kconfig     |    3 +-
 drivers/net/phy/motorcomm.c | 1575 ++++++++++++++++++++++++++++++++++-
 2 files changed, 1575 insertions(+), 3 deletions(-)
drivers/net/phy/Kconfig +2 -1
index d3835597e379..996d75afed44 100644
@@ -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 +1573 -2

1,652 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw
Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider.

Critical: 0 · High: 0 · Medium: 6 · Low: 3

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [Medium] The YT8824 driver silently redefines the meaning of the PHY- package 'reg' property: ytphy_read_top_ext()/ytphy_write_top_ext()…
- [Medium] yt8824_phy_package_probe_once() takes the PHY-to-MAC interface mode exclusively from a new 'phy-mode' property on the PHY *package*…
- [Medium] yt8824_config_aneg() programs the 2.5G advertisement (MDIO_AN_10GBT_CTRL_ADV2_5G) solely from phydev->advertising, ignoring…
- [Medium] yt8824_read_status_paged() unconditionally overwrites the link state computed by genphy_read_status() with the current vendor…
- [Medium] yt8824_probe() consumes the package one-shot flag (phy_package_probe_once() is a bare test_and_set_bit()) before running…
- [Medium] The package-shared mutex priv->shared_lock and priv->interface_mode are initialized inside…
- [Low] Concern (assessed FALSE POSITIVE): 'YT8824 support is advertised without disclosing that the driver can only bind from an ethernet-phy-…
- [Low] The YT8824 binding example names the package node 'ethernet-phy- package@0' while declaring 'reg = <9>'.
- [Low] yt8824_read_status_paged() calls genphy_c45_read_lpa() whenever phydev->autoneg_complete is set (without requiring phydev->autoneg ==…

--

net: phy: Add driver for Motorcomm Quad 2.5GbE phy

Adds support for the Motorcomm YT8824 quad-port 2.5G PHY to the existing motorcomm driver. The shared "Common Top Extended" register block is reached through the phy_package helpers, and a package-shared mutex plus a package-level phy-mode property drive the internal/usxgmii init paths.

A few questions below about the register-space addressing, the interface mode source, the read_status/config_aneg paths and the package probe sequencing.

Quoted 4 lines
drivers/net/phy/motorcomm.c +0 -0
index 90a4f86f2758b..7ab09666ab3f4 100644

[ ... ]

Quoted 10 lines
drivers/net/phy/motorcomm.c +6 -0
@@ -399,6 +425,12 @@ struct yt8521_priv {
 	u8 reg_page;
 };
 
+struct yt8824_shared_priv {
+	phy_interface_t interface_mode;
+	/* shared_lock used to UTPs operation isolation during swap reg space */
+	struct mutex shared_lock;
+};
+

[ ... ]

Quoted 17 lines
drivers/net/phy/motorcomm.c +16 -0
@@ -437,6 +469,78 @@ static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum)
+/**
+ * ytphy_read_top_ext() - read a PHY's top extended register for YT8824
+ * @phydev: a pointer to a &struct phy_device
+ * @regnum: register number to read
+ *
+ * Returns: the value of regnum reg or negative error code
+ */
+static int ytphy_read_top_ext(struct phy_device *phydev, u16 regnum)
+{
+	int ret;
+
+	/*
+	 * The package base address is used here to read the top ext registers.
+	 * For example, in internal mode, the top ext address is fixed at 9;
+	 * for usxgmii, the offset is 4. Instead of using the offset approach
+	 * a fixed address is used here to avoid situations such as when phy0

drivers/net/phy/motorcomm.c static int ytphy_read_ext_with_lock(struct phy_device *phydev, u16 regnum) · line 494

Quoted 10 lines
drivers/net/phy/motorcomm.c +10 -0
+	 * is not in use, where the top ext register address cannot be obtained
+	 * correctly.
+	 */
+	lockdep_assert_held(&phydev->mdio.bus->mdio_lock);
+	ret = __phy_package_write(phydev, 0, YTPHY_PAGE_SELECT, regnum);
+	if (ret < 0)
+		return ret;
+
+	return __phy_package_read(phydev, 0, YTPHY_PAGE_DATA);
+}

[Severity: Medium]
This uses package offset 0, so the address used for the top extended block is whatever of_phy_package_join() took verbatim from the package node:

drivers/net/phy/phy_package.c:of_phy_package_join() {
	...
	if (of_property_read_u32(package_node, "reg", &base_addr))
	...
}

Documentation/devicetree/bindings/net/ethernet-phy-package.yaml describes that property as:

reg:
minimum: 0
maximum: 31
description:
The base ID number for the PHY package. Commonly the ID of the first PHY in the PHY package.

The new motorcomm,yt8824.yaml lists reg as required but does not re-describe or constrain it, while the comment above states the hardware requirement (address 9 in internal mode, first PHY + 4 for usxgmii).

If a device tree follows the documented meaning and sets reg to the address of the first PHY, do ytphy_read_top_ext()/ytphy_write_top_ext() then write YTPHY_PAGE_SELECT/YTPHY_PAGE_DATA (0x1e/0x1f) into an unrelated sibling PHY? That would make every page switch through yt8824_read_page(), yt8824_write_page() and phy8824_page_write_with_lock() silently ineffective while clobbering another port's extended registers, and the efuse reads in yt8824_extern_config_sds_init_paged() would come from the wrong device.

Should the binding document and constrain reg for this device, or should the driver derive the top extended address rather than assuming package offset 0?

[ ... ]

Quoted 1 line
drivers/net/phy/motorcomm.c +0 -0
@@ -622,15 +726,1045 @@ static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)

[ ... ]

Quoted 11 lines
drivers/net/phy/motorcomm.c +9 -1
+static int yt8824_config_init(struct phy_device *phydev)
+{
+	struct yt8824_shared_priv *priv = phy_package_get_priv(phydev);
+	int ret;
+
+	mutex_lock(&priv->shared_lock);
+	if (priv->interface_mode == PHY_INTERFACE_MODE_INTERNAL) {
+		ret = yt8824_internal_config_init_paged(phydev);
 		if (ret < 0)
-			goto err_restore_page;
+			goto err;

drivers/net/phy/motorcomm.c static int ytphy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) · line 1760

Quoted 10 lines
drivers/net/phy/motorcomm.c +9 -0
+	} else {
+		ret = yt8824_extern_config_sds_init_paged(phydev);
+		if (ret < 0)
+			goto err;
+		ret = yt8824_extern_config_utp_init_paged(phydev);
+		if (ret < 0)
+			goto err;
 	}
+	mutex_unlock(&priv->shared_lock);
+	ret = yt8824_soft_reset(phydev);

[Severity: Medium]
This branch, and the same test in yt8824_soft_reset(), yt8824_power_on(), yt8824_power_down() and yt8824_restore_working_status(), uses only priv->interface_mode, which comes from a new phy-mode property on the PHY package node. phydev->interface is never consulted, even though phylib has already resolved it per port from the MAC's phy-mode/phy-connection-type by the time config_init runs.

Can these two descriptions of the same link disagree? A device tree whose MAC node says usxgmii while the package node says internal would run yt8824_internal_config_init_paged() and skip the SerDes isolate/soft-reset sequences in soft_reset/resume/suspend, with config_init still returning 0 and no diagnostic.

Also, the new property is per-package while phydev->interface is per-port, so a per-port difference cannot be expressed at all. Since this adds a new DT ABI that duplicates information phylib already has (qca807x used a vendor-specific qcom,package-mode property instead), would using phydev->interface here work?

[ ... ]

Quoted 1 line
drivers/net/phy/motorcomm.c +0 -0
@@ -3104,6 +4238,426 @@ static int yt8821_resume(struct phy_device *phydev)

[ ... ]

Quoted 9 lines
drivers/net/phy/motorcomm.c +9 -0
+static int yt8824_read_status_paged(struct phy_device *phydev)
+{
+	int link = 0;
+	int ret = 0;
+	int val = 0;
+
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		return ret;

drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4318

Quoted 10 lines
drivers/net/phy/motorcomm.c +10 -0
+
+	ret = genphy_read_status(phydev);
+	if (ret < 0)
+		return ret;
+
+	if (phydev->autoneg_complete) {
+		ret = genphy_c45_read_lpa(phydev);
+		if (ret < 0)
+			return ret;
+	}

[Severity: Low]
This tests only phydev->autoneg_complete, not phydev->autoneg. With "ethtool -s ethX autoneg off speed 1000 duplex full", clause 22 autonegotiation is still running (genphy_check_and_restart_aneg() leaves ANENABLE set), so BMSR_ANEGCOMPLETE and therefore autoneg_complete become 1 while phydev->autoneg is AUTONEG_DISABLE.

genphy_read_status() deliberately clears the pause state for that case:

drivers/net/phy/phy_device.c:genphy_read_status() {
	...
	phydev->pause = false;
	phydev->asym_pause = false;
	...
	if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete)
		phy_resolve_aneg_linkmode(phydev);
	else if (phydev->autoneg == AUTONEG_DISABLE)
		err = genphy_read_status_fixed(phydev);
	...
}

genphy_c45_read_lpa() then sets phydev->pause from LPA_PAUSE_CAP again. Should the call be gated on phydev->autoneg == AUTONEG_ENABLE too?

Quoted 7 lines
drivers/net/phy/motorcomm.c +7 -0
+
+	ret = phy_read(phydev, YTPHY_SPECIFIC_STATUS_REG);
+	if (ret < 0)
+		return ret;
+
+	val = ret;
+

drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4335

Quoted 10 lines
drivers/net/phy/motorcomm.c +10 -0
+	link = val & YTPHY_SSR_LINK;
+	if (link)
+		yt8821_adjust_status(phydev, val);
+
+	if (link) {
+		if (phydev->link == 0)
+			phydev_dbg(phydev, "%s, phy addr: %d, link up\n",
+				   __func__, phydev->mdio.addr);
+		phydev->link = 1;
+	} else {

[Severity: Medium]
Here the link state computed by genphy_read_status() is replaced by the current vendor status bit. genphy_update_link() keeps the latched-low BMSR indication in polling mode (and forces link = 0 while BMCR_ANRESTART is set) so that a drop between two polls is observable.

If a cable is unplugged and replugged between two 1 second polls, does this sequence lose the transition?

genphy_update_link() -> phydev->link = 0 (latched BMSR)
yt8824_read_status_paged() -> YTPHY_SSR_LINK set, phydev->link = 1
phy_check_link_status() -> link && state == PHY_RUNNING, no branch taken

drivers/net/phy/phy.c:phy_check_link_status() {
	if (phydev->link && phydev->state != PHY_RUNNING) {
	...
		phy_link_up(phydev);
	} else if (!phydev->link && phydev->state != PHY_NOLINK) {
	...
}

yt8821_adjust_status() has already updated phydev->speed/duplex, so if the new speed differs the MAC keeps its old configuration and phy_link_up() is never called. The same overwrite exists in the older yt8521/yt8821 helpers, but this is new code; could the generic link-down result be preserved instead of being promoted back to link up?

Quoted 8 lines
drivers/net/phy/motorcomm.c +8 -0
+		if (phydev->link == 1)
+			phydev_dbg(phydev, "%s, phy addr: %d, link down\n",
+				   __func__, phydev->mdio.addr);
+		phydev->link = 0;
+	}
+	phy_resolve_aneg_pause(phydev);
+	return 0;
+}

[ ... ]

Quoted 11 lines
drivers/net/phy/motorcomm.c +11 -0
+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;
+
+	mutex_lock(&priv->shared_lock);
+	ret = phy8824_page_write_with_lock(phydev, YT8824_RSSR_UTP_SPACE);
+	if (ret < 0)
+		goto err;
+

drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4601

Quoted 10 lines
drivers/net/phy/motorcomm.c +10 -0
+	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);

[Severity: Medium]
The 2.5G advertisement is programmed from phydev->advertising alone, without looking at phydev->autoneg or phydev->speed. Is the forced speed still honoured in this case?

"ethtool -s ethX autoneg off speed 1000 duplex full" keeps the 2500baseT_Full bit in phydev->advertising:

drivers/net/phy/phy.c:phy_ethtool_ksettings_set() {
	...
	linkmode_copy(phydev->advertising, advertising);
	...
}

so MDIO_AN_10GBT_CTRL_ADV2_5G is set here, and __genphy_config_aneg() then takes the forced-speed path which only rewrites the clause 22 registers:

drivers/net/phy/phy_device.c:__genphy_config_aneg() {
	...
	} else {
		linkmode_zero(fixed_advert);
		c = phy_caps_lookup(phydev->speed, phydev->duplex,
				    phydev->supported, true);
		if (c)
			linkmode_and(fixed_advert, phydev->supported,
				     c->linkmodes);
		advert = fixed_advert;
	}
	...
}

Nothing clears the 2.5G advertisement, so can the port still negotiate 2.5G with a capable partner after 1000/full was forced? Should ADV2_5G be cleared when autoneg is disabled and the forced speed is not 2500?

Quoted 23 lines
drivers/net/phy/motorcomm.c +23 -0
+
+err:
+	mutex_unlock(&priv->shared_lock);
+	return ret;
+}
+
+/**
+ * yt8824_phy_package_probe_once()  - init phy package 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);
+	int res;
+
+	if (!priv || !np) {
+		phydev_err(phydev, "%s: missing shared priv or DT node\n",
+			   __func__);
+		return -EINVAL;
+	}

drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4634

Quoted 10 lines
drivers/net/phy/motorcomm.c +10 -0
+	/* Initialise shared lock for YT8824 */
+	mutex_init(&priv->shared_lock);
+	res = of_get_phy_mode(np, &priv->interface_mode);
+	if (res < 0) {
+		phydev_warn(phydev, "%s, phy-mode missing in DTS.\n", __func__);
+		return res;
+	}
+
+	return 0;
+}

[Severity: Medium]
mutex_init(&priv->shared_lock) and the write of priv->interface_mode happen without the package lock held. phy_package_probe_once() is only a test_and_set_bit(), so it guarantees single execution but provides no mutual exclusion and no ordering for the other package members:

drivers/net/phy/phy_package.c:phy_package_probe_once() {
	return __phy_package_set_once(phydev, 1);
}

A sibling whose probe sees the bit already set returns immediately, and phy_probe() then calls yt8824_get_features(), which does mutex_lock(&priv->shared_lock). Can that run on a mutex whose wait_lock and wait_list are still the zeroed memory from the kzalloc'ed shared priv, and can interface_mode be read before it is written?

dp83640 wraps the same sequence:

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 the same phy_package_lock()/phy_package_unlock() pairing be appropriate here?

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 4650

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: Low]
This isn't a bug, but the join is unconditional, so a YT8824 that is not described under an ethernet-phy-package node cannot bind and fails with -EINVAL from of_phy_package_join(). That matches qca807x_probe(), which also calls devm_of_phy_package_join() unconditionally, and the requirement is documented by motorcomm,yt8824.yaml added earlier in the series. Would it be worth saying in the commit message that the YT8824 binds only from a PHY package topology?

drivers/net/phy/motorcomm.c static int yt8821_resume(struct phy_device *phydev) · line 4659

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]
The one-shot bit is consumed before the fallible initialization runs, and nothing puts it back if yt8824_phy_package_probe_once() fails.

of_get_phy_mode() leaves *interface untouched on error and the shared priv is kzalloc'ed, so priv->interface_mode stays PHY_INTERFACE_MODE_NA (0) when the phy-mode lookup fails. If a sibling of the same package already holds a reference, that sibling skips initialization entirely and runs with interface_mode == NA.

Every later test is of the form:

	if (priv->interface_mode == PHY_INTERFACE_MODE_INTERNAL)
		...internal path...
	else
		...SerDes path...

so does NA silently select the external USXGMII path? Those ports would run yt8824_extern_config_sds_init_paged() (efuse-derived PLL/LDO trims, VCO/CDR writes, MII_RESV1 preamble config, SerDes BMCR reset) and isolate/reset the SerDes on every resume/suspend/soft_reset even on a part wired for the internal host interface, with success returned.

Should the one-shot state be rolled back on failure (or the elect plus init be done under phy_package_lock() as dp83640_probe() does), and should PHY_INTERFACE_MODE_NA be rejected rather than defaulting to the SerDes path?

One more question about the binding added earlier in this series, Documentation/devicetree/bindings/net/motorcomm,yt8824.yaml:

[Severity: Low]
The example names the package node ethernet-phy-package@0 while declaring reg = <9>:

        ethernet-phy-package@0 {
            #address-cells = <1>;
            #size-cells = <0>;
            compatible = "motorcomm,yt8824-package";
            reg = <9>;

The unit address should match the first entry of reg, and reg is the value of_phy_package_join() turns into the package base address that ytphy_read_top_ext()/ytphy_write_top_ext() rely on. Should the node be named ethernet-phy-package@9? dtc's unit_address_vs_reg check only tests for presence, so dt_binding_check will not flag this.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260917131441.3428554-1-kyle.switch%40motor-comm.com
maintainer
#11 lore raw
In reply to Kyle Switch
Quoted 3 lines · Kyle Switch

changes in v20:
patch 1: Add phy-mode description in properties in

	 motorcomm,yt8824.yaml

At least some of the sashiko comments looks legit and relevant to me.

Note that the cover letter must carry some brief relevant description of the overall work.

/P

#12 lore raw
Quoted 11 lines · Paolo Abeni
Quoted 3 lines · Kyle Switch

changes in v20:
patch 1: Add phy-mode description in properties in motorcomm,yt8824.yaml

At least some of the sashiko comments looks legit and relevant to me.

Note that the cover letter must carry some brief relevant description of the overall work.
/P

Ans: Thank you for your suggestions and comments.

I will improve the cover letter description in the next version and

also pay attention to some of the issues mentioned by sashiko.