Skip to contentSkip to conversation

Add en8811h phy driver and devicetree binding doc

PATCH Superseded Eric Woudstra 6 participants 11 messages Feb 6, 2024 – Feb 15, 2024

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add en8811h phy driver and devicetree binding doc

Add the Airoha EN8811H 2.5 Gigabit PHY.

The phy supports 100/1000/2500 Mbps with auto negotiation only.

The driver uses two firmware files, for which updated versions are added to linux-firmware already.

This patch series adds the driver and the devicetree binding documentation.

Eric Woudstra (2):
dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity
net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

 .../bindings/net/airoha,en8811h.yaml          |   44 +
 drivers/net/phy/Kconfig                       |    5 +
 drivers/net/phy/Makefile                      |    1 +
 drivers/net/phy/air_en8811h.c                 | 1006 +++++++++++++++++
 4 files changed, 1056 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/airoha,en8811h.yaml
 create mode 100644 drivers/net/phy/air_en8811h.c
Signature · 1 line
2.42.1
#1 lore raw

PATCH 1/2 dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity

The en8811h phy can be set with serdes polarity reversed on rx and/or tx.

Changed from rfc patch:

Explicitly say what -rx and -tx means.

---
 .../bindings/net/airoha,en8811h.yaml          | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/airoha,en8811h.yaml
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +44 -0
new file mode 100644
index 000000000000..99898e2bed64
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/airoha,en8811h.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha EN8811H PHY
+
+maintainers:
+  - Eric Woudstra <[email protected]>
+
+description:
+  Bindings for Airoha EN8811H PHY
+
+allOf:
+  - $ref: ethernet-phy.yaml#
+
+properties:
+  airoha,pnswap-rx:
+    type: boolean
+    description:
+      Reverse rx polarity of the SERDES. This is the receiving
+      side of the lines from the MAC towards the EN881H.
+
+
+  airoha,pnswap-tx:
+    type: boolean
+    description:
+      Reverse tx polarity of SERDES. This is the transmitting
+      side of the lines from EN8811H towards the MAC.
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethphy1: ethernet-phy@1 {
+                reg = <1>;
+                airoha,pnswap-rx;
+        };
+    };
Signature · 1 line
2.42.1
#2 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity

Quoted 5 lines · Eric Woudstra

The en8811h phy can be set with serdes polarity reversed on rx and/or tx.

Changed from rfc patch:

Explicitly say what -rx and -tx means.

I don't know what does it mean. This is v1, so we don't expect changelog. If this is v2 (because there was RFC/RFT/RFkisses/RFhugs which are states of patchsets, not versions), then please mark it as v2 and put changelog under ---.

Quoted 16 lines
---
 .../bindings/net/airoha,en8811h.yaml          | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/airoha,en8811h.yaml
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +3 -0
new file mode 100644
index 000000000000..99898e2bed64
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +10 -0
+$id: http://devicetree.org/schemas/net/airoha,en8811h.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Airoha EN8811H PHY
+
+maintainers:
+  - Eric Woudstra <[email protected]>
+
+description:
+  Bindings for Airoha EN8811H PHY

Drop "Bindings for" and instead describe the hardware. You are duplicating now title.

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 18

Quoted 5 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +5 -0
+
+allOf:
+  - $ref: ethernet-phy.yaml#
+
+properties:

This won't match to anything... missing compatible. You probably want to align with ongoing work on the lists.

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 25

Quoted 7 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +7 -0
+  airoha,pnswap-rx:
+    type: boolean
+    description:
+      Reverse rx polarity of the SERDES. This is the receiving
+      side of the lines from the MAC towards the EN881H.
+
+

Only one blank line.

Quoted 7 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +7 -0
+  airoha,pnswap-tx:
+    type: boolean
+    description:
+      Reverse tx polarity of SERDES. This is the transmitting
+      side of the lines from EN8811H towards the MAC.
+
+unevaluatedProperties: false

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 42

