[rdkb][common][bsp][Refactor and sync kernel from openwrt]

[Description]
61c5ed8f [HIGH][kernel][mt7988][hnat][Remove unnecessary paths for the keep_ecn/keep_dscp features]
d8bab9e8 [kernel][common][hnt][Add spinlock to protect ETH to ETH or WiFi RX binding process]
4819d283 [MAC80211][misc][Change relayd trigger action]
061d2493 [kernel][common][eth][Fix Fiberstore SFP-10G-T IOT issue]
e306310c [kernel][common][hnat][Fix issue of GDM ingress control forward to PPE setting]
8085563c [kernel][mt7988][eth][Update 36-bit DMA feature to resolve panic issue]
13b52f22 [kernel][common][eth][Add more FE regions to the NETSYS dump]
9d750be1 [openwrt][mt7988][crypto][Add to fill the inner packet info for route-based IPSec]
c30b46e7 [openwrt][mt7988][crypto][Add support for route-based IPSec]
9f168704 [HIGH][kernel][mt7988][eth][Fix panic issue with Gangload mode during the Aquantia firmware download]
ccc3b9d5 [HIGH][kernel][common][hnat][Fix issue nf_conntrack statistics update when dump all_entry]
57722186 [MAC80211][eth][Fix patch conflict issue]
41446009 [kernel][common][hnat][Fix Coverity defects in HNAT]
8fc1960f [kernel][common][eth][Fix Coverity defects in the USXGMII/SGMII]
216d6f51 [kernel][common][eth][Add more PPE regions to the NETSYS dump]
2bcb8ccf [openwrt][change msdc clock source to 208M]
1c1d4082 [MAC80211][misc][Sync OpenWRT config to the internal autobuild]
d291e00f [kernel][common][eth][Add debugfs support for the SFP]
57367c44 [MAC80211][hnat][Fix the traffic stuck issue for fastpath and hwpath in RelayD]
48122e86 [HIGH][kernel][common][eth][Fix the GDM TX/RX packet statistics error issue]
3e8561e3 [MAC80211][hnat][Add foe_entry_size to the SoC private data]
bb16f717 [kernel][mt7981][spi][Add SPI TPM example in dts and fix calibration flow]
fd870459 [kernel][mt7986][spi][dts: Add SPI calibration for NAND/NOR flashes]
d46252bf [kernel][mt7981/mt7986/mt7988][spi][spi-calibration: Fix spi-cal-enable flow]
4f17c6e8 [MAC80211][hnat][Add iptables pkttype rules to skip Multicast binding]
cc9d48d3 [kernel][common][eth][Refactor LRO and RSS configurations to the reg_map method]
afa65d04 [MAC80211][hnat][Fix dscp info didn't fill in ib2 on wifi tx path]
bc65a45f [openwrt][common][bsp][Add readme]
3f799e36 [openwrt-24][common][bsp][Add .gitignore]
28400f24 [openwrt-24][common][bsp][Add initial support for openwrt master filogic target]
03a58907 [Critical][kernel][mt7988][eth][i2.5Gphy: Update firmware to 20240618 version]
ac5fadec [kernel][common][hnat][Refactor HNAT flow to prevent entry modification racing]
a61a1837 [HIGH][kernel][mt7986/mt7981][eth][Fix HW LRO IRQ request error]
159cbe4b [openwrt][MT7981][switch][remove AN8855 image build]
3cb56bd2 [kernel][mt7988][eth][Refactor 8GB_ADDRESSING to the upstream style]
d9b9dc3f [openwrt][MT7981][single DTS supports both MT7531 and AN8855]
7014c79d [kernel][mt7988][hnat][Change PPE entry IPV6_HNAPT condition to support NPTv6]
abcd0f5d [MAC80211][hnat][Add extension wed debugfs]
a9f09e2d [HIGH][kernel][common][eth][Fix incorrect TX DMA buffer length]
2c4ed95a [kernel][mt7628][eth][Remove redundant platform data of MT7628]
0b6689eb [openwrt][app][Fix Coverity defects in the switch utility, Part4]
10ce1caa [openwrt][app][Fix Coverity defects in the switch utility, Part3]
d907bd65 [openwrt][app][Fix Coverity defects in the switch utility, Part2]
60fae9b8 [openwrt][app][Fix Coverity defects in the switch utility, Part1]
15be55dc [kernel][common][eth][Fix warning of return with a value in returning void function]
4f7cc5ca [MAC80211][hnat][Refactor two-way hashing and per-flow accounting features to the upstream style]

[Release-log]

Change-Id: Id87559484a1999276c366c085684d5f98ceea33a
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.2-net-phy-sfp-add-rollball-support.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.10-net-phy-sfp-add-rollball-support.patch
similarity index 90%
rename from recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.2-net-phy-sfp-add-rollball-support.patch
rename to recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.10-net-phy-sfp-add-rollball-support.patch
index bac49cf..b044193 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.2-net-phy-sfp-add-rollball-support.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1709-v6.10-net-phy-sfp-add-rollball-support.patch
@@ -1,22 +1,22 @@
-From 1631a36b9ac022ce6ffb58b039a7e85ad3414ed5 Mon Sep 17 00:00:00 2001
-From: Sam Shih <sam.shih@mediatek.com>
-Date: Fri, 2 Jun 2023 13:06:01 +0800
+From 3d251a9986dd10bbc7ae03a9535d4c46d62f0274 Mon Sep 17 00:00:00 2001
+From: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
+Date: Fri, 5 Jul 2024 11:37:08 +0800
 Subject: [PATCH] 
  [backport-networking-drivers][999-1709-net-phy-sfp-add-rollball-support.patch]
 
 ---
  drivers/net/phy/marvell.c     |   2 +-
- drivers/net/phy/marvell10g.c  | 168 +++++++++++++--
- drivers/net/phy/mdio-i2c.c    | 309 +++++++++++++++++++++++++++-
- drivers/net/phy/phylink.c     |  74 +++++--
- drivers/net/phy/sfp-bus.c     | 102 +---------
- drivers/net/phy/sfp.c         | 373 +++++++++++++++++++++++++++++-----
+ drivers/net/phy/marvell10g.c  | 168 ++++++++++++-
+ drivers/net/phy/mdio-i2c.c    | 309 +++++++++++++++++++++++-
+ drivers/net/phy/phylink.c     |  74 ++++--
+ drivers/net/phy/sfp-bus.c     | 102 +-------
+ drivers/net/phy/sfp.c         | 428 ++++++++++++++++++++++++++++++----
  drivers/net/phy/sfp.h         |  11 +-
  include/linux/mdio/mdio-i2c.h |  10 +-
- 8 files changed, 874 insertions(+), 175 deletions(-)
+ 8 files changed, 926 insertions(+), 178 deletions(-)
 
 diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
-index 49801c2eb..f25881745 100644
+index 49801c2..f258817 100644
 --- a/drivers/net/phy/marvell.c
 +++ b/drivers/net/phy/marvell.c
 @@ -2175,7 +2175,7 @@ static struct phy_driver marvell_drivers[] = {
@@ -29,7 +29,7 @@
  		.config_init = &m88e1111_config_init,
  		.config_aneg = &marvell_config_aneg,
 diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
-index 1e4631761..7d080d52e 100644
+index 1e46317..7d080d5 100644
 --- a/drivers/net/phy/marvell10g.c
 +++ b/drivers/net/phy/marvell10g.c
 @@ -32,6 +32,15 @@
@@ -302,7 +302,7 @@
  };
  
 diff --git a/drivers/net/phy/mdio-i2c.c b/drivers/net/phy/mdio-i2c.c
-index 09200a70b..85db63c33 100644
+index 09200a7..85db63c 100644
 --- a/drivers/net/phy/mdio-i2c.c
 +++ b/drivers/net/phy/mdio-i2c.c
 @@ -12,6 +12,7 @@
@@ -654,7 +654,7 @@
  }
  EXPORT_SYMBOL_GPL(mdio_i2c_alloc);
 diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
