Lines Matching refs:hdev

128 	struct hl_device *hdev;  in hl_device_open()  local
133 hdev = idr_find(&hl_devs_idr, iminor(inode)); in hl_device_open()
136 if (!hdev) { in hl_device_open()
146 hpriv->hdev = hdev; in hl_device_open()
157 hl_mem_mgr_init(hpriv->hdev->dev, &hpriv->mem_mgr); in hl_device_open()
161 mutex_lock(&hdev->fpriv_list_lock); in hl_device_open()
163 if (!hl_device_operational(hdev, &status)) { in hl_device_open()
164 dev_dbg_ratelimited(hdev->dev, in hl_device_open()
166 dev_name(hdev->dev), hdev->status[status]); in hl_device_open()
177 if (hdev->is_in_dram_scrub) { in hl_device_open()
178 dev_dbg_ratelimited(hdev->dev, in hl_device_open()
180 dev_name(hdev->dev)); in hl_device_open()
185 if (hdev->compute_ctx_in_release) { in hl_device_open()
186 dev_dbg_ratelimited(hdev->dev, in hl_device_open()
188 dev_name(hdev->dev)); in hl_device_open()
193 if (hdev->is_compute_ctx_active) { in hl_device_open()
194 dev_dbg_ratelimited(hdev->dev, in hl_device_open()
196 dev_name(hdev->dev)); in hl_device_open()
201 rc = hl_ctx_create(hdev, hpriv); in hl_device_open()
203 dev_err(hdev->dev, "Failed to create context %d\n", rc); in hl_device_open()
207 list_add(&hpriv->dev_node, &hdev->fpriv_list); in hl_device_open()
208 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open()
210 hdev->asic_funcs->send_device_activity(hdev, true); in hl_device_open()
214 atomic_set(&hdev->captured_err_info.cs_timeout.write_enable, 1); in hl_device_open()
215 atomic_set(&hdev->captured_err_info.razwi.write_enable, 1); in hl_device_open()
216 hdev->captured_err_info.undef_opcode.write_enable = true; in hl_device_open()
218 hdev->open_counter++; in hl_device_open()
219 hdev->last_successful_open_jif = jiffies; in hl_device_open()
220 hdev->last_successful_open_ktime = ktime_get(); in hl_device_open()
225 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open()
227 hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr); in hl_device_open()
241 struct hl_device *hdev; in hl_device_open_ctrl() local
246 hdev = idr_find(&hl_devs_idr, iminor(inode)); in hl_device_open_ctrl()
249 if (!hdev) { in hl_device_open_ctrl()
262 hpriv->hdev = hdev; in hl_device_open_ctrl()
271 mutex_lock(&hdev->fpriv_ctrl_list_lock); in hl_device_open_ctrl()
273 if (!hl_device_operational(hdev, NULL)) { in hl_device_open_ctrl()
274 dev_dbg_ratelimited(hdev->dev_ctrl, in hl_device_open_ctrl()
276 dev_name(hdev->dev_ctrl)); in hl_device_open_ctrl()
281 list_add(&hpriv->dev_node, &hdev->fpriv_ctrl_list); in hl_device_open_ctrl()
282 mutex_unlock(&hdev->fpriv_ctrl_list_lock); in hl_device_open_ctrl()
287 mutex_unlock(&hdev->fpriv_ctrl_list_lock); in hl_device_open_ctrl()
296 static void set_driver_behavior_per_device(struct hl_device *hdev) in set_driver_behavior_per_device() argument
298 hdev->nic_ports_mask = 0; in set_driver_behavior_per_device()
299 hdev->fw_components = FW_TYPE_ALL_TYPES; in set_driver_behavior_per_device()
300 hdev->mmu_enable = MMU_EN_ALL; in set_driver_behavior_per_device()
301 hdev->cpu_queues_enable = 1; in set_driver_behavior_per_device()
302 hdev->pldm = 0; in set_driver_behavior_per_device()
303 hdev->hard_reset_on_fw_events = 1; in set_driver_behavior_per_device()
304 hdev->bmc_enable = 1; in set_driver_behavior_per_device()
305 hdev->reset_on_preboot_fail = 1; in set_driver_behavior_per_device()
306 hdev->heartbeat = 1; in set_driver_behavior_per_device()
309 static void copy_kernel_module_params_to_device(struct hl_device *hdev) in copy_kernel_module_params_to_device() argument
311 hdev->asic_prop.fw_security_enabled = is_asic_secured(hdev->asic_type); in copy_kernel_module_params_to_device()
313 hdev->major = hl_major; in copy_kernel_module_params_to_device()
314 hdev->memory_scrub = memory_scrub; in copy_kernel_module_params_to_device()
315 hdev->reset_on_lockup = reset_on_lockup; in copy_kernel_module_params_to_device()
316 hdev->boot_error_status_mask = boot_error_status_mask; in copy_kernel_module_params_to_device()
319 static void fixup_device_params_per_asic(struct hl_device *hdev, int timeout) in fixup_device_params_per_asic() argument
321 switch (hdev->asic_type) { in fixup_device_params_per_asic()
328 hdev->timeout_jiffies = msecs_to_jiffies(GAUDI_DEFAULT_TIMEOUT_LOCKED * in fixup_device_params_per_asic()
331 hdev->reset_upon_device_release = 0; in fixup_device_params_per_asic()
335 hdev->reset_upon_device_release = 0; in fixup_device_params_per_asic()
339 hdev->reset_upon_device_release = 1; in fixup_device_params_per_asic()
344 static int fixup_device_params(struct hl_device *hdev) in fixup_device_params() argument
350 hdev->fw_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC; in fixup_device_params()
351 hdev->fw_comms_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC; in fixup_device_params()
354 hdev->timeout_jiffies = msecs_to_jiffies(tmp_timeout * MSEC_PER_SEC); in fixup_device_params()
356 hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT; in fixup_device_params()
358 hdev->stop_on_err = true; in fixup_device_params()
359 hdev->reset_info.curr_reset_cause = HL_RESET_CAUSE_UNKNOWN; in fixup_device_params()
360 hdev->reset_info.prev_reset_trigger = HL_RESET_TRIGGER_DEFAULT; in fixup_device_params()
363 hdev->disabled = true; in fixup_device_params()
365 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU) && in fixup_device_params()
366 (hdev->fw_components & ~FW_TYPE_PREBOOT_CPU)) { in fixup_device_params()
372 if (!hdev->cpu_queues_enable) in fixup_device_params()
373 hdev->heartbeat = 0; in fixup_device_params()
375 fixup_device_params_per_asic(hdev, tmp_timeout); in fixup_device_params()
393 struct hl_device *hdev; in create_hdev() local
397 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); in create_hdev()
398 if (!hdev) in create_hdev()
402 hdev->pdev = pdev; in create_hdev()
405 strncpy(hdev->status[HL_DEVICE_STATUS_OPERATIONAL], "operational", HL_STR_MAX); in create_hdev()
406 strncpy(hdev->status[HL_DEVICE_STATUS_IN_RESET], "in reset", HL_STR_MAX); in create_hdev()
407 strncpy(hdev->status[HL_DEVICE_STATUS_MALFUNCTION], "disabled", HL_STR_MAX); in create_hdev()
408 strncpy(hdev->status[HL_DEVICE_STATUS_NEEDS_RESET], "needs reset", HL_STR_MAX); in create_hdev()
409 strncpy(hdev->status[HL_DEVICE_STATUS_IN_DEVICE_CREATION], in create_hdev()
411 strncpy(hdev->status[HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE], in create_hdev()
418 hdev->asic_type = get_asic_type(pdev->device); in create_hdev()
419 if (hdev->asic_type == ASIC_INVALID) { in create_hdev()
425 copy_kernel_module_params_to_device(hdev); in create_hdev()
427 set_driver_behavior_per_device(hdev); in create_hdev()
429 fixup_device_params(hdev); in create_hdev()
436 main_id = idr_alloc(&hl_devs_idr, hdev, 0, HL_MAX_MINORS, GFP_KERNEL); in create_hdev()
439 ctrl_id = idr_alloc(&hl_devs_idr, hdev, main_id + 1, in create_hdev()
458 hdev->id = main_id; in create_hdev()
459 hdev->id_control = ctrl_id; in create_hdev()
461 *dev = hdev; in create_hdev()
466 kfree(hdev); in create_hdev()
476 static void destroy_hdev(struct hl_device *hdev) in destroy_hdev() argument
480 idr_remove(&hl_devs_idr, hdev->id); in destroy_hdev()
481 idr_remove(&hl_devs_idr, hdev->id_control); in destroy_hdev()
484 kfree(hdev); in destroy_hdev()
489 struct hl_device *hdev = dev_get_drvdata(dev); in hl_pmops_suspend() local
493 if (!hdev) { in hl_pmops_suspend()
498 return hl_device_suspend(hdev); in hl_pmops_suspend()
503 struct hl_device *hdev = dev_get_drvdata(dev); in hl_pmops_resume() local
507 if (!hdev) { in hl_pmops_resume()
512 return hl_device_resume(hdev); in hl_pmops_resume()
527 struct hl_device *hdev; in hl_pci_probe() local
534 rc = create_hdev(&hdev, pdev); in hl_pci_probe()
538 pci_set_drvdata(pdev, hdev); in hl_pci_probe()
542 rc = hl_device_init(hdev, hl_class); in hl_pci_probe()
554 destroy_hdev(hdev); in hl_pci_probe()
568 struct hl_device *hdev; in hl_pci_remove() local
570 hdev = pci_get_drvdata(pdev); in hl_pci_remove()
571 if (!hdev) in hl_pci_remove()
574 hl_device_fini(hdev); in hl_pci_remove()
577 destroy_hdev(hdev); in hl_pci_remove()
592 struct hl_device *hdev = pci_get_drvdata(pdev); in hl_pci_err_detected() local
600 dev_warn(hdev->dev, "frozen state error detected\n"); in hl_pci_err_detected()
605 dev_warn(hdev->dev, "failure state error detected\n"); in hl_pci_err_detected()
613 hdev->asic_funcs->halt_engines(hdev, true, false); in hl_pci_err_detected()
626 struct hl_device *hdev = pci_get_drvdata(pdev); in hl_pci_err_resume() local
628 dev_warn(hdev->dev, "Resuming device after PCI slot reset\n"); in hl_pci_err_resume()
629 hl_device_resume(hdev); in hl_pci_err_resume()