[Mesa-dev] [PATCH] radv: check driver name before calling amdgpu.

Edward O'Callaghan funfunctor at folklore1984.net
Tue Oct 11 06:13:30 UTC 2016


Reviewed-by: Edward O'Callaghan <funfunctor at folklore1984.net>

On 10/11/2016 04:22 PM, Dave Airlie wrote:
> From: Dave Airlie <airlied at redhat.com>
> 
> 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 at redhat.com>
> ---
>  src/amd/vulkan/radv_device.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
> index 3d7ebab..c47ea19 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,18 @@ 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)
> +		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));
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161011/e2288b62/attachment.sig>


More information about the mesa-dev mailing list