-index f360d9225..67f34ed4c 100644
+index f360d92..67f34ed 100644
 --- a/drivers/net/phy/phylink.c
 +++ b/drivers/net/phy/phylink.c
 @@ -483,62 +483,105 @@ static void phylink_resolve(struct work_struct *w)
@@ -788,7 +788,7 @@
  	if (pl->phydev)
  		phy_start(pl->phydev);
 diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
-index a2f451c31..4be24406b 100644
+index a2f451c..4be2440 100644
 --- a/drivers/net/phy/sfp-bus.c
 +++ b/drivers/net/phy/sfp-bus.c
 @@ -10,12 +10,6 @@
@@ -936,18 +936,19 @@
  	if (ops && ops->module_insert)
  		ret = ops->module_insert(bus->upstream, id);
 diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
-index f8d1742e0..0fdf5d6d4 100644
+index a8eeb57..92c6f1a 100644
 --- a/drivers/net/phy/sfp.c
 +++ b/drivers/net/phy/sfp.c
-@@ -165,6 +165,7 @@ static const enum gpiod_flags gpio_flags[] = {
-  * on board (for a copper SFP) time to initialise.
+@@ -186,7 +186,7 @@ static const enum gpiod_flags gpio_flags[] = {
+  * R_PHY_RETRY is the number of attempts.
   */
- #define T_WAIT			msecs_to_jiffies(50)
-+#define T_WAIT_ROLLBALL		msecs_to_jiffies(25000)
- #define T_START_UP		msecs_to_jiffies(300)
- #define T_START_UP_BAD_GPON	msecs_to_jiffies(60000)
+ #define T_PHY_RETRY		msecs_to_jiffies(50)
+-#define R_PHY_RETRY		12
++#define R_PHY_RETRY		25
  
-@@ -204,8 +205,11 @@ static const enum gpiod_flags gpio_flags[] = {
+ /* SFP module presence detection is poor: the three MOD DEF signals are
+  * the same length on the PCB, which means it's possible for MOD DEF 0 to
+@@ -204,8 +204,11 @@ static const enum gpiod_flags gpio_flags[] = {
  
  /* SFP modules appear to always have their PHY configured for bus address
   * 0x56 (which with mdio-i2c, translates to a PHY address of 22).
@@ -960,7 +961,7 @@
  
  struct sff_data {
  	unsigned int gpios;
-@@ -217,6 +221,7 @@ struct sfp {
+@@ -217,6 +220,7 @@ struct sfp {
  	struct i2c_adapter *i2c;
  	struct mii_bus *i2c_mii;
  	struct sfp_bus *sfp_bus;
@@ -968,7 +969,7 @@
  	struct phy_device *mod_phy;
  	const struct sff_data *type;
  	size_t i2c_block_size;
-@@ -233,6 +238,7 @@ struct sfp {
+@@ -233,6 +237,7 @@ struct sfp {
  	bool need_poll;
  
  	struct mutex st_mutex;			/* Protects state */
@@ -976,11 +977,12 @@
  	unsigned int state_soft_mask;
  	unsigned int state;
  	struct delayed_work poll;
-@@ -249,6 +255,10 @@ struct sfp {
+@@ -249,6 +254,11 @@ struct sfp {
  	struct sfp_eeprom_id id;
  	unsigned int module_power_mW;
  	unsigned int module_t_start_up;
 +	unsigned int module_t_wait;
++	unsigned int phy_t_retry;
 +	bool tx_fault_ignore;
 +
 +	const struct sfp_quirk *quirk;
@@ -1006,7 +1008,7 @@
  	return false;
  }
  
-@@ -303,6 +325,180 @@ static const struct of_device_id sfp_of_match[] = {
+@@ -303,6 +325,224 @@ static const struct of_device_id sfp_of_match[] = {
  };
  MODULE_DEVICE_TABLE(of, sfp_of_match);
  
@@ -1025,6 +1027,42 @@
 +	sfp->mdio_protocol = MDIO_I2C_NONE;
 +}
 +
++// For 10GBASE-T short-reach modules
++static void sfp_fixup_10gbaset_30m(struct sfp *sfp)
++{
++	sfp->id.base.connector = SFF8024_CONNECTOR_RJ45;
++	sfp->id.base.extended_cc = SFF8024_ECC_10GBASE_T_SR;
++}
++
++static void sfp_fixup_rollball(struct sfp *sfp)
++{
++	sfp->mdio_protocol = MDIO_I2C_ROLLBALL;
++
++	/* RollBall modules may disallow access to PHY registers for up to 25
++	 * seconds, and the reads return 0xffff before that. Increase the time
++	 * between PHY probe retries from 50ms to 1s so that we will wait for
++	 * the PHY for a sufficient amount of time.
++	 */
++	sfp->phy_t_retry = msecs_to_jiffies(1000);
++}
++
++static void sfp_fixup_fs_2_5gt(struct sfp *sfp)
++{
++	sfp_fixup_rollball(sfp);
++
++	/* The RollBall fixup is not enough for FS modules, the PHY chip inside
++	 * them does not return 0xffff for PHY ID registers in all MMDs for the
++	 * while initializing. They need a 4 second wait before accessing PHY.
++	 */
++	sfp->module_t_wait = msecs_to_jiffies(4000);
++}
++
++static void sfp_fixup_fs_10gt(struct sfp *sfp)
++{
++	sfp_fixup_10gbaset_30m(sfp);
++	sfp_fixup_fs_2_5gt(sfp);
++}
++
 +static void sfp_fixup_halny_gsfp(struct sfp *sfp)
 +{
 +	/* Ignore the TX_FAULT and LOS signals on this module.
@@ -1034,12 +1072,6 @@
 +	sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
 +}
 +
-+static void sfp_fixup_rollball(struct sfp *sfp)
-+{
-+	sfp->mdio_protocol = MDIO_I2C_ROLLBALL;
-+	sfp->module_t_wait = T_WAIT_ROLLBALL;
-+}
-+
 +static void sfp_fixup_rollball_cc(struct sfp *sfp)
 +{
 +	sfp_fixup_rollball(sfp);
@@ -1107,6 +1139,20 @@
 +	SFP_QUIRK("ALCATELLUCENT", "3FE46541AA", '\0', sfp_quirk_2500basex,
 +		  sfp_fixup_long_startup),
 +
++	// Fiberstore SFP-10G-T doesn't identify as copper, uses the Rollball
++	// protocol to talk to the PHY and needs 4 sec wait before probing the
++	// PHY.
++	SFP_QUIRK_F("FS", "SFP-10G-T", '\0', sfp_fixup_fs_10gt),
++
++	// Fiberstore SFP-2.5G-T uses Rollball protocol to talk to the PHY and
++	// needs 4 sec wait before probing the PHY.
++	SFP_QUIRK_F("FS", "SFP-2.5G-T", '\0', sfp_fixup_fs_2_5gt),
++
++	// Fiberstore GPON-ONU-34-20BI can operate at 2500base-X, but report 1.2GBd
++	// NRZ in their EEPROM
++	SFP_QUIRK("FS", "GPON-ONU-34-20BI", '\0', sfp_quirk_2500basex,
++		  sfp_fixup_ignore_tx_fault),
++
 +	SFP_QUIRK_F("HALNy", "HL-GSFP", '\0', sfp_fixup_halny_gsfp),
 +
 +	// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd NRZ in
@@ -1187,7 +1233,7 @@
  static unsigned long poll_jiffies;
  
  static unsigned int sfp_gpio_get_state(struct sfp *sfp)
-@@ -414,9 +610,6 @@ static int sfp_i2c_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
+@@ -414,9 +654,6 @@ static int sfp_i2c_write(struct sfp *sfp, bool a2, u8 dev_addr, void *buf,
  
  static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
  {
@@ -1197,7 +1243,7 @@
  	if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
  		return -EINVAL;
  
-@@ -424,7 +617,15 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
+@@ -424,7 +661,15 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
  	sfp->read = sfp_i2c_read;
  	sfp->write = sfp_i2c_write;
  
@@ -1214,7 +1260,7 @@
  	if (IS_ERR(i2c_mii))
  		return PTR_ERR(i2c_mii);
  
-@@ -442,6 +643,12 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
+@@ -442,6 +687,12 @@ static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
  	return 0;
  }
  
@@ -1227,7 +1273,7 @@
  /* Interface */
  static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len)
  {
-@@ -487,17 +694,18 @@ static void sfp_soft_set_state(struct sfp *sfp, unsigned int state)
+@@ -487,17 +738,18 @@ static void sfp_soft_set_state(struct sfp *sfp, unsigned int state)
  static void sfp_soft_start_poll(struct sfp *sfp)
  {
  	const struct sfp_eeprom_id *id = &sfp->id;
@@ -1255,7 +1301,7 @@
  
  	if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) &&
  	    !sfp->need_poll)
-@@ -511,10 +719,11 @@ static void sfp_soft_stop_poll(struct sfp *sfp)
+@@ -511,10 +763,11 @@ static void sfp_soft_stop_poll(struct sfp *sfp)
  
  static unsigned int sfp_get_state(struct sfp *sfp)
  {
@@ -1270,7 +1316,7 @@
  		state |= sfp_soft_get_state(sfp);
  
  	return state;
-@@ -1448,12 +1657,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
+@@ -1448,12 +1701,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
  	sfp->mod_phy = NULL;
  }
  
@@ -1285,7 +1331,7 @@
  	if (phy == ERR_PTR(-ENODEV))
  		return PTR_ERR(phy);
  	if (IS_ERR(phy)) {
-@@ -1548,6 +1757,14 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn)
+@@ -1548,6 +1801,14 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn)
  	}
  }
  
@@ -1300,7 +1346,7 @@
  /* Probe a SFP for a PHY device if the module supports copper - the PHY
   * normally sits at I2C bus address 0x56, and may either be a clause 22
   * or clause 45 PHY.
-@@ -1563,36 +1780,52 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
+@@ -1563,36 +1824,52 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
  {
  	int err = 0;
  
@@ -1367,7 +1413,7 @@
  			/* The module appears not to implement bus address
  			 * 0xa2, so assume that the module powers up in the
  			 * indicated mode.
-@@ -1609,13 +1842,21 @@ static int sfp_module_parse_power(struct sfp *sfp)
+@@ -1609,13 +1886,21 @@ static int sfp_module_parse_power(struct sfp *sfp)
  		}
  	}
  
@@ -1391,7 +1437,7 @@
  			 power_mW / 1000, (power_mW / 100) % 10);
  		return 0;
  	}
-@@ -1692,7 +1933,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
+@@ -1692,7 +1977,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
  {
  	/* SFP module inserted - read I2C data */
  	struct sfp_eeprom_id id;
@@ -1400,7 +1446,7 @@
  	u8 check;
  	int ret;
  
-@@ -1747,10 +1988,16 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
+@@ -1747,10 +2032,16 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
  	 */
  	cotsworks = !memcmp(id.base.vendor_name, "COTSWORKS       ", 16);
  
@@ -1418,7 +1464,7 @@
  			dev_warn(sfp->dev,
  				 "EEPROM base structure checksum failure (0x%02x != 0x%02x)\n",
  				 check, id.base.cc_base);
-@@ -1819,11 +2066,33 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
+@@ -1819,11 +2110,34 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report)
  	if (ret < 0)
  		return ret;
  
