Skip to contentSkip to conversation

net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data struct to u64

PATCH Superseded Daniel Golle 3 participants 3 messages Jun 11, 2023 – Jun 13, 2023

Subsystems (4)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 6/8 net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data struct to u64

From: Lorenzo Bianconi <[email protected]>

This is a preliminary patch to introduce support for MT7988 SoC.

---
 drivers/net/ethernet/mediatek/mtk_eth_path.c | 22 +++----
 drivers/net/ethernet/mediatek/mtk_eth_soc.h  | 62 ++++++++++----------
 2 files changed, 42 insertions(+), 42 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_path.c +11 -11
index 317e447f49916..34ac492e047cb 100644
@@ -15,10 +15,10 @@
 struct mtk_eth_muxc {
 	const char	*name;
 	int		cap_bit;
-	int		(*set_path)(struct mtk_eth *eth, int path);
+	int		(*set_path)(struct mtk_eth *eth, u64 path);
 };
 
-static const char *mtk_eth_path_name(int path)
+static const char *mtk_eth_path_name(u64 path)
 {
 	switch (path) {
 	case MTK_ETH_PATH_GMAC1_RGMII:
@@ -40,7 +40,7 @@ static const char *mtk_eth_path_name(int path)
 	}
 }
 
-static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)
+static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
 {
 	bool updated = true;
 	u32 val, mask, set;
@@ -71,7 +71,7 @@ static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)
 	return 0;
 }
 
-static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)
+static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, u64 path)
 {
 	unsigned int val = 0;
 	bool updated = true;
@@ -94,7 +94,7 @@ static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)
 	return 0;
 }
 
-static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)
+static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, u64 path)
 {
 	unsigned int val = 0, mask = 0, reg = 0;
 	bool updated = true;
@@ -125,7 +125,7 @@ static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)
 	return 0;
 }
 
-static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)
+static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
 {
 	unsigned int val = 0;
 	bool updated = true;
@@ -163,7 +163,7 @@ static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)
 	return 0;
 }
 
-static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, int path)
+static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
 {
 	unsigned int val = 0;
 	bool updated = true;
@@ -218,7 +218,7 @@ static const struct mtk_eth_muxc mtk_eth_muxc[] = {
 	},
 };
 
-static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)
+static int mtk_eth_mux_setup(struct mtk_eth *eth, u64 path)
 {
 	int i, err = 0;
 
@@ -249,7 +249,7 @@ static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)
 
 int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
 {
-	int path;
+	u64 path;
 
 	path = (mac_id == 0) ?  MTK_ETH_PATH_GMAC1_SGMII :
 				MTK_ETH_PATH_GMAC2_SGMII;
@@ -260,7 +260,7 @@ int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
 
 int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
 {
-	int path = 0;
+	u64 path = 0;
 
 	if (mac_id == 1)
 		path = MTK_ETH_PATH_GMAC2_GEPHY;
@@ -274,7 +274,7 @@ int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
 
 int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
 {
-	int path;
+	u64 path;
 
 	path = (mac_id == 0) ?  MTK_ETH_PATH_GMAC1_RGMII :
 				MTK_ETH_PATH_GMAC2_RGMII;
drivers/net/ethernet/mediatek/mtk_eth_soc.h +31 -31

82 lines not on this page · raw message

Signature · 1 line
2.41.0
#1 lore raw
Quoted 6 lines · Daniel Golle

From: Lorenzo Bianconi <[email protected]>

This is a preliminary patch to introduce support for MT7988 SoC.

At some point, I'd really like to unpick this and see whether there's a better structure to it - so that mac_config() doesn't have to save the syscfg0 value, and restore it in mac_finish(). Given that syscfg0 is a shared register, are we sure the code that updates this register is safe from races caused by two MACs going through the config progress in two separate CPUs at the same time?

Is there anything which prevents two or more MACs wanting to mess with the contents of the SYSCFG0_SGMII_MASK bits? It's difficult to tell with the current code.

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!
#2 lore raw
Quoted 8 lines · Daniel Golle
Quoted 6 lines

From: Lorenzo Bianconi <[email protected]>

This is a preliminary patch to introduce support for MT7988 SoC.

Quoted 6 lines

At some point, I'd really like to unpick this and see whether there's a better structure to it - so that mac_config() doesn't have to save the syscfg0 value, and restore it in mac_finish(). Given that syscfg0 is a shared register, are we sure the code that updates this register is safe from races caused by two MACs going through the config progress in two separate CPUs at the same time?

Agree, this seems a bit racy. However it does not seem related to this patch. I would say we can address it with a follow-up patch.

Regards,
Lorenzo

Quoted 11 lines

Is there anything which prevents two or more MACs wanting to mess with the contents of the SYSCFG0_SGMII_MASK bits? It's difficult to tell with the current code.

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!