Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: Hold mutex while doing stats operations
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Mar 4, 2018
1 parent 88c0605 commit c6c8cd5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c6c8cd5

Please sign in to comment.