[PATCH xf86-video-amdgpu] Use render node for DRI3 if available

Michel Dänzer michel at daenzer.net
Tue Nov 17 01:31:57 PST 2015


On 13.11.2015 17:15, Jammy Zhou wrote:
> Change-Id: Ic96d4f02ad2a61659f10e19e87bd17c5564ea798

Should this be removed?


> +static int
> +amdgpu_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
> +{
> +	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
> +	int ret;
> +
> +	if (info->render_node)
> +		ret = open_render_node(screen, out);
> +
> +	if (ret != Success)
> +		ret = open_master_node(screen, out);

Please look at compiler warnings:

../../src/amdgpu_dri3.c: In function 'amdgpu_dri3_open':
../../src/amdgpu_dri3.c:112:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (ret != Success)
     ^

Maybe initialize ret to BadAlloc.


> @@ -169,10 +197,53 @@ static dri3_screen_info_rec amdgpu_dri3_screen_info = {
>  	.fd_from_pixmap = amdgpu_dri3_fd_from_pixmap
>  };
>  
> +static char *get_render_node(ScreenPtr screen)
> +{
> +	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
> +	drmDevicePtr *devices;
> +	uint32_t  num_devices;
> +	char *render_node = NULL;
> +	int r, i;
> +
> +	r = drmGetDevices(NULL, 0);

drmGetDevices was introduced in libdrm 2.4.65, so the corresponding
PKG_CHECK_MODULES stanza in configure.ac would have to be bumped
accordingly.


>  Bool
>  amdgpu_dri3_screen_init(ScreenPtr screen)
>  {
>  	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
> +
> +	info->render_node = get_render_node(screen);

However, couldn't you just use drmGetRenderDeviceNameFromFd here instead
of adding get_render_node()? That was introduced in libdrm 2.4.60.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the xorg-driver-ati mailing list