On Friday, 2018-10-26 11:42:12 -0500, Jason Ekstrand wrote: > This lets us get rid of a bunch of duplicated error messages.
Better than mine :P Reviewed-by: Eric Engestrom <[email protected]> > --- > src/intel/vulkan/anv_device.c | 50 +++++++++++++++------------------- > src/intel/vulkan/anv_private.h | 7 +++-- > src/intel/vulkan/anv_queue.c | 16 +++-------- > src/intel/vulkan/genX_query.c | 4 +-- > 4 files changed, 32 insertions(+), 45 deletions(-) > > diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c > index 70fc51ff306..ee35e013329 100644 > --- a/src/intel/vulkan/anv_device.c > +++ b/src/intel/vulkan/anv_device.c > @@ -2048,21 +2048,26 @@ void anv_GetDeviceQueue2( > *pQueue = NULL; > } > > -void > -anv_device_set_lost(struct anv_device *device, const char *msg, ...) > +VkResult > +_anv_device_set_lost(struct anv_device *device, > + const char *file, int line, > + const char *msg, ...) > { > - device->_lost = true; > + VkResult err; > + va_list ap; > > - if (env_var_as_boolean("ANV_ABORT_ON_DEVICE_LOSS", false)) { > - intel_loge("Device lost!"); > + device->_lost = true; > > - va_list ap; > - va_start(ap, msg); > - intel_loge_v(msg, ap); > - va_end(ap); > + va_start(ap, msg); > + err = __vk_errorv(device->instance, device, > + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, > + VK_ERROR_DEVICE_LOST, file, line, msg, ap); > + va_end(ap); > > + if (env_var_as_boolean("ANV_ABORT_ON_DEVICE_LOSS", false)) > abort(); > - } > + > + return err; > } > > VkResult > @@ -2079,19 +2084,13 @@ anv_device_query_status(struct anv_device *device) > int ret = anv_gem_gpu_get_reset_stats(device, &active, &pending); > if (ret == -1) { > /* We don't know the real error. */ > - anv_device_set_lost(device, "get_reset_stats failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "get_reset_stats failed: %m"); > + return anv_device_set_lost(device, "get_reset_stats failed: %m"); > } > > if (active) { > - anv_device_set_lost(device, "GPU hung on one of our command buffers"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "GPU hung on one of our command buffers"); > + return anv_device_set_lost(device, "GPU hung on one of our command > buffers"); > } else if (pending) { > - anv_device_set_lost(device, "GPU hung with commands in-flight"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "GPU hung with commands in-flight"); > + return anv_device_set_lost(device, "GPU hung with commands in-flight"); > } > > return VK_SUCCESS; > @@ -2109,9 +2108,7 @@ anv_device_bo_busy(struct anv_device *device, struct > anv_bo *bo) > return VK_NOT_READY; > } else if (ret == -1) { > /* We don't know the real error. */ > - anv_device_set_lost(device, "gem wait failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "gem wait failed: %m"); > + return anv_device_set_lost(device, "gem wait failed: %m"); > } > > /* Query for device status after the busy call. If the BO we're checking > @@ -2132,9 +2129,7 @@ anv_device_wait(struct anv_device *device, struct > anv_bo *bo, > return VK_TIMEOUT; > } else if (ret == -1) { > /* We don't know the real error. */ > - anv_device_set_lost(device, "gem wait failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "gem wait failed: %m"); > + return anv_device_set_lost(device, "gem wait failed: %m"); > } > > /* Query for device status after the wait. If the BO we're waiting on got > @@ -3111,9 +3106,8 @@ VkResult anv_GetCalibratedTimestampsEXT( > &pTimestamps[d]); > > if (ret != 0) { > - anv_device_set_lost(device, "Failed to get a timestamp"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "Failed to read the TIMESTAMP register: %m"); > + return anv_device_set_lost(device, "Failed to read the TIMESTAMP > " > + "register: %m"); > } > uint64_t device_period = DIV_ROUND_UP(1000000000, > timestamp_frequency); > max_clock_period = MAX2(max_clock_period, device_period); > diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h > index c5d636fef8d..25e290ed112 100644 > --- a/src/intel/vulkan/anv_private.h > +++ b/src/intel/vulkan/anv_private.h > @@ -1083,8 +1083,11 @@ anv_state_flush(struct anv_device *device, struct > anv_state state) > void anv_device_init_blorp(struct anv_device *device); > void anv_device_finish_blorp(struct anv_device *device); > > -void anv_device_set_lost(struct anv_device *device, > - const char *msg, ...); > +VkResult _anv_device_set_lost(struct anv_device *device, > + const char *file, int line, > + const char *msg, ...); > +#define anv_device_set_lost(dev, ...) \ > + _anv_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__) > > static inline bool > anv_device_is_lost(struct anv_device *device) > diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c > index 8e9f743fcb7..6247ba8751e 100644 > --- a/src/intel/vulkan/anv_queue.c > +++ b/src/intel/vulkan/anv_queue.c > @@ -42,9 +42,7 @@ anv_device_execbuf(struct anv_device *device, > int ret = device->no_hw ? 0 : anv_gem_execbuffer(device, execbuf); > if (ret != 0) { > /* We don't know the real error. */ > - anv_device_set_lost(device, "execbuf2 failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "execbuf2 failed: %m"); > + return anv_device_set_lost(device, "execbuf2 failed: %m"); > } > > struct drm_i915_gem_exec_object2 *objects = > @@ -243,9 +241,7 @@ out: > * VK_ERROR_DEVICE_LOST to ensure that clients do not attempt to > * submit the same job again to this device. > */ > - result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "vkQueueSubmit() failed"); > - anv_device_set_lost(device, "vkQueueSubmit() failed"); > + result = anv_device_set_lost(device, "vkQueueSubmit() failed"); > } > > pthread_mutex_unlock(&device->mutex); > @@ -438,9 +434,7 @@ VkResult anv_GetFenceStatus( > return VK_NOT_READY; > } else { > /* We don't know the real error. */ > - anv_device_set_lost(device, "drm_syncobj_wait failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "drm_syncobj_wait failed: %m"); > + return anv_device_set_lost(device, "drm_syncobj_wait failed: > %m"); > } > } else { > return VK_SUCCESS; > @@ -526,9 +520,7 @@ anv_wait_for_syncobj_fences(struct anv_device *device, > return VK_TIMEOUT; > } else { > /* We don't know the real error. */ > - anv_device_set_lost(device, "drm_syncobj_wait failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "drm_syncobj_wait failed: %m"); > + return anv_device_set_lost(device, "drm_syncobj_wait failed: %m"); > } > } else { > return VK_SUCCESS; > diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c > index 7dd9112d296..ce8757f2643 100644 > --- a/src/intel/vulkan/genX_query.c > +++ b/src/intel/vulkan/genX_query.c > @@ -181,9 +181,7 @@ wait_for_available(struct anv_device *device, > continue; > } else if (ret == -1) { > /* We don't know the real error. */ > - anv_device_set_lost(device, "gem wait failed: %m"); > - return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST, > - "gem wait failed: %m"); > + return anv_device_set_lost(device, "gem wait failed: %m"); > } else { > assert(ret == 0); > /* The BO is no longer busy. */ > -- > 2.19.1 > > _______________________________________________ > mesa-dev mailing list > [email protected] > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