Quoted 10 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +10 -0
+
+examples:
+  - |
+    mdio {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethphy1: ethernet-phy@1 {
+                reg = <1>;
+                airoha,pnswap-rx;

You have broken indentation.

Use 4 spaces for example indentation.

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 44

Quoted 2 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +2 -0
+        };
+    };

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity

Hi krzysztof,

I mistakenly thought that changing from rfc-patch to patch, the number would reset. I will mark the next one v2, or do you want me to mark it v3?

I have been using realtek,rtl82xx.yaml as an example. I see all your comments apply to this file also, so it would seem I could have chosen a better example. I will change it according your remarks.

Quoted 8 lines

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 18

Quoted 5 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +5 -0
+
+allOf:
+  - $ref: ethernet-phy.yaml#
+
+properties:

This won't match to anything... missing compatible. You probably want to align with ongoing work on the lists.

As for the compatible string, the PHY reports it's c45-id okay and phylink can find the driver with this id. Therefore I have left the compatible string out of the devicetree node of the phy and not specified it in the binding (also same as realtek,rtl82xx.yaml).

If you are implying that I need to use it, then I will add:

select:
properties:
compatible:
contains:
enum:
- ethernet-phy-id03a2.a411
required:
- compatible

To the binding, and

	compatible = "ethernet-phy-id03a2.a411";

To the devicetree node of the phy again.

Best regards,

Eric Woudstra

maintainer
#4 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity

Quoted 4 lines

As for the compatible string, the PHY reports it's c45-id okay and phylink can find the driver with this id. Therefore I have left the compatible string out of the devicetree node of the phy and not specified it in the binding (also same as realtek,rtl82xx.yaml).

As you pointed out, the kernel does not require a compatible. So in your board DT blob, you don't need it.

In the binding document, you can indicate a compatible can optionally be used, and in the example its a good idea it actually use it, so that the example gets checked by the tools.

Andrew

maintainer
#5 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: airoha,en8811h: Add en8811h serdes polarity

In reply to Eric Woudstra
Quoted 26 lines · Eric Woudstra

Hi krzysztof,

I mistakenly thought that changing from rfc-patch to patch, the number would reset. I will mark the next one v2, or do you want me to mark it v3?

I have been using realtek,rtl82xx.yaml as an example. I see all your comments apply to this file also, so it would seem I could have chosen a better example. I will change it according your remarks.

Quoted 8 lines

Documentation/devicetree/bindings/net/airoha,en8811h.yaml line 18

Quoted 5 lines
Documentation/devicetree/bindings/net/airoha,en8811h.yaml new file +5 -0
+
+allOf:
+  - $ref: ethernet-phy.yaml#
+
+properties:

This won't match to anything... missing compatible. You probably want to align with ongoing work on the lists.

As for the compatible string, the PHY reports it's c45-id okay and phylink can find the driver with this id. Therefore I have left the compatible string out of the devicetree node of the phy and not specified it in the binding (also same as realtek,rtl82xx.yaml).

If you are implying that I need to use it, then I will add:

Quoted 8 lines

select:
properties:
compatible:
contains:
enum:
- ethernet-phy-id03a2.a411
required:
- compatible

Don't need any of this unless you have a common/generic fallback compatible.

Quoted 10 lines

To the binding, and

	compatible = "ethernet-phy-id03a2.a411";

To the devicetree node of the phy again.

Best regards,

Eric Woudstra

#6 lore raw

PATCH 2/2 net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

In reply to Eric Woudstra

* Source originated from airoha's en8811h v1.2.1 driver
* Moved air_en8811h.h to air_en8811h.c
* Removed air_pbus_reg_write() as it writes to another device on mdio-bus
* Load firmware from /lib/firmware/airoha/ instead of /lib/firmware/
* Added .get_rate_matching()
* Use generic phy_read/write() and phy_read/write_mmd()
* Edited .get_features() to use generic C45 functions
* Edited .config_aneg() and .read_status() to use a mix of generic C22/C45
* Use led handling functions from mediatek-ge-soc.c
* Simplified led handling by storing led rules
* Cleanup macro definitions
* Cleanup code to pass checkpatch.pl
* General code cleanup

