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 <tarceri@itsqueeze.com> Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
@@ -47,6 +47,7 @@ enum {
|
|||||||
RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000,
|
RADV_DEBUG_NO_OUT_OF_ORDER = 0x20000,
|
||||||
RADV_DEBUG_INFO = 0x40000,
|
RADV_DEBUG_INFO = 0x40000,
|
||||||
RADV_DEBUG_ERRORS = 0x80000,
|
RADV_DEBUG_ERRORS = 0x80000,
|
||||||
|
RADV_DEBUG_STARTUP = 0x100000,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@@ -227,12 +227,20 @@ radv_physical_device_init(struct radv_physical_device *device,
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
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);
|
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
|
||||||
|
}
|
||||||
|
|
||||||
version = drmGetVersion(fd);
|
version = drmGetVersion(fd);
|
||||||
if (!version) {
|
if (!version) {
|
||||||
close(fd);
|
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,
|
return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||||
"failed to get version %s: %m", path);
|
"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")) {
|
if (strcmp(version->name, "amdgpu")) {
|
||||||
drmFreeVersion(version);
|
drmFreeVersion(version);
|
||||||
close(fd);
|
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;
|
return VK_ERROR_INCOMPATIBLE_DRIVER;
|
||||||
}
|
}
|
||||||
drmFreeVersion(version);
|
drmFreeVersion(version);
|
||||||
|
|
||||||
|
if (instance->debug_flags & RADV_DEBUG_STARTUP)
|
||||||
|
radv_logi("Found compatible device '%s'.", path);
|
||||||
|
|
||||||
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
|
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
|
||||||
device->instance = instance;
|
device->instance = instance;
|
||||||
assert(strlen(path) < ARRAY_SIZE(device->path));
|
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,
|
device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags,
|
||||||
instance->perftest_flags);
|
instance->perftest_flags);
|
||||||
if (!device->ws) {
|
if (!device->ws) {
|
||||||
result = VK_ERROR_INCOMPATIBLE_DRIVER;
|
result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,6 +338,7 @@ radv_physical_device_init(struct radv_physical_device *device,
|
|||||||
result = radv_init_wsi(device);
|
result = radv_init_wsi(device);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
device->ws->destroy(device->ws);
|
device->ws->destroy(device->ws);
|
||||||
|
vk_error(instance, result);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +409,7 @@ static const struct debug_control radv_debug_options[] = {
|
|||||||
{"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER},
|
{"nooutoforder", RADV_DEBUG_NO_OUT_OF_ORDER},
|
||||||
{"info", RADV_DEBUG_INFO},
|
{"info", RADV_DEBUG_INFO},
|
||||||
{"errors", RADV_DEBUG_ERRORS},
|
{"errors", RADV_DEBUG_ERRORS},
|
||||||
|
{"startup", RADV_DEBUG_STARTUP},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -488,6 +505,10 @@ VkResult radv_CreateInstance(
|
|||||||
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"),
|
instance->perftest_flags = parse_debug_string(getenv("RADV_PERFTEST"),
|
||||||
radv_perftest_options);
|
radv_perftest_options);
|
||||||
|
|
||||||
|
|
||||||
|
if (instance->debug_flags & RADV_DEBUG_STARTUP)
|
||||||
|
radv_logi("Created an instance");
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
|
for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
|
||||||
const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
|
const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];
|
||||||
int index = radv_get_instance_extension_index(ext_name);
|
int index = radv_get_instance_extension_index(ext_name);
|
||||||
@@ -550,6 +571,10 @@ radv_enumerate_devices(struct radv_instance *instance)
|
|||||||
instance->physicalDeviceCount = 0;
|
instance->physicalDeviceCount = 0;
|
||||||
|
|
||||||
max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
|
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)
|
if (max_devices < 1)
|
||||||
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
|
return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
|
||||||
|
|
||||||
|
@@ -228,6 +228,8 @@ void __radv_finishme(const char *file, int line, const char *format, ...)
|
|||||||
radv_printflike(3, 4);
|
radv_printflike(3, 4);
|
||||||
void radv_loge(const char *format, ...) radv_printflike(1, 2);
|
void radv_loge(const char *format, ...) radv_printflike(1, 2);
|
||||||
void radv_loge_v(const char *format, va_list va);
|
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.
|
* Print a FINISHME message, including its source location.
|
||||||
|
@@ -54,6 +54,26 @@ radv_loge_v(const char *format, va_list va)
|
|||||||
fprintf(stderr, "\n");
|
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)
|
void radv_printflike(3, 4)
|
||||||
__radv_finishme(const char *file, int line, const char *format, ...)
|
__radv_finishme(const char *file, int line, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user