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

From: Vladimir Oltean
Date: Mon Jun 02 2025 - 05:40:35 EST


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@xxxxxxxxx>
> ---
> 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.