* [PATCH net v6 1/4] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding
2026-11-23 13:08 [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver Prabhakar
@ 2026-11-23 13:08 ` Prabhakar
2026-11-23 13:08 ` [PATCH net v6 2/4] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-23 13:08 UTC (permalink / raw)
To: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven
Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar, stable
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
The LK_LEARNCOUNT register selects its write operation through the MODE
field in bits [31:30], with the new count value in the low bits. The
driver writes the raw A5PSW_LK_LEARNCOUNT_MODE_* values (0, 1, 2)
directly, so the MODE field is always 0 (SET) and the mode value ends up
in the count field instead.
Add an a5psw_set_learncount() helper that places the mode in the correct
field using FIELD_PREP(), and use it for all LEARNCOUNT writes.
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>
Reviewed-by: Clément Léger <clement.leger@linux.dev>
---
v6:
- Added a5psw_set_learncount() helper function
- Update commit message to clarify the purpose of the helper function
- Added reviewed-by tag
v5: https://lore.kernel.org/all/20261120002549.1908299-9-prabhakar.mahadev-lad.rj@bp.renesas.com/
---
drivers/net/dsa/rzn1_a5psw.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
index 13c46cf2c420..4c32e06a3cd2 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>
@@ -120,6 +121,12 @@ static void a5psw_port_mgmtfwd_set(struct a5psw *a5psw, int port, bool enable)
a5psw_port_pattern_set(a5psw, port, A5PSW_PATTERN_MGMTFWD, enable);
}
+static void a5psw_set_learncount(struct a5psw *a5psw, u32 mode)
+{
+ a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT,
+ FIELD_PREP(A5PSW_LK_LEARNCOUNT_MODE, mode));
+}
+
static void a5psw_port_tx_enable(struct a5psw *a5psw, int port, bool enable)
{
u32 mask = A5PSW_PORT_ENA_TX(port);
@@ -544,10 +551,8 @@ static int a5psw_port_fdb_add(struct dsa_switch *ds, int port,
if (ret)
goto lk_unlock;
- if (inc_learncount) {
- reg = A5PSW_LK_LEARNCOUNT_MODE_INC;
- a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
- }
+ if (inc_learncount)
+ a5psw_set_learncount(a5psw, A5PSW_LK_LEARNCOUNT_MODE_INC);
lk_unlock:
mutex_unlock(&a5psw->lk_lock);
@@ -603,10 +608,8 @@ static int a5psw_port_fdb_del(struct dsa_switch *ds, int port,
goto lk_unlock;
/* Decrement LEARNCOUNT */
- if (clear) {
- reg = A5PSW_LK_LEARNCOUNT_MODE_DEC;
- a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
- }
+ if (clear)
+ a5psw_set_learncount(a5psw, A5PSW_LK_LEARNCOUNT_MODE_DEC);
lk_unlock:
mutex_unlock(&a5psw->lk_lock);
@@ -963,8 +966,7 @@ static int a5psw_setup(struct dsa_switch *ds)
}
/* Reset learn count to 0 */
- reg = A5PSW_LK_LEARNCOUNT_MODE_SET;
- a5psw_reg_writel(a5psw, A5PSW_LK_LEARNCOUNT, reg);
+ a5psw_set_learncount(a5psw, A5PSW_LK_LEARNCOUNT_MODE_SET);
/* Clear VLAN resource table */
reg = A5PSW_VLAN_RES_WR_PORTMASK | A5PSW_VLAN_RES_WR_TAGMASK;
--
2.56.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v6 2/4] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset
2026-11-23 13:08 [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver Prabhakar
2026-11-23 13:08 ` [PATCH net v6 1/4] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
@ 2026-11-23 13:08 ` Prabhakar
2026-11-23 13:08 ` [PATCH net v6 3/4] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Prabhakar
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-23 13:08 UTC (permalink / raw)
To: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven
Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
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>
---
v6:
- No changes from v5
v5: https://lore.kernel.org/all/20261120002549.1908299-10-prabhakar.mahadev-lad.rj@bp.renesas.com/
---
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 v6 3/4] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation
2026-11-23 13:08 [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver Prabhakar
2026-11-23 13:08 ` [PATCH net v6 1/4] net: dsa: rzn1-a5psw: Fix LK_LEARNCOUNT write mode encoding Prabhakar
2026-11-23 13:08 ` [PATCH net v6 2/4] net: dsa: rzn1-a5psw: Fix VLANTransmitted counter offset Prabhakar
@ 2026-11-23 13:08 ` Prabhakar
2026-11-23 13:08 ` [PATCH net v6 4/4] net: dsa: rzn1-a5psw: Set driver data in probe Prabhakar
2026-11-23 13:12 ` [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver netdev-bot+sinfo
4 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-23 13:08 UTC (permalink / raw)
To: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven
Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
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>
Reviewed-by: Clément Léger <clement.leger@linux.dev>
---
v6:
- Added reviewed-by tag
v5: https://lore.kernel.org/all/20261120002549.1908299-11-prabhakar.mahadev-lad.rj@bp.renesas.com/
---
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 4c32e06a3cd2..7fc62956c5d0 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>
@@ -1102,7 +1103,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 v6 4/4] net: dsa: rzn1-a5psw: Set driver data in probe
2026-11-23 13:08 [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver Prabhakar
` (2 preceding siblings ...)
2026-11-23 13:08 ` [PATCH net v6 3/4] net: dsa: rzn1-a5psw: Fix MDIO clock divider calculation Prabhakar
@ 2026-11-23 13:08 ` Prabhakar
2026-11-23 13:12 ` [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver netdev-bot+sinfo
4 siblings, 0 replies; 7+ messages in thread
From: Prabhakar @ 2026-11-23 13:08 UTC (permalink / raw)
To: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven
Cc: Florian Fainelli, Ralph Siemsen, linux-renesas-soc, netdev,
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>
Reviewed-by: Clément Léger <clement.leger@linux.dev>
---
v6:
- Added reviewed-by tag
v5: https://lore.kernel.org/all/20261120002549.1908299-12-prabhakar.mahadev-lad.rj@bp.renesas.com/
---
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 7fc62956c5d0..4925d24ec2a3 100644
--- a/drivers/net/dsa/rzn1_a5psw.c
+++ b/drivers/net/dsa/rzn1_a5psw.c
@@ -1219,6 +1219,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 v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver
2026-11-23 13:08 [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver Prabhakar
` (3 preceding siblings ...)
2026-11-23 13:08 ` [PATCH net v6 4/4] net: dsa: rzn1-a5psw: Set driver data in probe Prabhakar
@ 2026-11-23 13:12 ` netdev-bot+sinfo
2026-11-23 13:16 ` Lad, Prabhakar
4 siblings, 1 reply; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-23 13:12 UTC (permalink / raw)
To: Prabhakar
Cc: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven, Florian Fainelli, Ralph Siemsen,
linux-renesas-soc, netdev, Prabhakar, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver
2026-11-23 13:12 ` [PATCH net v6 0/4] net: dsa: Fix various issues in rzn1-a5psw driver netdev-bot+sinfo
@ 2026-11-23 13:16 ` Lad, Prabhakar
0 siblings, 0 replies; 7+ messages in thread
From: Lad, Prabhakar @ 2026-11-23 13:16 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Clément Léger, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Geert Uytterhoeven, Florian Fainelli, Ralph Siemsen,
linux-renesas-soc, netdev, Prabhakar, Biju Das, Fabrizio Castro,
Lad Prabhakar
On Mon, Nov 23, 2026 at 1:12 PM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
The issues were found while manually comparing the hardware manuals
for RZ/N1 and RZ/T2H SoCs.
Cheers,
Prabhakar
^ permalink raw reply [flat|nested] 7+ messages in thread