diff options
author | Bas Nieuwenhuizen <[email protected]> | 2018-05-31 01:49:38 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2018-05-31 11:51:23 +0200 |
commit | b9fb2c266a4b1058a1f7befd97320769d5d0a18b (patch) | |
tree | 461673b487b0809a8da9f48699ea8175a1d6a697 /src/amd/vulkan | |
parent | 38933c11514696505e49fd8036ebd1d1e62fa6ec (diff) |
radv: Add startup debug option.
This adds a RADV_DEBUG=startup option to dump more info about
instance creation and device enumeration.
A common question end users have is why the direver is not loading
for them, and this has two common reasons:
1) They did not install the driver.
2) AMDGPU is not used for the card in the kernel.
This adds some info messages so we can easily get a some useful
output from end users.
Reviewed-by: Timothy Arceri <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r-- | src/amd/vulkan/radv_debug.h | 1 | ||||
-rw-r--r-- | src/amd/vulkan/radv_device.c | 29 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_util.c | 20 |
4 files changed, 50 insertions, 2 deletions
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h index e59f4898f0a..762b3382194 100644 --- a/src/amd/vulkan/radv_debug.h +++ b/src/amd/vulkan/radv_debug.h @@ -47,6 +47,7 @@ enum { RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000, RADV_DEBUG_INFO = 0x40000, RADV_DEBUG_ERRORS = 0x80000, + RADV_DEBUG_STARTUP = 0x100000, }; enum { diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 18d3746a6fa..68bd1757824 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -227,12 +227,20 @@ radv_physical_device_init(struct radv_physical_device *device, int fd; fd = open(path, O_RDWR | O_CLOEXEC); - if (fd < 0) + if (fd < 0) { + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Could not open device '%s'", path); + return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER); + } version = drmGetVersion(fd); if (!version) { close(fd); + + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Could not get the kernel driver version for device '%s'", path); + return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, "failed to get version %s: %m", path); } @@ -240,10 +248,17 @@ radv_physical_device_init(struct radv_physical_device *device, if (strcmp(version->name, "amdgpu")) { drmFreeVersion(version); close(fd); + + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Device '%s' is not using the amdgpu kernel driver.", path); + return VK_ERROR_INCOMPATIBLE_DRIVER; } drmFreeVersion(version); + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Found compatible device '%s'.", path); + device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = instance; assert(strlen(path) < ARRAY_SIZE(device->path)); @@ -252,7 +267,7 @@ radv_physical_device_init(struct radv_physical_device *device, device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags, instance->perftest_flags); if (!device->ws) { - result = VK_ERROR_INCOMPATIBLE_DRIVER; + result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER); goto fail; } @@ -323,6 +338,7 @@ radv_physical_device_init(struct radv_physical_device *device, result = radv_init_wsi(device); if (result != VK_SUCCESS) { device->ws->destroy(device->ws); + vk_error(instance, result); goto fail; } @@ -393,6 +409,7 @@ static const struct debug_control radv_debug_options[] = { {"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER}, {"info", RADV_DEBUG_INFO}, {"errors", RADV_DEBUG_ERRORS}, + {"startup", RADV_DEBUG_STARTUP}, {NULL, 0} }; @@ -488,6 +505,10 @@ VkResult radv_CreateInstance( instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"), radv_perftest_options); + + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Created an instance"); + for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i]; int index = radv_get_instance_extension_index(ext_name); @@ -550,6 +571,10 @@ radv_enumerate_devices(struct radv_instance *instance) instance->physicalDeviceCount = 0; max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices)); + + if (instance->debug_flags & RADV_DEBUG_STARTUP) + radv_logi("Found %d drm nodes", max_devices); + if (max_devices < 1) return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 5f18fc49394..518f11dbcbf 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -228,6 +228,8 @@ void __radv_finishme(const char *file, int line, const char *format, ...) radv_printflike(3, 4); void radv_loge(const char *format, ...) radv_printflike(1, 2); void radv_loge_v(const char *format, va_list va); +void radv_logi(const char *format, ...) radv_printflike(1, 2); +void radv_logi_v(const char *format, va_list va); /** * Print a FINISHME message, including its source location. diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c index 2af7da6c6cc..72bedc687d4 100644 --- a/src/amd/vulkan/radv_util.c +++ b/src/amd/vulkan/radv_util.c @@ -54,6 +54,26 @@ radv_loge_v(const char *format, va_list va) fprintf(stderr, "\n"); } +/** Log an error message. */ +void radv_printflike(1, 2) + radv_logi(const char *format, ...) +{ + va_list va; + + va_start(va, format); + radv_logi_v(format, va); + va_end(va); +} + +/** \see radv_logi() */ +void +radv_logi_v(const char *format, va_list va) +{ + fprintf(stderr, "radv: info: "); + vfprintf(stderr, format, va); + fprintf(stderr, "\n"); +} + void radv_printflike(3, 4) __radv_finishme(const char *file, int line, const char *format, ...) { |