Changes from original RFC patch:

* Use the correct order in Kconfig and Makefile
* Change some register naming to correspond with datasheet
* Use phy_driver .read_page() and .write_page()
* Use module_phy_driver()
* Use get_unaligned_le16() instead of macro
* In .config_aneg() and .read_status() use genphy_xxx() C22
* Use another vendor register to read real speed
* Load firmware only once and store firmware version
* Apply 2.5G LPA work-around (firmware before 24011202)
* Read 2.5G LPA from vendor register (firmware 24011202 and later)

Changes to be committed:

	modified:   drivers/net/phy/Kconfig
	modified:   drivers/net/phy/Makefile
	new file:   drivers/net/phy/air_en8811h.c
---
 drivers/net/phy/Kconfig       |    5 +
 drivers/net/phy/Makefile      |    1 +
 drivers/net/phy/air_en8811h.c | 1006 +++++++++++++++++++++++++++++++++
 3 files changed, 1012 insertions(+)
 create mode 100644 drivers/net/phy/air_en8811h.c
drivers/net/phy/Kconfig +5 -0
index e261e58bf158..efbff264b659 100644
@@ -76,6 +76,11 @@ config SFP
 
 comment "MII PHY device drivers"
 
+config AIR_EN8811H_PHY
+	tristate "Airoha EN8811H 2.5 Gigabit PHY"
+	help
+	  Currently supports the Airoha EN8811H PHY.
+
 config AMD_PHY
 	tristate "AMD and Altima PHYs"
 	help
drivers/net/phy/Makefile +1 -0
index 197acfa0b412..202ed7f450da 100644
@@ -34,6 +34,7 @@ obj-y				+= $(sfp-obj-y) $(sfp-obj-m)
 
 obj-$(CONFIG_ADIN_PHY)		+= adin.o
 obj-$(CONFIG_ADIN1100_PHY)	+= adin1100.o
+obj-$(CONFIG_AIR_EN8811H_PHY)   += air_en8811h.o
 obj-$(CONFIG_AMD_PHY)		+= amd.o
 obj-$(CONFIG_AQUANTIA_PHY)	+= aquantia/
 ifdef CONFIG_AX88796B_RUST_PHY
drivers/net/phy/air_en8811h.c new file +1006 -0

1,006 lines not on this page · raw message

Signature · 1 line
2.42.1
#7 lore raw

Re: [PATCH net-next 2/2] net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

drivers/net/phy/air_en8811h.c line 201

Quoted 8 lines · Eric Woudstra
drivers/net/phy/air_en8811h.c new file +8 -0
+static const unsigned long en8811h_led_trig = (BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
+					       BIT(TRIGGER_NETDEV_LINK)        |
+					       BIT(TRIGGER_NETDEV_LINK_10)     |
+					       BIT(TRIGGER_NETDEV_LINK_100)    |
+					       BIT(TRIGGER_NETDEV_LINK_1000)   |
+					       BIT(TRIGGER_NETDEV_LINK_2500)   |
+					       BIT(TRIGGER_NETDEV_RX)          |
+					       BIT(TRIGGER_NETDEV_TX));

Cosmetic: extra parens around bitwise OR is not necessary.

...

drivers/net/phy/air_en8811h.c line 244

Quoted 4 lines
drivers/net/phy/air_en8811h.c new file +4 -0
+static int air_buckpbus_reg_write(struct phy_device *phydev,
+				  u32 pbus_address, u32 pbus_data)
+{
+	int ret, saved_page;
	int saved_page;
	int ret = 0;

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);
	if (saved_page >= 0) {

drivers/net/phy/air_en8811h.c line 251

Quoted 5 lines
drivers/net/phy/air_en8811h.c new file +5 -0
+
+	ret = __air_buckpbus_reg_write(phydev, pbus_address, pbus_data);
+	if (ret < 0)
+		phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__,
+			   pbus_address, ret);
	}

