mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 23:42:43 +00:00
fb2c6e9d4d
Removed because they are upstream: generic/backport-5.15/704-15-v5.19-net-mtk_eth_soc-move-MAC_MCR-setting-to-mac_finish.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=c5c0760adc260d55265c086b9efb350ea6dda38b generic/pending-5.15/735-net-mediatek-mtk_eth_soc-release-MAC_MCR_FORCE_LINK-.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=448cc8b5f743985f6d1d98aa4efb386fef4c3bf2 generic/pending-5.15/736-net-ethernet-mtk_eth_soc-fix-PPE-hanging-issue.patch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=9fcadd125044007351905d40c405fadc2d3bb6d6 Add new configuration symbols for tegra target. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
274 lines
7.0 KiB
Diff
274 lines
7.0 KiB
Diff
From 1557c679f71c82a994eae0baadbaeb62b71e15bf Mon Sep 17 00:00:00 2001
|
|
From: Daniel Golle <daniel@makrotopia.org>
|
|
Date: Mon, 3 Apr 2023 02:18:16 +0100
|
|
Subject: [PATCH 09/16] net: dsa: mt7530: introduce mutex helpers
|
|
|
|
As the MDIO bus lock only needs to be involved if actually operating
|
|
on an MDIO-connected switch we will need to skip locking for built-in
|
|
switches which are accessed via MMIO.
|
|
Create helper functions which simplify that upcoming change.
|
|
|
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
drivers/net/dsa/mt7530.c | 73 ++++++++++++++++++++--------------------
|
|
1 file changed, 36 insertions(+), 37 deletions(-)
|
|
|
|
--- a/drivers/net/dsa/mt7530.c
|
|
+++ b/drivers/net/dsa/mt7530.c
|
|
@@ -144,31 +144,40 @@ err:
|
|
}
|
|
|
|
static void
|
|
-core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
|
+mt7530_mutex_lock(struct mt7530_priv *priv)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
+ mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+}
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+static void
|
|
+mt7530_mutex_unlock(struct mt7530_priv *priv)
|
|
+{
|
|
+ mutex_unlock(&priv->bus->mdio_lock);
|
|
+}
|
|
+
|
|
+static void
|
|
+core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
|
+{
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
}
|
|
|
|
static void
|
|
core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
u32 val;
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
|
|
val &= ~mask;
|
|
val |= set;
|
|
core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
}
|
|
|
|
static void
|
|
@@ -265,13 +274,11 @@ mt7530_mii_read(struct mt7530_priv *priv
|
|
static void
|
|
mt7530_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
-
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
mt7530_mii_write(priv, reg, val);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
}
|
|
|
|
static u32
|
|
@@ -283,14 +290,13 @@ _mt7530_unlocked_read(struct mt7530_dumm
|
|
static u32
|
|
_mt7530_read(struct mt7530_dummy_poll *p)
|
|
{
|
|
- struct mii_bus *bus = p->priv->bus;
|
|
u32 val;
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(p->priv);
|
|
|
|
val = mt7530_mii_read(p->priv, p->reg);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(p->priv);
|
|
|
|
return val;
|
|
}
|
|
@@ -308,13 +314,11 @@ static void
|
|
mt7530_rmw(struct mt7530_priv *priv, u32 reg,
|
|
u32 mask, u32 set)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
-
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
regmap_update_bits(priv->regmap, reg, mask, set);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
}
|
|
|
|
static void
|
|
@@ -646,14 +650,13 @@ static int
|
|
mt7531_ind_c45_phy_read(struct mt7530_priv *priv, int port, int devad,
|
|
int regnum)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
struct mt7530_dummy_poll p;
|
|
u32 reg, val;
|
|
int ret;
|
|
|
|
INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
|
|
!(val & MT7531_PHY_ACS_ST), 20, 100000);
|
|
@@ -686,7 +689,7 @@ mt7531_ind_c45_phy_read(struct mt7530_pr
|
|
|
|
ret = val & MT7531_MDIO_RW_DATA_MASK;
|
|
out:
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
return ret;
|
|
}
|
|
@@ -695,14 +698,13 @@ static int
|
|
mt7531_ind_c45_phy_write(struct mt7530_priv *priv, int port, int devad,
|
|
int regnum, u32 data)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
struct mt7530_dummy_poll p;
|
|
u32 val, reg;
|
|
int ret;
|
|
|
|
INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
|
|
!(val & MT7531_PHY_ACS_ST), 20, 100000);
|
|
@@ -734,7 +736,7 @@ mt7531_ind_c45_phy_write(struct mt7530_p
|
|
}
|
|
|
|
out:
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
return ret;
|
|
}
|
|
@@ -742,14 +744,13 @@ out:
|
|
static int
|
|
mt7531_ind_c22_phy_read(struct mt7530_priv *priv, int port, int regnum)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
struct mt7530_dummy_poll p;
|
|
int ret;
|
|
u32 val;
|
|
|
|
INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
ret = readx_poll_timeout(_mt7530_unlocked_read, &p, val,
|
|
!(val & MT7531_PHY_ACS_ST), 20, 100000);
|
|
@@ -772,7 +773,7 @@ mt7531_ind_c22_phy_read(struct mt7530_pr
|
|
|
|
ret = val & MT7531_MDIO_RW_DATA_MASK;
|
|
out:
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
return ret;
|
|
}
|
|
@@ -781,14 +782,13 @@ static int
|
|
mt7531_ind_c22_phy_write(struct mt7530_priv *priv, int port, int regnum,
|
|
u16 data)
|
|
{
|
|
- struct mii_bus *bus = priv->bus;
|
|
struct mt7530_dummy_poll p;
|
|
int ret;
|
|
u32 reg;
|
|
|
|
INIT_MT7530_DUMMY_POLL(&p, priv, MT7531_PHY_IAC);
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
ret = readx_poll_timeout(_mt7530_unlocked_read, &p, reg,
|
|
!(reg & MT7531_PHY_ACS_ST), 20, 100000);
|
|
@@ -810,7 +810,7 @@ mt7531_ind_c22_phy_write(struct mt7530_p
|
|
}
|
|
|
|
out:
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
return ret;
|
|
}
|
|
@@ -1162,7 +1162,6 @@ static int
|
|
mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
|
|
{
|
|
struct mt7530_priv *priv = ds->priv;
|
|
- struct mii_bus *bus = priv->bus;
|
|
int length;
|
|
u32 val;
|
|
|
|
@@ -1173,7 +1172,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
|
if (!dsa_is_cpu_port(ds, port))
|
|
return 0;
|
|
|
|
- mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
|
|
val = mt7530_mii_read(priv, MT7530_GMACCR);
|
|
val &= ~MAX_RX_PKT_LEN_MASK;
|
|
@@ -1194,7 +1193,7 @@ mt7530_port_change_mtu(struct dsa_switch
|
|
|
|
mt7530_mii_write(priv, MT7530_GMACCR, val);
|
|
|
|
- mutex_unlock(&bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
return 0;
|
|
}
|
|
@@ -1990,10 +1989,10 @@ mt7530_irq_thread_fn(int irq, void *dev_
|
|
u32 val;
|
|
int p;
|
|
|
|
- mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
val = mt7530_mii_read(priv, MT7530_SYS_INT_STS);
|
|
mt7530_mii_write(priv, MT7530_SYS_INT_STS, val);
|
|
- mutex_unlock(&priv->bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
|
|
for (p = 0; p < MT7530_NUM_PHYS; p++) {
|
|
if (BIT(p) & val) {
|
|
@@ -2029,7 +2028,7 @@ mt7530_irq_bus_lock(struct irq_data *d)
|
|
{
|
|
struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
|
|
|
|
- mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
|
+ mt7530_mutex_lock(priv);
|
|
}
|
|
|
|
static void
|
|
@@ -2038,7 +2037,7 @@ mt7530_irq_bus_sync_unlock(struct irq_da
|
|
struct mt7530_priv *priv = irq_data_get_irq_chip_data(d);
|
|
|
|
mt7530_mii_write(priv, MT7530_SYS_INT_EN, priv->irq_enable);
|
|
- mutex_unlock(&priv->bus->mdio_lock);
|
|
+ mt7530_mutex_unlock(priv);
|
|
}
|
|
|
|
static struct irq_chip mt7530_irq_chip = {
|