[Mesa-dev] [PATCH v2 3/5] anv: wire up vk_errorf macro to do debug reporting
Jason Ekstrand
jason at jlekstrand.net
Thu Sep 7 16:56:05 UTC 2017
On Mon, Aug 28, 2017 at 10:44 PM, Tapani Pälli <tapani.palli at intel.com>
wrote:
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
> src/intel/vulkan/anv_allocator.c | 8 +++++---
> src/intel/vulkan/anv_device.c | 38 ++++++++++++++++++++++++------
> --------
> src/intel/vulkan/anv_formats.c | 3 ++-
> src/intel/vulkan/anv_private.h | 12 +++++++++---
> src/intel/vulkan/anv_queue.c | 13 ++++++++-----
> src/intel/vulkan/anv_util.c | 4 +++-
> src/intel/vulkan/anv_wsi.c | 6 ++++--
> src/intel/vulkan/genX_query.c | 3 ++-
> 8 files changed, 57 insertions(+), 30 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_
> allocator.c
> index efaaebcf39..3fcf9e64af 100644
> --- a/src/intel/vulkan/anv_allocator.c
> +++ b/src/intel/vulkan/anv_allocator.c
> @@ -361,12 +361,14 @@ anv_block_pool_expand_range(struct anv_block_pool
> *pool,
> MAP_SHARED | MAP_POPULATE, pool->fd,
> BLOCK_POOL_MEMFD_CENTER - center_bo_offset);
> if (map == MAP_FAILED)
> - return vk_errorf(VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
> + return vk_errorf(pool->device->instance, pool->device,
> + VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
>
> gem_handle = anv_gem_userptr(pool->device, map, size);
> if (gem_handle == 0) {
> munmap(map, size);
> - return vk_errorf(VK_ERROR_TOO_MANY_OBJECTS, "userptr failed: %m");
> + return vk_errorf(pool->device->instance, pool->device,
> + VK_ERROR_TOO_MANY_OBJECTS, "userptr failed: %m");
> }
>
> cleanup->map = map;
> @@ -1190,7 +1192,7 @@ anv_bo_cache_init(struct anv_bo_cache *cache)
>
> if (pthread_mutex_init(&cache->mutex, NULL)) {
> _mesa_hash_table_destroy(cache->bo_map, NULL);
> - return vk_errorf(VK_ERROR_OUT_OF_HOST_MEMORY,
> + return vk_errorf(NULL, NULL, VK_ERROR_OUT_OF_HOST_MEMORY,
> "pthread_mutex_init failed: %m");
> }
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 037b8258df..3d1382e695 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -68,7 +68,7 @@ anv_compute_heap_size(int fd, uint64_t *heap_size)
> "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
>
> if (anv_gem_get_aperture(fd, >t_size) == -1) {
> - return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_FAILED,
> "failed to get aperture size: %m");
> }
> }
> @@ -210,13 +210,15 @@ anv_physical_device_init_uuids(struct
> anv_physical_device *device)
> {
> const struct build_id_note *note = build_id_find_nhdr("libvulkan_
> intel.so");
> if (!note) {
> - return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + return vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "Failed to find build-id");
> }
>
> unsigned build_id_len = build_id_length(note);
> if (build_id_len < 20) {
> - return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + return vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "build-id too short. It needs to be a SHA");
> }
>
> @@ -298,7 +300,8 @@ anv_physical_device_init(struct anv_physical_device
> *device,
> /* Broadwell, Cherryview, Skylake, Broxton, Kabylake is as fully
> * supported as anything */
> } else {
> - result = vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_INCOMPATIBLE_DRIVER,
> "Vulkan not yet supported on %s", device->name);
> goto fail;
> }
> @@ -308,27 +311,31 @@ anv_physical_device_init(struct anv_physical_device
> *device,
> device->cmd_parser_version =
> anv_gem_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
> if (device->cmd_parser_version == -1) {
> - result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "failed to get command parser version");
> goto fail;
> }
> }
>
> if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) {
> - result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "kernel missing gem wait");
> goto fail;
> }
>
> if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
> - result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "kernel missing execbuf2");
> goto fail;
> }
>
> if (!device->info.has_llc &&
> anv_gem_get_param(fd, I915_PARAM_MMAP_VERSION) < 1) {
> - result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_INITIALIZATION_FAILED,
> "kernel missing wc mmap");
> goto fail;
> }
> @@ -487,7 +494,7 @@ VkResult anv_CreateInstance(
> "incompatible driver version",
> ctor_cb->pUserData);
>
> - return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
> + return vk_errorf(NULL, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,
> "Client requested version %d.%d.%d",
> VK_VERSION_MAJOR(client_version),
> VK_VERSION_MINOR(client_version),
> @@ -1374,16 +1381,17 @@ anv_device_query_status(struct anv_device *device)
> if (ret == -1) {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST, "get_reset_stats failed:
> %m");
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "get_reset_stats failed: %m");
> }
>
> if (active) {
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST,
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> "GPU hung on one of our command buffers");
> } else if (pending) {
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST,
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> "GPU hung with commands in-flight");
> }
>
> @@ -1403,7 +1411,8 @@ anv_device_bo_busy(struct anv_device *device, struct
> anv_bo *bo)
> } else if (ret == -1) {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "gem wait failed: %m");
> }
>
> /* Query for device status after the busy call. If the BO we're
> checking
> @@ -1425,7 +1434,8 @@ anv_device_wait(struct anv_device *device, struct
> anv_bo *bo,
> } else if (ret == -1) {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "gem wait failed: %m");
> }
>
> /* Query for device status after the wait. If the BO we're waiting on
> got
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> formats.c
> index 9808508523..b6614dbede 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -721,7 +721,8 @@ VkResult anv_GetPhysicalDeviceImageFormatPr
> operties2KHR(
> * vkGetPhysicalDeviceImageFormatProperties2KHR returns
> * VK_ERROR_FORMAT_NOT_SUPPORTED.
> */
> - result = vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED,
> + result = vk_errorf(physical_device->instance, physical_device,
> + VK_ERROR_FORMAT_NOT_SUPPORTED,
> "unsupported VkExternalMemoryTypeFlagBitsKHR
> 0x%x",
> external_info->handleType);
> goto fail;
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index 4d59d5b24c..7d43ad1264 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -303,11 +303,17 @@ vk_to_isl_color(VkClearColorValue color)
> * propagating errors. Might be useful to plug in a stack trace here.
> */
>
> -VkResult __vk_errorf(VkResult error, const char *file, int line, const
> char *format, ...);
> +VkResult __vk_errorf(struct anv_instance *instance, const void *object,
> + VkDebugReportObjectTypeEXT type, VkResult error,
> + const char *file, int line, const char *format, ...);
>
> #ifdef DEBUG
> -#define vk_error(error) __vk_errorf(error, __FILE__, __LINE__, NULL);
> -#define vk_errorf(error, format, ...) __vk_errorf(error, __FILE__,
> __LINE__, format, ## __VA_ARGS__);
> +#define vk_error(error) __vk_errorf(NULL, NULL,\
> + VK_DEBUG_REPORT_OBJECT_TYPE_
> UNKNOWN_EXT,\
> + error, __FILE__, __LINE__, NULL);
> +#define vk_errorf(instance, obj, error, format, ...)\
> + __vk_errorf(NULL, NULL, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
> error,\
> + __FILE__, __LINE__, format, ## __VA_ARGS__);
> #define anv_debug(format, ...) fprintf(stderr, "debug: " format,
> ##__VA_ARGS__)
> #else
> #define vk_error(error) error
> diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
> index 429bac9739..1849e5277a 100644
> --- a/src/intel/vulkan/anv_queue.c
> +++ b/src/intel/vulkan/anv_queue.c
> @@ -43,7 +43,8 @@ anv_device_execbuf(struct anv_device *device,
> if (ret != 0) {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST, "execbuf2 failed: %m");
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "execbuf2 failed: %m");
> }
>
> struct drm_i915_gem_exec_object2 *objects =
> @@ -238,7 +239,8 @@ out:
> * VK_ERROR_DEVICE_LOST to ensure that clients do not attempt to
> * submit the same job again to this device.
> */
> - result = vk_errorf(VK_ERROR_DEVICE_LOST, "vkQueueSubmit() failed");
> + result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "vkQueueSubmit() failed");
> device->lost = true;
> }
>
> @@ -428,7 +430,7 @@ VkResult anv_GetFenceStatus(
> } else {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST,
> + return vk_errorf(device->instance, device,
> VK_ERROR_DEVICE_LOST,
> "drm_syncobj_wait failed: %m");
> }
> } else {
> @@ -508,7 +510,7 @@ anv_wait_for_syncobj_fences(struct anv_device *device,
> } else {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST,
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> "drm_syncobj_wait failed: %m");
> }
> } else {
> @@ -750,7 +752,8 @@ VkResult anv_ImportFenceFdKHR(
>
> if (anv_gem_syncobj_import_sync_file(device, new_impl.syncobj,
> fd)) {
> anv_gem_syncobj_destroy(device, new_impl.syncobj);
> - return vk_errorf(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
> + return vk_errorf(device->instance, NULL,
> + VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
> "syncobj sync file import failed: %m");
> }
> break;
> diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
> index a374db5cc6..5318528150 100644
> --- a/src/intel/vulkan/anv_util.c
> +++ b/src/intel/vulkan/anv_util.c
> @@ -93,7 +93,9 @@ __anv_perf_warn(struct anv_instance *instance, const
> void *object,
> }
>
> VkResult
> -__vk_errorf(VkResult error, const char *file, int line, const char
> *format, ...)
> +__vk_errorf(struct anv_instance *instance, const void *object,
> + VkDebugReportObjectTypeEXT type, VkResult error,
> + const char *file, int line, const char *format, ...)
> {
>
Were you planning to actually hook this into debug_report? I don't see
that code.
> va_list ap;
> char buffer[256];
> diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
> index 00edb220b2..c3e5dc1870 100644
> --- a/src/intel/vulkan/anv_wsi.c
> +++ b/src/intel/vulkan/anv_wsi.c
> @@ -248,7 +248,8 @@ anv_wsi_image_create(VkDevice device_h,
> surface->isl.row_pitch, I915_TILING_X);
> if (ret) {
> /* FINISHME: Choose a better error. */
> - result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_OUT_OF_DEVICE_MEMORY,
> "set_tiling failed: %m");
> goto fail_alloc_memory;
> }
> @@ -256,7 +257,8 @@ anv_wsi_image_create(VkDevice device_h,
> int fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle);
> if (fd == -1) {
> /* FINISHME: Choose a better error. */
> - result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
> + result = vk_errorf(device->instance, device,
> + VK_ERROR_OUT_OF_DEVICE_MEMORY,
> "handle_to_fd failed: %m");
> goto fail_alloc_memory;
> }
> diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
> index 5102412e8f..9c5fc86d7f 100644
> --- a/src/intel/vulkan/genX_query.c
> +++ b/src/intel/vulkan/genX_query.c
> @@ -167,7 +167,8 @@ wait_for_available(struct anv_device *device,
> } else if (ret == -1) {
> /* We don't know the real error. */
> device->lost = true;
> - return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
> + return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
> + "gem wait failed: %m");
> } else {
> assert(ret == 0);
> /* The BO is no longer busy. */
> --
> 2.13.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170907/02d2c92b/attachment-0001.html>
More information about the mesa-dev
mailing list