drivers/net/phy/air_en8811h.c line 254

Quoted 3 lines
drivers/net/phy/air_en8811h.c new file +3 -0
+
+	return phy_restore_page(phydev, saved_page, ret);
+;

Cosmetic: unnecessary ;

Quoted 19 lines
drivers/net/phy/air_en8811h.c new file +19 -0
+}
+
+static int __air_buckpbus_reg_read(struct phy_device *phydev,
+				   u32 pbus_address, u32 *pbus_data)
+{
+	int pbus_data_low, pbus_data_high;
+	int ret;
+
+	ret = __phy_write(phydev, AIR_PBUS_MODE, AIR_PBUS_MODE_ADDR_FIXED);
+	if (ret < 0)
+		return ret;
+
+	ret = __phy_write(phydev, AIR_PBUS_RD_ADDR_HIGH, HIWORD(pbus_address));
+	if (ret < 0)
+		return ret;
+
+	ret = __phy_write(phydev, AIR_PBUS_RD_ADDR_LOW,  LOWORD(pbus_address));
+	if (ret < 0)
+		return ret;

drivers/net/phy/air_en8811h.c line 283

Quoted 10 lines
drivers/net/phy/air_en8811h.c new file +10 -0
+
+	pbus_data_high = __phy_read(phydev, AIR_PBUS_RD_DATA_HIGH);
+	if (pbus_data_high < 0)
+		return ret;
+
+	pbus_data_low = __phy_read(phydev, AIR_PBUS_RD_DATA_LOW);
+	if (pbus_data_low < 0)
+		return ret;
+
+	*pbus_data = (u16)pbus_data_low | ((u32)(u16)pbus_data_high << 16);

I don't think you need the u16 casts here.

Quoted 4 lines
drivers/net/phy/air_en8811h.c new file +4 -0
+	return 0;
+}
+
+static int air_buckpbus_reg_read(struct phy_device *phydev,

drivers/net/phy/air_en8811h.c line 297

Quoted 10 lines
drivers/net/phy/air_en8811h.c new file +10 -0
+				 u32 pbus_address, u32 *pbus_data)
+{
+	int ret, saved_page;
+
+	saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);
+
+	ret = __air_buckpbus_reg_read(phydev, pbus_address, pbus_data);
+	if (ret < 0)
+		phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__,
+			   pbus_address, ret);

Same as air_buckpbus_reg_write().

...

drivers/net/phy/air_en8811h.c line 346

Quoted 11 lines
drivers/net/phy/air_en8811h.c new file +11 -0
+static int air_write_buf(struct phy_device *phydev, u32 address,
+			 const struct firmware *fw)
+{
+	int ret, saved_page;
+
+	saved_page = phy_select_page(phydev, AIR_PHY_PAGE_EXTENDED_4);
+
+	ret = __air_write_buf(phydev, address, fw);
+	if (ret < 0)
+		phydev_err(phydev, "%s 0x%08x failed: %d\n", __func__,
+			   address, ret);

Same as air_buckpbus_reg_write().

...

Quoted 12 lines
drivers/net/phy/air_en8811h.c new file +12 -0
+
+	cl45_data = phy_read_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BCR);
+	if (cl45_data < 0)
+		return cl45_data;
+
+	switch (mode) {
+	case AIR_LED_MODE_DISABLE:
+		cl45_data &= ~AIR_PHY_LED_BCR_EXT_CTRL;
+		cl45_data &= ~AIR_PHY_LED_BCR_MODE_MASK;
+		break;
+	case AIR_LED_MODE_USER_DEFINE:
+		cl45_data |= AIR_PHY_LED_BCR_EXT_CTRL;

drivers/net/phy/air_en8811h.c line 701

Quoted 10 lines
drivers/net/phy/air_en8811h.c new file +10 -0
+		cl45_data |= AIR_PHY_LED_BCR_CLK_EN;
+		break;
+	default:
+		phydev_err(phydev, "LED mode %d is not supported\n", mode);
+		return -EINVAL;
+	}
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BCR, cl45_data);
+	if (ret < 0)
+		return ret;

