Lines Matching +full:0 +full:ms

22 	struct ivpu_ms_instance *ms;  in get_instance_by_mask()  local
26 list_for_each_entry(ms, &file_priv->ms_instance_list, ms_instance_node) in get_instance_by_mask()
27 if (ms->mask == metric_mask) in get_instance_by_mask()
28 return ms; in get_instance_by_mask()
38 struct ivpu_ms_instance *ms; in ivpu_ms_start_ioctl() local
55 ms = kzalloc(sizeof(*ms), GFP_KERNEL); in ivpu_ms_start_ioctl()
56 if (!ms) { in ivpu_ms_start_ioctl()
61 ms->mask = args->metric_group_mask; in ivpu_ms_start_ioctl()
63 ret = ivpu_jsm_metric_streamer_info(vdev, ms->mask, 0, 0, &sample_size, NULL); in ivpu_ms_start_ioctl()
69 ms->bo = ivpu_bo_create_global(vdev, PAGE_ALIGN(single_buff_size * MS_NUM_BUFFERS), in ivpu_ms_start_ioctl()
71 if (!ms->bo) { in ivpu_ms_start_ioctl()
72 ivpu_err(vdev, "Failed to allocate MS buffer (size %llu)\n", single_buff_size); in ivpu_ms_start_ioctl()
77 ms->buff_size = ivpu_bo_size(ms->bo) / MS_NUM_BUFFERS; in ivpu_ms_start_ioctl()
78 ms->active_buff_vpu_addr = ms->bo->vpu_addr; in ivpu_ms_start_ioctl()
79 ms->inactive_buff_vpu_addr = ms->bo->vpu_addr + ms->buff_size; in ivpu_ms_start_ioctl()
80 ms->active_buff_ptr = ivpu_bo_vaddr(ms->bo); in ivpu_ms_start_ioctl()
81 ms->inactive_buff_ptr = ivpu_bo_vaddr(ms->bo) + ms->buff_size; in ivpu_ms_start_ioctl()
83 ret = ivpu_jsm_metric_streamer_start(vdev, ms->mask, args->sampling_period_ns, in ivpu_ms_start_ioctl()
84 ms->active_buff_vpu_addr, ms->buff_size); in ivpu_ms_start_ioctl()
89 args->max_data_size = ivpu_bo_size(ms->bo); in ivpu_ms_start_ioctl()
90 list_add_tail(&ms->ms_instance_node, &file_priv->ms_instance_list); in ivpu_ms_start_ioctl()
94 ivpu_bo_free(ms->bo); in ivpu_ms_start_ioctl()
96 kfree(ms); in ivpu_ms_start_ioctl()
103 copy_leftover_bytes(struct ivpu_ms_instance *ms, in copy_leftover_bytes() argument
108 if (ms->leftover_bytes) { in copy_leftover_bytes()
109 copy_bytes = min(user_size - *user_bytes_copied, ms->leftover_bytes); in copy_leftover_bytes()
110 if (copy_to_user(user_ptr + *user_bytes_copied, ms->leftover_addr, copy_bytes)) in copy_leftover_bytes()
113 ms->leftover_bytes -= copy_bytes; in copy_leftover_bytes()
114 ms->leftover_addr += copy_bytes; in copy_leftover_bytes()
118 return 0; in copy_leftover_bytes()
122 copy_samples_to_user(struct ivpu_device *vdev, struct ivpu_ms_instance *ms, in copy_samples_to_user() argument
128 *user_bytes_copied = 0; in copy_samples_to_user()
130 ret = copy_leftover_bytes(ms, user_ptr, user_size, user_bytes_copied); in copy_samples_to_user()
135 return 0; in copy_samples_to_user()
137 ret = ivpu_jsm_metric_streamer_update(vdev, ms->mask, ms->inactive_buff_vpu_addr, in copy_samples_to_user()
138 ms->buff_size, &bytes_written); in copy_samples_to_user()
142 swap(ms->active_buff_vpu_addr, ms->inactive_buff_vpu_addr); in copy_samples_to_user()
143 swap(ms->active_buff_ptr, ms->inactive_buff_ptr); in copy_samples_to_user()
145 ms->leftover_bytes = bytes_written; in copy_samples_to_user()
146 ms->leftover_addr = ms->inactive_buff_ptr; in copy_samples_to_user()
148 return copy_leftover_bytes(ms, user_ptr, user_size, user_bytes_copied); in copy_samples_to_user()
156 struct ivpu_ms_instance *ms; in ivpu_ms_get_data_ioctl() local
165 ms = get_instance_by_mask(file_priv, args->metric_group_mask); in ivpu_ms_get_data_ioctl()
166 if (!ms) { in ivpu_ms_get_data_ioctl()
173 ret = ivpu_jsm_metric_streamer_update(vdev, ms->mask, 0, 0, &bytes_written); in ivpu_ms_get_data_ioctl()
176 args->data_size = bytes_written + ms->leftover_bytes; in ivpu_ms_get_data_ioctl()
185 ret = copy_samples_to_user(vdev, ms, u64_to_user_ptr(args->buffer_ptr), in ivpu_ms_get_data_ioctl()
193 static void free_instance(struct ivpu_file_priv *file_priv, struct ivpu_ms_instance *ms) in free_instance() argument
197 list_del(&ms->ms_instance_node); in free_instance()
198 ivpu_jsm_metric_streamer_stop(file_priv->vdev, ms->mask); in free_instance()
199 ivpu_bo_free(ms->bo); in free_instance()
200 kfree(ms); in free_instance()
207 struct ivpu_ms_instance *ms; in ivpu_ms_stop_ioctl() local
214 ms = get_instance_by_mask(file_priv, args->metric_group_mask); in ivpu_ms_stop_ioctl()
215 if (ms) in ivpu_ms_stop_ioctl()
216 free_instance(file_priv, ms); in ivpu_ms_stop_ioctl()
220 return ms ? 0 : -EINVAL; in ivpu_ms_stop_ioctl()
249 0, 0, NULL, &args->data_size); in ivpu_ms_get_info_ioctl()
283 struct ivpu_ms_instance *ms, *tmp; in ivpu_ms_cleanup() local
292 list_for_each_entry_safe(ms, tmp, &file_priv->ms_instance_list, ms_instance_node) in ivpu_ms_cleanup()
293 free_instance(file_priv, ms); in ivpu_ms_cleanup()