Lines Matching full:pm
41 static void pm_calc_rlib_size(struct packet_manager *pm, in pm_calc_rlib_size() argument
48 struct kfd_node *node = pm->dqm->dev; in pm_calc_rlib_size()
51 process_count = pm->dqm->processes_count; in pm_calc_rlib_size()
52 queue_count = pm->dqm->active_queue_count; in pm_calc_rlib_size()
53 compute_queue_count = pm->dqm->active_cp_queue_count; in pm_calc_rlib_size()
54 gws_queue_count = pm->dqm->gws_queue_count; in pm_calc_rlib_size()
67 compute_queue_count > get_cp_queues_num(pm->dqm) || in pm_calc_rlib_size()
73 map_queue_size = pm->pmf->map_queues_size; in pm_calc_rlib_size()
75 *rlib_size = process_count * pm->pmf->map_process_size + in pm_calc_rlib_size()
83 *rlib_size += pm->pmf->runlist_size; in pm_calc_rlib_size()
88 static int pm_allocate_runlist_ib(struct packet_manager *pm, in pm_allocate_runlist_ib() argument
94 struct kfd_node *node = pm->dqm->dev; in pm_allocate_runlist_ib()
98 if (WARN_ON(pm->allocated)) in pm_allocate_runlist_ib()
101 pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription); in pm_allocate_runlist_ib()
103 mutex_lock(&pm->lock); in pm_allocate_runlist_ib()
105 retval = kfd_gtt_sa_allocate(node, *rl_buffer_size, &pm->ib_buffer_obj); in pm_allocate_runlist_ib()
112 *(void **)rl_buffer = pm->ib_buffer_obj->cpu_ptr; in pm_allocate_runlist_ib()
113 *rl_gpu_buffer = pm->ib_buffer_obj->gpu_addr; in pm_allocate_runlist_ib()
116 pm->allocated = true; in pm_allocate_runlist_ib()
119 mutex_unlock(&pm->lock); in pm_allocate_runlist_ib()
123 static int pm_create_runlist_ib(struct packet_manager *pm, in pm_create_runlist_ib() argument
130 struct kfd_node *node = pm->dqm->dev; in pm_create_runlist_ib()
141 retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr, in pm_create_runlist_ib()
147 pm->ib_size_bytes = alloc_size_bytes; in pm_create_runlist_ib()
150 pm->dqm->processes_count, pm->dqm->active_queue_count); in pm_create_runlist_ib()
156 if (processes_mapped >= pm->dqm->processes_count) { in pm_create_runlist_ib()
158 pm_release_ib(pm); in pm_create_runlist_ib()
162 retval = pm->pmf->map_process(pm, &rl_buffer[rl_wptr], qpd); in pm_create_runlist_ib()
167 inc_wptr(&rl_wptr, pm->pmf->map_process_size, in pm_create_runlist_ib()
178 retval = pm->pmf->map_queues(pm, in pm_create_runlist_ib()
186 pm->pmf->map_queues_size, in pm_create_runlist_ib()
198 retval = pm->pmf->map_queues(pm, in pm_create_runlist_ib()
207 pm->pmf->map_queues_size, in pm_create_runlist_ib()
215 if (!pm->is_over_subscription) in pm_create_runlist_ib()
219 retval = pm->pmf->runlist(pm, &rl_buffer[rl_wptr], in pm_create_runlist_ib()
224 pm->is_over_subscription = is_over_subscription; in pm_create_runlist_ib()
233 int pm_init(struct packet_manager *pm, struct device_queue_manager *dqm) in pm_init() argument
246 pm->pmf = &kfd_vi_pm_funcs; in pm_init()
252 pm->pmf = &kfd_aldebaran_pm_funcs; in pm_init()
254 pm->pmf = &kfd_v9_pm_funcs; in pm_init()
262 pm->dqm = dqm; in pm_init()
263 mutex_init(&pm->lock); in pm_init()
264 pm->priv_queue = kernel_queue_init(dqm->dev, KFD_QUEUE_TYPE_HIQ); in pm_init()
265 if (!pm->priv_queue) { in pm_init()
266 mutex_destroy(&pm->lock); in pm_init()
269 pm->allocated = false; in pm_init()
274 void pm_uninit(struct packet_manager *pm) in pm_uninit() argument
276 mutex_destroy(&pm->lock); in pm_uninit()
277 kernel_queue_uninit(pm->priv_queue); in pm_uninit()
278 pm->priv_queue = NULL; in pm_uninit()
281 int pm_send_set_resources(struct packet_manager *pm, in pm_send_set_resources() argument
284 struct kfd_node *node = pm->dqm->dev; in pm_send_set_resources()
289 size = pm->pmf->set_resources_size; in pm_send_set_resources()
290 mutex_lock(&pm->lock); in pm_send_set_resources()
291 kq_acquire_packet_buffer(pm->priv_queue, in pm_send_set_resources()
300 retval = pm->pmf->set_resources(pm, buffer, res); in pm_send_set_resources()
302 retval = kq_submit_packet(pm->priv_queue); in pm_send_set_resources()
304 kq_rollback_packet(pm->priv_queue); in pm_send_set_resources()
307 mutex_unlock(&pm->lock); in pm_send_set_resources()
312 int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues) in pm_send_runlist() argument
319 retval = pm_create_runlist_ib(pm, dqm_queues, &rl_gpu_ib_addr, in pm_send_runlist()
326 packet_size_dwords = pm->pmf->runlist_size / sizeof(uint32_t); in pm_send_runlist()
327 mutex_lock(&pm->lock); in pm_send_runlist()
329 retval = kq_acquire_packet_buffer(pm->priv_queue, in pm_send_runlist()
334 retval = pm->pmf->runlist(pm, rl_buffer, rl_gpu_ib_addr, in pm_send_runlist()
339 retval = kq_submit_packet(pm->priv_queue); in pm_send_runlist()
341 mutex_unlock(&pm->lock); in pm_send_runlist()
346 kq_rollback_packet(pm->priv_queue); in pm_send_runlist()
348 mutex_unlock(&pm->lock); in pm_send_runlist()
350 pm_release_ib(pm); in pm_send_runlist()
354 int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address, in pm_send_query_status() argument
357 struct kfd_node *node = pm->dqm->dev; in pm_send_query_status()
365 size = pm->pmf->query_status_size; in pm_send_query_status()
366 mutex_lock(&pm->lock); in pm_send_query_status()
367 kq_acquire_packet_buffer(pm->priv_queue, in pm_send_query_status()
375 retval = pm->pmf->query_status(pm, buffer, fence_address, fence_value); in pm_send_query_status()
377 retval = kq_submit_packet(pm->priv_queue); in pm_send_query_status()
379 kq_rollback_packet(pm->priv_queue); in pm_send_query_status()
382 mutex_unlock(&pm->lock); in pm_send_query_status()
386 int pm_update_grace_period(struct packet_manager *pm, uint32_t grace_period) in pm_update_grace_period() argument
388 struct kfd_node *node = pm->dqm->dev; in pm_update_grace_period()
393 size = pm->pmf->set_grace_period_size; in pm_update_grace_period()
395 mutex_lock(&pm->lock); in pm_update_grace_period()
398 kq_acquire_packet_buffer(pm->priv_queue, in pm_update_grace_period()
409 retval = pm->pmf->set_grace_period(pm, buffer, grace_period); in pm_update_grace_period()
411 retval = kq_submit_packet(pm->priv_queue); in pm_update_grace_period()
413 kq_rollback_packet(pm->priv_queue); in pm_update_grace_period()
417 mutex_unlock(&pm->lock); in pm_update_grace_period()
421 int pm_send_unmap_queue(struct packet_manager *pm, in pm_send_unmap_queue() argument
425 struct kfd_node *node = pm->dqm->dev; in pm_send_unmap_queue()
430 size = pm->pmf->unmap_queues_size; in pm_send_unmap_queue()
431 mutex_lock(&pm->lock); in pm_send_unmap_queue()
432 kq_acquire_packet_buffer(pm->priv_queue, in pm_send_unmap_queue()
440 retval = pm->pmf->unmap_queues(pm, buffer, filter, filter_param, reset); in pm_send_unmap_queue()
442 retval = kq_submit_packet(pm->priv_queue); in pm_send_unmap_queue()
444 kq_rollback_packet(pm->priv_queue); in pm_send_unmap_queue()
447 mutex_unlock(&pm->lock); in pm_send_unmap_queue()
451 void pm_release_ib(struct packet_manager *pm) in pm_release_ib() argument
453 mutex_lock(&pm->lock); in pm_release_ib()
454 if (pm->allocated) { in pm_release_ib()
455 kfd_gtt_sa_free(pm->dqm->dev, pm->ib_buffer_obj); in pm_release_ib()
456 pm->allocated = false; in pm_release_ib()
458 mutex_unlock(&pm->lock); in pm_release_ib()
465 struct packet_manager *pm = data; in pm_debugfs_runlist() local
467 mutex_lock(&pm->lock); in pm_debugfs_runlist()
469 if (!pm->allocated) { in pm_debugfs_runlist()
475 pm->ib_buffer_obj->cpu_ptr, pm->ib_size_bytes, false); in pm_debugfs_runlist()
478 mutex_unlock(&pm->lock); in pm_debugfs_runlist()
482 int pm_debugfs_hang_hws(struct packet_manager *pm) in pm_debugfs_hang_hws() argument
484 struct kfd_node *node = pm->dqm->dev; in pm_debugfs_hang_hws()
489 if (!pm->priv_queue) in pm_debugfs_hang_hws()
492 size = pm->pmf->query_status_size; in pm_debugfs_hang_hws()
493 mutex_lock(&pm->lock); in pm_debugfs_hang_hws()
494 kq_acquire_packet_buffer(pm->priv_queue, in pm_debugfs_hang_hws()
502 kq_submit_packet(pm->priv_queue); in pm_debugfs_hang_hws()
508 mutex_unlock(&pm->lock); in pm_debugfs_hang_hws()