Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, lee@kernel.org,
	mfd@lists.linux.dev, conor+dt@kernel.org
Subject: Re: [PATCH net-next v20 08/10] net: dsa: mt7530: move MDIO bus locking into regmap
Date: Tue, 18 Aug 2026 09:03:25 +0000	[thread overview]
Message-ID: <20260818090326.154B21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260817082034.20326-10-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Recursive mutex deadlock in `mt7530_fdb_cmd`, `mt7530_vlan_cmd`, and `mt7530_irq_mask_sync` due to unremoved manual locks.
- [High] Mismatched lock acquisition and release, plus recursive self-deadlock, in MT7531 indirect PHY access functions.
--

--- Patch [8]: [PATCH net-next v20 08/10] net: dsa: mt7530: move MDIO bus locking into regmap ---
commit 93dc44aef1eb650f9b327c234ee71f5777a75b62
Author: Daniel Golle <daniel@makrotopia.org>

net: dsa: mt7530: move MDIO bus locking into regmap

This patch moves MDIO bus locking into the switch register regmap by
configuring the .lock and .unlock callbacks. It removes several manual locking
wrappers, relying on the regmap to protect register accesses automatically.
It also attempts to switch MT7531 indirect PHY accesses to use reg_mutex.

> --- a/drivers/net/dsa/mt7530-mdio.c
> +++ b/drivers/net/dsa/mt7530-mdio.c
> @@ -148,12 +148,14 @@ static const struct regmap_config regmap_config = {
>  	.val_bits = 32,
>  	.reg_stride = 4,
>  	.max_register = MT7530_CREV,
> -	.disable_locking = true,
> +	.lock = mt7530_mdio_regmap_lock,
> +	.unlock = mt7530_mdio_regmap_unlock,
>  };

[Severity: High]
Will adding the lock to the regmap configuration cause a recursive deadlock
in other functions that still hold the manual lock?

For example, in mt7530_fdb_cmd(), the manual lock is still held across a
regmap_read_poll_timeout() call:

mt7530_fdb_cmd() {
	mt7530_mutex_lock(priv);

	ret = regmap_read_poll_timeout(priv->regmap, MT7530_ATC, val,
				       !(val & ATC_BUSY), 20, 20000);
	...
}

Since mt7530_mutex_lock() takes the non-recursive mdio_lock, and the regmap
now automatically attempts to take the same lock, does this code self-deadlock?

It looks like mt7530_vlan_cmd() and mt7530_irq_mask_sync() also still hold
mt7530_mutex_lock() while calling regmap operations.

> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
[ ... ]
> @@ -597,7 +577,7 @@ mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
>  
>  	ret = val & MT7531_MDIO_RW_DATA_MASK;
>  out:
> -	mt7530_mutex_unlock(priv);
> +	mutex_unlock(&priv->reg_mutex);
>  
>  	return ret;
>  }

[Severity: High]
Does this leave the locks in an unbalanced state?

The entry path of mt7531_ind_c45_phy_read() still calls
mt7530_mutex_lock(priv), which takes the mdio_lock:

mt7531_ind_c45_phy_read() {
	mt7530_mutex_lock(priv);
	...
	ret = regmap_read_poll_timeout(...)
	...
}

But the exit path now releases a completely different lock (reg_mutex),
which wasn't previously held.

This pattern also seems to be present in mt7531_ind_c45_phy_write(),
mt7531_ind_c22_phy_read(), and mt7531_ind_c22_phy_write(), where the
semantic patch updated the unlock label but missed replacing the entry lock.

Additionally, since the entry path still takes the manual mdio_lock, do the
subsequent regmap calls inside these functions also trigger the same
recursive deadlock mentioned earlier?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817082034.20326-1-ansuelsmth@gmail.com?part=8

  reply	other threads:[~2026-08-18  9:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  8:20 [PATCH net-next v20 00/10] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-08-17  8:20 ` [PATCH net-next v20 01/10] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 02/10] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 03/10] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 04/10] mfd: an8855: Add support for Airoha AN8855 Switch MFD Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 04/10] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-08-18  1:19   ` Wayen Yan
2026-08-17  8:20 ` [PATCH net-next v20 05/10] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 06/10] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 07/10] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-08-17  8:20 ` [PATCH net-next v20 08/10] net: dsa: mt7530: move MDIO bus locking into regmap Christian Marangi
2026-08-18  9:03   ` sashiko-bot [this message]
2026-08-17  8:20 ` [PATCH net-next v20 09/10] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17  8:20 ` [PATCH net-next v20 10/10] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-08-18  9:03   ` sashiko-bot
2026-08-17 15:38 ` [PATCH net-next v20 00/10] net: dsa: Add Airoha AN8855 support Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260818090326.154B21F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox