From: Daniel Golle <daniel@makrotopia.org>
To: "Chester A. Unal" <chester.a.unal@arinc9.com>,
Daniel Golle <daniel@makrotopia.org>,
Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Alexander Couzens <lynxis@fe80.eu>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Russell King <rmk+kernel@armlinux.org.uk>,
Sean Wang <sean.wang@mediatek.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Landen Chao <Landen.Chao@mediatek.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH net v2 3/5] net: dsa: mt7530: error out on failed reads in ATC/VTCR command polling
Date: Thu, 30 Jul 2026 01:14:52 +0100 [thread overview]
Message-ID: <b3158e751c5e8e3a36cd3bbb6b1c6f4ac9c17afd.1785368701.git.daniel@makrotopia.org> (raw)
In-Reply-To: <cover.1785368701.git.daniel@makrotopia.org>
mt7530_fdb_cmd() and mt7530_vlan_cmd() poll the command register
through a helper which returns 0 when the underlying read fails. A
failed bus transaction thus clears ATC_BUSY/VTCR_BUSY and is treated
as successful command completion, and the subsequent ATC_INVALID and
VTCR_INVALID checks are defeated the same way.
Poll using regmap_read_poll_timeout(), which stops on read errors and
propagates them, and use the register value it already read back
instead of re-reading it. Take the MDIO bus lock across the sequence
as the switch regmap is set up with locking disabled.
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Fixes: 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
v2:
* drop the extra regmap_read() after regmap_read_poll_timeout(); the
macro already leaves the polled value in val (found by Sashiko AI
review)
* print ret in the error messages and stop mislabeling propagated bus
errors as "reset timeout"/"poll timeout"
drivers/net/dsa/mt7530.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index f349b54c2d9e..aab26970f39b 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -252,24 +252,26 @@ mt7530_fdb_cmd(struct mt7530_priv *priv, enum mt7530_fdb_cmd cmd, u32 *rsp)
{
u32 val;
int ret;
- struct mt7530_dummy_poll p;
/* Set the command operating upon the MAC address entries */
val = ATC_BUSY | ATC_MAT(0) | cmd;
mt7530_write(priv, MT7530_ATC, val);
- INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_ATC);
- ret = readx_poll_timeout(_mt7530_read, &p, val,
- !(val & ATC_BUSY), 20, 20000);
+ mt7530_mutex_lock(priv);
+
+ ret = regmap_read_poll_timeout(priv->regmap, MT7530_ATC, val,
+ !(val & ATC_BUSY), 20, 20000);
+
+ mt7530_mutex_unlock(priv);
+
if (ret < 0) {
- dev_err(priv->dev, "reset timeout\n");
+ dev_err(priv->dev, "ATC poll failed: %d\n", ret);
return ret;
}
/* Additional sanity for read command if the specified
* entry is invalid
*/
- val = mt7530_read(priv, MT7530_ATC);
if ((cmd == MT7530_FDB_READ) && (val & ATC_INVALID))
return -EINVAL;
@@ -1630,22 +1632,24 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port,
static int
mt7530_vlan_cmd(struct mt7530_priv *priv, enum mt7530_vlan_cmd cmd, u16 vid)
{
- struct mt7530_dummy_poll p;
u32 val;
int ret;
val = VTCR_BUSY | VTCR_FUNC(cmd) | vid;
mt7530_write(priv, MT7530_VTCR, val);
- INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_VTCR);
- ret = readx_poll_timeout(_mt7530_read, &p, val,
- !(val & VTCR_BUSY), 20, 20000);
+ mt7530_mutex_lock(priv);
+
+ ret = regmap_read_poll_timeout(priv->regmap, MT7530_VTCR, val,
+ !(val & VTCR_BUSY), 20, 20000);
+
+ mt7530_mutex_unlock(priv);
+
if (ret < 0) {
- dev_err(priv->dev, "poll timeout\n");
+ dev_err(priv->dev, "VTCR poll failed: %d\n", ret);
return ret;
}
- val = mt7530_read(priv, MT7530_VTCR);
if (val & VTCR_INVALID) {
dev_err(priv->dev, "read VTCR invalid\n");
return -EINVAL;
--
2.55.0
next prev parent reply other threads:[~2026-07-30 0:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 0:14 [PATCH net v2 0/5] net: dsa: mt7530: fix swallowed MDIO read errors Daniel Golle
2026-07-30 0:14 ` [PATCH net v2 1/5] net: pcs: mtk-lynxi: check regmap reads in mtk_pcs_lynxi_get_state() Daniel Golle
2026-08-04 2:08 ` Andrew Lunn
2026-07-30 0:14 ` [PATCH net v2 2/5] net: dsa: mt7530: check bus->read() errors in the MDIO regmap backend Daniel Golle
2026-07-30 0:14 ` Daniel Golle [this message]
2026-07-30 0:14 ` [PATCH net v2 4/5] net: dsa: mt7530: error out on failed reads in MT7531 PHY polling Daniel Golle
2026-07-30 0:15 ` [PATCH net v2 5/5] net: dsa: mt7530: serialize the regmap IRQ chip like every other user Daniel Golle
2026-08-04 2:09 ` Andrew Lunn
2026-07-30 1:44 ` [PATCH net v2 0/5] net: dsa: mt7530: fix swallowed MDIO read errors 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=b3158e751c5e8e3a36cd3bbb6b1c6f4ac9c17afd.1785368701.git.daniel@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=Landen.Chao@mediatek.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chester.a.unal@arinc9.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=lynxis@fe80.eu \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sean.wang@mediatek.com \
/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
all inboxes | Powered by JetHome®