* [PATCH net v2 1/4] net: dsa: realtek: rtl8365mb: use devm_mutex_init for mib_lock
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
@ 2026-07-27 1:56 ` Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 2/4] net: dsa: realtek: use devm_mutex_init for regmap lock Luiz Angelo Daros de Luca
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-27 1:56 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Rasmussen, Florian Fainelli, Mieczyslaw Nalewaj
Cc: Luiz Angelo Daros de Luca, netdev, linux-kernel
With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() needs to be called
before the lock is discarded. Use devm_mutex_init() instead so the
cleanup is handled automatically.
Fixes: 4af2950c50c86 ("net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC")
Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/rtl8365mb_main.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index 5ac091bf93c9..aa05375b090a 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -1988,16 +1988,19 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port,
spin_unlock(&p->stats_lock);
}
-static void rtl8365mb_stats_setup(struct realtek_priv *priv)
+static int rtl8365mb_stats_setup(struct realtek_priv *priv)
{
struct rtl8365mb *mb = priv->chip_data;
struct dsa_switch *ds = &priv->ds;
struct dsa_port *dp;
+ int ret;
/* Per-chip global mutex to protect MIB counter access, since doing
* so requires accessing a series of registers in a particular order.
*/
- mutex_init(&mb->mib_lock);
+ ret = devm_mutex_init(priv->dev, &mb->mib_lock);
+ if (ret)
+ return ret;
dsa_switch_for_each_available_port(dp, ds) {
struct rtl8365mb_port *p = &mb->ports[dp->index];
@@ -2010,6 +2013,8 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv)
*/
INIT_DELAYED_WORK(&p->mib_work, rtl8365mb_stats_poll);
}
+
+ return 0;
}
static void rtl8365mb_stats_teardown(struct realtek_priv *priv)
@@ -2567,7 +2572,12 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
}
/* Start statistics counter polling */
- rtl8365mb_stats_setup(priv);
+ ret = rtl8365mb_stats_setup(priv);
+ if (ret) {
+ dev_err(priv->dev, "failed to setup stats: %pe\n",
+ ERR_PTR(ret));
+ goto out_teardown_irq;
+ }
return 0;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 2/4] net: dsa: realtek: use devm_mutex_init for regmap lock
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 1/4] net: dsa: realtek: rtl8365mb: use devm_mutex_init for mib_lock Luiz Angelo Daros de Luca
@ 2026-07-27 1:56 ` Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 3/4] net: dsa: realtek: use devm_mutex_init for vlan_lock Luiz Angelo Daros de Luca
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-27 1:56 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Rasmussen, Florian Fainelli, Mieczyslaw Nalewaj
Cc: Luiz Angelo Daros de Luca, netdev, linux-kernel
With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() needs to be called
before the lock is discarded. Use devm_mutex_init() instead so the
cleanup is handled automatically.
Fixes: 907e772f6f6de ("net: dsa: realtek: allow subdrivers to externally lock regmap")
Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/rtl83xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
index 71124ecca92f..9402bfe4f85a 100644
--- a/drivers/net/dsa/realtek/rtl83xx.c
+++ b/drivers/net/dsa/realtek/rtl83xx.c
@@ -156,7 +156,10 @@ rtl83xx_probe(struct device *dev,
if (!priv)
return ERR_PTR(-ENOMEM);
- mutex_init(&priv->map_lock);
+ ret = devm_mutex_init(dev, &priv->map_lock);
+ if (ret)
+ return ERR_PTR(ret);
+
mutex_init(&priv->vlan_lock);
mutex_init(&priv->l2_lock);
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 3/4] net: dsa: realtek: use devm_mutex_init for vlan_lock
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 1/4] net: dsa: realtek: rtl8365mb: use devm_mutex_init for mib_lock Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 2/4] net: dsa: realtek: use devm_mutex_init for regmap lock Luiz Angelo Daros de Luca
@ 2026-07-27 1:56 ` Luiz Angelo Daros de Luca
2026-07-27 1:56 ` [PATCH net v2 4/4] net: dsa: realtek: use devm_mutex_init for l2_lock Luiz Angelo Daros de Luca
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-27 1:56 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Rasmussen, Florian Fainelli, Mieczyslaw Nalewaj
Cc: Luiz Angelo Daros de Luca, netdev, linux-kernel
With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() needs to be called
before the lock is discarded. Use devm_mutex_init() instead so the
cleanup is handled automatically.
Fixes: 9da2c8672f771 ("net: dsa: realtek: rtl8365mb: add VLAN support")
Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/rtl83xx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
index 9402bfe4f85a..9f40afb19ab2 100644
--- a/drivers/net/dsa/realtek/rtl83xx.c
+++ b/drivers/net/dsa/realtek/rtl83xx.c
@@ -160,7 +160,10 @@ rtl83xx_probe(struct device *dev,
if (ret)
return ERR_PTR(ret);
- mutex_init(&priv->vlan_lock);
+ ret = devm_mutex_init(dev, &priv->vlan_lock);
+ if (ret)
+ return ERR_PTR(ret);
+
mutex_init(&priv->l2_lock);
rc.lock_arg = priv;
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 4/4] net: dsa: realtek: use devm_mutex_init for l2_lock
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
` (2 preceding siblings ...)
2026-07-27 1:56 ` [PATCH net v2 3/4] net: dsa: realtek: use devm_mutex_init for vlan_lock Luiz Angelo Daros de Luca
@ 2026-07-27 1:56 ` Luiz Angelo Daros de Luca
2026-07-27 12:26 ` [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Linus Walleij
2026-07-27 12:38 ` Alvin Šipraga
5 siblings, 0 replies; 7+ messages in thread
From: Luiz Angelo Daros de Luca @ 2026-07-27 1:56 UTC (permalink / raw)
To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Rasmussen, Florian Fainelli, Mieczyslaw Nalewaj
Cc: Luiz Angelo Daros de Luca, netdev, linux-kernel
With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() needs to be called
before the lock is discarded. Use devm_mutex_init() instead so the
cleanup is handled automatically.
Fixes: 336e3e4a1ab37 ("net: dsa: realtek: rtl8365mb: add FDB support")
Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
drivers/net/dsa/realtek/rtl83xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
index 9f40afb19ab2..9dd50b20c000 100644
--- a/drivers/net/dsa/realtek/rtl83xx.c
+++ b/drivers/net/dsa/realtek/rtl83xx.c
@@ -164,7 +164,9 @@ rtl83xx_probe(struct device *dev,
if (ret)
return ERR_PTR(ret);
- mutex_init(&priv->l2_lock);
+ ret = devm_mutex_init(dev, &priv->l2_lock);
+ if (ret)
+ return ERR_PTR(ret);
rc.lock_arg = priv;
priv->map = devm_regmap_init(dev, NULL, priv, &rc);
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
` (3 preceding siblings ...)
2026-07-27 1:56 ` [PATCH net v2 4/4] net: dsa: realtek: use devm_mutex_init for l2_lock Luiz Angelo Daros de Luca
@ 2026-07-27 12:26 ` Linus Walleij
2026-07-27 12:38 ` Alvin Šipraga
5 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2026-07-27 12:26 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Alvin Šipraga, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Michael Rasmussen,
Florian Fainelli, Mieczyslaw Nalewaj, netdev, linux-kernel
On Mon, Jul 27, 2026 at 3:56 AM Luiz Angelo Daros de Luca
<luizluca@gmail.com> wrote:
> This series fixes mutex teardown in the Realtek DSA drivers.
>
> With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() must be called before
> the mutex is discarded. Using devm_mutex_init() lets the driver core
> handle that automatically.
>
> The changes are split into individual commits based on the feature that
> introduced each lock to allow proper backports to stable trees.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
The series:
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init
2026-07-27 1:56 [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Luiz Angelo Daros de Luca
` (4 preceding siblings ...)
2026-07-27 12:26 ` [PATCH net v2 0/4] net: dsa: realtek: use devm_mutex_init Linus Walleij
@ 2026-07-27 12:38 ` Alvin Šipraga
5 siblings, 0 replies; 7+ messages in thread
From: Alvin Šipraga @ 2026-07-27 12:38 UTC (permalink / raw)
To: Luiz Angelo Daros de Luca
Cc: Linus Walleij, Alvin Šipraga, Andrew Lunn, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Michael Rasmussen, Florian Fainelli, Mieczyslaw Nalewaj, netdev,
linux-kernel
On Sun, Jul 26, 2026 at 10:56:07PM -0300, Luiz Angelo Daros de Luca wrote:
> This series fixes mutex teardown in the Realtek DSA drivers.
>
> With CONFIG_DEBUG_MUTEXES enabled, mutex_destroy() must be called before
> the mutex is discarded. Using devm_mutex_init() lets the driver core
> handle that automatically.
>
> The changes are split into individual commits based on the feature that
> introduced each lock to allow proper backports to stable trees.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
For the whole series,
Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>
^ permalink raw reply [flat|nested] 7+ messages in thread