* [PATCH net v3 1/5] net: dsa: vsc73xx: fix port MAC configuration in full duplex mode
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
@ 2024-08-09 19:38 ` Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 2/5] net: dsa: vsc73xx: pass value in phy_write operation Pawel Dembicki
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pawel Dembicki @ 2024-08-09 19:38 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Linus Walleij, Florian Fainelli, Andrew Lunn,
Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiner Kallweit, Russell King,
linux-kernel
According to the datasheet description ("Port Mode Procedure" in 5.6.2),
the VSC73XX_MAC_CFG_WEXC_DIS bit is configured only for half duplex mode.
The WEXC_DIS bit is responsible for MAC behavior after an excessive
collision. Let's set it as described in the datasheet.
Fixes: 05bd97fc559d ("net: dsa: Add Vitesse VSC73xx DSA router driver")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v3:
- resend only
v2:
- Added 'Fixes' and 'Reviewed-by' to commit message.
This patch came from net-next series[0].
Changes since net-next:
- rebased to netdev/main only
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index d9d3e30fd47a..f548ed4cb23f 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -957,6 +957,11 @@ static void vsc73xx_mac_link_up(struct phylink_config *config,
if (duplex == DUPLEX_FULL)
val |= VSC73XX_MAC_CFG_FDX;
+ else
+ /* In datasheet description ("Port Mode Procedure" in 5.6.2)
+ * this bit is configured only for half duplex.
+ */
+ val |= VSC73XX_MAC_CFG_WEXC_DIS;
/* This routine is described in the datasheet (below ARBDISC register
* description)
@@ -967,7 +972,6 @@ static void vsc73xx_mac_link_up(struct phylink_config *config,
get_random_bytes(&seed, 1);
val |= seed << VSC73XX_MAC_CFG_SEED_OFFSET;
val |= VSC73XX_MAC_CFG_SEED_LOAD;
- val |= VSC73XX_MAC_CFG_WEXC_DIS;
/* Those bits are responsible for MTU only. Kernel takes care about MTU,
* let's enable +8 bytes frame length unconditionally.
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v3 2/5] net: dsa: vsc73xx: pass value in phy_write operation
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 1/5] net: dsa: vsc73xx: fix port MAC configuration in full duplex mode Pawel Dembicki
@ 2024-08-09 19:38 ` Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 3/5] net: dsa: vsc73xx: check busy flag in MDIO operations Pawel Dembicki
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pawel Dembicki @ 2024-08-09 19:38 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Linus Walleij, Florian Fainelli, Andrew Lunn,
Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiner Kallweit, Russell King,
linux-kernel
In the 'vsc73xx_phy_write' function, the register value is missing,
and the phy write operation always sends zeros.
This commit passes the value variable into the proper register.
Fixes: 05bd97fc559d ("net: dsa: Add Vitesse VSC73xx DSA router driver")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v3:
- resend only
v2:
- Fixed 'Fixes' and added 'Reviewed-by' to commit message
This patch came from net-next series[0].
Changes since net-next:
- rebased to netdev/main only
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index f548ed4cb23f..4b300c293dec 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -574,7 +574,7 @@ static int vsc73xx_phy_write(struct dsa_switch *ds, int phy, int regnum,
return 0;
}
- cmd = (phy << 21) | (regnum << 16);
+ cmd = (phy << 21) | (regnum << 16) | val;
ret = vsc73xx_write(vsc, VSC73XX_BLOCK_MII, 0, 1, cmd);
if (ret)
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v3 3/5] net: dsa: vsc73xx: check busy flag in MDIO operations
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 1/5] net: dsa: vsc73xx: fix port MAC configuration in full duplex mode Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 2/5] net: dsa: vsc73xx: pass value in phy_write operation Pawel Dembicki
@ 2024-08-09 19:38 ` Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 4/5] net: dsa: vsc73xx: allow phy resetting Pawel Dembicki
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pawel Dembicki @ 2024-08-09 19:38 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Linus Walleij, Florian Fainelli, Andrew Lunn,
Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiner Kallweit, Russell King,
linux-kernel
The VSC73xx has a busy flag used during MDIO operations. It is raised
when MDIO read/write operations are in progress. Without it, PHYs are
misconfigured and bus operations do not work as expected.
Fixes: 05bd97fc559d ("net: dsa: Add Vitesse VSC73xx DSA router driver")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v3:
- removed blank line and unnecessary variable init
v2:
- used defines from patch moved to net-next
This patch came from net-next series[0].
Changes since net-next:
- removed mutex
- used method poll.h to poll busy value in 'vsc73xx_mdio_busy_check'
- use 'vsc73xx_mdio_busy_check' for control if mdio is ready
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 37 +++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index 4b300c293dec..a789b2da9b7d 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -40,6 +40,10 @@
#define VSC73XX_BLOCK_ARBITER 0x5 /* Only subblock 0 */
#define VSC73XX_BLOCK_SYSTEM 0x7 /* Only subblock 0 */
+/* MII Block subblock */
+#define VSC73XX_BLOCK_MII_INTERNAL 0x0 /* Internal MDIO subblock */
+#define VSC73XX_BLOCK_MII_EXTERNAL 0x1 /* External MDIO subblock */
+
#define CPU_PORT 6 /* CPU port */
/* MAC Block registers */
@@ -225,6 +229,8 @@
#define VSC73XX_MII_CMD 0x1
#define VSC73XX_MII_DATA 0x2
+#define VSC73XX_MII_STAT_BUSY BIT(3)
+
/* Arbiter block 5 registers */
#define VSC73XX_ARBEMPTY 0x0c
#define VSC73XX_ARBDISC 0x0e
@@ -299,6 +305,7 @@
#define IS_739X(a) (IS_7395(a) || IS_7398(a))
#define VSC73XX_POLL_SLEEP_US 1000
+#define VSC73XX_MDIO_POLL_SLEEP_US 5
#define VSC73XX_POLL_TIMEOUT_US 10000
struct vsc73xx_counter {
@@ -527,6 +534,22 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
return 0;
}
+static int vsc73xx_mdio_busy_check(struct vsc73xx *vsc)
+{
+ int ret, err;
+ u32 val;
+
+ ret = read_poll_timeout(vsc73xx_read, err,
+ err < 0 || !(val & VSC73XX_MII_STAT_BUSY),
+ VSC73XX_MDIO_POLL_SLEEP_US,
+ VSC73XX_POLL_TIMEOUT_US, false, vsc,
+ VSC73XX_BLOCK_MII, VSC73XX_BLOCK_MII_INTERNAL,
+ VSC73XX_MII_STAT, &val);
+ if (ret)
+ return ret;
+ return err;
+}
+
static int vsc73xx_phy_read(struct dsa_switch *ds, int phy, int regnum)
{
struct vsc73xx *vsc = ds->priv;
@@ -534,12 +557,20 @@ static int vsc73xx_phy_read(struct dsa_switch *ds, int phy, int regnum)
u32 val;
int ret;
+ ret = vsc73xx_mdio_busy_check(vsc);
+ if (ret)
+ return ret;
+
/* Setting bit 26 means "read" */
cmd = BIT(26) | (phy << 21) | (regnum << 16);
ret = vsc73xx_write(vsc, VSC73XX_BLOCK_MII, 0, 1, cmd);
if (ret)
return ret;
- msleep(2);
+
+ ret = vsc73xx_mdio_busy_check(vsc);
+ if (ret)
+ return ret;
+
ret = vsc73xx_read(vsc, VSC73XX_BLOCK_MII, 0, 2, &val);
if (ret)
return ret;
@@ -563,6 +594,10 @@ static int vsc73xx_phy_write(struct dsa_switch *ds, int phy, int regnum,
u32 cmd;
int ret;
+ ret = vsc73xx_mdio_busy_check(vsc);
+ if (ret)
+ return ret;
+
/* It was found through tedious experiments that this router
* chip really hates to have it's PHYs reset. They
* never recover if that happens: autonegotiation stops
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v3 4/5] net: dsa: vsc73xx: allow phy resetting
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
` (2 preceding siblings ...)
2024-08-09 19:38 ` [PATCH net v3 3/5] net: dsa: vsc73xx: check busy flag in MDIO operations Pawel Dembicki
@ 2024-08-09 19:38 ` Pawel Dembicki
2024-08-09 19:38 ` [PATCH net v3 5/5] net: phy: vitesse: repair vsc73xx autonegotiation Pawel Dembicki
2024-08-12 10:50 ` [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Pawel Dembicki @ 2024-08-09 19:38 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Linus Walleij, Florian Fainelli, Andrew Lunn,
Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiner Kallweit, Russell King,
linux-kernel
Resetting the VSC73xx PHY was problematic because the MDIO bus, without
a busy check, read and wrote incorrect register values.
My investigation indicates that resetting the PHY only triggers changes
in configuration. However, improper register values written earlier
were only exposed after a soft reset.
The reset itself wasn't the issue; rather, the problem stemmed from
incorrect read and write operations.
A 'soft_reset' can now proceed normally. There are no reasons to keep
the VSC73xx from being reset.
This commit removes the reset blockade in the 'vsc73xx_phy_write'
function.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v3:
- resend only
v2:
- improved commit description
This patch came from net-next series[0].
Changes since net-next:
- rebased to netdev/main only
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
drivers/net/dsa/vitesse-vsc73xx-core.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index a789b2da9b7d..e3f95d2cc2c1 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -598,17 +598,6 @@ static int vsc73xx_phy_write(struct dsa_switch *ds, int phy, int regnum,
if (ret)
return ret;
- /* It was found through tedious experiments that this router
- * chip really hates to have it's PHYs reset. They
- * never recover if that happens: autonegotiation stops
- * working after a reset. Just filter out this command.
- * (Resetting the whole chip is OK.)
- */
- if (regnum == 0 && (val & BIT(15))) {
- dev_info(vsc->dev, "reset PHY - disallowed\n");
- return 0;
- }
-
cmd = (phy << 21) | (regnum << 16) | val;
ret = vsc73xx_write(vsc, VSC73XX_BLOCK_MII, 0, 1, cmd);
if (ret)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v3 5/5] net: phy: vitesse: repair vsc73xx autonegotiation
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
` (3 preceding siblings ...)
2024-08-09 19:38 ` [PATCH net v3 4/5] net: dsa: vsc73xx: allow phy resetting Pawel Dembicki
@ 2024-08-09 19:38 ` Pawel Dembicki
2024-08-12 10:50 ` [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: Pawel Dembicki @ 2024-08-09 19:38 UTC (permalink / raw)
To: netdev
Cc: Pawel Dembicki, Linus Walleij, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Heiner Kallweit, Russell King, linux-kernel
When the vsc73xx mdio bus work properly, the generic autonegotiation
configuration works well.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
v3:
- removed MDI-X with disabled autoneg feature (it will goes to
net-next in future)
v2:
- resend only
This patch came from net-next series[0].
Changes since net-next:
- rebased to netdev/main only
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20240729210615.279952-6-paweldembicki@gmail.com/
---
drivers/net/phy/vitesse.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 897b979ec03c..3b5fcaf0dd36 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -237,16 +237,6 @@ static int vsc739x_config_init(struct phy_device *phydev)
return 0;
}
-static int vsc73xx_config_aneg(struct phy_device *phydev)
-{
- /* The VSC73xx switches does not like to be instructed to
- * do autonegotiation in any way, it prefers that you just go
- * with the power-on/reset defaults. Writing some registers will
- * just make autonegotiation permanently fail.
- */
- return 0;
-}
-
/* This adds a skew for both TX and RX clocks, so the skew should only be
* applied to "rgmii-id" interfaces. It may not work as expected
* on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces.
@@ -444,7 +434,6 @@ static struct phy_driver vsc82xx_driver[] = {
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = vsc738x_config_init,
- .config_aneg = vsc73xx_config_aneg,
.read_page = vsc73xx_read_page,
.write_page = vsc73xx_write_page,
}, {
@@ -453,7 +442,6 @@ static struct phy_driver vsc82xx_driver[] = {
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = vsc738x_config_init,
- .config_aneg = vsc73xx_config_aneg,
.read_page = vsc73xx_read_page,
.write_page = vsc73xx_write_page,
}, {
@@ -462,7 +450,6 @@ static struct phy_driver vsc82xx_driver[] = {
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = vsc739x_config_init,
- .config_aneg = vsc73xx_config_aneg,
.read_page = vsc73xx_read_page,
.write_page = vsc73xx_write_page,
}, {
@@ -471,7 +458,6 @@ static struct phy_driver vsc82xx_driver[] = {
.phy_id_mask = 0x000ffff0,
/* PHY_GBIT_FEATURES */
.config_init = vsc739x_config_init,
- .config_aneg = vsc73xx_config_aneg,
.read_page = vsc73xx_read_page,
.write_page = vsc73xx_write_page,
}, {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations
2024-08-09 19:38 [PATCH net v3 0/5] net: dsa: vsc73xx: fix MDIO bus access and PHY operations Pawel Dembicki
` (4 preceding siblings ...)
2024-08-09 19:38 ` [PATCH net v3 5/5] net: phy: vitesse: repair vsc73xx autonegotiation Pawel Dembicki
@ 2024-08-12 10:50 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-12 10:50 UTC (permalink / raw)
To: Pawel Dembicki
Cc: netdev, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, hkallweit1, linux, linus.walleij, linux-kernel
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Fri, 9 Aug 2024 21:38:01 +0200 you wrote:
> This series are extracted patches from net-next series [0].
>
> The VSC73xx driver has issues with PHY configuration. This patch series
> fixes most of them.
>
> The first patch synchronizes the register configuration routine with the
> datasheet recommendations.
>
> [...]
Here is the summary with links:
- [net,v3,1/5] net: dsa: vsc73xx: fix port MAC configuration in full duplex mode
https://git.kernel.org/netdev/net/c/63796bc2e97c
- [net,v3,2/5] net: dsa: vsc73xx: pass value in phy_write operation
https://git.kernel.org/netdev/net/c/5b9eebc2c7a5
- [net,v3,3/5] net: dsa: vsc73xx: check busy flag in MDIO operations
https://git.kernel.org/netdev/net/c/fa63c6434b6f
- [net,v3,4/5] net: dsa: vsc73xx: allow phy resetting
https://git.kernel.org/netdev/net/c/9f9a72654622
- [net,v3,5/5] net: phy: vitesse: repair vsc73xx autonegotiation
https://git.kernel.org/netdev/net/c/de7a670f8def
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 7+ messages in thread