Lines Matching defs:hdev

21 static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
27 if (hl_device_disabled_or_in_reset(hdev))
38 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
42 dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
47 static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
53 if (hl_device_disabled_or_in_reset(hdev))
65 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
69 dev_err(hdev->dev, "Failed to write to I2C, error %d\n", rc);
74 static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state)
79 if (hl_device_disabled_or_in_reset(hdev))
89 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
93 dev_err(hdev->dev, "Failed to set LED %d, error %d\n", led, rc);
238 if (!dev_entry->hdev->mmu_enable)
271 vm = &ctx->hdev->vm;
306 return ctx->hdev->asic_prop.mmu_pgt_addr +
307 (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size);
313 return hop_addr + ctx->hdev->asic_prop.mmu_pte_size *
377 struct hl_device *hdev = dev_entry->hdev;
378 struct asic_fixed_properties *prop = &hdev->asic_prop;
391 if (!hdev->mmu_enable)
395 ctx = hdev->kernel_ctx;
397 ctx = hdev->compute_ctx;
400 dev_err(hdev->dev, "no ctx available\n");
417 hop0_pte = hdev->asic_funcs->read_pte(hdev, hop0_pte_addr);
424 hop1_pte = hdev->asic_funcs->read_pte(hdev, hop1_pte_addr);
431 hop2_pte = hdev->asic_funcs->read_pte(hdev, hop2_pte_addr);
438 hop3_pte = hdev->asic_funcs->read_pte(hdev, hop3_pte_addr);
449 hop4_pte = hdev->asic_funcs->read_pte(hdev,
465 hop4_pte = hdev->asic_funcs->read_pte(hdev,
475 hop5_pte = hdev->asic_funcs->read_pte(hdev,
525 dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n",
539 struct hl_device *hdev = dev_entry->hdev;
544 if (!hdev->mmu_enable)
571 dev_err(hdev->dev, "usage: echo <asid> <0xaddr> > mmu\n");
580 struct hl_device *hdev = dev_entry->hdev;
582 if (atomic_read(&hdev->in_reset)) {
583 dev_warn_ratelimited(hdev->dev,
588 hdev->asic_funcs->is_device_idle(hdev, NULL, s);
593 static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
595 struct asic_fixed_properties *prop = &hdev->asic_prop;
597 if (!hdev->mmu_enable)
600 if (hdev->dram_supports_virtual_memory &&
615 static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr,
618 struct hl_ctx *ctx = hdev->compute_ctx;
619 struct asic_fixed_properties *prop = &hdev->asic_prop;
627 dev_err(hdev->dev, "no ctx available\n");
643 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
650 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
657 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
664 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
673 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr);
686 dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n",
698 struct hl_device *hdev = entry->hdev;
704 if (atomic_read(&hdev->in_reset)) {
705 dev_warn_ratelimited(hdev->dev, "Can't read during reset\n");
712 if (hl_is_device_va(hdev, addr)) {
713 rc = device_va_to_pa(hdev, addr, &addr);
718 rc = hdev->asic_funcs->debugfs_read32(hdev, addr, &val);
720 dev_err(hdev->dev, "Failed to read from 0x%010llx\n", addr);
733 struct hl_device *hdev = entry->hdev;
738 if (atomic_read(&hdev->in_reset)) {
739 dev_warn_ratelimited(hdev->dev, "Can't write during reset\n");
747 if (hl_is_device_va(hdev, addr)) {
748 rc = device_va_to_pa(hdev, addr, &addr);
753 rc = hdev->asic_funcs->debugfs_write32(hdev, addr, value);
755 dev_err(hdev->dev, "Failed to write 0x%08x to 0x%010llx\n",
767 struct hl_device *hdev = entry->hdev;
776 if (hl_is_device_va(hdev, addr)) {
777 rc = device_va_to_pa(hdev, addr, &addr);
782 rc = hdev->asic_funcs->debugfs_read64(hdev, addr, &val);
784 dev_err(hdev->dev, "Failed to read from 0x%010llx\n", addr);
797 struct hl_device *hdev = entry->hdev;
806 if (hl_is_device_va(hdev, addr)) {
807 rc = device_va_to_pa(hdev, addr, &addr);
812 rc = hdev->asic_funcs->debugfs_write64(hdev, addr, value);
814 dev_err(hdev->dev, "Failed to write 0x%016llx to 0x%010llx\n",
826 struct hl_device *hdev = entry->hdev;
833 if (hdev->pdev->current_state == PCI_D0)
835 else if (hdev->pdev->current_state == PCI_D3hot)
850 struct hl_device *hdev = entry->hdev;
859 pci_set_power_state(hdev->pdev, PCI_D0);
860 pci_restore_state(hdev->pdev);
861 rc = pci_enable_device(hdev->pdev);
865 pci_save_state(hdev->pdev);
866 pci_disable_device(hdev->pdev);
867 pci_set_power_state(hdev->pdev, PCI_D3hot);
869 dev_dbg(hdev->dev, "invalid power state value %u\n", value);
880 struct hl_device *hdev = entry->hdev;
888 rc = hl_debugfs_i2c_read(hdev, entry->i2c_bus, entry->i2c_addr,
891 dev_err(hdev->dev,
908 struct hl_device *hdev = entry->hdev;
916 rc = hl_debugfs_i2c_write(hdev, entry->i2c_bus, entry->i2c_addr,
919 dev_err(hdev->dev,
932 struct hl_device *hdev = entry->hdev;
942 hl_debugfs_led_set(hdev, 0, value);
951 struct hl_device *hdev = entry->hdev;
961 hl_debugfs_led_set(hdev, 1, value);
970 struct hl_device *hdev = entry->hdev;
980 hl_debugfs_led_set(hdev, 2, value);
997 struct hl_device *hdev = entry->hdev;
1007 hdev->disabled = true;
1009 hdev->disabled = false;
1011 hdev->asic_funcs->suspend(hdev);
1013 hdev->asic_funcs->resume(hdev);
1015 hdev->device_cpu_disabled = true;
1017 dev_err(hdev->dev,
1029 struct hl_device *hdev = entry->hdev;
1036 sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask);
1047 struct hl_device *hdev = entry->hdev;
1051 if (atomic_read(&hdev->in_reset)) {
1052 dev_warn_ratelimited(hdev->dev,
1061 hdev->clock_gating_mask = value;
1062 hdev->asic_funcs->set_clock_gating(hdev);
1071 struct hl_device *hdev = entry->hdev;
1078 sprintf(tmp_buf, "%d\n", hdev->stop_on_err);
1089 struct hl_device *hdev = entry->hdev;
1093 if (atomic_read(&hdev->in_reset)) {
1094 dev_warn_ratelimited(hdev->dev,
1103 hdev->stop_on_err = value ? 1 : 0;
1105 hl_device_reset(hdev, false, false);
1205 void hl_debugfs_add_device(struct hl_device *hdev)
1207 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1213 dev_entry->hdev = hdev;
1233 dev_entry->root = debugfs_create_dir(dev_name(hdev->dev),
1329 void hl_debugfs_remove_device(struct hl_device *hdev)
1331 struct hl_dbg_device_entry *entry = &hdev->hl_debugfs;
1341 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs;
1350 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs;
1359 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs;
1368 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs;
1377 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs;
1386 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs;
1393 void hl_debugfs_add_job(struct hl_device *hdev, struct hl_cs_job *job)
1395 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1402 void hl_debugfs_remove_job(struct hl_device *hdev, struct hl_cs_job *job)
1404 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1411 void hl_debugfs_add_userptr(struct hl_device *hdev, struct hl_userptr *userptr)
1413 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1420 void hl_debugfs_remove_userptr(struct hl_device *hdev,
1423 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1430 void hl_debugfs_add_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx)
1432 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1439 void hl_debugfs_remove_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx)
1441 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;