95b7cc6afe5112403eda7aa9ecd66744c2b2b186
[openwrt/staging/ldir.git] /
1 From 54d4147a121cec5004a673a58572da346e4458f8 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 3 Apr 2023 02:19:28 +0100
4 Subject: [PATCH 15/16] net: dsa: mt7530: skip locking if MDIO bus isn't
5 present
6
7 As MT7530 and MT7531 internally use 32-bit wide registers, each access
8 to any register of the switch requires several operations on the MDIO
9 bus. Hence if there is congruent access, e.g. due to PCS or PHY
10 polling, this can mess up and interfere with another ongoing register
11 access sequence.
12
13 However, the MDIO bus mutex is only relevant for MDIO-connected
14 switches. Prepare switches which have there registers directly mapped
15 into the SoCs register space via MMIO which do not require such
16 locking. There we can simply use regmap's default locking mechanism.
17
18 Hence guard mutex operations to only be performed in case of MDIO
19 connected switches.
20
21 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
22 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
23 Signed-off-by: David S. Miller <davem@davemloft.net>
24 ---
25 drivers/net/dsa/mt7530.c | 6 ++++--
26 1 file changed, 4 insertions(+), 2 deletions(-)
27
28 --- a/drivers/net/dsa/mt7530.c
29 +++ b/drivers/net/dsa/mt7530.c
30 @@ -144,13 +144,15 @@ err:
31 static void
32 mt7530_mutex_lock(struct mt7530_priv *priv)
33 {
34 - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
35 + if (priv->bus)
36 + mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
37 }
38
39 static void
40 mt7530_mutex_unlock(struct mt7530_priv *priv)
41 {
42 - mutex_unlock(&priv->bus->mdio_lock);
43 + if (priv->bus)
44 + mutex_unlock(&priv->bus->mdio_lock);
45 }
46
47 static void