Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Caleb James DeLisle" <cjd@cjdns.fr>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [net-next v5 4/7] net: dsa: mediatek: support PLL setup on MMIO MT7530
Date: Tue, 17 Nov 2026 18:35:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-219353@kernel.org> (raw)
In-Reply-To: <20261116183332.168858-5-cjd@cjdns.fr>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: dsa: mt7530: missing child_bus mdio_lock in core_write()
  and core_rmw()
--

commit 6d735d3a6c864581e5a423bea72209587b069abd
Author: Caleb James DeLisle <cjd@cjdns.fr>

net: dsa: mediatek: support PLL setup on MMIO MT7530

This commit saves the switch's child MDIO bus in priv->child_bus and falls
back to it in core_write() and core_rmw() when priv->bus is NULL so MMIO
MT7530 switches can configure core PLL registers via MDIO.

> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 09b7e9d2d0253..53ac692d5ba93 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -77,6 +77,12 @@ core_write(struct mt7530_priv *priv, u32 reg, u32 val)
>  	struct mii_bus *bus = priv->bus;
>  	int ret;
>  
> +	if (!bus)
> +		bus = priv->child_bus;
> +
> +	if (WARN_ON_ONCE(!bus))
> +		return;
> +
>  	mt7530_mutex_lock(priv);
>  
>  	/* Write the desired MMD Devad */
> @@ -112,6 +118,12 @@ core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
>  	u32 val;
>  	int ret;
>  
> +	if (!bus)
> +		bus = priv->child_bus;
> +
> +	if (WARN_ON_ONCE(!bus))
> +		return;
> +
>  	mt7530_mutex_lock(priv);
>  
>  	/* Write the desired MMD Devad */

[Severity: Medium]
Does falling back to priv->child_bus in core_write() and core_rmw() leave
the multi-step Clause 22 MMD sequence unlocked when priv->bus is NULL?

mt7530_mutex_lock() and mt7530_mutex_unlock() only lock priv->bus->mdio_lock:

drivers/net/dsa/mt7530.c:mt7530_mutex_lock() {
	if (priv->bus)
		mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
}

When priv->bus is NULL on an MMIO MT7530 switch, mt7530_mutex_lock() is a
no-op, and core_write() and core_rmw() invoke raw bus->write() and
bus->read() callbacks across four or five MII_MMD_CTRL and MII_MMD_DATA
transfers without holding priv->child_bus->mdio_lock.  Although each
individual Clause 22 transfer takes priv->reg_mutex inside
mt7531_ind_c22_phy_read() and mt7531_ind_c22_phy_write(), priv->reg_mutex is
dropped between transfers, so phylib polling or other activity on
priv->child_bus can interleave between MII_MMD_CTRL and MII_MMD_DATA and
corrupt the MMD register access (for example during mt7530_mac_config() ->
mt7530_setup_port6()).

Locking bus->mdio_lock when falling back to priv->child_bus will not
deadlock because core_write() and core_rmw() call bus->write() and
bus->read() directly rather than mdiobus_write() or mdiobus_read(), and the
underlying MMIO callbacks only acquire priv->reg_mutex.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116183332.168858-1-cjd@cjdns.fr?part=4

  reply	other threads:[~2026-11-17 18:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 18:33 [net-next v5 0/7] net: dsa: mt7530: support EcoNet EN751221 Caleb James DeLisle
2026-11-16 18:33 ` [net-next v5 1/7] net: dsa: mt7530: get ctrl phy addr using a function Caleb James DeLisle
2026-11-16 18:33 ` [net-next v5 2/7] dt-bindings: net: dsa: mediatek,mt7530: describe 'passthrough' hierarchy Caleb James DeLisle
2026-11-16 18:33 ` [net-next v5 3/7] net: dsa: mediatek: add support for passthrough mode Caleb James DeLisle
2026-11-17  0:30   ` kernel test robot
2026-11-17 18:35   ` sashiko-bot
2026-11-16 18:33 ` [net-next v5 4/7] net: dsa: mediatek: support PLL setup on MMIO MT7530 Caleb James DeLisle
2026-11-17 18:35   ` sashiko-bot [this message]
2026-11-16 18:33 ` [net-next v5 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch Caleb James DeLisle
2026-11-17 18:35   ` sashiko-bot
2026-11-16 18:33 ` [net-next v5 6/7] dt-bindings: net: dsa: mediatek,mt7530: add EcoNet EN751221 switches Caleb James DeLisle
2026-11-17 18:35   ` sashiko-bot
2026-11-16 18:33 ` [net-next v5 7/7] net: dsa: mediatek: support EN751221 switch Caleb James DeLisle
2026-11-17 18:35   ` sashiko-bot

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=sashiko-outbox-219353@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cjd@cjdns.fr \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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