Please always use phy_modify_mmd() rather than a
phy_read_mmd()...phy_write_mmd():

	cl45_data = 0;

	if (mode == AIR_LED_MODE_USER_DEFINE)
		cl45_data = AIR_PHY_LED_BCR_EXT_CTRL |
			    AIR_PHY_LED_BCR_CLK_EN;

	ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, AIR_PHY_LED_BCR,
			     AIR_PHY_LED_BCR_EXT_CTRL |
			     AIR_PHY_LED_BCR_CLK_EN, cl45_data);
	if (ret < 0)
		return ret;

This ensures that the read/modify/write is done atomically on the bus.

...

drivers/net/phy/air_en8811h.c line 830

Quoted 7 lines
drivers/net/phy/air_en8811h.c new file +7 -0
+	ret = air_buckpbus_reg_read(phydev, EN8811H_GPIO_OUTPUT, &pbus_value);
+	if (ret < 0)
+		return ret;
+	pbus_value |= EN8811H_GPIO_OUTPUT_345;
+	ret = air_buckpbus_reg_write(phydev, EN8811H_GPIO_OUTPUT, pbus_value);
+	if (ret < 0)
+		return ret;

Searching the driver for "air_buckpbus_reg_read", there are four instances where you read-modify-write, and only one instance which is just a read.

I wonder whether it would make more sense to structure the accessors as

__air_buckpbus_set_address(phydev, addr)
__air_buckpbus_read(phydev, *data)
__air_buckpbus_write(phydev, data)

which would make implementing reg_read, reg_write and reg_modify() easier, and the addition of reg_modify() means that (a) there are less bus cycles (through having to set the address twice) and (b) ensures that the read-modify-write can be done atomically on the bus. This assumes that reading data doesn't auto-increment the address (which you would need to check.)

...

drivers/net/phy/air_en8811h.c line 858

Quoted 9 lines
drivers/net/phy/air_en8811h.c new file +9 -0
+static int en8811h_config_aneg(struct phy_device *phydev)
+{
+	bool changed = false;
+	int err, val;
+
+	val = 0;
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+			      phydev->advertising))
+		val |= MDIO_AN_10GBT_CTRL_ADV2_5G;

While you only support 2500base-T, is there any reason not to use linkmode_adv_to_mii_10gbt_adv_t() ?

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
#8 lore raw

Re: [PATCH net-next 2/2] net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

Hi Russell,

Thanks for your suggestions, I will change it accordingly.

Quoted 10 lines

Searching the driver for "air_buckpbus_reg_read", there are four instances where you read-modify-write, and only one instance which is just a read.

I wonder whether it would make more sense to structure the accessors as

__air_buckpbus_set_address(phydev, addr)
__air_buckpbus_read(phydev, *data)
__air_buckpbus_write(phydev, data)

Quoted 6 lines

which would make implementing reg_read, reg_write and reg_modify() easier, and the addition of reg_modify() means that (a) there are less bus cycles (through having to set the address twice) and (b) ensures that the read-modify-write can be done atomically on the bus. This assumes that reading data doesn't auto-increment the address (which you would need to check.)

I will see if I can change the code to:

__air_buckpbus_set_address(phydev, addr)
__air_buckpbus_read(phydev, *data)
__air_buckpbus_write(phydev, data)
air_buckpbus_reg_read()
air_buckpbus_reg_write()
air_buckpbus_reg_modify()

While not changing (except if (saved_page >= 0)):

        __air_write_buf()
        air_write_buf()
Quoted 2 lines

While you only support 2500base-T, is there any reason not to use linkmode_adv_to_mii_10gbt_adv_t() ?

I will change it to use linkmode_adv_to_mii_10gbt_adv_t().

Best Regards,

Eric Woudstra

#9 lore raw

Re: [PATCH net-next 2/2] net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

Hi Russell,

Quoted 26 lines
Quoted 10 lines

