Skip to content

Commit 0179720

Browse files
ilantayariSaeed Mahameed
authored and
Saeed Mahameed
committed
net/mlx5: Introduce trigger_health_work function
Introduce new function for entering bad-health state. This function will be called from FPGA-related logic in a later patch from asynchronous event (IRQ) context, for that we change the spin lock to an IRQ-safe one. Signed-off-by: Ilan Tayari <ilant@mellanox.com> Reviewed-by: Boris Pismenny <borisp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent 2e9d3e8 commit 0179720

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

drivers/net/ethernet/mellanox/mlx5/core/health.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,21 @@ static void health_care(struct work_struct *work)
185185
struct mlx5_core_health *health;
186186
struct mlx5_core_dev *dev;
187187
struct mlx5_priv *priv;
188+
unsigned long flags;
188189

189190
health = container_of(work, struct mlx5_core_health, work);
190191
priv = container_of(health, struct mlx5_priv, health);
191192
dev = container_of(priv, struct mlx5_core_dev, priv);
192193
mlx5_core_warn(dev, "handling bad device here\n");
193194
mlx5_handle_bad_state(dev);
194195

195-
spin_lock(&health->wq_lock);
196+
spin_lock_irqsave(&health->wq_lock, flags);
196197
if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
197198
schedule_delayed_work(&health->recover_work, recover_delay);
198199
else
199200
dev_err(&dev->pdev->dev,
200201
"new health works are not permitted at this stage\n");
201-
spin_unlock(&health->wq_lock);
202+
spin_unlock_irqrestore(&health->wq_lock, flags);
202203
}
203204

204205
static const char *hsynd_str(u8 synd)
@@ -269,6 +270,20 @@ static unsigned long get_next_poll_jiffies(void)
269270
return next;
270271
}
271272

273+
void mlx5_trigger_health_work(struct mlx5_core_dev *dev)
274+
{
275+
struct mlx5_core_health *health = &dev->priv.health;
276+
unsigned long flags;
277+
278+
spin_lock_irqsave(&health->wq_lock, flags);
279+
if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
280+
queue_work(health->wq, &health->work);
281+
else
282+
dev_err(&dev->pdev->dev,
283+
"new health works are not permitted at this stage\n");
284+
spin_unlock_irqrestore(&health->wq_lock, flags);
285+
}
286+
272287
static void poll_health(unsigned long data)
273288
{
274289
struct mlx5_core_dev *dev = (struct mlx5_core_dev *)data;
@@ -297,13 +312,7 @@ static void poll_health(unsigned long data)
297312
if (in_fatal(dev) && !health->sick) {
298313
health->sick = true;
299314
print_health_info(dev);
300-
spin_lock(&health->wq_lock);
301-
if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
302-
queue_work(health->wq, &health->work);
303-
else
304-
dev_err(&dev->pdev->dev,
305-
"new health works are not permitted at this stage\n");
306-
spin_unlock(&health->wq_lock);
315+
mlx5_trigger_health_work(dev);
307316
}
308317
}
309318

@@ -333,10 +342,11 @@ void mlx5_stop_health_poll(struct mlx5_core_dev *dev)
333342
void mlx5_drain_health_wq(struct mlx5_core_dev *dev)
334343
{
335344
struct mlx5_core_health *health = &dev->priv.health;
345+
unsigned long flags;
336346

337-
spin_lock(&health->wq_lock);
347+
spin_lock_irqsave(&health->wq_lock, flags);
338348
set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
339-
spin_unlock(&health->wq_lock);
349+
spin_unlock_irqrestore(&health->wq_lock, flags);
340350
cancel_delayed_work_sync(&health->recover_work);
341351
cancel_work_sync(&health->work);
342352
}

include/linux/mlx5/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ int mlx5_health_init(struct mlx5_core_dev *dev);
915915
void mlx5_start_health_poll(struct mlx5_core_dev *dev);
916916
void mlx5_stop_health_poll(struct mlx5_core_dev *dev);
917917
void mlx5_drain_health_wq(struct mlx5_core_dev *dev);
918+
void mlx5_trigger_health_work(struct mlx5_core_dev *dev);
918919
int mlx5_buf_alloc_node(struct mlx5_core_dev *dev, int size,
919920
struct mlx5_buf *buf, int node);
920921
int mlx5_buf_alloc(struct mlx5_core_dev *dev, int size, struct mlx5_buf *buf);

0 commit comments

Comments
 (0)