Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding
       [not found] <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
@ 2026-11-20  0:25 ` Prabhakar
  2026-11-20  3:27   ` Andrew Lunn
  2026-11-20  6:01   ` Clement Leger
  2026-11-20  0:25 ` [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-20  0:25 UTC (permalink / raw)
  To: Clément Léger, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit,
	Russell King, Simon Horman, Philipp Zabel, Geert Uytterhoeven,
	Magnus Damm
  Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

The LK_LEARNCOUNT write mode lives in bits [31:30] of the register, but
the driver writes the raw A5PSW_LK_LEARNCOUNT_MODE_* values (0, 1, 2)
directly. As a result, adding an FDB entry writes "set LEARNCOUNT to 1"
and deleting one writes "set LEARNCOUNT to 2", instead of atomically
incrementing/decrementing the counter.

Use FIELD_PREP() with A5PSW_LK_LEARNCOUNT_MODE so the mode lands in the
correct bit field.

Fixes: 5edf246c6869 ("net: dsa: rzn1-a5psw: add FDB support")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
 drivers/net/dsa/rzn1_a5psw.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
index 13c46cf2c420..7fd2652813ac 100644
--- a/drivers/net/dsa/rzn1_a5psw.c
+++ b/drivers/net/dsa/rzn1_a5psw.c
@@ -5,6 +5,7 @@
  * Clément Léger <clement.leger@bootlin.com>
  */
 
+#include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/etherdevice.h>
 #include <linux/if_bridge.h>
@@ -545,7 +546,8 @@ static int a5psw_port_fdb_add(struct dsa_switch *ds, int port,
 		goto lk_unlock;
 
 	if (inc_learncount) {
-		reg = A5PSW_LK_LEARNCOUNT_MODE_INC;
+		reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
+				 A5PSW_LK_LEARNCOUNT_MODE_INC);
 		a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
 	}
 
@@ -604,7 +606,8 @@ static int a5psw_port_fdb_del(struct dsa_switch *ds, int port,
 
 	/* Decrement LEARNCOUNT */
 	if (clear) {
-		reg = A5PSW_LK_LEARNCOUNT_MODE_DEC;
+		reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
+				 A5PSW_LK_LEARNCOUNT_MODE_DEC);
 		a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
 	}
 
@@ -963,7 +966,8 @@ static int a5psw_setup(struct dsa_switch *ds)
 	}
 
 	/* Reset learn count to 0 */
-	reg = A5PSW_LK_LEARNCOUNT_MODE_SET;
+	reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
+			 A5PSW_LK_LEARNCOUNT_MODE_SET);
 	a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
 
 	/* Clear VLAN resource table */
-- 
2.56.1


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

