Lines Matching defs:hdev
23 static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
29 if (!hl_device_operational(hdev, NULL))
33 dev_err(hdev->dev, "I2C transaction length %u, exceeds maximum of %u\n",
47 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
50 dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
55 static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
61 if (!hl_device_operational(hdev, NULL))
65 dev_err(hdev->dev, "I2C transaction length %u, exceeds maximum of %u\n",
80 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
84 dev_err(hdev->dev, "Failed to write to I2C, error %d\n", rc);
89 static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state)
94 if (!hl_device_operational(hdev, NULL))
104 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
108 dev_err(hdev->dev, "Failed to set LED %d, error %d\n", led, rc);
305 vm = &ctx->hdev->vm;
331 ctx = hl_get_compute_ctx(dev_entry->hdev);
430 struct hl_device *hdev = dev_entry->hdev;
437 ctx = hdev->kernel_ctx;
439 ctx = hl_get_compute_ctx(hdev);
442 dev_err(hdev->dev, "no ctx available\n");
447 dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n",
488 struct hl_device *hdev = dev_entry->hdev;
517 dev_err(hdev->dev, "usage: echo <asid> <0xaddr> > mmu\n");
526 struct hl_device *hdev = dev_entry->hdev;
530 dev_err(hdev->dev, "mmu_cap_mask is not set\n");
534 rc = hdev->asic_funcs->ack_mmu_errors(hdev, dev_entry->mmu_cap_mask);
550 struct hl_device *hdev = dev_entry->hdev;
571 dev_err(hdev->dev, "usage: echo <0xmmu_cap_mask > > mmu_error\n");
580 struct hl_device *hdev = dev_entry->hdev;
583 if (hdev->reset_info.in_reset) {
584 dev_warn_ratelimited(hdev->dev,
595 hdev->asic_funcs->is_device_idle(hdev, NULL, 0, &eng_data);
598 dev_err(hdev->dev,
616 struct hl_device *hdev = entry->hdev;
617 u64 val = hdev->memory_scrub_val;
620 if (!hl_device_operational(hdev, NULL)) {
621 dev_warn_ratelimited(hdev->dev, "Can't scrub memory, device is not operational\n");
625 mutex_lock(&hdev->fpriv_list_lock);
626 if (hdev->is_compute_ctx_active) {
627 mutex_unlock(&hdev->fpriv_list_lock);
628 dev_err(hdev->dev, "can't scrub dram, context exist\n");
631 hdev->is_in_dram_scrub = true;
632 mutex_unlock(&hdev->fpriv_list_lock);
634 rc = hdev->asic_funcs->scrub_device_dram(hdev, val);
636 mutex_lock(&hdev->fpriv_list_lock);
637 hdev->is_in_dram_scrub = false;
638 mutex_unlock(&hdev->fpriv_list_lock);
645 static bool hl_is_device_va(struct hl_device *hdev, u64 addr)
647 struct asic_fixed_properties *prop = &hdev->asic_prop;
664 static bool hl_is_device_internal_memory_va(struct hl_device *hdev, u64 addr,
667 struct asic_fixed_properties *prop = &hdev->asic_prop;
689 static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr, u32 size,
701 ctx = hl_get_compute_ctx(hdev);
704 dev_err(hdev->dev, "no ctx available\n");
731 dev_err(hdev->dev,
740 dev_err(hdev->dev,
752 static int hl_access_dev_mem_by_region(struct hl_device *hdev, u64 addr,
761 mem_reg = &hdev->pci_mem_region[i];
767 return hdev->asic_funcs->access_dev_mem(hdev, i, addr, val, acc_type);
773 static void hl_access_host_mem(struct hl_device *hdev, u64 addr, u64 *val,
776 struct asic_fixed_properties *prop = &hdev->asic_prop;
793 dev_err(hdev->dev, "hostmem access-type %d id not supported\n", acc_type);
798 static int hl_access_mem(struct hl_device *hdev, u64 addr, u64 *val,
803 u64 host_start = hdev->asic_prop.host_base_address;
804 u64 host_end = hdev->asic_prop.host_end_address;
808 user_address = hl_is_device_va(hdev, addr);
810 rc = device_va_to_pa(hdev, addr, acc_size, &addr);
815 rc = hl_access_dev_mem_by_region(hdev, addr, val, acc_type, &found);
817 dev_err(hdev->dev,
826 if (!user_address || device_iommu_mapped(&hdev->pdev->dev)) {
832 hl_access_host_mem(hdev, addr, val, acc_type);
840 dev_err(hdev->dev, "invalid addr %#llx\n", addr);
848 struct hl_device *hdev = entry->hdev;
854 if (hdev->reset_info.in_reset) {
855 dev_warn_ratelimited(hdev->dev, "Can't read during reset\n");
862 rc = hl_access_mem(hdev, addr, &value64, DEBUGFS_READ32);
877 struct hl_device *hdev = entry->hdev;
882 if (hdev->reset_info.in_reset) {
883 dev_warn_ratelimited(hdev->dev, "Can't write during reset\n");
892 rc = hl_access_mem(hdev, addr, &value64, DEBUGFS_WRITE32);
903 struct hl_device *hdev = entry->hdev;
909 if (hdev->reset_info.in_reset) {
910 dev_warn_ratelimited(hdev->dev, "Can't read during reset\n");
917 rc = hl_access_mem(hdev, addr, &val, DEBUGFS_READ64);
930 struct hl_device *hdev = entry->hdev;
935 if (hdev->reset_info.in_reset) {
936 dev_warn_ratelimited(hdev->dev, "Can't write during reset\n");
944 rc = hl_access_mem(hdev, addr, &value, DEBUGFS_WRITE64);
955 struct hl_device *hdev = entry->hdev;
960 if (hdev->reset_info.in_reset) {
961 dev_warn_ratelimited(hdev->dev, "Can't DMA during reset\n");
969 dev_err(hdev->dev, "DMA read failed. size can't be 0\n");
974 dev_err(hdev->dev,
979 if (!hl_is_device_internal_memory_va(hdev, addr, size)) {
980 dev_err(hdev->dev,
994 rc = hdev->asic_funcs->debugfs_read_dma(hdev, addr, size,
997 dev_err(hdev->dev, "Failed to DMA from 0x%010llx\n", addr);
1012 struct hl_device *hdev = entry->hdev;
1016 if (hdev->reset_info.in_reset) {
1017 dev_warn_ratelimited(hdev->dev, "Can't dump monitors during reset\n");
1025 dev_err(hdev->dev, "Must write 1 to trigger monitor dump\n");
1039 rc = hdev->asic_funcs->get_monitor_dump(hdev, entry->mon_dump_blob_desc.data);
1041 dev_err(hdev->dev, "Failed to dump monitors\n");
1056 struct hl_device *hdev = entry->hdev;
1063 if (hdev->pdev->current_state == PCI_D0)
1065 else if (hdev->pdev->current_state == PCI_D3hot)
1080 struct hl_device *hdev = entry->hdev;
1089 pci_set_power_state(hdev->pdev, PCI_D0);
1090 pci_restore_state(hdev->pdev);
1091 rc = pci_enable_device(hdev->pdev);
1095 pci_save_state(hdev->pdev);
1096 pci_disable_device(hdev->pdev);
1097 pci_set_power_state(hdev->pdev, PCI_D3hot);
1099 dev_dbg(hdev->dev, "invalid power state value %u\n", value);
1110 struct hl_device *hdev = entry->hdev;
1118 rc = hl_debugfs_i2c_read(hdev, entry->i2c_bus, entry->i2c_addr,
1121 dev_err(hdev->dev,
1138 struct hl_device *hdev = entry->hdev;
1146 rc = hl_debugfs_i2c_write(hdev, entry->i2c_bus, entry->i2c_addr,
1149 dev_err(hdev->dev,
1162 struct hl_device *hdev = entry->hdev;
1172 hl_debugfs_led_set(hdev, 0, value);
1181 struct hl_device *hdev = entry->hdev;
1191 hl_debugfs_led_set(hdev, 1, value);
1200 struct hl_device *hdev = entry->hdev;
1210 hl_debugfs_led_set(hdev, 2, value);
1227 struct hl_device *hdev = entry->hdev;
1237 hdev->disabled = true;
1239 hdev->disabled = false;
1241 hdev->asic_funcs->suspend(hdev);
1243 hdev->asic_funcs->resume(hdev);
1245 hdev->device_cpu_disabled = true;
1247 dev_err(hdev->dev,
1271 struct hl_device *hdev = entry->hdev;
1275 if (!hdev->asic_prop.configurable_stop_on_err)
1281 sprintf(tmp_buf, "%d\n", hdev->stop_on_err);
1292 struct hl_device *hdev = entry->hdev;
1296 if (!hdev->asic_prop.configurable_stop_on_err)
1299 if (hdev->reset_info.in_reset) {
1300 dev_warn_ratelimited(hdev->dev,
1309 hdev->stop_on_err = value ? 1 : 0;
1311 hl_device_reset(hdev, 0);
1320 struct hl_device *hdev = entry->hdev;
1322 hdev->asic_funcs->ack_protection_bits_errors(hdev);
1350 struct hl_device *hdev = entry->hdev;
1360 dev_err(hdev->dev, "Invalid number of dumps to skip\n");
1385 struct hl_device *hdev = entry->hdev;
1393 jiffies_to_msecs(hdev->timeout_jiffies) / 1000);
1404 struct hl_device *hdev = entry->hdev;
1413 hdev->timeout_jiffies = msecs_to_jiffies(value * 1000);
1415 hdev->timeout_jiffies = MAX_SCHEDULE_TIMEOUT;
1424 struct hl_device *hdev = entry->hdev;
1426 hdev->asic_funcs->check_if_razwi_happened(hdev);
1612 static void add_files_to_device(struct hl_device *hdev, struct hl_dbg_device_entry *dev_entry,
1622 &hdev->memory_scrub_val);
1708 &hdev->reset_info.skip_reset_on_timeout);
1725 &hdev->device_release_watchdog_timeout_sec);
1738 int hl_debugfs_device_init(struct hl_device *hdev)
1740 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1743 dev_entry->hdev = hdev;
1770 void hl_debugfs_device_fini(struct hl_device *hdev)
1772 struct hl_dbg_device_entry *entry = &hdev->hl_debugfs;
1787 void hl_debugfs_add_device(struct hl_device *hdev)
1789 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1791 dev_entry->root = debugfs_create_dir(dev_name(hdev->dev), hl_debug_root);
1793 add_files_to_device(hdev, dev_entry, dev_entry->root);
1794 if (!hdev->asic_prop.fw_security_enabled)
1798 void hl_debugfs_remove_device(struct hl_device *hdev)
1800 struct hl_dbg_device_entry *entry = &hdev->hl_debugfs;
1807 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs;
1816 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs;
1825 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs;
1834 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs;
1843 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs;
1852 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs;
1859 void hl_debugfs_add_job(struct hl_device *hdev, struct hl_cs_job *job)
1861 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1868 void hl_debugfs_remove_job(struct hl_device *hdev, struct hl_cs_job *job)
1870 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1877 void hl_debugfs_add_userptr(struct hl_device *hdev, struct hl_userptr *userptr)
1879 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1886 void hl_debugfs_remove_userptr(struct hl_device *hdev,
1889 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1896 void hl_debugfs_add_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx)
1898 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1905 void hl_debugfs_remove_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx)
1907 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;
1917 * @hdev: pointer to the device structure
1921 void hl_debugfs_set_state_dump(struct hl_device *hdev, char *data,
1924 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs;