From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH v2 net-next 2/5] net: dsa: mv88e6xxx: Hold mutex while doing stats operations
Date: Thu, 1 Mar 2018 02:02:28 +0100 [thread overview]
Message-ID: <1519866151-13419-3-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1519866151-13419-1-git-send-email-andrew@lunn.ch>
Until now, there has been no need to hold the reg mutex while getting
the count of statistics, or the strings, because the hardware was not
accessed. When adding support for SERDES statistics, it is necessary
to access the hardware, to determine if a port is using the SERDES
interface. So add mutex lock/unlocks.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
---
v2: Consolidate get_sset_count into one function
---
drivers/net/dsa/mv88e6xxx/chip.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8c9a30d1b06f..27ca0fcb1040 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -724,8 +724,12 @@ static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
{
struct mv88e6xxx_chip *chip = ds->priv;
+ mutex_lock(&chip->reg_lock);
+
if (chip->info->ops->stats_get_strings)
chip->info->ops->stats_get_strings(chip, data);
+
+ mutex_unlock(&chip->reg_lock);
}
static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
@@ -757,11 +761,14 @@ static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port)
{
struct mv88e6xxx_chip *chip = ds->priv;
+ int ret = 0;
+ mutex_lock(&chip->reg_lock);
if (chip->info->ops->stats_get_sset_count)
- return chip->info->ops->stats_get_sset_count(chip);
+ ret = chip->info->ops->stats_get_sset_count(chip);
+ mutex_unlock(&chip->reg_lock);
- return 0;
+ return ret;
}
static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
--
2.16.2
next prev parent reply other threads:[~2018-03-01 1:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 1:02 [PATCH v2 net-next 0/5] Export SERDES stats via ethtool -S Andrew Lunn
2018-03-01 1:02 ` [PATCH v2 net-next 1/5] dsa: Pass the port to get_sset_count() Andrew Lunn
2018-03-01 1:02 ` Andrew Lunn [this message]
2018-03-01 1:02 ` [PATCH v2 net-next 3/5] net: dsa: mv88e6xxx: Allow the SERDES interfaces to have statistics Andrew Lunn
2018-03-01 1:02 ` [PATCH v2 net-next 4/5] net: dsa: mv88e6xxx: Add helper to determining if port has SERDES Andrew Lunn
2018-03-01 1:02 ` [PATCH v2 net-next 5/5] net: dsa: mv88e6xxx: Get mv88e6352 SERDES statistics Andrew Lunn
2018-03-02 3:10 ` Andrew Lunn
2018-03-04 18:48 ` Florian Fainelli
2018-03-04 18:35 ` [PATCH v2 net-next 0/5] Export SERDES stats via ethtool -S David Miller
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=1519866151-13419-3-git-send-email-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.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;
as well as URLs for NNTP newsgroup(s).