mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
net: mscc: ocelot: turn stats_lock into a spinlock
ocelot_get_stats64() currently runs unlocked and therefore may collide with ocelot_port_update_stats() which indirectly accesses the same counters. However, ocelot_get_stats64() runs in atomic context, and we cannot simply take the sleepable ocelot->stats_lock mutex. We need to convert it to an atomic spinlock first. Do that as a preparatory change. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
173ca86618
commit
22d842e3ef
@ -2171,7 +2171,7 @@ static void vsc9959_psfp_sgi_table_del(struct ocelot *ocelot,
|
||||
static void vsc9959_psfp_counters_get(struct ocelot *ocelot, u32 index,
|
||||
struct felix_stream_filter_counters *counters)
|
||||
{
|
||||
mutex_lock(&ocelot->stats_lock);
|
||||
spin_lock(&ocelot->stats_lock);
|
||||
|
||||
ocelot_rmw(ocelot, SYS_STAT_CFG_STAT_VIEW(index),
|
||||
SYS_STAT_CFG_STAT_VIEW_M,
|
||||
@ -2188,7 +2188,7 @@ static void vsc9959_psfp_counters_get(struct ocelot *ocelot, u32 index,
|
||||
SYS_STAT_CFG_STAT_CLEAR_SHOT(0x10),
|
||||
SYS_STAT_CFG);
|
||||
|
||||
mutex_unlock(&ocelot->stats_lock);
|
||||
spin_unlock(&ocelot->stats_lock);
|
||||
}
|
||||
|
||||
static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
|
||||
|
@ -1906,13 +1906,13 @@ static void ocelot_check_stats_work(struct work_struct *work)
|
||||
stats_work);
|
||||
int i, err;
|
||||
|
||||
mutex_lock(&ocelot->stats_lock);
|
||||
spin_lock(&ocelot->stats_lock);
|
||||
for (i = 0; i < ocelot->num_phys_ports; i++) {
|
||||
err = ocelot_port_update_stats(ocelot, i);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&ocelot->stats_lock);
|
||||
spin_unlock(&ocelot->stats_lock);
|
||||
|
||||
if (err)
|
||||
dev_err(ocelot->dev, "Error %d updating ethtool stats\n", err);
|
||||
@ -1925,7 +1925,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
mutex_lock(&ocelot->stats_lock);
|
||||
spin_lock(&ocelot->stats_lock);
|
||||
|
||||
/* check and update now */
|
||||
err = ocelot_port_update_stats(ocelot, port);
|
||||
@ -1934,7 +1934,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data)
|
||||
for (i = 0; i < ocelot->num_stats; i++)
|
||||
*data++ = ocelot->stats[port * ocelot->num_stats + i];
|
||||
|
||||
mutex_unlock(&ocelot->stats_lock);
|
||||
spin_unlock(&ocelot->stats_lock);
|
||||
|
||||
if (err)
|
||||
dev_err(ocelot->dev, "Error %d updating ethtool stats\n", err);
|
||||
@ -3363,7 +3363,7 @@ int ocelot_init(struct ocelot *ocelot)
|
||||
if (!ocelot->stats)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&ocelot->stats_lock);
|
||||
spin_lock_init(&ocelot->stats_lock);
|
||||
mutex_init(&ocelot->ptp_lock);
|
||||
mutex_init(&ocelot->mact_lock);
|
||||
mutex_init(&ocelot->fwd_domain_lock);
|
||||
@ -3511,7 +3511,6 @@ void ocelot_deinit(struct ocelot *ocelot)
|
||||
cancel_delayed_work(&ocelot->stats_work);
|
||||
destroy_workqueue(ocelot->stats_queue);
|
||||
destroy_workqueue(ocelot->owq);
|
||||
mutex_destroy(&ocelot->stats_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(ocelot_deinit);
|
||||
|
||||
|
@ -752,7 +752,7 @@ struct ocelot {
|
||||
struct ocelot_psfp_list psfp;
|
||||
|
||||
/* Workqueue to check statistics for overflow with its lock */
|
||||
struct mutex stats_lock;
|
||||
spinlock_t stats_lock;
|
||||
u64 *stats;
|
||||
struct delayed_work stats_work;
|
||||
struct workqueue_struct *stats_queue;
|
||||
|
Loading…
Reference in New Issue
Block a user