Lines Matching refs:pdd

75 static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd);
88 struct kfd_process_device *pdd; member
102 struct kfd_process_device *pdd; in kfd_sdma_activity_worker() local
115 pdd = workarea->pdd; in kfd_sdma_activity_worker()
116 if (!pdd) in kfd_sdma_activity_worker()
118 dqm = pdd->dev->dqm; in kfd_sdma_activity_worker()
119 qpd = &pdd->qpd; in kfd_sdma_activity_worker()
174 workarea->sdma_activity_counter = pdd->sdma_past_activity_counter; in kfd_sdma_activity_worker()
184 mm = get_task_mm(pdd->process->lead_thread); in kfd_sdma_activity_worker()
211 workarea->sdma_activity_counter += pdd->sdma_past_activity_counter; in kfd_sdma_activity_worker()
272 struct kfd_process_device *pdd = NULL; in kfd_get_cu_occupancy() local
274 pdd = container_of(attr, struct kfd_process_device, attr_cu_occupancy); in kfd_get_cu_occupancy()
275 dev = pdd->dev; in kfd_get_cu_occupancy()
280 proc = pdd->process; in kfd_get_cu_occupancy()
281 if (pdd->qpd.queue_count == 0) { in kfd_get_cu_occupancy()
307 struct kfd_process_device *pdd = container_of(attr, struct kfd_process_device, in kfd_procfs_show() local
309 return snprintf(buffer, PAGE_SIZE, "%llu\n", READ_ONCE(pdd->vram_usage)); in kfd_procfs_show()
311 struct kfd_process_device *pdd = container_of(attr, struct kfd_process_device, in kfd_procfs_show() local
318 sdma_activity_work_handler.pdd = pdd; in kfd_procfs_show()
398 struct kfd_process_device *pdd = container_of(attr, in kfd_procfs_stats_show() local
403 evict_jiffies = atomic64_read(&pdd->evict_duration_counter); in kfd_procfs_stats_show()
423 struct kfd_process_device *pdd; in kfd_sysfs_counters_show() local
426 pdd = container_of(attr, struct kfd_process_device, in kfd_sysfs_counters_show()
428 return sysfs_emit(buf, "%llu\n", READ_ONCE(pdd->faults)); in kfd_sysfs_counters_show()
431 pdd = container_of(attr, struct kfd_process_device, in kfd_sysfs_counters_show()
433 return sysfs_emit(buf, "%llu\n", READ_ONCE(pdd->page_in)); in kfd_sysfs_counters_show()
436 pdd = container_of(attr, struct kfd_process_device, in kfd_sysfs_counters_show()
438 return sysfs_emit(buf, "%llu\n", READ_ONCE(pdd->page_out)); in kfd_sysfs_counters_show()
550 struct kfd_process_device *pdd = p->pdds[i]; in kfd_procfs_add_sysfs_stats() local
553 "stats_%u", pdd->dev->id); in kfd_procfs_add_sysfs_stats()
554 pdd->kobj_stats = kfd_alloc_struct(pdd->kobj_stats); in kfd_procfs_add_sysfs_stats()
555 if (!pdd->kobj_stats) in kfd_procfs_add_sysfs_stats()
558 ret = kobject_init_and_add(pdd->kobj_stats, in kfd_procfs_add_sysfs_stats()
566 kobject_put(pdd->kobj_stats); in kfd_procfs_add_sysfs_stats()
567 pdd->kobj_stats = NULL; in kfd_procfs_add_sysfs_stats()
571 kfd_sysfs_create_file(pdd->kobj_stats, &pdd->attr_evict, in kfd_procfs_add_sysfs_stats()
574 if (pdd->dev->kfd2kgd->get_cu_occupancy) in kfd_procfs_add_sysfs_stats()
575 kfd_sysfs_create_file(pdd->kobj_stats, in kfd_procfs_add_sysfs_stats()
576 &pdd->attr_cu_occupancy, in kfd_procfs_add_sysfs_stats()
598 struct kfd_process_device *pdd = p->pdds[i]; in kfd_procfs_add_sysfs_counters() local
602 "counters_%u", pdd->dev->id); in kfd_procfs_add_sysfs_counters()
616 pdd->kobj_counters = kobj_counters; in kfd_procfs_add_sysfs_counters()
617 kfd_sysfs_create_file(kobj_counters, &pdd->attr_faults, in kfd_procfs_add_sysfs_counters()
619 kfd_sysfs_create_file(kobj_counters, &pdd->attr_page_in, in kfd_procfs_add_sysfs_counters()
621 kfd_sysfs_create_file(kobj_counters, &pdd->attr_page_out, in kfd_procfs_add_sysfs_counters()
639 struct kfd_process_device *pdd = p->pdds[i]; in kfd_procfs_add_sysfs_files() local
641 snprintf(pdd->vram_filename, MAX_SYSFS_FILENAME_LEN, "vram_%u", in kfd_procfs_add_sysfs_files()
642 pdd->dev->id); in kfd_procfs_add_sysfs_files()
643 kfd_sysfs_create_file(p->kobj, &pdd->attr_vram, in kfd_procfs_add_sysfs_files()
644 pdd->vram_filename); in kfd_procfs_add_sysfs_files()
646 snprintf(pdd->sdma_filename, MAX_SYSFS_FILENAME_LEN, "sdma_%u", in kfd_procfs_add_sysfs_files()
647 pdd->dev->id); in kfd_procfs_add_sysfs_files()
648 kfd_sysfs_create_file(p->kobj, &pdd->attr_sdma, in kfd_procfs_add_sysfs_files()
649 pdd->sdma_filename); in kfd_procfs_add_sysfs_files()
690 struct kfd_process_device *pdd, void **kptr) in kfd_process_free_gpuvm() argument
692 struct kfd_node *dev = pdd->dev; in kfd_process_free_gpuvm()
699 amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(dev->adev, mem, pdd->drm_priv); in kfd_process_free_gpuvm()
700 amdgpu_amdkfd_gpuvm_free_memory_of_gpu(dev->adev, mem, pdd->drm_priv, in kfd_process_free_gpuvm()
710 static int kfd_process_alloc_gpuvm(struct kfd_process_device *pdd, in kfd_process_alloc_gpuvm() argument
714 struct kfd_node *kdev = pdd->dev; in kfd_process_alloc_gpuvm()
718 pdd->drm_priv, mem, NULL, in kfd_process_alloc_gpuvm()
724 pdd->drm_priv); in kfd_process_alloc_gpuvm()
746 amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(kdev->adev, *mem, pdd->drm_priv); in kfd_process_alloc_gpuvm()
749 amdgpu_amdkfd_gpuvm_free_memory_of_gpu(kdev->adev, *mem, pdd->drm_priv, in kfd_process_alloc_gpuvm()
763 static int kfd_process_device_reserve_ib_mem(struct kfd_process_device *pdd) in kfd_process_device_reserve_ib_mem() argument
765 struct qcm_process_device *qpd = &pdd->qpd; in kfd_process_device_reserve_ib_mem()
778 ret = kfd_process_alloc_gpuvm(pdd, qpd->ib_base, PAGE_SIZE, flags, in kfd_process_device_reserve_ib_mem()
789 static void kfd_process_device_destroy_ib_mem(struct kfd_process_device *pdd) in kfd_process_device_destroy_ib_mem() argument
791 struct qcm_process_device *qpd = &pdd->qpd; in kfd_process_device_destroy_ib_mem()
796 kfd_process_free_gpuvm(qpd->ib_mem, pdd, &qpd->ib_kaddr); in kfd_process_device_destroy_ib_mem()
946 static void kfd_process_device_free_bos(struct kfd_process_device *pdd) in kfd_process_device_free_bos() argument
948 struct kfd_process *p = pdd->process; in kfd_process_device_free_bos()
957 idr_for_each_entry(&pdd->alloc_idr, mem, id) { in kfd_process_device_free_bos()
968 amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pdd->dev->adev, mem, in kfd_process_device_free_bos()
969 pdd->drm_priv, NULL); in kfd_process_device_free_bos()
970 kfd_process_device_remove_obj_handle(pdd, id); in kfd_process_device_free_bos()
980 struct kfd_process_device *pdd; in kfd_process_kunmap_signal_bo() local
990 pdd = kfd_get_process_device_data(kdev, p); in kfd_process_kunmap_signal_bo()
991 if (!pdd) in kfd_process_kunmap_signal_bo()
995 pdd, GET_IDR_HANDLE(p->signal_handle)); in kfd_process_kunmap_signal_bo()
1018 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_destroy_pdds() local
1021 pdd->dev->id, p->pasid); in kfd_process_destroy_pdds()
1023 kfd_process_device_destroy_cwsr_dgpu(pdd); in kfd_process_destroy_pdds()
1024 kfd_process_device_destroy_ib_mem(pdd); in kfd_process_destroy_pdds()
1026 if (pdd->drm_file) { in kfd_process_destroy_pdds()
1028 pdd->dev->adev, pdd->drm_priv); in kfd_process_destroy_pdds()
1029 fput(pdd->drm_file); in kfd_process_destroy_pdds()
1032 if (pdd->qpd.cwsr_kaddr && !pdd->qpd.cwsr_base) in kfd_process_destroy_pdds()
1033 free_pages((unsigned long)pdd->qpd.cwsr_kaddr, in kfd_process_destroy_pdds()
1036 idr_destroy(&pdd->alloc_idr); in kfd_process_destroy_pdds()
1038 kfd_free_process_doorbells(pdd->dev->kfd, pdd); in kfd_process_destroy_pdds()
1040 if (pdd->dev->kfd->shared_resources.enable_mes) in kfd_process_destroy_pdds()
1041 amdgpu_amdkfd_free_gtt_mem(pdd->dev->adev, in kfd_process_destroy_pdds()
1042 pdd->proc_ctx_bo); in kfd_process_destroy_pdds()
1047 if (pdd->runtime_inuse) { in kfd_process_destroy_pdds()
1048 pm_runtime_mark_last_busy(adev_to_drm(pdd->dev->adev)->dev); in kfd_process_destroy_pdds()
1049 pm_runtime_put_autosuspend(adev_to_drm(pdd->dev->adev)->dev); in kfd_process_destroy_pdds()
1050 pdd->runtime_inuse = false; in kfd_process_destroy_pdds()
1053 kfree(pdd); in kfd_process_destroy_pdds()
1061 struct kfd_process_device *pdd; in kfd_process_remove_sysfs() local
1073 pdd = p->pdds[i]; in kfd_process_remove_sysfs()
1075 sysfs_remove_file(p->kobj, &pdd->attr_vram); in kfd_process_remove_sysfs()
1076 sysfs_remove_file(p->kobj, &pdd->attr_sdma); in kfd_process_remove_sysfs()
1078 sysfs_remove_file(pdd->kobj_stats, &pdd->attr_evict); in kfd_process_remove_sysfs()
1079 if (pdd->dev->kfd2kgd->get_cu_occupancy) in kfd_process_remove_sysfs()
1080 sysfs_remove_file(pdd->kobj_stats, in kfd_process_remove_sysfs()
1081 &pdd->attr_cu_occupancy); in kfd_process_remove_sysfs()
1082 kobject_del(pdd->kobj_stats); in kfd_process_remove_sysfs()
1083 kobject_put(pdd->kobj_stats); in kfd_process_remove_sysfs()
1084 pdd->kobj_stats = NULL; in kfd_process_remove_sysfs()
1088 pdd = p->pdds[i]; in kfd_process_remove_sysfs()
1090 sysfs_remove_file(pdd->kobj_counters, &pdd->attr_faults); in kfd_process_remove_sysfs()
1091 sysfs_remove_file(pdd->kobj_counters, &pdd->attr_page_in); in kfd_process_remove_sysfs()
1092 sysfs_remove_file(pdd->kobj_counters, &pdd->attr_page_out); in kfd_process_remove_sysfs()
1093 kobject_del(pdd->kobj_counters); in kfd_process_remove_sysfs()
1094 kobject_put(pdd->kobj_counters); in kfd_process_remove_sysfs()
1095 pdd->kobj_counters = NULL; in kfd_process_remove_sysfs()
1172 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_notifier_release_internal() local
1175 if (!kfd_dbg_is_rlc_restore_supported(pdd->dev) && p->runtime_info.ttmp_setup) in kfd_process_notifier_release_internal()
1176 amdgpu_gfx_off_ctrl(pdd->dev->adev, true); in kfd_process_notifier_release_internal()
1322 static int kfd_process_device_init_cwsr_dgpu(struct kfd_process_device *pdd) in kfd_process_device_init_cwsr_dgpu() argument
1324 struct kfd_node *dev = pdd->dev; in kfd_process_device_init_cwsr_dgpu()
1325 struct qcm_process_device *qpd = &pdd->qpd; in kfd_process_device_init_cwsr_dgpu()
1337 ret = kfd_process_alloc_gpuvm(pdd, qpd->cwsr_base, in kfd_process_device_init_cwsr_dgpu()
1348 kfd_process_set_trap_debug_flag(&pdd->qpd, in kfd_process_device_init_cwsr_dgpu()
1349 pdd->process->debug_trap_enabled); in kfd_process_device_init_cwsr_dgpu()
1358 static void kfd_process_device_destroy_cwsr_dgpu(struct kfd_process_device *pdd) in kfd_process_device_destroy_cwsr_dgpu() argument
1360 struct kfd_node *dev = pdd->dev; in kfd_process_device_destroy_cwsr_dgpu()
1361 struct qcm_process_device *qpd = &pdd->qpd; in kfd_process_device_destroy_cwsr_dgpu()
1366 kfd_process_free_gpuvm(qpd->cwsr_mem, pdd, &qpd->cwsr_kaddr); in kfd_process_device_destroy_cwsr_dgpu()
1564 struct kfd_process_device *pdd = NULL; in kfd_create_process_device_data() local
1569 pdd = kzalloc(sizeof(*pdd), GFP_KERNEL); in kfd_create_process_device_data()
1570 if (!pdd) in kfd_create_process_device_data()
1573 pdd->dev = dev; in kfd_create_process_device_data()
1574 INIT_LIST_HEAD(&pdd->qpd.queues_list); in kfd_create_process_device_data()
1575 INIT_LIST_HEAD(&pdd->qpd.priv_queue_list); in kfd_create_process_device_data()
1576 pdd->qpd.dqm = dev->dqm; in kfd_create_process_device_data()
1577 pdd->qpd.pqm = &p->pqm; in kfd_create_process_device_data()
1578 pdd->qpd.evicted = 0; in kfd_create_process_device_data()
1579 pdd->qpd.mapped_gws_queue = false; in kfd_create_process_device_data()
1580 pdd->process = p; in kfd_create_process_device_data()
1581 pdd->bound = PDD_UNBOUND; in kfd_create_process_device_data()
1582 pdd->already_dequeued = false; in kfd_create_process_device_data()
1583 pdd->runtime_inuse = false; in kfd_create_process_device_data()
1584 pdd->vram_usage = 0; in kfd_create_process_device_data()
1585 pdd->sdma_past_activity_counter = 0; in kfd_create_process_device_data()
1586 pdd->user_gpu_id = dev->id; in kfd_create_process_device_data()
1587 atomic64_set(&pdd->evict_duration_counter, 0); in kfd_create_process_device_data()
1592 &pdd->proc_ctx_bo, in kfd_create_process_device_data()
1593 &pdd->proc_ctx_gpu_addr, in kfd_create_process_device_data()
1594 &pdd->proc_ctx_cpu_ptr, in kfd_create_process_device_data()
1600 memset(pdd->proc_ctx_cpu_ptr, 0, AMDGPU_MES_PROC_CTX_SIZE); in kfd_create_process_device_data()
1603 p->pdds[p->n_pdds++] = pdd; in kfd_create_process_device_data()
1604 if (kfd_dbg_is_per_vmid_supported(pdd->dev)) in kfd_create_process_device_data()
1605 pdd->spi_dbg_override = pdd->dev->kfd2kgd->disable_debug_trap( in kfd_create_process_device_data()
1606 pdd->dev->adev, in kfd_create_process_device_data()
1611 idr_init(&pdd->alloc_idr); in kfd_create_process_device_data()
1613 return pdd; in kfd_create_process_device_data()
1616 kfree(pdd); in kfd_create_process_device_data()
1634 int kfd_process_device_init_vm(struct kfd_process_device *pdd, in kfd_process_device_init_vm() argument
1646 if (pdd->drm_priv) in kfd_process_device_init_vm()
1654 p = pdd->process; in kfd_process_device_init_vm()
1655 dev = pdd->dev; in kfd_process_device_init_vm()
1664 pdd->drm_priv = drm_file->private_data; in kfd_process_device_init_vm()
1665 atomic64_set(&pdd->tlb_seq, 0); in kfd_process_device_init_vm()
1667 ret = kfd_process_device_reserve_ib_mem(pdd); in kfd_process_device_init_vm()
1670 ret = kfd_process_device_init_cwsr_dgpu(pdd); in kfd_process_device_init_vm()
1678 pdd->drm_file = drm_file; in kfd_process_device_init_vm()
1683 kfd_process_device_destroy_cwsr_dgpu(pdd); in kfd_process_device_init_vm()
1685 kfd_process_device_destroy_ib_mem(pdd); in kfd_process_device_init_vm()
1687 pdd->drm_priv = NULL; in kfd_process_device_init_vm()
1703 struct kfd_process_device *pdd; in kfd_bind_process_to_device() local
1706 pdd = kfd_get_process_device_data(dev, p); in kfd_bind_process_to_device()
1707 if (!pdd) { in kfd_bind_process_to_device()
1712 if (!pdd->drm_priv) in kfd_bind_process_to_device()
1720 if (!pdd->runtime_inuse) { in kfd_bind_process_to_device()
1732 pdd->runtime_inuse = true; in kfd_bind_process_to_device()
1734 return pdd; in kfd_bind_process_to_device()
1740 int kfd_process_device_create_obj_handle(struct kfd_process_device *pdd, in kfd_process_device_create_obj_handle() argument
1743 return idr_alloc(&pdd->alloc_idr, mem, 0, 0, GFP_KERNEL); in kfd_process_device_create_obj_handle()
1749 void *kfd_process_device_translate_handle(struct kfd_process_device *pdd, in kfd_process_device_translate_handle() argument
1755 return idr_find(&pdd->alloc_idr, handle); in kfd_process_device_translate_handle()
1761 void kfd_process_device_remove_obj_handle(struct kfd_process_device *pdd, in kfd_process_device_remove_obj_handle() argument
1765 idr_remove(&pdd->alloc_idr, handle); in kfd_process_device_remove_obj_handle()
1817 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_evict_queues() local
1819 kfd_smi_event_queue_eviction(pdd->dev, p->lead_thread->pid, in kfd_process_evict_queues()
1822 r = pdd->dev->dqm->ops.evict_process_queues(pdd->dev->dqm, in kfd_process_evict_queues()
1823 &pdd->qpd); in kfd_process_evict_queues()
1842 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_evict_queues() local
1847 kfd_smi_event_queue_restore(pdd->dev, p->lead_thread->pid); in kfd_process_evict_queues()
1849 if (pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm, in kfd_process_evict_queues()
1850 &pdd->qpd)) in kfd_process_evict_queues()
1866 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_restore_queues() local
1868 kfd_smi_event_queue_restore(pdd->dev, p->lead_thread->pid); in kfd_process_restore_queues()
1870 r = pdd->dev->dqm->ops.restore_process_queues(pdd->dev->dqm, in kfd_process_restore_queues()
1871 &pdd->qpd); in kfd_process_restore_queues()
2029 struct kfd_process_device *pdd; in kfd_reserved_mem_mmap() local
2037 pdd = kfd_get_process_device_data(dev, process); in kfd_reserved_mem_mmap()
2038 if (!pdd) in kfd_reserved_mem_mmap()
2040 qpd = &pdd->qpd; in kfd_reserved_mem_mmap()
2057 void kfd_flush_tlb(struct kfd_process_device *pdd, enum TLB_FLUSH_TYPE type) in kfd_flush_tlb() argument
2059 struct amdgpu_vm *vm = drm_priv_to_vm(pdd->drm_priv); in kfd_flush_tlb()
2061 struct kfd_node *dev = pdd->dev; in kfd_flush_tlb()
2070 if (atomic64_xchg(&pdd->tlb_seq, tlb_seq) == tlb_seq) in kfd_flush_tlb()
2077 if (pdd->qpd.vmid) in kfd_flush_tlb()
2079 pdd->qpd.vmid); in kfd_flush_tlb()
2083 dev->adev, pdd->process->pasid, type, xcc); in kfd_flush_tlb()
2088 int kfd_process_drain_interrupts(struct kfd_process_device *pdd) in kfd_process_drain_interrupts() argument
2094 if (!KFD_IS_SOC15(pdd->dev)) in kfd_process_drain_interrupts()
2097 pdd->process->irq_drain_is_open = true; in kfd_process_drain_interrupts()
2102 irq_drain_fence[3] = pdd->process->pasid; in kfd_process_drain_interrupts()
2107 if (KFD_GC_VERSION(pdd->dev->kfd) == IP_VERSION(9, 4, 3)) { in kfd_process_drain_interrupts()
2108 node_id = ffs(pdd->dev->interrupt_bitmap) - 1; in kfd_process_drain_interrupts()
2113 if (amdgpu_amdkfd_send_close_event_drain_irq(pdd->dev->adev, in kfd_process_drain_interrupts()
2115 pdd->process->irq_drain_is_open = false; in kfd_process_drain_interrupts()
2119 r = wait_event_interruptible(pdd->process->wait_irq_drain, in kfd_process_drain_interrupts()
2120 !READ_ONCE(pdd->process->irq_drain_is_open)); in kfd_process_drain_interrupts()
2122 pdd->process->irq_drain_is_open = false; in kfd_process_drain_interrupts()
2216 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_device_data_by_id() local
2218 if (pdd->user_gpu_id == gpu_id) in kfd_process_device_data_by_id()
2219 return pdd; in kfd_process_device_data_by_id()
2233 struct kfd_process_device *pdd = p->pdds[i]; in kfd_process_get_user_gpu_id() local
2235 if (pdd->dev->id == actual_gpu_id) in kfd_process_get_user_gpu_id()
2236 return pdd->user_gpu_id; in kfd_process_get_user_gpu_id()