Skip to content

Commit 163f3d2

Browse files
idoschdavem330
authored andcommitted
mlxsw: core_env: Defer handling of module temperature warning events
Module temperature events are currently handled in softIRQ context, requiring the 'module_info_lock' to be a spin lock. In future patchsets we will need to be able to hold the lock while sleeping. Therefore, defer handling of these events using a work queue so that the next patch will be able to convert the lock to a mutex. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 25a91f8 commit 163f3d2

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_env.c

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,20 +482,30 @@ static int mlxsw_env_module_temp_event_enable(struct mlxsw_core *mlxsw_core,
482482
return 0;
483483
}
484484

485-
static void mlxsw_env_mtwe_event_func(const struct mlxsw_reg_info *reg,
486-
char *mtwe_pl, void *priv)
485+
struct mlxsw_env_module_temp_warn_event {
486+
struct mlxsw_env *mlxsw_env;
487+
char mtwe_pl[MLXSW_REG_MTWE_LEN];
488+
struct work_struct work;
489+
};
490+
491+
static void mlxsw_env_mtwe_event_work(struct work_struct *work)
487492
{
488-
struct mlxsw_env *mlxsw_env = priv;
493+
struct mlxsw_env_module_temp_warn_event *event;
494+
struct mlxsw_env *mlxsw_env;
489495
int i, sensor_warning;
490496
bool is_overheat;
491497

498+
event = container_of(work, struct mlxsw_env_module_temp_warn_event,
499+
work);
500+
mlxsw_env = event->mlxsw_env;
501+
492502
for (i = 0; i < mlxsw_env->module_count; i++) {
493503
/* 64-127 of sensor_index are mapped to the port modules
494504
* sequentially (module 0 is mapped to sensor_index 64,
495505
* module 1 to sensor_index 65 and so on)
496506
*/
497507
sensor_warning =
498-
mlxsw_reg_mtwe_sensor_warning_get(mtwe_pl,
508+
mlxsw_reg_mtwe_sensor_warning_get(event->mtwe_pl,
499509
i + MLXSW_REG_MTMP_MODULE_INDEX_MIN);
500510
spin_lock(&mlxsw_env->module_info_lock);
501511
is_overheat =
@@ -524,10 +534,29 @@ static void mlxsw_env_mtwe_event_func(const struct mlxsw_reg_info *reg,
524534
spin_unlock(&mlxsw_env->module_info_lock);
525535
}
526536
}
537+
538+
kfree(event);
539+
}
540+
541+
static void
542+
mlxsw_env_mtwe_listener_func(const struct mlxsw_reg_info *reg, char *mtwe_pl,
543+
void *priv)
544+
{
545+
struct mlxsw_env_module_temp_warn_event *event;
546+
struct mlxsw_env *mlxsw_env = priv;
547+
548+
event = kmalloc(sizeof(*event), GFP_ATOMIC);
549+
if (!event)
550+
return;
551+
552+
event->mlxsw_env = mlxsw_env;
553+
memcpy(event->mtwe_pl, mtwe_pl, MLXSW_REG_MTWE_LEN);
554+
INIT_WORK(&event->work, mlxsw_env_mtwe_event_work);
555+
mlxsw_core_schedule_work(&event->work);
527556
}
528557

529558
static const struct mlxsw_listener mlxsw_env_temp_warn_listener =
530-
MLXSW_EVENTL(mlxsw_env_mtwe_event_func, MTWE, MTWE);
559+
MLXSW_EVENTL(mlxsw_env_mtwe_listener_func, MTWE, MTWE);
531560

532561
static int mlxsw_env_temp_warn_event_register(struct mlxsw_core *mlxsw_core)
533562
{

0 commit comments

Comments
 (0)