Lines Matching defs:hdev

76  * @hdev: pointer to habanalabs device structure.
81 static enum hl_asic_type get_asic_type(struct hl_device *hdev)
83 struct pci_dev *pdev = hdev->pdev;
139 struct hl_device *hdev;
144 hdev = idr_find(&hl_devs_idr, iminor(inode));
147 if (!hdev) {
157 hpriv->hdev = hdev;
168 hl_mem_mgr_init(hpriv->hdev->dev, &hpriv->mem_mgr);
172 mutex_lock(&hdev->fpriv_list_lock);
174 if (!hl_device_operational(hdev, &status)) {
175 dev_dbg_ratelimited(hdev->dev,
177 dev_name(hdev->dev), hdev->status[status]);
188 if (hdev->is_in_dram_scrub) {
189 dev_dbg_ratelimited(hdev->dev,
191 dev_name(hdev->dev));
196 if (hdev->compute_ctx_in_release) {
197 dev_dbg_ratelimited(hdev->dev,
199 dev_name(hdev->dev));
204 if (hdev->is_compute_ctx_active) {
205 dev_dbg_ratelimited(hdev->dev,
207 dev_name(hdev->dev));
212 rc = hl_ctx_create(hdev, hpriv);
214 dev_err(hdev->dev, "Failed to create context %d\n", rc);
218 list_add(&hpriv->dev_node, &hdev->fpriv_list);
219 mutex_unlock(&hdev->fpriv_list_lock);
221 hdev->asic_funcs->send_device_activity(hdev, true);
225 hl_enable_err_info_capture(&hdev->captured_err_info);
227 hdev->open_counter++;
228 hdev->last_successful_open_jif = jiffies;
229 hdev->last_successful_open_ktime = ktime_get();
234 mutex_unlock(&hdev->fpriv_list_lock);
237 hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr);
251 struct hl_device *hdev;
256 hdev = idr_find(&hl_devs_idr, iminor(inode));
259 if (!hdev) {
272 hpriv->hdev = hdev;
281 mutex_lock(&hdev->fpriv_ctrl_list_lock);
283 if (!hl_ctrl_device_operational(hdev, NULL)) {
284 dev_dbg_ratelimited(hdev->dev_ctrl,
286 dev_name(hdev->dev_ctrl));
291 list_add(&hpriv->dev_node, &hdev->fpriv_ctrl_list);
292 mutex_unlock(&hdev->fpriv_ctrl_list_lock);
297 mutex_unlock(&hdev->fpriv_ctrl_list_lock);
306 static void set_driver_behavior_per_device(struct hl_device *hdev)
308 hdev->nic_ports_mask = 0;
309 hdev->fw_components = FW_TYPE_ALL_TYPES;
310 hdev->cpu_queues_enable = 1;
311 hdev->pldm = 0;
312 hdev->hard_reset_on_fw_events = 1;
313 hdev->bmc_enable = 1;
314 hdev->reset_on_preboot_fail = 1;
315 hdev->heartbeat = 1;
318 static void copy_kernel_module_params_to_device(struct hl_device *hdev)
320 hdev->asic_prop.fw_security_enabled = is_asic_secured(hdev->asic_type);
322 hdev->major = hl_major;
323 hdev->hclass = hl_class;
324 hdev->memory_scrub = memory_scrub;
325 hdev->reset_on_lockup = reset_on_lockup;
326 hdev->boot_error_status_mask = boot_error_status_mask;
329 static void fixup_device_params_per_asic(struct hl_device *hdev, int timeout)
331 switch (hdev->asic_type) {
338 hdev->timeout_jiffies = msecs_to_jiffies(GAUDI_DEFAULT_TIMEOUT_LOCKED *
341 hdev->reset_upon_device_release = 0;
345 hdev->reset_upon_device_release = 0;
349 hdev->reset_upon_device_release = 1;
354 static int fixup_device_params(struct hl_device *hdev)
360 hdev->fw_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC;
361 hdev->fw_comms_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC;
364 hdev->timeout_jiffies = msecs_to_jiffies(tmp_timeout * MSEC_PER_SEC);
366 hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
368 hdev->stop_on_err = true;
369 hdev->reset_info.curr_reset_cause = HL_RESET_CAUSE_UNKNOWN;
370 hdev->reset_info.prev_reset_trigger = HL_RESET_TRIGGER_DEFAULT;
373 hdev->disabled = true;
375 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU) &&
376 (hdev->fw_components & ~FW_TYPE_PREBOOT_CPU)) {
382 if (!hdev->cpu_queues_enable)
383 hdev->heartbeat = 0;
384 fixup_device_params_per_asic(hdev, tmp_timeout);
402 struct hl_device *hdev;
406 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
407 if (!hdev)
411 hdev->pdev = pdev;
414 strncpy(hdev->status[HL_DEVICE_STATUS_OPERATIONAL], "operational", HL_STR_MAX);
415 strncpy(hdev->status[HL_DEVICE_STATUS_IN_RESET], "in reset", HL_STR_MAX);
416 strncpy(hdev->status[HL_DEVICE_STATUS_MALFUNCTION], "disabled", HL_STR_MAX);
417 strncpy(hdev->status[HL_DEVICE_STATUS_NEEDS_RESET], "needs reset", HL_STR_MAX);
418 strncpy(hdev->status[HL_DEVICE_STATUS_IN_DEVICE_CREATION],
420 strncpy(hdev->status[HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE],
427 hdev->asic_type = get_asic_type(hdev);
428 if (hdev->asic_type == ASIC_INVALID) {
434 copy_kernel_module_params_to_device(hdev);
436 set_driver_behavior_per_device(hdev);
438 fixup_device_params(hdev);
445 main_id = idr_alloc(&hl_devs_idr, hdev, 0, HL_MAX_MINORS, GFP_KERNEL);
448 ctrl_id = idr_alloc(&hl_devs_idr, hdev, main_id + 1,
467 hdev->id = main_id;
468 hdev->id_control = ctrl_id;
470 *dev = hdev;
475 kfree(hdev);
485 static void destroy_hdev(struct hl_device *hdev)
489 idr_remove(&hl_devs_idr, hdev->id);
490 idr_remove(&hl_devs_idr, hdev->id_control);
493 kfree(hdev);
498 struct hl_device *hdev = dev_get_drvdata(dev);
502 if (!hdev) {
507 return hl_device_suspend(hdev);
512 struct hl_device *hdev = dev_get_drvdata(dev);
516 if (!hdev) {
521 return hl_device_resume(hdev);
536 struct hl_device *hdev;
543 rc = create_hdev(&hdev, pdev);
547 pci_set_drvdata(pdev, hdev);
549 rc = hl_device_init(hdev);
560 destroy_hdev(hdev);
574 struct hl_device *hdev;
576 hdev = pci_get_drvdata(pdev);
577 if (!hdev)
580 hl_device_fini(hdev);
582 destroy_hdev(hdev);
597 struct hl_device *hdev = pci_get_drvdata(pdev);
602 dev_warn(hdev->dev, "PCI normal state error detected\n");
606 dev_warn(hdev->dev, "PCI frozen state error detected\n");
611 dev_warn(hdev->dev, "PCI failure state error detected\n");
619 hdev->asic_funcs->halt_engines(hdev, true, false);
632 struct hl_device *hdev = pci_get_drvdata(pdev);
634 dev_warn(hdev->dev, "Resuming device after PCI slot reset\n");
635 hl_device_resume(hdev);
647 struct hl_device *hdev = pci_get_drvdata(pdev);
649 dev_warn(hdev->dev, "PCI slot reset detected\n");