[RFC PATCH 05/10] net: dsa: b53: prevent DIS_LEARNING access on BCM5325

Álvaro Fernández Rojas posted 10 patches 6 months, 2 weeks ago
There is a newer version of this series
[RFC PATCH 05/10] net: dsa: b53: prevent DIS_LEARNING access on BCM5325
Posted by Álvaro Fernández Rojas 6 months, 2 weeks ago
BCM5325 doesn't implement DIS_LEARNING register so we should avoid reading
or writing it.

Fixes: f9b3827ee66c ("net: dsa: b53: Support setting learning on port")
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 6b2ad82aa95f..9667d4107139 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -593,6 +593,9 @@ static void b53_port_set_learning(struct b53_device *dev, int port,
 {
 	u16 reg;
 
+	if (is5325(dev))
+		return;
+
 	b53_read16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, &reg);
 	if (learning)
 		reg &= ~BIT(port);
-- 
2.39.5

Re: [RFC PATCH 05/10] net: dsa: b53: prevent DIS_LEARNING access on BCM5325
Posted by Vladimir Oltean 6 months, 2 weeks ago
On Sat, May 31, 2025 at 12:13:03PM +0200, Álvaro Fernández Rojas wrote:
> BCM5325 doesn't implement DIS_LEARNING register so we should avoid reading
> or writing it.
> 
> Fixes: f9b3827ee66c ("net: dsa: b53: Support setting learning on port")
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/net/dsa/b53/b53_common.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index 6b2ad82aa95f..9667d4107139 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
> @@ -593,6 +593,9 @@ static void b53_port_set_learning(struct b53_device *dev, int port,
>  {
>  	u16 reg;
>  
> +	if (is5325(dev))
> +		return;
> +
>  	b53_read16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, &reg);
>  	if (learning)
>  		reg &= ~BIT(port);
> -- 
> 2.39.5
> 

I think if this switch family has that limitation, you should also patch
b53_br_flags_pre() to not permit BR_LEARNING in flags.val, and return
-EINVAL in that case. Otherwise, the "ip link set swp0 type bridge_slave
learning off" command will go through.