@@ -1436,6 +1482,7 @@
 +
 +	sfp->module_t_start_up = T_START_UP;
 +	sfp->module_t_wait = T_WAIT;
++	sfp->phy_t_retry = T_PHY_RETRY;
 +
 +	sfp->tx_fault_ignore = false;
 +
@@ -1456,7 +1503,7 @@
  
  	return 0;
  }
-@@ -1936,7 +2205,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
+@@ -1936,7 +2250,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
  			break;
  
  		/* Report the module insertion to the upstream device */
@@ -1466,7 +1513,7 @@
  		if (err < 0) {
  			sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0);
  			break;
-@@ -1995,6 +2265,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+@@ -1995,6 +2310,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
  			sfp_module_stop(sfp->sfp_bus);
  		if (sfp->mod_phy)
  			sfp_sm_phy_detach(sfp);
@@ -1475,7 +1522,7 @@
  		sfp_module_tx_disable(sfp);
  		sfp_soft_stop_poll(sfp);
  		sfp_sm_next(sfp, SFP_S_DOWN, 0);
-@@ -2018,9 +2290,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+@@ -2018,9 +2335,10 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
  
  		/* We need to check the TX_FAULT state, which is not defined
  		 * while TX_DISABLE is asserted. The earliest we want to do
@@ -1488,7 +1535,7 @@
  		break;
  
  	case SFP_S_WAIT:
-@@ -2034,8 +2307,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+@@ -2034,8 +2352,8 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
  			 * deasserting.
  			 */
  			timeout = sfp->module_t_start_up;
