netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: microchip: Fix KSZ8863 reset problem
@ 2025-08-02  0:22 Tristram.Ha
  2025-08-02 18:59 ` Oleksij Rempel
  0 siblings, 1 reply; 3+ messages in thread
From: Tristram.Ha @ 2025-08-02  0:22 UTC (permalink / raw)
  To: Oleksij Rempel, Woojung Huh, Andrew Lunn, Vladimir Oltean
  Cc: Maxime Chevallier, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel, Tristram Ha

From: Tristram Ha <tristram.ha@microchip.com>

ksz8873_valid_regs[] was added for register access for KSZ8863/KSZ8873
switches, but the reset register is not in the list so
ksz8_reset_switch() does not take any effect.

ksz_cfg() is updated to display an error so that there will be a future
check for adding new register access code.

A side effect of not resetting the switch is the static MAC table is not
cleared.  Further additions to the table will show write error as there
are only 8 entries in the table.

Fixes: d0dec3333040 ("net: dsa: microchip: Add register access control for KSZ8873 chip")
Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
---
 drivers/net/dsa/microchip/ksz8.c       | 7 ++++++-
 drivers/net/dsa/microchip/ksz_common.c | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
index 76e490070e9c..6d282a8e3684 100644
--- a/drivers/net/dsa/microchip/ksz8.c
+++ b/drivers/net/dsa/microchip/ksz8.c
@@ -36,7 +36,12 @@
 
 static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
 {
-	regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
+	int ret;
+
+	ret = regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
+	if (ret)
+		dev_err(dev->dev, "can't update reg 0x%x: %pe\n", addr,
+			ERR_PTR(ret));
 }
 
 static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 7292bfe2f7ca..4cb14288ff0f 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -1447,6 +1447,7 @@ static const struct regmap_range ksz8873_valid_regs[] = {
 	regmap_reg_range(0x3f, 0x3f),
 
 	/* advanced control registers */
+	regmap_reg_range(0x43, 0x43),
 	regmap_reg_range(0x60, 0x6f),
 	regmap_reg_range(0x70, 0x75),
 	regmap_reg_range(0x76, 0x78),
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: dsa: microchip: Fix KSZ8863 reset problem
  2025-08-02  0:22 [PATCH net] net: dsa: microchip: Fix KSZ8863 reset problem Tristram.Ha
@ 2025-08-02 18:59 ` Oleksij Rempel
  2025-08-07  0:53   ` Tristram.Ha
  0 siblings, 1 reply; 3+ messages in thread
From: Oleksij Rempel @ 2025-08-02 18:59 UTC (permalink / raw)
  To: Tristram.Ha
  Cc: Oleksij Rempel, Woojung Huh, Andrew Lunn, Vladimir Oltean,
	Maxime Chevallier, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, UNGLinuxDriver, netdev, linux-kernel

Hi,

On Fri, Aug 01, 2025 at 05:22:53PM -0700, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <tristram.ha@microchip.com>
> 
> ksz8873_valid_regs[] was added for register access for KSZ8863/KSZ8873
> switches, but the reset register is not in the list so
> ksz8_reset_switch() does not take any effect.
> 
> ksz_cfg() is updated to display an error so that there will be a future
> check for adding new register access code.
> 
> A side effect of not resetting the switch is the static MAC table is not
> cleared.  Further additions to the table will show write error as there
> are only 8 entries in the table.

Thank you for fixing it!

> Fixes: d0dec3333040 ("net: dsa: microchip: Add register access control for KSZ8873 chip")
> Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
> ---
>  drivers/net/dsa/microchip/ksz8.c       | 7 ++++++-
>  drivers/net/dsa/microchip/ksz_common.c | 1 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
> index 76e490070e9c..6d282a8e3684 100644
> --- a/drivers/net/dsa/microchip/ksz8.c
> +++ b/drivers/net/dsa/microchip/ksz8.c
> @@ -36,7 +36,12 @@
>  
>  static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
>  {
> -	regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
> +	int ret;
> +
> +	ret = regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
> +	if (ret)
> +		dev_err(dev->dev, "can't update reg 0x%x: %pe\n", addr,
> +			ERR_PTR(ret));

Better using ksz_rmw8() instead. It is already providing error message.

In this file there is 4 direct accesses to regmap_update_bits() without
error handling. It would be great if you have chance to replace it with
ksz_rmw8() too.

>  }
>  
>  static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 7292bfe2f7ca..4cb14288ff0f 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -1447,6 +1447,7 @@ static const struct regmap_range ksz8873_valid_regs[] = {
>  	regmap_reg_range(0x3f, 0x3f),
>  
>  	/* advanced control registers */
> +	regmap_reg_range(0x43, 0x43),

This register is no documented in the public documentation. Out of
curiosity, are there some where more information about this two
"reserved" register ranges: 0x3A-0x3E and 0x40-0x5F?

Best regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net: dsa: microchip: Fix KSZ8863 reset problem
  2025-08-02 18:59 ` Oleksij Rempel
