2 * Copyright (c) 2013-2017, Mellanox Technologies, Ltd. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <linux/kernel.h>
29 #include <linux/module.h>
30 #include <linux/random.h>
31 #include <linux/vmalloc.h>
32 #include <linux/hardirq.h>
33 #include <linux/delay.h>
34 #include <dev/mlx5/driver.h>
35 #include <dev/mlx5/mlx5_ifc.h>
36 #include "mlx5_core.h"
38 #define MLX5_HEALTH_POLL_INTERVAL (2 * HZ)
42 MLX5_DROP_NEW_HEALTH_WORK,
43 MLX5_DROP_NEW_RECOVERY_WORK,
44 MLX5_DROP_NEW_WATCHDOG_WORK,
48 MLX5_SENSOR_NO_ERR = 0,
49 MLX5_SENSOR_PCI_COMM_ERR = 1,
50 MLX5_SENSOR_PCI_ERR = 2,
51 MLX5_SENSOR_NIC_DISABLED = 3,
52 MLX5_SENSOR_NIC_SW_RESET = 4,
53 MLX5_SENSOR_FW_SYND_RFR = 5,
56 static int mlx5_fw_reset_enable = 1;
57 SYSCTL_INT(_hw_mlx5, OID_AUTO, fw_reset_enable, CTLFLAG_RWTUN,
58 &mlx5_fw_reset_enable, 0,
59 "Enable firmware reset");
61 static unsigned int sw_reset_to = 1200;
62 SYSCTL_UINT(_hw_mlx5, OID_AUTO, sw_reset_timeout, CTLFLAG_RWTUN,
64 "Minimum timeout in seconds between two firmware resets");
67 static int lock_sem_sw_reset(struct mlx5_core_dev *dev)
72 ret = -mlx5_vsc_lock(dev);
74 mlx5_core_warn(dev, "Timed out locking gateway %d\n", ret);
78 ret = -mlx5_vsc_lock_addr_space(dev, MLX5_SEMAPHORE_SW_RESET);
81 mlx5_core_dbg(dev, "SW reset FW semaphore already locked, another function will handle the reset\n");
83 mlx5_core_warn(dev, "SW reset semaphore lock return %d\n", ret);
86 /* Unlock GW access */
92 static int unlock_sem_sw_reset(struct mlx5_core_dev *dev)
97 ret = -mlx5_vsc_lock(dev);
99 mlx5_core_warn(dev, "Timed out locking gateway %d\n", ret);
103 ret = -mlx5_vsc_unlock_addr_space(dev, MLX5_SEMAPHORE_SW_RESET);
105 /* Unlock GW access */
106 mlx5_vsc_unlock(dev);
111 u8 mlx5_get_nic_state(struct mlx5_core_dev *dev)
113 return (ioread32be(&dev->iseg->cmdq_addr_l_sz) >> 8) & 7;
116 void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state)
118 u32 cur_cmdq_addr_l_sz;
120 cur_cmdq_addr_l_sz = ioread32be(&dev->iseg->cmdq_addr_l_sz);
121 iowrite32be((cur_cmdq_addr_l_sz & 0xFFFFF000) |
122 state << MLX5_NIC_IFC_OFFSET,
123 &dev->iseg->cmdq_addr_l_sz);
126 static bool sensor_fw_synd_rfr(struct mlx5_core_dev *dev)
128 struct mlx5_core_health *health = &dev->priv.health;
129 struct mlx5_health_buffer __iomem *h = health->health;
130 u32 rfr = ioread32be(&h->rfr) >> MLX5_RFR_OFFSET;
131 u8 synd = ioread8(&h->synd);
134 mlx5_core_dbg(dev, "FW requests reset, synd: %d\n", synd);
138 static void mlx5_trigger_cmd_completions(struct mlx5_core_dev *dev)
143 /* wait for pending handlers to complete */
144 synchronize_irq(dev->priv.msix_arr[MLX5_EQ_VEC_CMD].vector);
145 spin_lock_irqsave(&dev->cmd.alloc_lock, flags);
146 vector = ~dev->cmd.bitmask & ((1ul << (1 << dev->cmd.log_sz)) - 1);
150 vector |= MLX5_TRIGGERED_CMD_COMP;
151 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags);
153 mlx5_core_dbg(dev, "vector 0x%jx\n", (uintmax_t)vector);
154 mlx5_cmd_comp_handler(dev, vector, MLX5_CMD_MODE_EVENTS);
158 spin_unlock_irqrestore(&dev->cmd.alloc_lock, flags);
161 static bool sensor_pci_no_comm(struct mlx5_core_dev *dev)
163 struct mlx5_core_health *health = &dev->priv.health;
164 struct mlx5_health_buffer __iomem *h = health->health;
165 bool err = ioread32be(&h->fw_ver) == 0xffffffff;
170 static bool sensor_nic_disabled(struct mlx5_core_dev *dev)
172 return mlx5_get_nic_state(dev) == MLX5_NIC_IFC_DISABLED;
175 static bool sensor_nic_sw_reset(struct mlx5_core_dev *dev)
177 return mlx5_get_nic_state(dev) == MLX5_NIC_IFC_SW_RESET;
180 static u32 check_fatal_sensors(struct mlx5_core_dev *dev)
182 if (sensor_pci_no_comm(dev))
183 return MLX5_SENSOR_PCI_COMM_ERR;
184 if (pci_channel_offline(dev->pdev))
185 return MLX5_SENSOR_PCI_ERR;
186 if (sensor_nic_disabled(dev))
187 return MLX5_SENSOR_NIC_DISABLED;
188 if (sensor_nic_sw_reset(dev))
189 return MLX5_SENSOR_NIC_SW_RESET;
190 if (sensor_fw_synd_rfr(dev))
191 return MLX5_SENSOR_FW_SYND_RFR;
193 return MLX5_SENSOR_NO_ERR;
196 static void reset_fw_if_needed(struct mlx5_core_dev *dev)
199 u32 cmdq_addr, fatal_error;
201 if (!mlx5_fw_reset_enable)
203 supported = (ioread32be(&dev->iseg->initializing) >>
204 MLX5_FW_RESET_SUPPORTED_OFFSET) & 1;
208 /* The reset only needs to be issued by one PF. The health buffer is
209 * shared between all functions, and will be cleared during a reset.
210 * Check again to avoid a redundant 2nd reset. If the fatal erros was
211 * PCI related a reset won't help.
213 fatal_error = check_fatal_sensors(dev);
214 if (fatal_error == MLX5_SENSOR_PCI_COMM_ERR ||
215 fatal_error == MLX5_SENSOR_NIC_DISABLED ||
216 fatal_error == MLX5_SENSOR_NIC_SW_RESET) {
217 mlx5_core_warn(dev, "Not issuing FW reset. Either it's already done or won't help.\n");
221 mlx5_core_warn(dev, "Issuing FW Reset\n");
222 /* Write the NIC interface field to initiate the reset, the command
223 * interface address also resides here, don't overwrite it.
225 cmdq_addr = ioread32be(&dev->iseg->cmdq_addr_l_sz);
226 iowrite32be((cmdq_addr & 0xFFFFF000) |
227 MLX5_NIC_IFC_SW_RESET << MLX5_NIC_IFC_OFFSET,
228 &dev->iseg->cmdq_addr_l_sz);
232 mlx5_health_allow_reset(struct mlx5_core_dev *dev)
234 struct mlx5_core_health *health = &dev->priv.health;
238 if (health->last_reset_req != 0) {
239 delta = ticks - health->last_reset_req;
241 ret = delta >= sw_reset_to;
247 * In principle, ticks may be 0. Setting it to off by one (-1)
248 * to prevent certain reset in next request.
250 health->last_reset_req = ticks ? : -1;
252 mlx5_core_warn(dev, "Firmware reset elided due to "
253 "auto-reset frequency threshold.\n");
257 #define MLX5_CRDUMP_WAIT_MS 60000
258 #define MLX5_FW_RESET_WAIT_MS 1000
259 #define MLX5_NIC_STATE_POLL_MS 5
260 void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)
262 int end, delay_ms = MLX5_CRDUMP_WAIT_MS;
266 fatal_error = check_fatal_sensors(dev);
268 if (fatal_error || force) {
269 if (xchg(&dev->state, MLX5_DEVICE_STATE_INTERNAL_ERROR) ==
270 MLX5_DEVICE_STATE_INTERNAL_ERROR)
273 mlx5_core_err(dev, "internal state error detected\n");
274 mlx5_trigger_cmd_completions(dev);
277 mutex_lock(&dev->intf_state_mutex);
282 if (fatal_error == MLX5_SENSOR_FW_SYND_RFR &&
283 mlx5_health_allow_reset(dev)) {
284 /* Get cr-dump and reset FW semaphore */
285 if (mlx5_core_is_pf(dev))
286 lock = lock_sem_sw_reset(dev);
288 /* Execute cr-dump and SW reset */
289 if (lock != -EBUSY) {
291 reset_fw_if_needed(dev);
292 delay_ms = MLX5_FW_RESET_WAIT_MS;
296 /* Recover from SW reset */
297 end = jiffies + msecs_to_jiffies(delay_ms);
299 if (sensor_nic_disabled(dev))
302 msleep(MLX5_NIC_STATE_POLL_MS);
303 } while (!time_after(jiffies, end));
305 if (!sensor_nic_disabled(dev)) {
306 dev_err(&dev->pdev->dev, "NIC IFC still %d after %ums.\n",
307 mlx5_get_nic_state(dev), delay_ms);
310 /* Release FW semaphore if you are the lock owner */
312 unlock_sem_sw_reset(dev);
314 mlx5_core_err(dev, "system error event triggered\n");
317 mlx5_core_event(dev, MLX5_DEV_EVENT_SYS_ERROR, 1);
318 mutex_unlock(&dev->intf_state_mutex);
321 static void mlx5_handle_bad_state(struct mlx5_core_dev *dev)
323 u8 nic_mode = mlx5_get_nic_state(dev);
325 if (nic_mode == MLX5_NIC_IFC_SW_RESET) {
326 /* The IFC mode field is 3 bits, so it will read 0x7 in two cases:
327 * 1. PCI has been disabled (ie. PCI-AER, PF driver unloaded
328 * and this is a VF), this is not recoverable by SW reset.
329 * Logging of this is handled elsewhere.
330 * 2. FW reset has been issued by another function, driver can
331 * be reloaded to recover after the mode switches to
332 * MLX5_NIC_IFC_DISABLED.
334 if (dev->priv.health.fatal_error != MLX5_SENSOR_PCI_COMM_ERR)
335 mlx5_core_warn(dev, "NIC SW reset is already progress\n");
337 mlx5_core_warn(dev, "Communication with FW over the PCI link is down\n");
339 mlx5_core_warn(dev, "NIC mode %d\n", nic_mode);
342 mlx5_disable_device(dev);
345 #define MLX5_FW_RESET_WAIT_MS 1000
346 #define MLX5_NIC_STATE_POLL_MS 5
347 static void health_recover(struct work_struct *work)
349 unsigned long end = jiffies + msecs_to_jiffies(MLX5_FW_RESET_WAIT_MS);
350 struct mlx5_core_health *health;
351 struct delayed_work *dwork;
352 struct mlx5_core_dev *dev;
353 struct mlx5_priv *priv;
357 dwork = container_of(work, struct delayed_work, work);
358 health = container_of(dwork, struct mlx5_core_health, recover_work);
359 priv = container_of(health, struct mlx5_priv, health);
360 dev = container_of(priv, struct mlx5_core_dev, priv);
362 mtx_lock(&Giant); /* XXX newbus needs this */
364 if (sensor_pci_no_comm(dev)) {
365 dev_err(&dev->pdev->dev, "health recovery flow aborted, PCI reads still not working\n");
369 nic_mode = mlx5_get_nic_state(dev);
370 while (nic_mode != MLX5_NIC_IFC_DISABLED &&
371 !time_after(jiffies, end)) {
372 msleep(MLX5_NIC_STATE_POLL_MS);
373 nic_mode = mlx5_get_nic_state(dev);
376 if (nic_mode != MLX5_NIC_IFC_DISABLED) {
377 dev_err(&dev->pdev->dev, "health recovery flow aborted, unexpected NIC IFC mode %d.\n",
383 dev_err(&dev->pdev->dev, "starting health recovery flow\n");
384 mlx5_recover_device(dev);
390 /* How much time to wait until health resetting the driver (in msecs) */
391 #define MLX5_RECOVERY_DELAY_MSECS 60000
392 #define MLX5_RECOVERY_NO_DELAY 0
393 static unsigned long get_recovery_delay(struct mlx5_core_dev *dev)
395 return dev->priv.health.fatal_error == MLX5_SENSOR_PCI_ERR ||
396 dev->priv.health.fatal_error == MLX5_SENSOR_PCI_COMM_ERR ?
397 MLX5_RECOVERY_DELAY_MSECS : MLX5_RECOVERY_NO_DELAY;
400 static void health_care(struct work_struct *work)
402 struct mlx5_core_health *health;
403 unsigned long recover_delay;
404 struct mlx5_core_dev *dev;
405 struct mlx5_priv *priv;
408 health = container_of(work, struct mlx5_core_health, work);
409 priv = container_of(health, struct mlx5_priv, health);
410 dev = container_of(priv, struct mlx5_core_dev, priv);
412 mlx5_core_warn(dev, "handling bad device here\n");
413 mlx5_handle_bad_state(dev);
414 recover_delay = msecs_to_jiffies(get_recovery_delay(dev));
416 spin_lock_irqsave(&health->wq_lock, flags);
417 if (!test_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags)) {
418 mlx5_core_warn(dev, "Scheduling recovery work with %lums delay\n",
420 schedule_delayed_work(&health->recover_work, recover_delay);
422 dev_err(&dev->pdev->dev,
423 "new health works are not permitted at this stage\n");
425 spin_unlock_irqrestore(&health->wq_lock, flags);
428 static int get_next_poll_jiffies(void)
432 get_random_bytes(&next, sizeof(next));
434 next += jiffies + MLX5_HEALTH_POLL_INTERVAL;
439 void mlx5_trigger_health_work(struct mlx5_core_dev *dev)
441 struct mlx5_core_health *health = &dev->priv.health;
444 spin_lock_irqsave(&health->wq_lock, flags);
445 if (!test_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags))
446 queue_work(health->wq, &health->work);
448 dev_err(&dev->pdev->dev,
449 "new health works are not permitted at this stage\n");
450 spin_unlock_irqrestore(&health->wq_lock, flags);
453 static const char *hsynd_str(u8 synd)
456 case MLX5_HEALTH_SYNDR_FW_ERR:
457 return "firmware internal error";
458 case MLX5_HEALTH_SYNDR_IRISC_ERR:
459 return "irisc not responding";
460 case MLX5_HEALTH_SYNDR_HW_UNRECOVERABLE_ERR:
461 return "unrecoverable hardware error";
462 case MLX5_HEALTH_SYNDR_CRC_ERR:
463 return "firmware CRC error";
464 case MLX5_HEALTH_SYNDR_FETCH_PCI_ERR:
465 return "ICM fetch PCI error";
466 case MLX5_HEALTH_SYNDR_HW_FTL_ERR:
467 return "HW fatal error\n";
468 case MLX5_HEALTH_SYNDR_ASYNC_EQ_OVERRUN_ERR:
469 return "async EQ buffer overrun";
470 case MLX5_HEALTH_SYNDR_EQ_ERR:
472 case MLX5_HEALTH_SYNDR_EQ_INV:
473 return "Invalid EQ referenced";
474 case MLX5_HEALTH_SYNDR_FFSER_ERR:
475 return "FFSER error";
476 case MLX5_HEALTH_SYNDR_HIGH_TEMP:
477 return "High temprature";
479 return "unrecognized error";
483 static void print_health_info(struct mlx5_core_dev *dev)
485 struct mlx5_core_health *health = &dev->priv.health;
486 struct mlx5_health_buffer __iomem *h = health->health;
491 /* If the syndrom is 0, the device is OK and no need to print buffer */
492 if (!ioread8(&h->synd))
495 for (i = 0; i < ARRAY_SIZE(h->assert_var); i++)
496 printf("mlx5_core: INFO: ""assert_var[%d] 0x%08x\n", i, ioread32be(h->assert_var + i));
498 printf("mlx5_core: INFO: ""assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr));
499 printf("mlx5_core: INFO: ""assert_callra 0x%08x\n", ioread32be(&h->assert_callra));
500 snprintf(fw_str, sizeof(fw_str), "%d.%d.%d", fw_rev_maj(dev), fw_rev_min(dev), fw_rev_sub(dev));
501 printf("mlx5_core: INFO: ""fw_ver %s\n", fw_str);
502 printf("mlx5_core: INFO: ""hw_id 0x%08x\n", ioread32be(&h->hw_id));
503 printf("mlx5_core: INFO: ""irisc_index %d\n", ioread8(&h->irisc_index));
504 printf("mlx5_core: INFO: ""synd 0x%x: %s\n", ioread8(&h->synd), hsynd_str(ioread8(&h->synd)));
505 printf("mlx5_core: INFO: ""ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
506 fw = ioread32be(&h->fw_ver);
507 printf("mlx5_core: INFO: ""raw fw_ver 0x%08x\n", fw);
510 static void health_watchdog(struct work_struct *work)
512 struct mlx5_core_dev *dev;
517 dev = container_of(work, struct mlx5_core_dev, priv.health.work_watchdog);
519 if (!MLX5_CAP_GEN(dev, mcam_reg) ||
520 !MLX5_CAP_MCAM_FEATURE(dev, pcie_status_and_power))
523 err = mlx5_pci_read_power_status(dev, &power, &status);
525 mlx5_core_warn(dev, "Failed reading power status: %d\n", err);
529 dev->pwr_value = power;
531 if (dev->pwr_status != status) {
532 device_t bsddev = dev->pdev->dev.bsddev;
536 dev->pwr_status = status;
537 device_printf(bsddev, "PCI power is not published by the PCIe slot.\n");
540 dev->pwr_status = status;
541 device_printf(bsddev, "PCIe slot advertised sufficient power (%uW).\n", power);
544 dev->pwr_status = status;
545 device_printf(bsddev, "WARN: Detected insufficient power on the PCIe slot (%uW).\n", power);
549 device_printf(bsddev, "WARN: Unknown power state detected(%d).\n", status);
556 mlx5_trigger_health_watchdog(struct mlx5_core_dev *dev)
558 struct mlx5_core_health *health = &dev->priv.health;
561 spin_lock_irqsave(&health->wq_lock, flags);
562 if (!test_bit(MLX5_DROP_NEW_WATCHDOG_WORK, &health->flags))
563 queue_work(health->wq_watchdog, &health->work_watchdog);
565 dev_err(&dev->pdev->dev,
566 "scheduling watchdog is not permitted at this stage\n");
567 spin_unlock_irqrestore(&health->wq_lock, flags);
570 static void poll_health(unsigned long data)
572 struct mlx5_core_dev *dev = (struct mlx5_core_dev *)data;
573 struct mlx5_core_health *health = &dev->priv.health;
577 if (dev->state != MLX5_DEVICE_STATE_UP)
580 count = ioread32be(health->health_counter);
581 if (count == health->prev)
582 ++health->miss_counter;
584 health->miss_counter = 0;
586 health->prev = count;
587 if (health->miss_counter == MAX_MISSES) {
588 mlx5_core_err(dev, "device's health compromised - reached miss count\n");
589 print_health_info(dev);
592 fatal_error = check_fatal_sensors(dev);
594 if (fatal_error && !health->fatal_error) {
595 mlx5_core_err(dev, "Fatal error %u detected\n", fatal_error);
596 dev->priv.health.fatal_error = fatal_error;
597 print_health_info(dev);
598 mlx5_trigger_health_work(dev);
601 mod_timer(&health->timer, get_next_poll_jiffies());
604 void mlx5_start_health_poll(struct mlx5_core_dev *dev)
606 struct mlx5_core_health *health = &dev->priv.health;
608 init_timer(&health->timer);
609 health->fatal_error = MLX5_SENSOR_NO_ERR;
610 clear_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
611 clear_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags);
612 clear_bit(MLX5_DROP_NEW_WATCHDOG_WORK, &health->flags);
613 health->health = &dev->iseg->health;
614 health->health_counter = &dev->iseg->health_counter;
616 setup_timer(&health->timer, poll_health, (unsigned long)dev);
617 mod_timer(&health->timer,
618 round_jiffies(jiffies + MLX5_HEALTH_POLL_INTERVAL));
620 /* do initial PCI power state readout */
621 mlx5_trigger_health_watchdog(dev);
624 void mlx5_stop_health_poll(struct mlx5_core_dev *dev, bool disable_health)
626 struct mlx5_core_health *health = &dev->priv.health;
629 if (disable_health) {
630 spin_lock_irqsave(&health->wq_lock, flags);
631 set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
632 set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags);
633 set_bit(MLX5_DROP_NEW_WATCHDOG_WORK, &health->flags);
634 spin_unlock_irqrestore(&health->wq_lock, flags);
637 del_timer_sync(&health->timer);
640 void mlx5_drain_health_wq(struct mlx5_core_dev *dev)
642 struct mlx5_core_health *health = &dev->priv.health;
645 spin_lock_irqsave(&health->wq_lock, flags);
646 set_bit(MLX5_DROP_NEW_HEALTH_WORK, &health->flags);
647 set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags);
648 set_bit(MLX5_DROP_NEW_WATCHDOG_WORK, &health->flags);
649 spin_unlock_irqrestore(&health->wq_lock, flags);
650 cancel_delayed_work_sync(&health->recover_work);
651 cancel_work_sync(&health->work);
652 cancel_work_sync(&health->work_watchdog);
655 void mlx5_drain_health_recovery(struct mlx5_core_dev *dev)
657 struct mlx5_core_health *health = &dev->priv.health;
660 spin_lock_irqsave(&health->wq_lock, flags);
661 set_bit(MLX5_DROP_NEW_RECOVERY_WORK, &health->flags);
662 spin_unlock_irqrestore(&health->wq_lock, flags);
663 cancel_delayed_work_sync(&dev->priv.health.recover_work);
666 void mlx5_health_cleanup(struct mlx5_core_dev *dev)
668 struct mlx5_core_health *health = &dev->priv.health;
670 destroy_workqueue(health->wq);
671 destroy_workqueue(health->wq_watchdog);
674 int mlx5_health_init(struct mlx5_core_dev *dev)
676 struct mlx5_core_health *health;
679 health = &dev->priv.health;
681 snprintf(name, sizeof(name), "%s-rec", dev_name(&dev->pdev->dev));
682 health->wq = create_singlethread_workqueue(name);
686 snprintf(name, sizeof(name), "%s-wdg", dev_name(&dev->pdev->dev));
687 health->wq_watchdog = create_singlethread_workqueue(name);
688 if (!health->wq_watchdog) {
689 destroy_workqueue(health->wq);
693 spin_lock_init(&health->wq_lock);
694 INIT_WORK(&health->work, health_care);
695 INIT_WORK(&health->work_watchdog, health_watchdog);
696 INIT_DELAYED_WORK(&health->recover_work, health_recover);