Commit e5fe068a authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-mv88e6xxx-Improve-PTP-access-latency'

Andrew Lunn says:

====================
net: dsa: mv88e6xxx: Improve PTP access latency

PTP needs to retrieve the hardware timestamps from the switch device
in a low latency manor. However ethtool -S and bridge fdb show can
hold the switch register access mutex for a long time. These patches
changes the reading the statistics and the ATU so that the mutex is
released and taken again between each statistic or ATU entry. The PTP
code can then interleave its access to the hardware, keeping its
latency low.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 65bd449c a61e5406
...@@ -714,9 +714,12 @@ static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, ...@@ -714,9 +714,12 @@ static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
stat = &mv88e6xxx_hw_stats[i]; stat = &mv88e6xxx_hw_stats[i];
if (stat->type & types) { if (stat->type & types) {
mutex_lock(&chip->reg_lock);
data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
bank1_select, bank1_select,
histogram); histogram);
mutex_unlock(&chip->reg_lock);
j++; j++;
} }
} }
...@@ -764,14 +767,13 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, ...@@ -764,14 +767,13 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
mutex_lock(&chip->reg_lock); mutex_lock(&chip->reg_lock);
ret = mv88e6xxx_stats_snapshot(chip, port); ret = mv88e6xxx_stats_snapshot(chip, port);
if (ret < 0) { mutex_unlock(&chip->reg_lock);
mutex_unlock(&chip->reg_lock);
if (ret < 0)
return; return;
}
mv88e6xxx_get_stats(chip, port, data); mv88e6xxx_get_stats(chip, port, data);
mutex_unlock(&chip->reg_lock);
} }
static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip) static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
...@@ -1435,7 +1437,9 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, ...@@ -1435,7 +1437,9 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
eth_broadcast_addr(addr.mac); eth_broadcast_addr(addr.mac);
do { do {
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
mutex_unlock(&chip->reg_lock);
if (err) if (err)
return err; return err;
...@@ -1468,7 +1472,10 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, ...@@ -1468,7 +1472,10 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
int err; int err;
/* Dump port's default Filtering Information Database (VLAN ID 0) */ /* Dump port's default Filtering Information Database (VLAN ID 0) */
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_port_get_fid(chip, port, &fid); err = mv88e6xxx_port_get_fid(chip, port, &fid);
mutex_unlock(&chip->reg_lock);
if (err) if (err)
return err; return err;
...@@ -1478,7 +1485,9 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, ...@@ -1478,7 +1485,9 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
/* Dump VLANs' Filtering Information Databases */ /* Dump VLANs' Filtering Information Databases */
do { do {
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_vtu_getnext(chip, &vlan); err = mv88e6xxx_vtu_getnext(chip, &vlan);
mutex_unlock(&chip->reg_lock);
if (err) if (err)
return err; return err;
...@@ -1498,13 +1507,8 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, ...@@ -1498,13 +1507,8 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
dsa_fdb_dump_cb_t *cb, void *data) dsa_fdb_dump_cb_t *cb, void *data)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
int err;
mutex_lock(&chip->reg_lock); return mv88e6xxx_port_db_dump(chip, port, cb, data);
err = mv88e6xxx_port_db_dump(chip, port, cb, data);
mutex_unlock(&chip->reg_lock);
return err;
} }
static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment