diff mbox series

[net] net: stmmac: dwmac4: fix PCS duplex mode decode

Message ID E1sOz2O-00Gm9W-B7@rmk-PC.armlinux.org.uk (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: stmmac: dwmac4: fix PCS duplex mode decode | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 856 this patch: 856
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 860 this patch: 860
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 861 this patch: 861
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-03--15-00 (tests: 663)

Commit Message

Russell King (Oracle) July 3, 2024, 12:24 p.m. UTC
dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.

Thanks to Abhishek Chauhan for providing a response on this issue.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Halaney July 3, 2024, 1:57 p.m. UTC | #1
On Wed, Jul 03, 2024 at 01:24:40PM GMT, Russell King (Oracle) wrote:
> dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.
> 
> Thanks to Abhishek Chauhan for providing a response on this issue.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Fixes: 70523e639bf8c ("drivers: net: stmmac: reworking the PCS code.")
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index b25774d69195..26d837554a2d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -791,7 +791,7 @@ static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
>  		else
>  			x->pcs_speed = SPEED_10;
>  
> -		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK);
> +		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD);

Since GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK is confusing and unused I think
removing it altogether would be a good call.

Thanks,
Andrew
Andrew Lunn July 3, 2024, 2:06 p.m. UTC | #2
On Wed, Jul 03, 2024 at 01:24:40PM +0100, Russell King (Oracle) wrote:
> dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.

This appears to be the only use of
GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK. Maybe it should be removed after
this change?

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Serge Semin July 3, 2024, 2:55 p.m. UTC | #3
On Wed, Jul 03, 2024 at 01:24:40PM +0100, Russell King (Oracle) wrote:
> dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.
> 
> Thanks to Abhishek Chauhan for providing a response on this issue.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Right. The PHYIF_CTRLSTATUS CSR has the link status bits defined
starting from 16-bit position. So the method has improperly detected
duplex mode. Bit zero is occupied with the TC-flag (transmit RGMII,
SMII, SGMII configs) which is never set and which means the method
always reported the half-duplex link mode.

Reviewed-by: Serge Semin <fancer.lancer@gmail.com>

-Serge(y)

> ---
>  drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> index b25774d69195..26d837554a2d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
> @@ -791,7 +791,7 @@ static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
>  		else
>  			x->pcs_speed = SPEED_10;
>  
> -		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK);
> +		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD);
>  
>  		pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed,
>  			x->pcs_duplex ? "Full" : "Half");
> -- 
> 2.30.2
>
Serge Semin July 3, 2024, 3:07 p.m. UTC | #4
On Wed, Jul 03, 2024 at 04:06:54PM +0200, Andrew Lunn wrote:
> On Wed, Jul 03, 2024 at 01:24:40PM +0100, Russell King (Oracle) wrote:
> > dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> > register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> > rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.
> 
> This appears to be the only use of
> GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK. Maybe it should be removed after
> this change?

There is a PCS-refactoring work initiated by Russell, which besides of
other things may eventually imply dropping this macro:
https://lore.kernel.org/netdev/20240624132802.14238-6-fancer.lancer@gmail.com/
So unless it is strongly required I guess there is no much need in
respinning this patch or implementing additional one for now.

-Serge(y)

> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> 
>     Andrew
Russell King (Oracle) July 3, 2024, 3:29 p.m. UTC | #5
On Wed, Jul 03, 2024 at 06:07:54PM +0300, Serge Semin wrote:
> On Wed, Jul 03, 2024 at 04:06:54PM +0200, Andrew Lunn wrote:
> > On Wed, Jul 03, 2024 at 01:24:40PM +0100, Russell King (Oracle) wrote:
> > > dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> > > register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> > > rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.
> > 
> > This appears to be the only use of
> > GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK. Maybe it should be removed after
> > this change?
> 
> There is a PCS-refactoring work initiated by Russell, which besides of
> other things may eventually imply dropping this macro:
> https://lore.kernel.org/netdev/20240624132802.14238-6-fancer.lancer@gmail.com/
> So unless it is strongly required I guess there is no much need in
> respinning this patch or implementing additional one for now.

Nevertheless, a respin is worth doing with Andrew's suggested change
because this patch will impact the refactoring work even without that
change. We might as well have a complete patch for this change.

(Besides, I've already incorporated Andrew's feedback!)
Serge Semin July 3, 2024, 5:26 p.m. UTC | #6
On Wed, Jul 03, 2024 at 04:29:24PM +0100, Russell King (Oracle) wrote:
> On Wed, Jul 03, 2024 at 06:07:54PM +0300, Serge Semin wrote:
> > On Wed, Jul 03, 2024 at 04:06:54PM +0200, Andrew Lunn wrote:
> > > On Wed, Jul 03, 2024 at 01:24:40PM +0100, Russell King (Oracle) wrote:
> > > > dwmac4 was decoding the duplex mode from the GMAC_PHYIF_CONTROL_STATUS
> > > > register incorrectly, using GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK (value 1)
> > > > rather than GMAC_PHYIF_CTRLSTATUS_LNKMOD (bit 16). Fix this.
> > > 
> > > This appears to be the only use of
> > > GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK. Maybe it should be removed after
> > > this change?
> > 
> > There is a PCS-refactoring work initiated by Russell, which besides of
> > other things may eventually imply dropping this macro:
> > https://lore.kernel.org/netdev/20240624132802.14238-6-fancer.lancer@gmail.com/
> > So unless it is strongly required I guess there is no much need in
> > respinning this patch or implementing additional one for now.
> 
> Nevertheless, a respin is worth doing with Andrew's suggested change
> because this patch will impact the refactoring work even without that
> change. We might as well have a complete patch for this change.
> 
> (Besides, I've already incorporated Andrew's feedback!)

Ok. I just noted that that the respinning wasn't required due to the
same change implied by another patchset. But since you have already
implemented the change to make the patch more complete, then it's even
better than waiting for our STMMAC PCS discussions over.

-Serge(y)

> 
> -- 
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index b25774d69195..26d837554a2d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -791,7 +791,7 @@  static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
 		else
 			x->pcs_speed = SPEED_10;
 
-		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD_MASK);
+		x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD);
 
 		pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed,
 			x->pcs_duplex ? "Full" : "Half");