Lines Matching +full:rc +full:- +full:map +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
13 * hl_format_as_binary - helper function, format an integer as binary
37 buf_len -= 3; in hl_format_as_binary()
43 bit = n & (1 << (sizeof(n) * BITS_PER_BYTE - 1)); in hl_format_as_binary()
58 * resize_to_fit - helper function, resize buffer to fit given amount of data
79 return -ENOMEM; in resize_to_fit()
89 * hl_snprintf_resize() - print formatted data to buffer, resize as needed
110 int rc; in hl_snprintf_resize() local
113 return -EINVAL; in hl_snprintf_resize()
116 length = vsnprintf(*buf + *offset, *size - *offset, format, args); in hl_snprintf_resize()
119 rc = resize_to_fit(buf, size, *offset + length + 1); in hl_snprintf_resize()
120 if (rc < 0) in hl_snprintf_resize()
121 return rc; in hl_snprintf_resize()
122 else if (rc > 0) { in hl_snprintf_resize()
125 length = vsnprintf(*buf + *offset, *size - *offset, format, in hl_snprintf_resize()
136 * hl_sync_engine_to_string - convert engine type enum to string literal
155 * hl_print_resize_sync_engine - helper function, format engine name and ID
174 * hl_state_dump_get_sync_name - transform sync object id to name if available
178 * Returns a name literal or NULL if not resolved.
184 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_get_sync_name()
187 hash_for_each_possible(sds->so_id_to_str_tb, entry, in hl_state_dump_get_sync_name()
189 if (sync_id == entry->id) in hl_state_dump_get_sync_name()
190 return entry->name; in hl_state_dump_get_sync_name()
196 * hl_state_dump_get_monitor_name - transform monitor object dump to monitor
197 * name if available
201 * Returns a name literal or NULL if not resolved.
208 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_get_monitor_name()
211 hash_for_each_possible(sds->monitor_id_to_str_tb, in hl_state_dump_get_monitor_name()
212 entry, node, mon->id) in hl_state_dump_get_monitor_name()
213 if (mon->id == entry->id) in hl_state_dump_get_monitor_name()
214 return entry->name; in hl_state_dump_get_monitor_name()
220 * hl_state_dump_free_sync_to_engine_map - free sync object to engine map
221 * @map: sync object to engine map
225 void hl_state_dump_free_sync_to_engine_map(struct hl_sync_to_engine_map *map) in hl_state_dump_free_sync_to_engine_map() argument
231 hash_for_each_safe(map->tb, i, tmp_node, entry, node) { in hl_state_dump_free_sync_to_engine_map()
232 hash_del(&entry->node); in hl_state_dump_free_sync_to_engine_map()
238 * hl_state_dump_get_sync_to_engine - transform sync_id to
240 * @map: sync object to engine map
244 * Note, returned NULL shall not be considered as a failure as the map
248 hl_state_dump_get_sync_to_engine(struct hl_sync_to_engine_map *map, u32 sync_id) in hl_state_dump_get_sync_to_engine() argument
252 hash_for_each_possible(map->tb, entry, node, sync_id) in hl_state_dump_get_sync_to_engine()
253 if (entry->sync_id == sync_id) in hl_state_dump_get_sync_to_engine()
259 * hl_state_dump_read_sync_objects - read sync objects array
267 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_read_sync_objects()
272 base_addr = sds->props[SP_SYNC_OBJ_BASE_ADDR] + in hl_state_dump_read_sync_objects()
273 sds->props[SP_NEXT_SYNC_OBJ_ADDR] * index; in hl_state_dump_read_sync_objects()
275 sync_objects = vmalloc(sds->props[SP_SYNC_OBJ_AMOUNT] * sizeof(u32)); in hl_state_dump_read_sync_objects()
279 for (i = 0; i < sds->props[SP_SYNC_OBJ_AMOUNT]; ++i) in hl_state_dump_read_sync_objects()
286 * hl_state_dump_free_sync_objects - free sync objects array allocated by
297 * hl_state_dump_print_syncs_single_block - print active sync objects on a
304 * @map: sync engines names map
311 struct hl_sync_to_engine_map *map) in hl_state_dump_print_syncs_single_block() argument
313 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_print_syncs_single_block()
316 int rc = 0, i; in hl_state_dump_print_syncs_single_block() local
318 if (sds->sync_namager_names) { in hl_state_dump_print_syncs_single_block()
319 rc = hl_snprintf_resize( in hl_state_dump_print_syncs_single_block()
321 sds->sync_namager_names[index]); in hl_state_dump_print_syncs_single_block()
322 if (rc) in hl_state_dump_print_syncs_single_block()
328 rc = -ENOMEM; in hl_state_dump_print_syncs_single_block()
332 for (i = 0; i < sds->props[SP_SYNC_OBJ_AMOUNT]; ++i) { in hl_state_dump_print_syncs_single_block()
339 sync_object_addr = sds->props[SP_SYNC_OBJ_BASE_ADDR] + in hl_state_dump_print_syncs_single_block()
340 sds->props[SP_NEXT_SYNC_OBJ_ADDR] * index + in hl_state_dump_print_syncs_single_block()
343 rc = hl_snprintf_resize(buf, size, offset, "sync id: %u", i); in hl_state_dump_print_syncs_single_block()
344 if (rc) in hl_state_dump_print_syncs_single_block()
348 rc = hl_snprintf_resize(buf, size, offset, " %s", in hl_state_dump_print_syncs_single_block()
350 if (rc) in hl_state_dump_print_syncs_single_block()
353 rc = hl_snprintf_resize(buf, size, offset, ", value: %u", in hl_state_dump_print_syncs_single_block()
355 if (rc) in hl_state_dump_print_syncs_single_block()
359 entry = hl_state_dump_get_sync_to_engine(map, in hl_state_dump_print_syncs_single_block()
362 rc = hl_snprintf_resize(buf, size, offset, in hl_state_dump_print_syncs_single_block()
364 if (rc) in hl_state_dump_print_syncs_single_block()
366 rc = hl_print_resize_sync_engine(buf, size, offset, in hl_state_dump_print_syncs_single_block()
367 entry->engine_type, in hl_state_dump_print_syncs_single_block()
368 entry->engine_id); in hl_state_dump_print_syncs_single_block()
369 if (rc) in hl_state_dump_print_syncs_single_block()
373 rc = hl_snprintf_resize(buf, size, offset, "\n"); in hl_state_dump_print_syncs_single_block()
374 if (rc) in hl_state_dump_print_syncs_single_block()
381 return rc; in hl_state_dump_print_syncs_single_block()
385 * hl_state_dump_print_syncs - print active sync objects
398 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_print_syncs()
399 struct hl_sync_to_engine_map *map; in hl_state_dump_print_syncs() local
401 int rc = 0; in hl_state_dump_print_syncs() local
403 map = kzalloc(sizeof(*map), GFP_KERNEL); in hl_state_dump_print_syncs()
404 if (!map) in hl_state_dump_print_syncs()
405 return -ENOMEM; in hl_state_dump_print_syncs()
407 rc = sds->funcs.gen_sync_to_engine_map(hdev, map); in hl_state_dump_print_syncs()
408 if (rc) in hl_state_dump_print_syncs()
411 rc = hl_snprintf_resize(buf, size, offset, "Non zero sync objects:\n"); in hl_state_dump_print_syncs()
412 if (rc) in hl_state_dump_print_syncs()
415 if (sds->sync_namager_names) { in hl_state_dump_print_syncs()
416 for (index = 0; sds->sync_namager_names[index]; ++index) { in hl_state_dump_print_syncs()
417 rc = hl_state_dump_print_syncs_single_block( in hl_state_dump_print_syncs()
418 hdev, index, buf, size, offset, map); in hl_state_dump_print_syncs()
419 if (rc) in hl_state_dump_print_syncs()
423 for (index = 0; index < sds->props[SP_NUM_CORES]; ++index) { in hl_state_dump_print_syncs()
424 rc = hl_state_dump_print_syncs_single_block( in hl_state_dump_print_syncs()
425 hdev, index, buf, size, offset, map); in hl_state_dump_print_syncs()
426 if (rc) in hl_state_dump_print_syncs()
432 hl_state_dump_free_sync_to_engine_map(map); in hl_state_dump_print_syncs()
434 kfree(map); in hl_state_dump_print_syncs()
436 return rc; in hl_state_dump_print_syncs()
440 * hl_state_dump_alloc_read_sm_block_monitors - read monitors for a specific
451 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_alloc_read_sm_block_monitors()
456 monitors = vmalloc(sds->props[SP_MONITORS_AMOUNT] * in hl_state_dump_alloc_read_sm_block_monitors()
461 base_addr = sds->props[SP_NEXT_SYNC_OBJ_ADDR] * index; in hl_state_dump_alloc_read_sm_block_monitors()
463 for (i = 0; i < sds->props[SP_MONITORS_AMOUNT]; ++i) { in hl_state_dump_alloc_read_sm_block_monitors()
466 RREG32(base_addr + sds->props[SP_MON_OBJ_WR_ADDR_LOW] + in hl_state_dump_alloc_read_sm_block_monitors()
470 RREG32(base_addr + sds->props[SP_MON_OBJ_WR_ADDR_HIGH] + in hl_state_dump_alloc_read_sm_block_monitors()
474 RREG32(base_addr + sds->props[SP_MON_OBJ_WR_DATA] + in hl_state_dump_alloc_read_sm_block_monitors()
478 RREG32(base_addr + sds->props[SP_MON_OBJ_ARM_DATA] + in hl_state_dump_alloc_read_sm_block_monitors()
482 RREG32(base_addr + sds->props[SP_MON_OBJ_STATUS] + in hl_state_dump_alloc_read_sm_block_monitors()
490 * hl_state_dump_free_monitors - free the monitors structure
500 * hl_state_dump_print_monitors_single_block - print active monitors on a
515 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_print_monitors_single_block()
517 int rc = 0, i; in hl_state_dump_print_monitors_single_block() local
519 if (sds->sync_namager_names) { in hl_state_dump_print_monitors_single_block()
520 rc = hl_snprintf_resize( in hl_state_dump_print_monitors_single_block()
522 sds->sync_namager_names[index]); in hl_state_dump_print_monitors_single_block()
523 if (rc) in hl_state_dump_print_monitors_single_block()
529 rc = -ENOMEM; in hl_state_dump_print_monitors_single_block()
533 for (i = 0; i < sds->props[SP_MONITORS_AMOUNT]; ++i) { in hl_state_dump_print_monitors_single_block()
534 if (!(sds->funcs.monitor_valid(&monitors[i]))) in hl_state_dump_print_monitors_single_block()
538 rc = sds->funcs.print_single_monitor(buf, size, offset, hdev, in hl_state_dump_print_monitors_single_block()
540 if (rc) in hl_state_dump_print_monitors_single_block()
549 return rc; in hl_state_dump_print_monitors_single_block()
553 * hl_state_dump_print_monitors - print active monitors
565 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_print_monitors()
567 int rc = 0; in hl_state_dump_print_monitors() local
569 rc = hl_snprintf_resize(buf, size, offset, in hl_state_dump_print_monitors()
571 if (rc) in hl_state_dump_print_monitors()
574 if (sds->sync_namager_names) { in hl_state_dump_print_monitors()
575 for (index = 0; sds->sync_namager_names[index]; ++index) { in hl_state_dump_print_monitors()
576 rc = hl_state_dump_print_monitors_single_block( in hl_state_dump_print_monitors()
578 if (rc) in hl_state_dump_print_monitors()
582 for (index = 0; index < sds->props[SP_NUM_CORES]; ++index) { in hl_state_dump_print_monitors()
583 rc = hl_state_dump_print_monitors_single_block( in hl_state_dump_print_monitors()
585 if (rc) in hl_state_dump_print_monitors()
591 return rc; in hl_state_dump_print_monitors()
595 * hl_state_dump_print_engine_fences - print active fences for a specific
608 struct hl_state_dump_specs *sds = &hdev->state_dump_specs; in hl_state_dump_print_engine_fences()
609 int rc = 0, i, n_fences; in hl_state_dump_print_engine_fences() local
614 n_fences = sds->props[SP_NUM_OF_TPC_ENGINES]; in hl_state_dump_print_engine_fences()
615 base_addr = sds->props[SP_TPC0_CMDQ]; in hl_state_dump_print_engine_fences()
616 next_fence = sds->props[SP_NEXT_TPC]; in hl_state_dump_print_engine_fences()
619 n_fences = sds->props[SP_NUM_OF_MME_ENGINES]; in hl_state_dump_print_engine_fences()
620 base_addr = sds->props[SP_MME_CMDQ]; in hl_state_dump_print_engine_fences()
621 next_fence = sds->props[SP_NEXT_MME]; in hl_state_dump_print_engine_fences()
624 n_fences = sds->props[SP_NUM_OF_DMA_ENGINES]; in hl_state_dump_print_engine_fences()
625 base_addr = sds->props[SP_DMA_CMDQ]; in hl_state_dump_print_engine_fences()
626 next_fence = sds->props[SP_DMA_QUEUES_OFFSET]; in hl_state_dump_print_engine_fences()
629 return -EINVAL; in hl_state_dump_print_engine_fences()
632 rc = sds->funcs.print_fences_single_engine( in hl_state_dump_print_engine_fences()
635 sds->props[SP_FENCE0_CNT_OFFSET], in hl_state_dump_print_engine_fences()
637 sds->props[SP_CP_STS_OFFSET], in hl_state_dump_print_engine_fences()
639 if (rc) in hl_state_dump_print_engine_fences()
643 return rc; in hl_state_dump_print_engine_fences()
647 * hl_state_dump_print_fences - print active fences
656 int rc = 0; in hl_state_dump_print_fences() local
658 rc = hl_snprintf_resize(buf, size, offset, "Valid (armed) fences:\n"); in hl_state_dump_print_fences()
659 if (rc) in hl_state_dump_print_fences()
662 rc = hl_state_dump_print_engine_fences(hdev, ENGINE_TPC, buf, size, offset); in hl_state_dump_print_fences()
663 if (rc) in hl_state_dump_print_fences()
666 rc = hl_state_dump_print_engine_fences(hdev, ENGINE_MME, buf, size, offset); in hl_state_dump_print_fences()
667 if (rc) in hl_state_dump_print_fences()
670 rc = hl_state_dump_print_engine_fences(hdev, ENGINE_DMA, buf, size, offset); in hl_state_dump_print_fences()
671 if (rc) in hl_state_dump_print_fences()
675 return rc; in hl_state_dump_print_fences()
679 * hl_state_dump() - dump system state
686 int rc; in hl_state_dump() local
688 rc = hl_snprintf_resize(&buf, &size, &offset, in hl_state_dump()
691 if (rc) in hl_state_dump()
694 rc = hl_state_dump_print_syncs(hdev, &buf, &size, &offset); in hl_state_dump()
695 if (rc) in hl_state_dump()
700 rc = hl_state_dump_print_monitors(hdev, &buf, &size, &offset); in hl_state_dump()
701 if (rc) in hl_state_dump()
706 rc = hl_state_dump_print_fences(hdev, &buf, &size, &offset); in hl_state_dump()
707 if (rc) in hl_state_dump()
717 return rc; in hl_state_dump()