• Home
  • Raw
  • Download

Lines Matching +full:ctx +full:- +full:asid

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2019 HabanaLabs, Ltd.
28 return -EBUSY; in hl_debugfs_i2c_read()
38 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_debugfs_i2c_read()
42 dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc); in hl_debugfs_i2c_read()
54 return -EBUSY; in hl_debugfs_i2c_write()
65 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_debugfs_i2c_write()
69 dev_err(hdev->dev, "Failed to write to I2C, error %d\n", rc); in hl_debugfs_i2c_write()
89 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_debugfs_led_set()
93 dev_err(hdev->dev, "Failed to set LED %d, error %d\n", led, rc); in hl_debugfs_led_set()
98 struct hl_debugfs_entry *entry = s->private; in command_buffers_show()
99 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in command_buffers_show()
103 spin_lock(&dev_entry->cb_spinlock); in command_buffers_show()
105 list_for_each_entry(cb, &dev_entry->cb_list, debugfs_list) { in command_buffers_show()
109 seq_puts(s, " CB ID CTX ID CB size CB RefCnt mmap? CS counter\n"); in command_buffers_show()
110 seq_puts(s, "---------------------------------------------------------------\n"); in command_buffers_show()
114 cb->id, cb->ctx->asid, cb->size, in command_buffers_show()
115 kref_read(&cb->refcount), in command_buffers_show()
116 cb->mmap, cb->cs_cnt); in command_buffers_show()
119 spin_unlock(&dev_entry->cb_spinlock); in command_buffers_show()
129 struct hl_debugfs_entry *entry = s->private; in command_submission_show()
130 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in command_submission_show()
134 spin_lock(&dev_entry->cs_spinlock); in command_submission_show()
136 list_for_each_entry(cs, &dev_entry->cs_list, debugfs_list) { in command_submission_show()
140 seq_puts(s, " CS ID CTX ASID CS RefCnt Submitted Completed\n"); in command_submission_show()
141 seq_puts(s, "------------------------------------------------------\n"); in command_submission_show()
145 cs->sequence, cs->ctx->asid, in command_submission_show()
146 kref_read(&cs->refcount), in command_submission_show()
147 cs->submitted, cs->completed); in command_submission_show()
150 spin_unlock(&dev_entry->cs_spinlock); in command_submission_show()
160 struct hl_debugfs_entry *entry = s->private; in command_submission_jobs_show()
161 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in command_submission_jobs_show()
165 spin_lock(&dev_entry->cs_job_spinlock); in command_submission_jobs_show()
167 list_for_each_entry(job, &dev_entry->cs_job_list, debugfs_list) { in command_submission_jobs_show()
171 seq_puts(s, " JOB ID CS ID CTX ASID H/W Queue\n"); in command_submission_jobs_show()
172 seq_puts(s, "---------------------------------------\n"); in command_submission_jobs_show()
174 if (job->cs) in command_submission_jobs_show()
177 job->id, job->cs->sequence, job->cs->ctx->asid, in command_submission_jobs_show()
178 job->hw_queue_id); in command_submission_jobs_show()
182 job->id, HL_KERNEL_ASID_ID, job->hw_queue_id); in command_submission_jobs_show()
185 spin_unlock(&dev_entry->cs_job_spinlock); in command_submission_jobs_show()
195 struct hl_debugfs_entry *entry = s->private; in userptr_show()
196 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in userptr_show()
202 spin_lock(&dev_entry->userptr_spinlock); in userptr_show()
204 list_for_each_entry(userptr, &dev_entry->userptr_list, debugfs_list) { in userptr_show()
209 seq_puts(s, "----------------------------------------------------------\n"); in userptr_show()
212 " 0x%-14llx %-10u %-30s\n", in userptr_show()
213 userptr->addr, userptr->size, dma_dir[userptr->dir]); in userptr_show()
216 spin_unlock(&dev_entry->userptr_spinlock); in userptr_show()
226 struct hl_debugfs_entry *entry = s->private; in vm_show()
227 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in vm_show()
228 struct hl_ctx *ctx; in vm_show() local
238 if (!dev_entry->hdev->mmu_enable) in vm_show()
241 spin_lock(&dev_entry->ctx_mem_hash_spinlock); in vm_show()
243 list_for_each_entry(ctx, &dev_entry->ctx_mem_hash_list, debugfs_list) { in vm_show()
245 seq_puts(s, "\n\n----------------------------------------------------"); in vm_show()
246 seq_puts(s, "\n----------------------------------------------------\n\n"); in vm_show()
247 seq_printf(s, "ctx asid: %u\n", ctx->asid); in vm_show()
251 seq_puts(s, "----------------------------------------------------\n"); in vm_show()
252 mutex_lock(&ctx->mem_hash_lock); in vm_show()
253 hash_for_each(ctx->mem_hash, i, hnode, node) { in vm_show()
254 vm_type = hnode->ptr; in vm_show()
257 userptr = hnode->ptr; in vm_show()
259 " 0x%-14llx %-10u\n", in vm_show()
260 hnode->vaddr, userptr->size); in vm_show()
262 phys_pg_pack = hnode->ptr; in vm_show()
264 " 0x%-14llx %-10llu %-4u\n", in vm_show()
265 hnode->vaddr, phys_pg_pack->total_size, in vm_show()
266 phys_pg_pack->handle); in vm_show()
269 mutex_unlock(&ctx->mem_hash_lock); in vm_show()
271 vm = &ctx->hdev->vm; in vm_show()
272 spin_lock(&vm->idr_lock); in vm_show()
274 if (!idr_is_empty(&vm->phys_pg_pack_handles)) in vm_show()
277 idr_for_each_entry(&vm->phys_pg_pack_handles, phys_pg_pack, i) { in vm_show()
278 if (phys_pg_pack->asid != ctx->asid) in vm_show()
281 seq_printf(s, "\nhandle: %u\n", phys_pg_pack->handle); in vm_show()
283 phys_pg_pack->page_size); in vm_show()
285 seq_puts(s, "---------------------\n"); in vm_show()
286 for (j = 0 ; j < phys_pg_pack->npages ; j++) { in vm_show()
287 seq_printf(s, " 0x%-14llx\n", in vm_show()
288 phys_pg_pack->pages[j]); in vm_show()
291 spin_unlock(&vm->idr_lock); in vm_show()
295 spin_unlock(&dev_entry->ctx_mem_hash_spinlock); in vm_show()
304 static inline u64 get_hop0_addr(struct hl_ctx *ctx) in get_hop0_addr() argument
306 return ctx->hdev->asic_prop.mmu_pgt_addr + in get_hop0_addr()
307 (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size); in get_hop0_addr()
310 static inline u64 get_hopN_pte_addr(struct hl_ctx *ctx, u64 hop_addr, in get_hopN_pte_addr() argument
313 return hop_addr + ctx->hdev->asic_prop.mmu_pte_size * in get_hopN_pte_addr()
317 static inline u64 get_hop0_pte_addr(struct hl_ctx *ctx, in get_hop0_pte_addr() argument
321 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop0_mask, in get_hop0_pte_addr()
322 mmu_specs->hop0_shift); in get_hop0_pte_addr()
325 static inline u64 get_hop1_pte_addr(struct hl_ctx *ctx, in get_hop1_pte_addr() argument
329 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop1_mask, in get_hop1_pte_addr()
330 mmu_specs->hop1_shift); in get_hop1_pte_addr()
333 static inline u64 get_hop2_pte_addr(struct hl_ctx *ctx, in get_hop2_pte_addr() argument
337 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop2_mask, in get_hop2_pte_addr()
338 mmu_specs->hop2_shift); in get_hop2_pte_addr()
341 static inline u64 get_hop3_pte_addr(struct hl_ctx *ctx, in get_hop3_pte_addr() argument
345 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop3_mask, in get_hop3_pte_addr()
346 mmu_specs->hop3_shift); in get_hop3_pte_addr()
349 static inline u64 get_hop4_pte_addr(struct hl_ctx *ctx, in get_hop4_pte_addr() argument
353 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop4_mask, in get_hop4_pte_addr()
354 mmu_specs->hop4_shift); in get_hop4_pte_addr()
357 static inline u64 get_hop5_pte_addr(struct hl_ctx *ctx, in get_hop5_pte_addr() argument
361 return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop5_mask, in get_hop5_pte_addr()
362 mmu_specs->hop5_shift); in get_hop5_pte_addr()
375 struct hl_debugfs_entry *entry = s->private; in mmu_show()
376 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in mmu_show()
377 struct hl_device *hdev = dev_entry->hdev; in mmu_show()
378 struct asic_fixed_properties *prop = &hdev->asic_prop; in mmu_show()
380 struct hl_ctx *ctx; in mmu_show() local
389 virt_addr = dev_entry->mmu_addr; in mmu_show()
391 if (!hdev->mmu_enable) in mmu_show()
394 if (dev_entry->mmu_asid == HL_KERNEL_ASID_ID) in mmu_show()
395 ctx = hdev->kernel_ctx; in mmu_show()
397 ctx = hdev->compute_ctx; in mmu_show()
399 if (!ctx) { in mmu_show()
400 dev_err(hdev->dev, "no ctx available\n"); in mmu_show()
404 is_dram_addr = hl_mem_area_inside_range(virt_addr, prop->dmmu.page_size, in mmu_show()
405 prop->dmmu.start_addr, in mmu_show()
406 prop->dmmu.end_addr); in mmu_show()
409 mmu_prop = is_dram_addr ? &prop->dmmu : &prop->pmmu; in mmu_show()
411 mutex_lock(&ctx->mmu_lock); in mmu_show()
415 hop0_addr = get_hop0_addr(ctx); in mmu_show()
416 hop0_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop0_addr, virt_addr); in mmu_show()
417 hop0_pte = hdev->asic_funcs->read_pte(hdev, hop0_pte_addr); in mmu_show()
423 hop1_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop1_addr, virt_addr); in mmu_show()
424 hop1_pte = hdev->asic_funcs->read_pte(hdev, hop1_pte_addr); in mmu_show()
430 hop2_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop2_addr, virt_addr); in mmu_show()
431 hop2_pte = hdev->asic_funcs->read_pte(hdev, hop2_pte_addr); in mmu_show()
437 hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr); in mmu_show()
438 hop3_pte = hdev->asic_funcs->read_pte(hdev, hop3_pte_addr); in mmu_show()
440 if (mmu_prop->num_hops == MMU_ARCH_5_HOPS) { in mmu_show()
447 hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, in mmu_show()
449 hop4_pte = hdev->asic_funcs->read_pte(hdev, in mmu_show()
463 hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, in mmu_show()
465 hop4_pte = hdev->asic_funcs->read_pte(hdev, in mmu_show()
473 hop5_pte_addr = get_hop5_pte_addr(ctx, mmu_prop, in mmu_show()
475 hop5_pte = hdev->asic_funcs->read_pte(hdev, in mmu_show()
485 seq_printf(s, "asid: %u, virt_addr: 0x%llx\n", in mmu_show()
486 dev_entry->mmu_asid, dev_entry->mmu_addr); in mmu_show()
504 if (mmu_prop->num_hops == MMU_ARCH_5_HOPS) { in mmu_show()
525 dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n", in mmu_show()
528 mutex_unlock(&ctx->mmu_lock); in mmu_show()
536 struct seq_file *s = file->private_data; in mmu_asid_va_write()
537 struct hl_debugfs_entry *entry = s->private; in mmu_asid_va_write()
538 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in mmu_asid_va_write()
539 struct hl_device *hdev = dev_entry->hdev; in mmu_asid_va_write()
544 if (!hdev->mmu_enable) in mmu_asid_va_write()
547 if (count > sizeof(kbuf) - 1) in mmu_asid_va_write()
558 rc = kstrtouint(kbuf, 10, &dev_entry->mmu_asid); in mmu_asid_va_write()
564 rc = kstrtoull(c+3, 16, &dev_entry->mmu_addr); in mmu_asid_va_write()
571 dev_err(hdev->dev, "usage: echo <asid> <0xaddr> > mmu\n"); in mmu_asid_va_write()
573 return -EINVAL; in mmu_asid_va_write()
578 struct hl_debugfs_entry *entry = s->private; in engines_show()
579 struct hl_dbg_device_entry *dev_entry = entry->dev_entry; in engines_show()
580 struct hl_device *hdev = dev_entry->hdev; in engines_show()
582 if (atomic_read(&hdev->in_reset)) { in engines_show()
583 dev_warn_ratelimited(hdev->dev, in engines_show()
588 hdev->asic_funcs->is_device_idle(hdev, NULL, s); in engines_show()
595 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_is_device_va()
597 if (!hdev->mmu_enable) in hl_is_device_va()
600 if (hdev->dram_supports_virtual_memory && in hl_is_device_va()
601 (addr >= prop->dmmu.start_addr && addr < prop->dmmu.end_addr)) in hl_is_device_va()
604 if (addr >= prop->pmmu.start_addr && in hl_is_device_va()
605 addr < prop->pmmu.end_addr) in hl_is_device_va()
608 if (addr >= prop->pmmu_huge.start_addr && in hl_is_device_va()
609 addr < prop->pmmu_huge.end_addr) in hl_is_device_va()
618 struct hl_ctx *ctx = hdev->compute_ctx; in device_va_to_pa() local
619 struct asic_fixed_properties *prop = &hdev->asic_prop; in device_va_to_pa()
626 if (!ctx) { in device_va_to_pa()
627 dev_err(hdev->dev, "no ctx available\n"); in device_va_to_pa()
628 return -EINVAL; in device_va_to_pa()
631 is_dram_addr = hl_mem_area_inside_range(virt_addr, prop->dmmu.page_size, in device_va_to_pa()
632 prop->dmmu.start_addr, in device_va_to_pa()
633 prop->dmmu.end_addr); in device_va_to_pa()
636 mmu_prop = is_dram_addr ? &prop->dmmu : &prop->pmmu; in device_va_to_pa()
638 mutex_lock(&ctx->mmu_lock); in device_va_to_pa()
641 hop_addr = get_hop0_addr(ctx); in device_va_to_pa()
642 hop_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop_addr, virt_addr); in device_va_to_pa()
643 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); in device_va_to_pa()
649 hop_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop_addr, virt_addr); in device_va_to_pa()
650 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); in device_va_to_pa()
656 hop_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop_addr, virt_addr); in device_va_to_pa()
657 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); in device_va_to_pa()
663 hop_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop_addr, virt_addr); in device_va_to_pa()
664 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); in device_va_to_pa()
671 hop_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop_addr, in device_va_to_pa()
673 hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); in device_va_to_pa()
686 dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n", in device_va_to_pa()
688 rc = -EINVAL; in device_va_to_pa()
690 mutex_unlock(&ctx->mmu_lock); in device_va_to_pa()
697 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_data_read32()
698 struct hl_device *hdev = entry->hdev; in hl_data_read32()
700 u64 addr = entry->addr; in hl_data_read32()
704 if (atomic_read(&hdev->in_reset)) { in hl_data_read32()
705 dev_warn_ratelimited(hdev->dev, "Can't read during reset\n"); in hl_data_read32()
718 rc = hdev->asic_funcs->debugfs_read32(hdev, addr, &val); in hl_data_read32()
720 dev_err(hdev->dev, "Failed to read from 0x%010llx\n", addr); in hl_data_read32()
732 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_data_write32()
733 struct hl_device *hdev = entry->hdev; in hl_data_write32()
734 u64 addr = entry->addr; in hl_data_write32()
738 if (atomic_read(&hdev->in_reset)) { in hl_data_write32()
739 dev_warn_ratelimited(hdev->dev, "Can't write during reset\n"); in hl_data_write32()
753 rc = hdev->asic_funcs->debugfs_write32(hdev, addr, value); in hl_data_write32()
755 dev_err(hdev->dev, "Failed to write 0x%08x to 0x%010llx\n", in hl_data_write32()
766 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_data_read64()
767 struct hl_device *hdev = entry->hdev; in hl_data_read64()
769 u64 addr = entry->addr; in hl_data_read64()
782 rc = hdev->asic_funcs->debugfs_read64(hdev, addr, &val); in hl_data_read64()
784 dev_err(hdev->dev, "Failed to read from 0x%010llx\n", addr); in hl_data_read64()
796 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_data_write64()
797 struct hl_device *hdev = entry->hdev; in hl_data_write64()
798 u64 addr = entry->addr; in hl_data_write64()
812 rc = hdev->asic_funcs->debugfs_write64(hdev, addr, value); in hl_data_write64()
814 dev_err(hdev->dev, "Failed to write 0x%016llx to 0x%010llx\n", in hl_data_write64()
825 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_get_power_state()
826 struct hl_device *hdev = entry->hdev; in hl_get_power_state()
833 if (hdev->pdev->current_state == PCI_D0) in hl_get_power_state()
835 else if (hdev->pdev->current_state == PCI_D3hot) in hl_get_power_state()
841 "current power state: %d\n1 - D0\n2 - D3hot\n3 - Unknown\n", i); in hl_get_power_state()
849 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_set_power_state()
850 struct hl_device *hdev = entry->hdev; in hl_set_power_state()
859 pci_set_power_state(hdev->pdev, PCI_D0); in hl_set_power_state()
860 pci_restore_state(hdev->pdev); in hl_set_power_state()
861 rc = pci_enable_device(hdev->pdev); in hl_set_power_state()
865 pci_save_state(hdev->pdev); in hl_set_power_state()
866 pci_disable_device(hdev->pdev); in hl_set_power_state()
867 pci_set_power_state(hdev->pdev, PCI_D3hot); in hl_set_power_state()
869 dev_dbg(hdev->dev, "invalid power state value %u\n", value); in hl_set_power_state()
870 return -EINVAL; in hl_set_power_state()
879 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_i2c_data_read()
880 struct hl_device *hdev = entry->hdev; in hl_i2c_data_read()
888 rc = hl_debugfs_i2c_read(hdev, entry->i2c_bus, entry->i2c_addr, in hl_i2c_data_read()
889 entry->i2c_reg, &val); in hl_i2c_data_read()
891 dev_err(hdev->dev, in hl_i2c_data_read()
893 entry->i2c_bus, entry->i2c_addr, entry->i2c_reg); in hl_i2c_data_read()
907 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_i2c_data_write()
908 struct hl_device *hdev = entry->hdev; in hl_i2c_data_write()
916 rc = hl_debugfs_i2c_write(hdev, entry->i2c_bus, entry->i2c_addr, in hl_i2c_data_write()
917 entry->i2c_reg, value); in hl_i2c_data_write()
919 dev_err(hdev->dev, in hl_i2c_data_write()
921 value, entry->i2c_bus, entry->i2c_addr, entry->i2c_reg); in hl_i2c_data_write()
931 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_led0_write()
932 struct hl_device *hdev = entry->hdev; in hl_led0_write()
950 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_led1_write()
951 struct hl_device *hdev = entry->hdev; in hl_led1_write()
969 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_led2_write()
970 struct hl_device *hdev = entry->hdev; in hl_led2_write()
996 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_device_write()
997 struct hl_device *hdev = entry->hdev; in hl_device_write()
1007 hdev->disabled = true; in hl_device_write()
1009 hdev->disabled = false; in hl_device_write()
1011 hdev->asic_funcs->suspend(hdev); in hl_device_write()
1013 hdev->asic_funcs->resume(hdev); in hl_device_write()
1015 hdev->device_cpu_disabled = true; in hl_device_write()
1017 dev_err(hdev->dev, in hl_device_write()
1019 count = -EINVAL; in hl_device_write()
1028 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_clk_gate_read()
1029 struct hl_device *hdev = entry->hdev; in hl_clk_gate_read()
1036 sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask); in hl_clk_gate_read()
1046 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_clk_gate_write()
1047 struct hl_device *hdev = entry->hdev; in hl_clk_gate_write()
1051 if (atomic_read(&hdev->in_reset)) { in hl_clk_gate_write()
1052 dev_warn_ratelimited(hdev->dev, in hl_clk_gate_write()
1061 hdev->clock_gating_mask = value; in hl_clk_gate_write()
1062 hdev->asic_funcs->set_clock_gating(hdev); in hl_clk_gate_write()
1070 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_stop_on_err_read()
1071 struct hl_device *hdev = entry->hdev; in hl_stop_on_err_read()
1078 sprintf(tmp_buf, "%d\n", hdev->stop_on_err); in hl_stop_on_err_read()
1088 struct hl_dbg_device_entry *entry = file_inode(f)->i_private; in hl_stop_on_err_write()
1089 struct hl_device *hdev = entry->hdev; in hl_stop_on_err_write()
1093 if (atomic_read(&hdev->in_reset)) { in hl_stop_on_err_write()
1094 dev_warn_ratelimited(hdev->dev, in hl_stop_on_err_write()
1103 hdev->stop_on_err = value ? 1 : 0; in hl_stop_on_err_write()
1179 struct hl_debugfs_entry *node = inode->i_private; in hl_debugfs_open()
1181 return single_open(file, node->info_ent->show, node); in hl_debugfs_open()
1187 struct hl_debugfs_entry *node = file->f_inode->i_private; in hl_debugfs_write()
1189 if (node->info_ent->write) in hl_debugfs_write()
1190 return node->info_ent->write(file, buf, count, f_pos); in hl_debugfs_write()
1192 return -EINVAL; in hl_debugfs_write()
1207 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_add_device()
1213 dev_entry->hdev = hdev; in hl_debugfs_add_device()
1214 dev_entry->entry_arr = kmalloc_array(count, in hl_debugfs_add_device()
1217 if (!dev_entry->entry_arr) in hl_debugfs_add_device()
1220 INIT_LIST_HEAD(&dev_entry->file_list); in hl_debugfs_add_device()
1221 INIT_LIST_HEAD(&dev_entry->cb_list); in hl_debugfs_add_device()
1222 INIT_LIST_HEAD(&dev_entry->cs_list); in hl_debugfs_add_device()
1223 INIT_LIST_HEAD(&dev_entry->cs_job_list); in hl_debugfs_add_device()
1224 INIT_LIST_HEAD(&dev_entry->userptr_list); in hl_debugfs_add_device()
1225 INIT_LIST_HEAD(&dev_entry->ctx_mem_hash_list); in hl_debugfs_add_device()
1226 mutex_init(&dev_entry->file_mutex); in hl_debugfs_add_device()
1227 spin_lock_init(&dev_entry->cb_spinlock); in hl_debugfs_add_device()
1228 spin_lock_init(&dev_entry->cs_spinlock); in hl_debugfs_add_device()
1229 spin_lock_init(&dev_entry->cs_job_spinlock); in hl_debugfs_add_device()
1230 spin_lock_init(&dev_entry->userptr_spinlock); in hl_debugfs_add_device()
1231 spin_lock_init(&dev_entry->ctx_mem_hash_spinlock); in hl_debugfs_add_device()
1233 dev_entry->root = debugfs_create_dir(dev_name(hdev->dev), in hl_debugfs_add_device()
1238 dev_entry->root, in hl_debugfs_add_device()
1239 &dev_entry->addr); in hl_debugfs_add_device()
1243 dev_entry->root, in hl_debugfs_add_device()
1249 dev_entry->root, in hl_debugfs_add_device()
1255 dev_entry->root, in hl_debugfs_add_device()
1261 dev_entry->root, in hl_debugfs_add_device()
1262 &dev_entry->i2c_bus); in hl_debugfs_add_device()
1266 dev_entry->root, in hl_debugfs_add_device()
1267 &dev_entry->i2c_addr); in hl_debugfs_add_device()
1271 dev_entry->root, in hl_debugfs_add_device()
1272 &dev_entry->i2c_reg); in hl_debugfs_add_device()
1276 dev_entry->root, in hl_debugfs_add_device()
1282 dev_entry->root, in hl_debugfs_add_device()
1288 dev_entry->root, in hl_debugfs_add_device()
1294 dev_entry->root, in hl_debugfs_add_device()
1300 dev_entry->root, in hl_debugfs_add_device()
1306 dev_entry->root, in hl_debugfs_add_device()
1312 dev_entry->root, in hl_debugfs_add_device()
1316 for (i = 0, entry = dev_entry->entry_arr ; i < count ; i++, entry++) { in hl_debugfs_add_device()
1320 dev_entry->root, in hl_debugfs_add_device()
1323 entry->dent = ent; in hl_debugfs_add_device()
1324 entry->info_ent = &hl_debugfs_list[i]; in hl_debugfs_add_device()
1325 entry->dev_entry = dev_entry; in hl_debugfs_add_device()
1331 struct hl_dbg_device_entry *entry = &hdev->hl_debugfs; in hl_debugfs_remove_device()
1333 debugfs_remove_recursive(entry->root); in hl_debugfs_remove_device()
1335 mutex_destroy(&entry->file_mutex); in hl_debugfs_remove_device()
1336 kfree(entry->entry_arr); in hl_debugfs_remove_device()
1341 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs; in hl_debugfs_add_file()
1343 mutex_lock(&dev_entry->file_mutex); in hl_debugfs_add_file()
1344 list_add(&hpriv->debugfs_list, &dev_entry->file_list); in hl_debugfs_add_file()
1345 mutex_unlock(&dev_entry->file_mutex); in hl_debugfs_add_file()
1350 struct hl_dbg_device_entry *dev_entry = &hpriv->hdev->hl_debugfs; in hl_debugfs_remove_file()
1352 mutex_lock(&dev_entry->file_mutex); in hl_debugfs_remove_file()
1353 list_del(&hpriv->debugfs_list); in hl_debugfs_remove_file()
1354 mutex_unlock(&dev_entry->file_mutex); in hl_debugfs_remove_file()
1359 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs; in hl_debugfs_add_cb()
1361 spin_lock(&dev_entry->cb_spinlock); in hl_debugfs_add_cb()
1362 list_add(&cb->debugfs_list, &dev_entry->cb_list); in hl_debugfs_add_cb()
1363 spin_unlock(&dev_entry->cb_spinlock); in hl_debugfs_add_cb()
1368 struct hl_dbg_device_entry *dev_entry = &cb->hdev->hl_debugfs; in hl_debugfs_remove_cb()
1370 spin_lock(&dev_entry->cb_spinlock); in hl_debugfs_remove_cb()
1371 list_del(&cb->debugfs_list); in hl_debugfs_remove_cb()
1372 spin_unlock(&dev_entry->cb_spinlock); in hl_debugfs_remove_cb()
1377 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs; in hl_debugfs_add_cs()
1379 spin_lock(&dev_entry->cs_spinlock); in hl_debugfs_add_cs()
1380 list_add(&cs->debugfs_list, &dev_entry->cs_list); in hl_debugfs_add_cs()
1381 spin_unlock(&dev_entry->cs_spinlock); in hl_debugfs_add_cs()
1386 struct hl_dbg_device_entry *dev_entry = &cs->ctx->hdev->hl_debugfs; in hl_debugfs_remove_cs()
1388 spin_lock(&dev_entry->cs_spinlock); in hl_debugfs_remove_cs()
1389 list_del(&cs->debugfs_list); in hl_debugfs_remove_cs()
1390 spin_unlock(&dev_entry->cs_spinlock); in hl_debugfs_remove_cs()
1395 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_add_job()
1397 spin_lock(&dev_entry->cs_job_spinlock); in hl_debugfs_add_job()
1398 list_add(&job->debugfs_list, &dev_entry->cs_job_list); in hl_debugfs_add_job()
1399 spin_unlock(&dev_entry->cs_job_spinlock); in hl_debugfs_add_job()
1404 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_remove_job()
1406 spin_lock(&dev_entry->cs_job_spinlock); in hl_debugfs_remove_job()
1407 list_del(&job->debugfs_list); in hl_debugfs_remove_job()
1408 spin_unlock(&dev_entry->cs_job_spinlock); in hl_debugfs_remove_job()
1413 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_add_userptr()
1415 spin_lock(&dev_entry->userptr_spinlock); in hl_debugfs_add_userptr()
1416 list_add(&userptr->debugfs_list, &dev_entry->userptr_list); in hl_debugfs_add_userptr()
1417 spin_unlock(&dev_entry->userptr_spinlock); in hl_debugfs_add_userptr()
1423 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_remove_userptr()
1425 spin_lock(&dev_entry->userptr_spinlock); in hl_debugfs_remove_userptr()
1426 list_del(&userptr->debugfs_list); in hl_debugfs_remove_userptr()
1427 spin_unlock(&dev_entry->userptr_spinlock); in hl_debugfs_remove_userptr()
1430 void hl_debugfs_add_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx) in hl_debugfs_add_ctx_mem_hash() argument
1432 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_add_ctx_mem_hash()
1434 spin_lock(&dev_entry->ctx_mem_hash_spinlock); in hl_debugfs_add_ctx_mem_hash()
1435 list_add(&ctx->debugfs_list, &dev_entry->ctx_mem_hash_list); in hl_debugfs_add_ctx_mem_hash()
1436 spin_unlock(&dev_entry->ctx_mem_hash_spinlock); in hl_debugfs_add_ctx_mem_hash()
1439 void hl_debugfs_remove_ctx_mem_hash(struct hl_device *hdev, struct hl_ctx *ctx) in hl_debugfs_remove_ctx_mem_hash() argument
1441 struct hl_dbg_device_entry *dev_entry = &hdev->hl_debugfs; in hl_debugfs_remove_ctx_mem_hash()
1443 spin_lock(&dev_entry->ctx_mem_hash_spinlock); in hl_debugfs_remove_ctx_mem_hash()
1444 list_del(&ctx->debugfs_list); in hl_debugfs_remove_ctx_mem_hash()
1445 spin_unlock(&dev_entry->ctx_mem_hash_spinlock); in hl_debugfs_remove_ctx_mem_hash()