radv: check driver name before calling amdgpu.
This checks the kernel driver name is amdgpu before calling libdrm_amdgpu. This avoids the following error: amdgpu_device_initialize: DRM version is 1.6.0 but this driver is only compatible with 3.x.x when run on a machine with i915 graphics as well as amdgpu. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
6215b47648
commit
fc28f89157
|
@ -32,6 +32,7 @@
|
||||||
#include "radv_private.h"
|
#include "radv_private.h"
|
||||||
#include "util/strtod.h"
|
#include "util/strtod.h"
|
||||||
|
|
||||||
|
#include <xf86drm.h>
|
||||||
#include <amdgpu.h>
|
#include <amdgpu.h>
|
||||||
#include <amdgpu_drm.h>
|
#include <amdgpu_drm.h>
|
||||||
#include "amdgpu_id.h"
|
#include "amdgpu_id.h"
|
||||||
|
@ -55,6 +56,7 @@ radv_physical_device_init(struct radv_physical_device *device,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
drmVersionPtr version;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
fd = open(path, O_RDWR | O_CLOEXEC);
|
||||||
|
@ -62,6 +64,20 @@ radv_physical_device_init(struct radv_physical_device *device,
|
||||||
return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
|
return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||||
"failed to open %s: %m", path);
|
"failed to open %s: %m", path);
|
||||||
|
|
||||||
|
version = drmGetVersion(fd);
|
||||||
|
if (!version) {
|
||||||
|
close(fd);
|
||||||
|
return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
|
||||||
|
"failed to get version %s: %m", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(version->name, "amdgpu")) {
|
||||||
|
drmFreeVersion(version);
|
||||||
|
close(fd);
|
||||||
|
return VK_ERROR_INCOMPATIBLE_DRIVER;
|
||||||
|
}
|
||||||
|
drmFreeVersion(version);
|
||||||
|
|
||||||
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));
|
||||||
|
|
Loading…
Reference in New Issue