@@ -1499,7 +1546,7 @@
  			else
  				timeout = 1;
  
-@@ -2057,6 +2330,12 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+@@ -2057,6 +2375,12 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
  				     sfp->sm_fault_retries == N_FAULT_INIT);
  		} else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
  	init_done:
@@ -1512,7 +1559,23 @@
  			sfp->sm_phy_retries = R_PHY_RETRY;
  			goto phy_probe;
  		}
-@@ -2409,6 +2688,8 @@ static int sfp_probe(struct platform_device *pdev)
+@@ -2070,9 +2394,13 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+ 		 * clear.  Probe for the PHY and check the LOS state.
+ 		 */
+ 		ret = sfp_sm_probe_for_phy(sfp);
+-		if (ret == -ENODEV) {
++		if (ret == -ENODEV || ret == -EINVAL) {
+ 			if (--sfp->sm_phy_retries) {
+-				sfp_sm_next(sfp, SFP_S_INIT_PHY, T_PHY_RETRY);
++				sfp_sm_next(sfp, SFP_S_INIT_PHY,
++					    sfp->phy_t_retry);
++				dev_info(sfp->dev,
++					"no PHY detected, %u tries left\n",
++					sfp->sm_phy_retries);
+ 				break;
+ 			} else {
+ 				dev_info(sfp->dev, "no PHY detected\n");
+@@ -2409,6 +2737,8 @@ static int sfp_probe(struct platform_device *pdev)
  				return PTR_ERR(sfp->gpio[i]);
  		}
  
@@ -1522,7 +1585,7 @@
  	sfp->set_state = sfp_gpio_set_state;
  
 diff --git a/drivers/net/phy/sfp.h b/drivers/net/phy/sfp.h
-index b83f70526..f533e2dd6 100644
+index b83f705..f533e2d 100644
 --- a/drivers/net/phy/sfp.h
 +++ b/drivers/net/phy/sfp.h
 @@ -6,6 +6,14 @@
@@ -1551,7 +1614,7 @@
  int sfp_module_start(struct sfp_bus *bus);
  void sfp_module_stop(struct sfp_bus *bus);
 diff --git a/include/linux/mdio/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h
-index 751dab281..1c2114068 100644
+index 751dab2..1c21140 100644
 --- a/include/linux/mdio/mdio-i2c.h
 +++ b/include/linux/mdio/mdio-i2c.h
 @@ -11,6 +11,14 @@ struct device;
@@ -1571,5 +1634,5 @@
  
  #endif
 -- 
-2.34.1
+2.18.0
 
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1717-v5.12-net-phy-sfp-add-debugfs-support.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1717-v5.12-net-phy-sfp-add-debugfs-support.patch
new file mode 100644
index 0000000..6b136a4
--- /dev/null
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-1717-v5.12-net-phy-sfp-add-debugfs-support.patch
@@ -0,0 +1,107 @@
+From 83e56d18e57fc46c3a25f917dbd42fb9b1599ab1 Mon Sep 17 00:00:00 2001
+From: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
+Date: Mon, 1 Jul 2024 16:05:32 +0800
+Subject: [PATCH] 
+ [backport-networking-drivers][999-1717-v5.12-net-phy-sfp-add-debugfs-support.patch]
+
+---
+ drivers/net/phy/sfp.c | 55 +++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 55 insertions(+)
+
+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
+index d49a825..4bcc2bb 100644
+--- a/drivers/net/phy/sfp.c
++++ b/drivers/net/phy/sfp.c
+@@ -1,6 +1,7 @@
+ // SPDX-License-Identifier: GPL-2.0
+ #include <linux/acpi.h>
+ #include <linux/ctype.h>
++#include <linux/debugfs.h>
+ #include <linux/delay.h>
+ #include <linux/gpio/consumer.h>
+ #include <linux/hwmon.h>
+@@ -268,6 +269,9 @@ struct sfp {
+ 	char *hwmon_name;
+ #endif
+ 
++#if IS_ENABLED(CONFIG_DEBUG_FS)
++	struct dentry *debugfs_dir;
++#endif
+ };
+ 
+ static bool sff_module_supported(const struct sfp_eeprom_id *id)
+@@ -1617,6 +1621,54 @@ static void sfp_module_tx_enable(struct sfp *sfp)
+ 	sfp_set_state(sfp, sfp->state);
+ }
+ 
++#if IS_ENABLED(CONFIG_DEBUG_FS)
++static int sfp_debug_state_show(struct seq_file *s, void *data)
++{
++	struct sfp *sfp = s->private;
++
++	seq_printf(s, "Module state: %s\n",
++		   mod_state_to_str(sfp->sm_mod_state));
++	seq_printf(s, "Module probe attempts: %d %d\n",
++		   R_PROBE_RETRY_INIT - sfp->sm_mod_tries_init,
++		   R_PROBE_RETRY_SLOW - sfp->sm_mod_tries);
++	seq_printf(s, "Device state: %s\n",
++		   dev_state_to_str(sfp->sm_dev_state));
++	seq_printf(s, "Main state: %s\n",
++		   sm_state_to_str(sfp->sm_state));
++	seq_printf(s, "Fault recovery remaining retries: %d\n",
++		   sfp->sm_fault_retries);
++	seq_printf(s, "PHY probe remaining retries: %d\n",
++		   sfp->sm_phy_retries);
++	seq_printf(s, "moddef0: %d\n", !!(sfp->state & SFP_F_PRESENT));
++	seq_printf(s, "rx_los: %d\n", !!(sfp->state & SFP_F_LOS));
++	seq_printf(s, "tx_fault: %d\n", !!(sfp->state & SFP_F_TX_FAULT));
++	seq_printf(s, "tx_disable: %d\n", !!(sfp->state & SFP_F_TX_DISABLE));
++	return 0;
++}
++DEFINE_SHOW_ATTRIBUTE(sfp_debug_state);
++
++static void sfp_debugfs_init(struct sfp *sfp)
++{
++	sfp->debugfs_dir = debugfs_create_dir(dev_name(sfp->dev), NULL);
++
++	debugfs_create_file("state", 0600, sfp->debugfs_dir, sfp,
++			    &sfp_debug_state_fops);
++}
++
++static void sfp_debugfs_exit(struct sfp *sfp)
++{
++	debugfs_remove_recursive(sfp->debugfs_dir);
++}
++#else
++static void sfp_debugfs_init(struct sfp *sfp)
++{
++}
++
++static void sfp_debugfs_exit(struct sfp *sfp)
++{
++}
++#endif
++
+ static void sfp_module_tx_fault_reset(struct sfp *sfp)
+ {
+ 	unsigned int state = sfp->state;
+@@ -2795,6 +2847,8 @@ static int sfp_probe(struct platform_device *pdev)
+ 	if (!sfp->sfp_bus)
+ 		return -ENOMEM;
+ 
++	sfp_debugfs_init(sfp);
++
+ 	return 0;
+ }
+ 
+@@ -2802,6 +2856,7 @@ static int sfp_remove(struct platform_device *pdev)
+ {
+ 	struct sfp *sfp = platform_get_drvdata(pdev);
+ 
++	sfp_debugfs_exit(sfp);
+ 	sfp_unregister_socket(sfp->sfp_bus);
+ 
+ 	rtnl_lock();
+-- 
+2.18.0
+
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2103-drivers-char-tpm-Add-calibration-example-for-SPI-TPM-module.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2103-drivers-char-tpm-Add-calibration-example-for-SPI-TPM-module.patch
index 47ac32a..0732a6d 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2103-drivers-char-tpm-Add-calibration-example-for-SPI-TPM-module.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2103-drivers-char-tpm-Add-calibration-example-for-SPI-TPM-module.patch
@@ -10,11 +10,9 @@
  drivers/char/tpm/tpm_tis_spi.c  |  7 +++++++
  3 files changed, 28 insertions(+)
 
-diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
-index 70f785994..b9898a56d 100644
 --- a/drivers/char/tpm/tpm_tis_core.c
 +++ b/drivers/char/tpm/tpm_tis_core.c
-@@ -817,6 +817,21 @@ static const struct tpm_class_ops tpm_tis = {
+@@ -823,6 +823,21 @@ static const struct tpm_class_ops tpm_ti
  	.clk_enable = tpm_tis_clkrun_enable,
  };
  
@@ -36,19 +34,19 @@
  int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
  		      const struct tpm_tis_phy_ops *phy_ops,
  		      acpi_handle acpi_dev_handle)
-@@ -864,6 +879,10 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
+@@ -870,6 +885,12 @@ int tpm_tis_core_init(struct device *dev
  	if (chip->ops->clk_enable != NULL)
  		chip->ops->clk_enable(chip, true);
  
-+	rc = priv->phy_ops->do_calibration(priv, dev);
-+	if (rc)
-+		goto out_err;
++	if (phy_ops->do_calibration) {
++		rc = priv->phy_ops->do_calibration(priv, dev);
++		if (rc)
++			goto out_err;
++	}
 +
  	if (wait_startup(chip, 0) != 0) {
  		rc = -ENODEV;
  		goto out_err;
-diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
-index 7337819f5..7bb0bc8b6 100644
 --- a/drivers/char/tpm/tpm_tis_core.h
 +++ b/drivers/char/tpm/tpm_tis_core.h
 @@ -106,6 +106,7 @@ struct tpm_tis_phy_ops {
@@ -67,11 +65,9 @@
  int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
  		      const struct tpm_tis_phy_ops *phy_ops,
  		      acpi_handle acpi_dev_handle);
-diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
-index 19513e622..3be2d53a5 100644
 --- a/drivers/char/tpm/tpm_tis_spi.c
 +++ b/drivers/char/tpm/tpm_tis_spi.c
-@@ -184,12 +184,19 @@ static int tpm_tis_spi_write32(struct tpm_tis_data *data, u32 addr, u32 value)
+@@ -184,12 +184,19 @@ static int tpm_tis_spi_write32(struct tp
  	return rc;
  }
  
@@ -91,6 +87,3 @@
  };
  
  static int tpm_tis_spi_probe(struct spi_device *dev)
--- 
-2.34.1
-
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2372-drivers-spi-Add-support-for-dynamic-calibration.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2372-drivers-spi-Add-support-for-dynamic-calibration.patch
index d438084..2c6bcef 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2372-drivers-spi-Add-support-for-dynamic-calibration.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2372-drivers-spi-Add-support-for-dynamic-calibration.patch
@@ -9,11 +9,9 @@
  include/linux/spi/spi.h |  42 ++++++++++++
  2 files changed, 183 insertions(+)
 
-diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
-index e562735a3..28bad4a8b 100644
 --- a/drivers/spi/spi.c
 +++ b/drivers/spi/spi.c
-@@ -1109,6 +1109,74 @@ static int spi_transfer_wait(struct spi_controller *ctlr,
+@@ -1109,6 +1109,82 @@ static int spi_transfer_wait(struct spi_
  	return 0;
  }
  
@@ -32,8 +30,13 @@
 +	bool hit;
 +
 +	/* Make sure we can start calibration */
-+	if(!ctlr->cal_target || !ctlr->cal_rule || !ctlr->append_caldata)
++	if(!ctlr->cal_target || !ctlr->cal_rule) {
++		return 0;
++	} else if(!ctlr->append_caldata) {
++		pr_err("%s: calibration is enabled but no controller data.\n",
++		       __func__);
 +		return -EINVAL;
++	}
 +	datalen = ctlr->cal_rule->datalen;
 +	addrlen = ctlr->cal_rule->addrlen;
 +
@@ -70,9 +73,12 @@
 +			*target->cal_item = DIV_ROUND_CLOSEST(hit_val, total_hit);
 +			dev_info(&spi->dev, "calibration result: 0x%x", *target->cal_item);
 +		} else {
++			/* We don't return error in this case because you don't know calibration
++			 * failure is caused by bus error or wrong calibration data provided by
++			 * user or driver.
++			 */
 +			*target->cal_item = origin;
 +			dev_warn(&spi->dev, "calibration failed, fallback to default: 0x%x", origin);
-+			ret = -EIO;
 +		}
 +
 +		list_del(pos);
@@ -88,7 +94,7 @@
  static void _spi_transfer_delay_ns(u32 ns)
  {
  	if (!ns)
-@@ -1720,6 +1788,75 @@ void spi_flush_queue(struct spi_controller *ctlr)
+@@ -1720,6 +1796,75 @@ void spi_flush_queue(struct spi_controll
  /*-------------------------------------------------------------------------*/
  
  #if defined(CONFIG_OF)
@@ -164,7 +170,7 @@
  static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
  			   struct device_node *nc)
  {
-@@ -1841,6 +1978,10 @@ of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc)
+@@ -1841,6 +1986,10 @@ of_register_spi_device(struct spi_contro
  	if (rc)
  		goto err_out;
  
@@ -175,8 +181,6 @@
  	/* Store a pointer to the node in the device structure */
  	of_node_get(nc);
  	spi->dev.of_node = nc;
-diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
-index 7067f85ce..5330cd9b0 100644
 --- a/include/linux/spi/spi.h
 +++ b/include/linux/spi/spi.h
 @@ -264,6 +264,40 @@ struct spi_driver {
@@ -232,7 +236,7 @@
  	int (*fw_translate_cs)(struct spi_controller *ctlr, unsigned cs);
  };
  
-@@ -1369,6 +1408,9 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
+@@ -1369,6 +1408,9 @@ spi_register_board_info(struct spi_board
  	{ return 0; }
  #endif
  
@@ -242,6 +246,3 @@
  /* If you're hotplugging an adapter with devices (parport, usb, etc)
   * use spi_new_device() to describe each device.  You can also call
   * spi_unregister_device() to start making that device vanish, but
--- 
-2.34.1
-
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2719-net-phy-aquantia-add-firmware-download.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2719-net-phy-aquantia-add-firmware-download.patch
index 407896c..3d1f602 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2719-net-phy-aquantia-add-firmware-download.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2719-net-phy-aquantia-add-firmware-download.patch
@@ -153,7 +153,7 @@
 index 000000000..d2828aad4
 --- /dev/null
 +++ b/drivers/net/phy/aquantia_firmware.c
-@@ -0,0 +1,1109 @@
+@@ -0,0 +1,1110 @@
 +// SPDX-License-Identifier: GPL-2.0
 +/* FW download driver for Aquantia PHY
 + */
@@ -1227,7 +1227,6 @@
 +				 PTR_ERR(gangload_kthread));
 +			return PTR_ERR(gangload_kthread);
 +		}
-+		wake_up_process(gangload_kthread);
 +	}
 +
 +	for (i = 0; i < gangload; i++) {
@@ -1250,6 +1249,8 @@
 +	gangload_phydevs[gangload] = phydev;
 +	gangload++;
 +
++	wake_up_process(gangload_kthread);
++
 +	return 0;
 +}
 +
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2727-net-phy-sfp-add-debug-info.patch.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2727-net-phy-sfp-add-debug-info.patch.patch
index 593ddb1..c985f4b 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2727-net-phy-sfp-add-debug-info.patch.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/999-2727-net-phy-sfp-add-debug-info.patch.patch
@@ -6,9 +6,9 @@
 ---
  drivers/net/phy/phylink.c     | 11 +++++++-
  drivers/net/phy/sfp-bus.c     |  3 +++
- drivers/net/phy/sfp.c         | 51 +++++++++++++++++++++++++++++------
+ drivers/net/phy/sfp.c         | 50 +++++++++++++++++++++++++++++------
  include/linux/mdio/mdio-i2c.h | 16 +++++++++++
- 4 files changed, 72 insertions(+), 9 deletions(-)
+ 4 files changed, 71 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
 index 949e3b8..bb4cd28 100644
@@ -141,11 +141,10 @@
  	err = sfp_add_phy(sfp->sfp_bus, phy);
  	if (err) {
  		phy_device_remove(phy);
-@@ -1779,6 +1810,10 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp)
+@@ -1779,6 +1810,9 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp)
  static int sfp_sm_probe_for_phy(struct sfp *sfp)
  {
  	int err = 0;
-+	struct phy_device *phy;
 +
 +	dev_info(sfp->dev, "probing phy device through the [%s] protocol\n",
 +	         mdio_i2c_proto_type(sfp->mdio_protocol));
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/patches-5.4.inc b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/patches-5.4.inc
index 8bf5b8b..81a4054 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/patches-5.4.inc
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/patches-5.4.inc
@@ -48,7 +48,7 @@
     file://999-1703-v5.18-mxl-gpy-phy-support.patch \
     file://999-1704-v6.2-net-phy-aquantia-add-AQR113C.patch \
     file://999-1708-v6.2-net-phy-add-5GBASER.patch \
-    file://999-1709-v6.2-net-phy-sfp-add-rollball-support.patch \
+    file://999-1709-v6.10-net-phy-sfp-add-rollball-support.patch \
     file://999-1710-v6.2-net-phy-add-phylink-pcs-support.patch;apply=no \
     file://999-1711-v6.2-net-phy-add-phylink-pcs-decode-helper.patch \
     file://999-1712-v6.2-net-phy-add-phylink-rate-matching-support.patch;apply=no \
@@ -56,6 +56,7 @@
     file://999-1714-v5.15-net-dsa-add-netdev_upper_dev_link.patch \
     file://999-1715-v6.2-net-dsa-add-set-queue-mapping.patch \
     file://999-1716-v6.6-net-phy-add-phylink-pcs_enable-and-pcs_disable.patch;apply=no \
+    file://999-1717-v5.12-net-phy-sfp-add-debugfs-support.patch \
     file://999-1750-v5.18-net-macsec-get-ready-to-backport-from-5-18.patch \
     file://999-1751-01-v5.18-net-macsec-move-some-definitions-in-a-dedicated-header.patch \
     file://999-1752-02-v5.18-net-macsec-introduce-the-macsec_context-structure.patch \