Lines Matching defs:hdev

116  * @hdev: pointer to habanalabs device structure.
121 static enum hl_asic_type get_asic_type(struct hl_device *hdev)
123 struct pci_dev *pdev = hdev->pdev;
177 struct hl_device *hdev = to_hl_device(ddev);
186 hpriv->hdev = hdev;
193 hl_mem_mgr_init(hpriv->hdev->dev, &hpriv->mem_mgr);
197 mutex_lock(&hdev->fpriv_list_lock);
199 if (!hl_device_operational(hdev, &status)) {
200 dev_dbg_ratelimited(hdev->dev,
202 dev_name(hdev->dev), hdev->status[status]);
213 if (hdev->is_in_dram_scrub) {
214 dev_dbg_ratelimited(hdev->dev,
216 dev_name(hdev->dev));
221 if (hdev->compute_ctx_in_release) {
222 dev_dbg_ratelimited(hdev->dev,
224 dev_name(hdev->dev));
229 if (hdev->is_compute_ctx_active) {
230 dev_dbg_ratelimited(hdev->dev,
232 dev_name(hdev->dev));
237 rc = hl_ctx_create(hdev, hpriv);
239 dev_err(hdev->dev, "Failed to create context %d\n", rc);
243 list_add(&hpriv->dev_node, &hdev->fpriv_list);
244 mutex_unlock(&hdev->fpriv_list_lock);
246 hdev->asic_funcs->send_device_activity(hdev, true);
250 hl_enable_err_info_capture(&hdev->captured_err_info);
252 hdev->open_counter++;
253 hdev->last_successful_open_jif = jiffies;
254 hdev->last_successful_open_ktime = ktime_get();
262 mutex_unlock(&hdev->fpriv_list_lock);
265 hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr);
278 struct hl_device *hdev;
283 hdev = idr_find(&hl_devs_idr, iminor(inode));
286 if (!hdev) {
299 hpriv->hdev = hdev;
306 mutex_lock(&hdev->fpriv_ctrl_list_lock);
308 if (!hl_ctrl_device_operational(hdev, NULL)) {
309 dev_dbg_ratelimited(hdev->dev_ctrl,
311 dev_name(hdev->dev_ctrl));
316 list_add(&hpriv->dev_node, &hdev->fpriv_ctrl_list);
317 mutex_unlock(&hdev->fpriv_ctrl_list_lock);
322 mutex_unlock(&hdev->fpriv_ctrl_list_lock);
331 static void set_driver_behavior_per_device(struct hl_device *hdev)
333 hdev->nic_ports_mask = 0;
334 hdev->fw_components = FW_TYPE_ALL_TYPES;
335 hdev->cpu_queues_enable = 1;
336 hdev->pldm = 0;
337 hdev->hard_reset_on_fw_events = 1;
338 hdev->bmc_enable = 1;
339 hdev->reset_on_preboot_fail = 1;
340 hdev->heartbeat = 1;
343 static void copy_kernel_module_params_to_device(struct hl_device *hdev)
345 hdev->asic_prop.fw_security_enabled = is_asic_secured(hdev->asic_type);
347 hdev->major = hl_major;
348 hdev->memory_scrub = memory_scrub;
349 hdev->reset_on_lockup = reset_on_lockup;
350 hdev->boot_error_status_mask = boot_error_status_mask;
353 static void fixup_device_params_per_asic(struct hl_device *hdev, int timeout)
355 switch (hdev->asic_type) {
362 hdev->timeout_jiffies = msecs_to_jiffies(GAUDI_DEFAULT_TIMEOUT_LOCKED *
365 hdev->reset_upon_device_release = 0;
369 hdev->reset_upon_device_release = 0;
373 hdev->reset_upon_device_release = 1;
378 static int fixup_device_params(struct hl_device *hdev)
384 hdev->fw_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC;
385 hdev->fw_comms_poll_interval_usec = HL_FW_STATUS_POLL_INTERVAL_USEC;
388 hdev->timeout_jiffies = msecs_to_jiffies(tmp_timeout * MSEC_PER_SEC);
390 hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
392 hdev->stop_on_err = true;
393 hdev->reset_info.curr_reset_cause = HL_RESET_CAUSE_UNKNOWN;
394 hdev->reset_info.prev_reset_trigger = HL_RESET_TRIGGER_DEFAULT;
397 hdev->disabled = true;
399 if (!(hdev->fw_components & FW_TYPE_PREBOOT_CPU) &&
400 (hdev->fw_components & ~FW_TYPE_PREBOOT_CPU)) {
406 if (!hdev->cpu_queues_enable)
407 hdev->heartbeat = 0;
408 fixup_device_params_per_asic(hdev, tmp_timeout);
413 static int allocate_device_id(struct hl_device *hdev)
418 id = idr_alloc(&hl_devs_idr, hdev, 0, HL_MAX_MINORS, GFP_KERNEL);
427 hdev->id = id;
433 hdev->cdev_idx = hdev->id;
450 struct hl_device *hdev;
455 hdev = devm_drm_dev_alloc(&pdev->dev, &hl_driver, struct hl_device, drm);
456 if (IS_ERR(hdev))
457 return PTR_ERR(hdev);
459 hdev->dev = hdev->drm.dev;
462 hdev->pdev = pdev;
465 strscpy(hdev->status[HL_DEVICE_STATUS_OPERATIONAL], "operational", HL_STR_MAX);
466 strscpy(hdev->status[HL_DEVICE_STATUS_IN_RESET], "in reset", HL_STR_MAX);
467 strscpy(hdev->status[HL_DEVICE_STATUS_MALFUNCTION], "disabled", HL_STR_MAX);
468 strscpy(hdev->status[HL_DEVICE_STATUS_NEEDS_RESET], "needs reset", HL_STR_MAX);
469 strscpy(hdev->status[HL_DEVICE_STATUS_IN_DEVICE_CREATION],
471 strscpy(hdev->status[HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE],
478 hdev->asic_type = get_asic_type(hdev);
479 if (hdev->asic_type == ASIC_INVALID) {
485 copy_kernel_module_params_to_device(hdev);
487 set_driver_behavior_per_device(hdev);
489 fixup_device_params(hdev);
491 rc = allocate_device_id(hdev);
495 *dev = hdev;
509 static void destroy_hdev(struct hl_device *hdev)
513 idr_remove(&hl_devs_idr, hdev->id);
520 struct hl_device *hdev = dev_get_drvdata(dev);
524 if (!hdev) {
529 return hl_device_suspend(hdev);
534 struct hl_device *hdev = dev_get_drvdata(dev);
538 if (!hdev) {
543 return hl_device_resume(hdev);
558 struct hl_device *hdev;
565 rc = create_hdev(&hdev, pdev);
569 pci_set_drvdata(pdev, hdev);
571 rc = hl_device_init(hdev);
582 destroy_hdev(hdev);
596 struct hl_device *hdev;
598 hdev = pci_get_drvdata(pdev);
599 if (!hdev)
602 hl_device_fini(hdev);
604 destroy_hdev(hdev);
619 struct hl_device *hdev = pci_get_drvdata(pdev);
624 dev_warn(hdev->dev, "PCI normal state error detected\n");
628 dev_warn(hdev->dev, "PCI frozen state error detected\n");
633 dev_warn(hdev->dev, "PCI failure state error detected\n");
641 hdev->asic_funcs->halt_engines(hdev, true, false);
654 struct hl_device *hdev = pci_get_drvdata(pdev);
656 dev_warn(hdev->dev, "Resuming device after PCI slot reset\n");
657 hl_device_resume(hdev);
669 struct hl_device *hdev = pci_get_drvdata(pdev);
671 dev_warn(hdev->dev, "PCI slot reset detected\n");
678 struct hl_device *hdev;
680 hdev = pci_get_drvdata(pdev);
681 if (!hdev)
684 hdev->disabled = true;
689 struct hl_device *hdev;
692 hdev = pci_get_drvdata(pdev);
693 if (!hdev)
705 hl_device_reset(hdev, flags);