Lines Matching refs:hdev

90 	struct hl_device *hdev;  in hl_device_open()  local
95 hdev = idr_find(&hl_devs_idr, iminor(inode)); in hl_device_open()
98 if (!hdev) { in hl_device_open()
108 hpriv->hdev = hdev; in hl_device_open()
120 mutex_lock(&hdev->fpriv_list_lock); in hl_device_open()
122 if (hl_device_disabled_or_in_reset(hdev)) { in hl_device_open()
123 dev_err_ratelimited(hdev->dev, in hl_device_open()
125 dev_name(hdev->dev)); in hl_device_open()
130 if (hdev->in_debug) { in hl_device_open()
131 dev_err_ratelimited(hdev->dev, in hl_device_open()
133 dev_name(hdev->dev)); in hl_device_open()
138 if (hdev->compute_ctx) { in hl_device_open()
139 dev_dbg_ratelimited(hdev->dev, in hl_device_open()
141 dev_name(hdev->dev)); in hl_device_open()
146 rc = hl_ctx_create(hdev, hpriv); in hl_device_open()
148 dev_err(hdev->dev, "Failed to create context %d\n", rc); in hl_device_open()
157 hl_device_set_frequency(hdev, PLL_HIGH); in hl_device_open()
159 list_add(&hpriv->dev_node, &hdev->fpriv_list); in hl_device_open()
160 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open()
167 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open()
169 hl_cb_mgr_fini(hpriv->hdev, &hpriv->cb_mgr); in hl_device_open()
170 hl_ctx_mgr_fini(hpriv->hdev, &hpriv->ctx_mgr); in hl_device_open()
182 struct hl_device *hdev; in hl_device_open_ctrl() local
187 hdev = idr_find(&hl_devs_idr, iminor(inode)); in hl_device_open_ctrl()
190 if (!hdev) { in hl_device_open_ctrl()
200 mutex_lock(&hdev->fpriv_list_lock); in hl_device_open_ctrl()
202 if (hl_device_disabled_or_in_reset(hdev)) { in hl_device_open_ctrl()
203 dev_err_ratelimited(hdev->dev_ctrl, in hl_device_open_ctrl()
205 dev_name(hdev->dev_ctrl)); in hl_device_open_ctrl()
210 list_add(&hpriv->dev_node, &hdev->fpriv_list); in hl_device_open_ctrl()
211 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open_ctrl()
213 hpriv->hdev = hdev; in hl_device_open_ctrl()
224 mutex_unlock(&hdev->fpriv_list_lock); in hl_device_open_ctrl()
229 static void set_driver_behavior_per_device(struct hl_device *hdev) in set_driver_behavior_per_device() argument
231 hdev->mmu_enable = 1; in set_driver_behavior_per_device()
232 hdev->cpu_enable = 1; in set_driver_behavior_per_device()
233 hdev->fw_loading = 1; in set_driver_behavior_per_device()
234 hdev->cpu_queues_enable = 1; in set_driver_behavior_per_device()
235 hdev->heartbeat = 1; in set_driver_behavior_per_device()
236 hdev->clock_gating_mask = ULONG_MAX; in set_driver_behavior_per_device()
238 hdev->reset_pcilink = 0; in set_driver_behavior_per_device()
239 hdev->axi_drain = 0; in set_driver_behavior_per_device()
240 hdev->sram_scrambler_enable = 1; in set_driver_behavior_per_device()
241 hdev->dram_scrambler_enable = 1; in set_driver_behavior_per_device()
242 hdev->bmc_enable = 1; in set_driver_behavior_per_device()
243 hdev->hard_reset_on_fw_events = 1; in set_driver_behavior_per_device()
261 struct hl_device *hdev; in create_hdev() local
266 hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); in create_hdev()
267 if (!hdev) in create_hdev()
274 hdev->asic_type = get_asic_type(pdev->device); in create_hdev()
275 if (hdev->asic_type == ASIC_INVALID) { in create_hdev()
281 hdev->asic_type = asic_type; in create_hdev()
284 hdev->major = hl_major; in create_hdev()
285 hdev->reset_on_lockup = reset_on_lockup; in create_hdev()
286 hdev->pldm = 0; in create_hdev()
288 set_driver_behavior_per_device(hdev); in create_hdev()
291 hdev->timeout_jiffies = msecs_to_jiffies(timeout_locked * 1000); in create_hdev()
293 hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT; in create_hdev()
295 hdev->disabled = true; in create_hdev()
296 hdev->pdev = pdev; /* can be NULL in case of simulator device */ in create_hdev()
299 hdev->dma_mask = 32; in create_hdev()
306 main_id = idr_alloc(&hl_devs_idr, hdev, 0, HL_MAX_MINORS, in create_hdev()
310 ctrl_id = idr_alloc(&hl_devs_idr, hdev, main_id + 1, in create_hdev()
329 hdev->id = main_id; in create_hdev()
330 hdev->id_control = ctrl_id; in create_hdev()
332 *dev = hdev; in create_hdev()
337 kfree(hdev); in create_hdev()
347 void destroy_hdev(struct hl_device *hdev) in destroy_hdev() argument
351 idr_remove(&hl_devs_idr, hdev->id); in destroy_hdev()
352 idr_remove(&hl_devs_idr, hdev->id_control); in destroy_hdev()
355 kfree(hdev); in destroy_hdev()
360 struct hl_device *hdev = dev_get_drvdata(dev); in hl_pmops_suspend() local
364 if (!hdev) { in hl_pmops_suspend()
369 return hl_device_suspend(hdev); in hl_pmops_suspend()
374 struct hl_device *hdev = dev_get_drvdata(dev); in hl_pmops_resume() local
378 if (!hdev) { in hl_pmops_resume()
383 return hl_device_resume(hdev); in hl_pmops_resume()
399 struct hl_device *hdev; in hl_pci_probe() local
406 rc = create_hdev(&hdev, pdev, ASIC_INVALID, -1); in hl_pci_probe()
410 pci_set_drvdata(pdev, hdev); in hl_pci_probe()
414 rc = hl_device_init(hdev, hl_class); in hl_pci_probe()
426 destroy_hdev(hdev); in hl_pci_probe()
440 struct hl_device *hdev; in hl_pci_remove() local
442 hdev = pci_get_drvdata(pdev); in hl_pci_remove()
443 if (!hdev) in hl_pci_remove()
446 hl_device_fini(hdev); in hl_pci_remove()
449 destroy_hdev(hdev); in hl_pci_remove()
464 struct hl_device *hdev = pci_get_drvdata(pdev); in hl_pci_err_detected() local
472 dev_warn(hdev->dev, "frozen state error detected\n"); in hl_pci_err_detected()
477 dev_warn(hdev->dev, "failure state error detected\n"); in hl_pci_err_detected()
485 hdev->asic_funcs->halt_engines(hdev, true); in hl_pci_err_detected()
498 struct hl_device *hdev = pci_get_drvdata(pdev); in hl_pci_err_resume() local
500 dev_warn(hdev->dev, "Resuming device after PCI slot reset\n"); in hl_pci_err_resume()
501 hl_device_resume(hdev); in hl_pci_err_resume()