All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency
@ 2018-02-15 13:38 Andrew Lunn
  2018-02-15 13:38 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: Release mutex between each statistics read Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrew Lunn @ 2018-02-15 13:38 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Vivien Didelot, Andrew Lunn

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.

Andrew Lunn (2):
  net: dsa: mv88e6xxx: Release mutex between each statistics read
  net: dsa: mv88e6xxx: Release mutex between each ATU read

 drivers/net/dsa/mv88e6xxx/chip.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] net: dsa: mv88e6xxx: Release mutex between each statistics read
  2018-02-15 13:38 [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency Andrew Lunn
@ 2018-02-15 13:38 ` Andrew Lunn
  2018-02-15 13:38 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Release mutex between each ATU read Andrew Lunn
  2018-02-16 20:37 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2018-02-15 13:38 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Vivien Didelot, Andrew Lunn

The PTP code needs low latency access to the PTP hardware timestamps.
Reading all the statistics in one go adds a lot of latency to the PTP
code. So take and release the reg_lock mutex for each individual
statistics, allowing the PTP thread jump in between.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index af63710e93c1..bd5cb8a0330e 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -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++) {
 		stat = &mv88e6xxx_hw_stats[i];
 		if (stat->type & types) {
+			mutex_lock(&chip->reg_lock);
 			data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
 							      bank1_select,
 							      histogram);
+			mutex_unlock(&chip->reg_lock);
+
 			j++;
 		}
 	}
@@ -764,14 +767,13 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
 	mutex_lock(&chip->reg_lock);
 
 	ret = mv88e6xxx_stats_snapshot(chip, port);
-	if (ret < 0) {
-		mutex_unlock(&chip->reg_lock);
+	mutex_unlock(&chip->reg_lock);
+
+	if (ret < 0)
 		return;
-	}
 
 	mv88e6xxx_get_stats(chip, port, data);
 
-	mutex_unlock(&chip->reg_lock);
 }
 
 static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net: dsa: mv88e6xxx: Release mutex between each ATU read
  2018-02-15 13:38 [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency Andrew Lunn
  2018-02-15 13:38 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: Release mutex between each statistics read Andrew Lunn
@ 2018-02-15 13:38 ` Andrew Lunn
  2018-02-16 20:37 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2018-02-15 13:38 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Vivien Didelot, Andrew Lunn

The PTP code needs low latency access to the PTP hardware timestamps.
Reading all the ATU entries in one go adds a lot of latency to the PTP
code. So take and release the reg_lock mutex for each individual MAC
address in the ATU, allowing the PTP thread jump in between.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index bd5cb8a0330e..39c7ad7e490f 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1437,7 +1437,9 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
 	eth_broadcast_addr(addr.mac);
 
 	do {
+		mutex_lock(&chip->reg_lock);
 		err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
+		mutex_unlock(&chip->reg_lock);
 		if (err)
 			return err;
 
@@ -1470,7 +1472,10 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 	int err;
 
 	/* Dump port's default Filtering Information Database (VLAN ID 0) */
+	mutex_lock(&chip->reg_lock);
 	err = mv88e6xxx_port_get_fid(chip, port, &fid);
+	mutex_unlock(&chip->reg_lock);
+
 	if (err)
 		return err;
 
@@ -1480,7 +1485,9 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 
 	/* Dump VLANs' Filtering Information Databases */
 	do {
+		mutex_lock(&chip->reg_lock);
 		err = mv88e6xxx_vtu_getnext(chip, &vlan);
+		mutex_unlock(&chip->reg_lock);
 		if (err)
 			return err;
 
@@ -1500,13 +1507,8 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
 				   dsa_fdb_dump_cb_t *cb, void *data)
 {
 	struct mv88e6xxx_chip *chip = ds->priv;
-	int err;
-
-	mutex_lock(&chip->reg_lock);
-	err = mv88e6xxx_port_db_dump(chip, port, cb, data);
-	mutex_unlock(&chip->reg_lock);
 
-	return err;
+	return mv88e6xxx_port_db_dump(chip, port, cb, data);
 }
 
 static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency
  2018-02-15 13:38 [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency Andrew Lunn
  2018-02-15 13:38 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: Release mutex between each statistics read Andrew Lunn
  2018-02-15 13:38 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Release mutex between each ATU read Andrew Lunn
@ 2018-02-16 20:37 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-02-16 20:37 UTC (permalink / raw)
  To: andrew; +Cc: netdev, vivien.didelot

From: Andrew Lunn <andrew@lunn.ch>
Date: Thu, 15 Feb 2018 14:38:33 +0100

> 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.

Series applied, thanks Andrew.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-16 20:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 13:38 [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency Andrew Lunn
2018-02-15 13:38 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: Release mutex between each statistics read Andrew Lunn
2018-02-15 13:38 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: Release mutex between each ATU read Andrew Lunn
2018-02-16 20:37 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: Improve PTP access latency David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.