Skip to content

Commit 1e1caa9

Browse files
claudiu-mdavem330
authored andcommitted
ocelot: Clean up stats update deferred work
This is preventive cleanup that may save troubles later. No need to cancel repeateadly queued work if code is properly refactored. Don't let the ethtool -s process interfere with the stat workqueue scheduling. Signed-off-by: Claudiu Manoil <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a8fd48b commit 1e1caa9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,8 @@ static void ocelot_get_strings(struct net_device *netdev, u32 sset, u8 *data)
959959
ETH_GSTRING_LEN);
960960
}
961961

962-
static void ocelot_check_stats(struct work_struct *work)
962+
static void ocelot_update_stats(struct ocelot *ocelot)
963963
{
964-
struct delayed_work *del_work = to_delayed_work(work);
965-
struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work);
966964
int i, j;
967965

968966
mutex_lock(&ocelot->stats_lock);
@@ -986,11 +984,19 @@ static void ocelot_check_stats(struct work_struct *work)
986984
}
987985
}
988986

989-
cancel_delayed_work(&ocelot->stats_work);
987+
mutex_unlock(&ocelot->stats_lock);
988+
}
989+
990+
static void ocelot_check_stats_work(struct work_struct *work)
991+
{
992+
struct delayed_work *del_work = to_delayed_work(work);
993+
struct ocelot *ocelot = container_of(del_work, struct ocelot,
994+
stats_work);
995+
996+
ocelot_update_stats(ocelot);
997+
990998
queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
991999
OCELOT_STATS_CHECK_DELAY);
992-
993-
mutex_unlock(&ocelot->stats_lock);
9941000
}
9951001

9961002
static void ocelot_get_ethtool_stats(struct net_device *dev,
@@ -1001,7 +1007,7 @@ static void ocelot_get_ethtool_stats(struct net_device *dev,
10011007
int i;
10021008

10031009
/* check and update now */
1004-
ocelot_check_stats(&ocelot->stats_work.work);
1010+
ocelot_update_stats(ocelot);
10051011

10061012
/* Copy all counters */
10071013
for (i = 0; i < ocelot->num_stats; i++)
@@ -1809,7 +1815,7 @@ int ocelot_init(struct ocelot *ocelot)
18091815
ANA_CPUQ_8021_CFG_CPUQ_BPDU_VAL(6),
18101816
ANA_CPUQ_8021_CFG, i);
18111817

1812-
INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats);
1818+
INIT_DELAYED_WORK(&ocelot->stats_work, ocelot_check_stats_work);
18131819
queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work,
18141820
OCELOT_STATS_CHECK_DELAY);
18151821
return 0;

0 commit comments

Comments
 (0)