@ 2025-08-07  0:53   ` Tristram.Ha
  0 siblings, 0 replies; 3+ messages in thread
From: Tristram.Ha @ 2025-08-07  0:53 UTC (permalink / raw)
  To: o.rempel
  Cc: linux, Woojung.Huh, andrew, olteanv, maxime.chevallier, davem,
	edumazet, kuba, pabeni, UNGLinuxDriver, netdev, linux-kernel

> On Fri, Aug 01, 2025 at 05:22:53PM -0700, Tristram.Ha@microchip.com wrote:
> > From: Tristram Ha <tristram.ha@microchip.com>
> >
> > ksz8873_valid_regs[] was added for register access for KSZ8863/KSZ8873
> > switches, but the reset register is not in the list so
> > ksz8_reset_switch() does not take any effect.
> >
> > ksz_cfg() is updated to display an error so that there will be a future
> > check for adding new register access code.
> >
> > A side effect of not resetting the switch is the static MAC table is not
> > cleared.  Further additions to the table will show write error as there
> > are only 8 entries in the table.
> 
> Thank you for fixing it!
> 
> > Fixes: d0dec3333040 ("net: dsa: microchip: Add register access control for KSZ8873
> chip")
> > Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
> > ---
> >  drivers/net/dsa/microchip/ksz8.c       | 7 ++++++-
> >  drivers/net/dsa/microchip/ksz_common.c | 1 +
> >  2 files changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
> > index 76e490070e9c..6d282a8e3684 100644
> > --- a/drivers/net/dsa/microchip/ksz8.c
> > +++ b/drivers/net/dsa/microchip/ksz8.c
> > @@ -36,7 +36,12 @@
> >
> >  static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
> >  {
> > -     regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
> > +     int ret;
> > +
> > +     ret = regmap_update_bits(ksz_regmap_8(dev), addr, bits, set ? bits : 0);
> > +     if (ret)
> > +             dev_err(dev->dev, "can't update reg 0x%x: %pe\n", addr,
> > +                     ERR_PTR(ret));
> 
> Better using ksz_rmw8() instead. It is already providing error message.
> 
> In this file there is 4 direct accesses to regmap_update_bits() without
> error handling. It would be great if you have chance to replace it with
> ksz_rmw8() too.

Will do.

> >  }
> >
> >  static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
> > diff --git a/drivers/net/dsa/microchip/ksz_common.c
> b/drivers/net/dsa/microchip/ksz_common.c
> > index 7292bfe2f7ca..4cb14288ff0f 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.c
> > +++ b/drivers/net/dsa/microchip/ksz_common.c
> > @@ -1447,6 +1447,7 @@ static const struct regmap_range ksz8873_valid_regs[] =
> {
> >       regmap_reg_range(0x3f, 0x3f),
> >
> >       /* advanced control registers */
> > +     regmap_reg_range(0x43, 0x43),
> 
> This register is no documented in the public documentation. Out of
> curiosity, are there some where more information about this two
> "reserved" register ranges: 0x3A-0x3E and 0x40-0x5F?

The current KSZ8863 and KSZ8873 datasheets available from Microchip
website do define this 0x43 register as it is a basic operation to reset
the chip.  One thing is the register bits are automatically cleared so it
does not require a second write.

Registers 0x1A-1E and 0x2A-2E are used for LinkMD feature of the PHY and
other PHY related status, so they do not apply for port 3 with 0x3A-3E.

Registers 0x40-0x5F are not used as they are not in the datasheet.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-07  0:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-02  0:22 [PATCH net] net: dsa: microchip: Fix KSZ8863 reset problem Tristram.Ha
2025-08-02 18:59 ` Oleksij Rempel
2025-08-07  0:53   ` Tristram.Ha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).