Searching the driver for "air_buckpbus_reg_read", there are four instances where you read-modify-write, and only one instance which is just a read.

I wonder whether it would make more sense to structure the accessors as

__air_buckpbus_set_address(phydev, addr)
__air_buckpbus_read(phydev, *data)
__air_buckpbus_write(phydev, data)

Quoted 6 lines

which would make implementing reg_read, reg_write and reg_modify() easier, and the addition of reg_modify() means that (a) there are less bus cycles (through having to set the address twice) and (b) ensures that the read-modify-write can be done atomically on the bus. This assumes that reading data doesn't auto-increment the address (which you would need to check.)

I will see if I can change the code to:

__air_buckpbus_set_address(phydev, addr)
__air_buckpbus_read(phydev, *data)
__air_buckpbus_write(phydev, data)
air_buckpbus_reg_read()
air_buckpbus_reg_write()
air_buckpbus_reg_modify()

Quoted 5 lines

While not changing (except if (saved_page >= 0)):

        __air_write_buf()
        air_write_buf()

I just remember, the address register for write, is a different register from the address register for read. So we always have to write to address registers twice.

I can still implement an atomic air_buckpbus_reg_modify() though.

Best regards,

Eric Woudstra

#10 lore raw

Re: [PATCH net-next 2/2] net: phy: air_en8811h: Add the Airoha EN8811H PHY driver

In reply to Eric Woudstra

Hi Eric,

kernel test robot noticed the following build warnings:

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Woudstra/dt-bindings-net-airoha-en8811h-Add-en8811h-serdes-polarity/20240207-035021
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240206194751.1901802-3-ericwouds%40gmail.com
patch subject: [PATCH net-next 2/2] net: phy: air_en8811h: Add the Airoha EN8811H PHY driver
config: sh-randconfig-r081-20240211 (https://download.01.org/0day-ci/archive/20240211/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/net/phy/air_en8811h.c:560 air_led_hw_control_set() error: testing array offset 'index' after use.

vim +/index +560 drivers/net/phy/air_en8811h.c

3fe47bc0b949e7 Eric Woudstra 2024-02-06  551  static int air_led_hw_control_set(struct phy_device *phydev, u8 index,
3fe47bc0b949e7 Eric Woudstra 2024-02-06  552  				  unsigned long rules)
3fe47bc0b949e7 Eric Woudstra 2024-02-06  553  {
3fe47bc0b949e7 Eric Woudstra 2024-02-06  554  	struct en8811h_priv *priv = phydev->priv;
3fe47bc0b949e7 Eric Woudstra 2024-02-06  555  	u16 on = 0, blink = 0;
3fe47bc0b949e7 Eric Woudstra 2024-02-06  556  	int ret;
3fe47bc0b949e7 Eric Woudstra 2024-02-06  557  
3fe47bc0b949e7 Eric Woudstra 2024-02-06  558  	priv->led[index].rules = rules;
                                                         ^^^^^^

out of bounds

3fe47bc0b949e7 Eric Woudstra 2024-02-06 559
3fe47bc0b949e7 Eric Woudstra 2024-02-06 @560 if (index >= EN8811H_LED_COUNT)

                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

Too late. priv->led[] has EN8811H_LED_COUNT elements.

3fe47bc0b949e7 Eric Woudstra 2024-02-06  561  		return -EINVAL;
3fe47bc0b949e7 Eric Woudstra 2024-02-06  562  
3fe47bc0b949e7 Eric Woudstra 2024-02-06  563  	if (rules & (BIT(TRIGGER_NETDEV_LINK_10)   | BIT(TRIGGER_NETDEV_LINK))) {
3fe47bc0b949e7 Eric Woudstra 2024-02-06  564  		on |= AIR_PHY_LED_ON_LINK10;
3fe47bc0b949e7 Eric Woudstra 2024-02-06  565  		if (rules & BIT(TRIGGER_NETDEV_RX))
3fe47bc0b949e7 Eric Woudstra 2024-02-06  566  			blink |= AIR_PHY_LED_BLINK_10RX;
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki