summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_device.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-10-11 15:21:25 +1000
committerDave Airlie <airlied@redhat.com>2016-10-12 08:56:41 +1000
commitfc28f89157254ddf638e52ea20cdfe675ab4c382 (patch)
tree5cc39f7e6ca5184be5d686bec946ca3b11aa9a3a /src/amd/vulkan/radv_device.c
parent6215b476482fa3a76d3245d88ab127a7c060e115 (diff)
downloadexternal_mesa3d-fc28f89157254ddf638e52ea20cdfe675ab4c382.zip
external_mesa3d-fc28f89157254ddf638e52ea20cdfe675ab4c382.tar.gz
external_mesa3d-fc28f89157254ddf638e52ea20cdfe675ab4c382.tar.bz2
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>
Diffstat (limited to 'src/amd/vulkan/radv_device.c')
-rw-r--r--src/amd/vulkan/radv_device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 79ef8ed..6e06863 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -32,6 +32,7 @@
#include "radv_private.h"
#include "util/strtod.h"
+#include <xf86drm.h>
#include <amdgpu.h>
#include <amdgpu_drm.h>
#include "amdgpu_id.h"
@@ -55,6 +56,7 @@ radv_physical_device_init(struct radv_physical_device *device,
const char *path)
{
VkResult result;
+ drmVersionPtr version;
int fd;
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,
"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->instance = instance;
assert(strlen(path) < ARRAY_SIZE(device->path));