* [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset
       [not found] <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
  2026-11-20  0:25 ` [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
@ 2026-11-20  0:25 ` Prabhakar
  2026-11-20  3:29   ` Andrew Lunn
  2026-11-20  0:25 ` [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Prabhakar
  2026-11-20  0:25 ` [PATCH net-next v5 11/24] net: dsa: rzn1-a5psw: Set driver data in probe Prabhakar
  3 siblings, 1 reply; 7+ messages in thread
From: Prabhakar @ 2026-11-20  0:25 UTC (permalink / raw)
  To: Clément Léger, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit,
	Russell King, Simon Horman, Philipp Zabel, Geert Uytterhoeven,
	Magnus Damm
  Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

The RZ/N1 hardware manual places the VLANTransmittedOK counter at
offset 0x8f4, not 0x8ec. Correct the register offset so the driver
reads the counter from the right location.

Fixes: c7243fd4a62f ("net: dsa: rzn1-a5psw: add statistics support")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
 drivers/net/dsa/rzn1_a5psw.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h
index d54acedac194..9693f8503b0b 100644
--- a/drivers/net/dsa/rzn1_a5psw.h
+++ b/drivers/net/dsa/rzn1_a5psw.h
@@ -185,7 +185,7 @@
 #define A5PSW_etherStatsFragments		0x8E0
 
 #define A5PSW_VLANReceived			0x8E8
-#define A5PSW_VLANTransmitted			0x8EC
+#define A5PSW_VLANTransmitted			0x8F4
 
 #define A5PSW_aDeferred				0x910
 #define A5PSW_aMultipleCollisions		0x914
-- 
2.56.1


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

* [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation
       [not found] <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
  2026-11-20  0:25 ` [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
  2026-11-20  0:25 ` [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
@ 2026-11-20  0:25 ` Prabhakar
  2026-11-20  0:25 ` [PATCH net-next v5 11/24] net: dsa: rzn1-a5psw: Set driver data in probe Prabhakar
  3 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-20  0:25 UTC (permalink / raw)
  To: Clément Léger, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit,
	Russell King, Simon Horman, Philipp Zabel, Geert Uytterhoeven,
	Magnus Damm
  Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

The MDC frequency is hclk / (2 * CLKDIV + 1) on RZ/N1 as well as
RZ/T2H and RZ/N2H. The existing calculation uses the wrong divisor
formula and can set MDC above the requested clock-frequency.

Calculate the smallest CLKDIV that keeps MDC at or below the requested
frequency.

Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
 drivers/net/dsa/rzn1_a5psw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
index 7fd2652813ac..df3b3f75b489 100644
--- a/drivers/net/dsa/rzn1_a5psw.c
+++ b/drivers/net/dsa/rzn1_a5psw.c
@@ -11,6 +11,7 @@
 #include <linux/if_bridge.h>
 #include <linux/if_ether.h>
 #include <linux/kernel.h>
+#include <linux/math.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_mdio.h>
@@ -1104,7 +1105,7 @@ static int a5psw_mdio_config(struct a5psw *a5psw, u32 mdio_freq)
 	u32 cfgstatus;
 
 	rate = clk_get_rate(a5psw->hclk);
-	div = ((rate / mdio_freq) / 2);
+	div = DIV_ROUND_UP(DIV_ROUND_UP(rate, mdio_freq) - 1, 2);
 	if (div > FIELD_MAX(A5PSW_MDIO_CFG_STATUS_CLKDIV) ||
 	    div < A5PSW_MDIO_CLK_DIV_MIN) {
 		dev_err(a5psw->dev, "MDIO clock div %ld out of range\n", div);
-- 
2.56.1


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

* [PATCH net-next v5 11/24] net: dsa: rzn1-a5psw: Set driver data in probe
       [not found] <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
                   ` (2 preceding siblings ...)
  2026-11-20  0:25 ` [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Prabhakar
@ 2026-11-20  0:25 ` Prabhakar
  3 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-20  0:25 UTC (permalink / raw)
  To: Clément Léger, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit,
	Russell King, Simon Horman, Philipp Zabel, Geert Uytterhoeven,
	Magnus Damm
  Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

a5psw_remove() and a5psw_shutdown() retrieve the driver private data
using platform_get_drvdata(), but a5psw_probe() never sets it.
Consequently, both callbacks return early without unregistering or
shutting down the DSA switch.

Set the driver data in probe to ensure the remove and shutdown
callbacks can access the private data and perform the required DSA
cleanup.

Fixes: 888cdb892b61 ("net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v4->v5:
- New patch
---
 drivers/net/dsa/rzn1_a5psw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
index df3b3f75b489..0e4bbf34ec27 100644
--- a/drivers/net/dsa/rzn1_a5psw.c
+++ b/drivers/net/dsa/rzn1_a5psw.c
@@ -1221,6 +1221,7 @@ static int a5psw_probe(struct platform_device *pdev)
 	if (!a5psw)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, a5psw);
 	a5psw->dev = dev;
 	mutex_init(&a5psw->lk_lock);
 	spin_lock_init(&a5psw->reg_lock);
-- 
2.56.1


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

* Re: [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding
  2026-11-20  0:25 ` [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
@ 2026-11-20  3:27   ` Andrew Lunn
  2026-11-20  6:01   ` Clement Leger
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2026-11-20  3:27 UTC (permalink / raw)
  To: Prabhakar
  Cc: Clément Léger, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit, Russell King,
	Simon Horman, Philipp Zabel, Geert Uytterhoeven, Magnus Damm,
	Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

On Fri, Nov 20, 2026 at 12:25:18AM +0000, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> The LK_LEARNCOUNT write mode lives in bits [31:30] of the register, but
> the driver writes the raw A5PSW_LK_LEARNCOUNT_MODE_* values (0, 1, 2)
> directly. As a result, adding an FDB entry writes "set LEARNCOUNT to 1"
> and deleting one writes "set LEARNCOUNT to 2", instead of atomically
> incrementing/decrementing the counter.
> 
> Use FIELD_PREP() with A5PSW_LK_LEARNCOUNT_MODE so the mode lands in the
> correct bit field.
> 
> Fixes: 5edf246c6869 ("net: dsa: rzn1-a5psw: add FDB support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

This sounds like a real problem that should be fixed? So please submit
it to net, not net-next.

   Andrew

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

* Re: [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset
  2026-11-20  0:25 ` [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
@ 2026-11-20  3:29   ` Andrew Lunn
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2026-11-20  3:29 UTC (permalink / raw)
  To: Prabhakar
  Cc: Clément Léger, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit, Russell King,
	Simon Horman, Philipp Zabel, Geert Uytterhoeven, Magnus Damm,
	Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable

On Fri, Nov 20, 2026 at 12:25:19AM +0000, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> The RZ/N1 hardware manual places the VLANTransmittedOK counter at
> offset 0x8f4, not 0x8ec. Correct the register offset so the driver
> reads the counter from the right location.
> 
> Fixes: c7243fd4a62f ("net: dsa: rzn1-a5psw: add statistics support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

This again seems like a real fix, so should be for net.

Submitting these to net will also help with your patch count.

	   Andrew

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

* Re: [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding
  2026-11-20  0:25 ` [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
  2026-11-20  3:27   ` Andrew Lunn
@ 2026-11-20  6:01   ` Clement Leger
  1 sibling, 0 replies; 7+ messages in thread
From: Clement Leger @ 2026-11-20  6:01 UTC (permalink / raw)
  To: Prabhakar, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Heiner Kallweit, Russell King,
	Simon Horman, Philipp Zabel, Geert Uytterhoeven, Magnus Damm
  Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
	devicetree, Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar,
	stable



On 11/20/26 01:25, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> The LK_LEARNCOUNT write mode lives in bits [31:30] of the register, but
> the driver writes the raw A5PSW_LK_LEARNCOUNT_MODE_* values (0, 1, 2)
> directly. As a result, adding an FDB entry writes "set LEARNCOUNT to 1"
> and deleting one writes "set LEARNCOUNT to 2", instead of atomically
> incrementing/decrementing the counter.
> 
> Use FIELD_PREP() with A5PSW_LK_LEARNCOUNT_MODE so the mode lands in the
> correct bit field.
> 
> Fixes: 5edf246c6869 ("net: dsa: rzn1-a5psw: add FDB support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v4->v5:
> - New patch
> ---
>   drivers/net/dsa/rzn1_a5psw.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
> index 13c46cf2c420..7fd2652813ac 100644
> --- a/drivers/net/dsa/rzn1_a5psw.c
> +++ b/drivers/net/dsa/rzn1_a5psw.c
> @@ -5,6 +5,7 @@
>    * Clément Léger <clement.leger@bootlin.com>
>    */
>   
> +#include <linux/bitfield.h>
>   #include <linux/clk.h>
>   #include <linux/etherdevice.h>
>   #include <linux/if_bridge.h>
> @@ -545,7 +546,8 @@ static int a5psw_port_fdb_add(struct dsa_switch *ds, int port,
>   		goto lk_unlock;
>   
>   	if (inc_learncount) {
> -		reg = A5PSW_LK_LEARNCOUNT_MODE_INC;
> +		reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
> +				 A5PSW_LK_LEARNCOUNT_MODE_INC);
>   		a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
>   	}
>   
> @@ -604,7 +606,8 @@ static int a5psw_port_fdb_del(struct dsa_switch *ds, int port,
>   
>   	/* Decrement LEARNCOUNT */
>   	if (clear) {
> -		reg = A5PSW_LK_LEARNCOUNT_MODE_DEC;
> +		reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
> +				 A5PSW_LK_LEARNCOUNT_MODE_DEC);
>   		a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
>   	}
>   
> @@ -963,7 +966,8 @@ static int a5psw_setup(struct dsa_switch *ds)
>   	}
>   
>   	/* Reset learn count to 0 */
> -	reg = A5PSW_LK_LEARNCOUNT_MODE_SET;
> +	reg = FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE,
> +			 A5PSW_LK_LEARNCOUNT_MODE_SET);
>   	a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
>   
>   	/* Clear VLAN resource table */

Hi Prabhakar,

It could probably be worth it to add a small a5psw_set_learncount() 
helper that contains these the FIELD_PREP + writel.

Otherwise, LGTM:

Reviewed-by: Clément Léger <clement.leger@linux.dev>

Thanks,

Clément


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

end of thread, other threads:[~2026-11-20  6:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
2026-11-20  0:25 ` [PATCH net-next v5 08/24] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
2026-11-20  3:27   ` Andrew Lunn
2026-11-20  6:01   ` Clement Leger
2026-11-20  0:25 ` [PATCH net-next v5 09/24] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
2026-11-20  3:29   ` Andrew Lunn
2026-11-20  0:25 ` [PATCH net-next v5 10/24] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Prabhakar
2026-11-20  0:25 ` [PATCH net-next v5 11/24] net: dsa: rzn1-a5psw: Set driver data in probe Prabhakar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox