[Piglit] [v6 03/12] framework: automatic drm authentication for dma buffer support

Eric Anholt eric at anholt.net
Tue May 21 13:56:01 PDT 2013


Topi Pohjolainen <topi.pohjolainen at intel.com> writes:

> From: Chad Versace <chad.versace at linux.intel.com>
>
> Fix tests to work as non-root user. Get DRM authentication before
> calling intel_bufmgr_gem_init().
>
> v2 (Topi): refactored into its own patch and allowing the dma
>            buffer support to be compiled even without this

Ouch, I'd missed that this was going to be required.  Some day we'll get
fd passing into the DRI protocol and this won't be required any more.
Or we'll get proper separation between clients in the kernel so there's
no reason to auth at all any more.

I'm not sure what's going to happen here in the case of a non-X11
platform running these tests, but I'm OK with it for now.

> +#ifdef HAVE_XCB_DRI2
> +static int
> +piglit_drm_x11_authenticate(void)
> +{
> +	drm_magic_t magic;
> +	xcb_connection_t *conn;
> +	int screen;
> +	xcb_screen_iterator_t screen_iter;
> +	xcb_dri2_authenticate_cookie_t auth_cookie;
> +	xcb_dri2_authenticate_reply_t *auth_reply;
> +	int ret = 0;
> +
> +	conn = xcb_connect(NULL, &screen);
> +	if (!conn) {
> +		printf("piglit: failed to connect to X server for DRI2 "
> +		       "authentication\n");
> +		return -1;
> +	}
> +
> +	ret = drmGetMagic(piglit_drm_device_get(), &magic);
> +	if (ret) {
> +		printf("piglit: failed to get DRM magic\n");
> +		return -1;
> +	}
> +
> +	screen_iter = xcb_setup_roots_iterator(xcb_get_setup(conn));
> +	auth_cookie = xcb_dri2_authenticate_unchecked(conn,
> +	                                              screen_iter.data->root,
> +	                                              magic);
> +	auth_reply = xcb_dri2_authenticate_reply(conn, auth_cookie, NULL);
> +
> +	if (auth_reply == NULL || !auth_reply->authenticated) {
> +		printf("piglit: failed to authenticate with DRI2\n");
> +		return -1;
> +	}
> +	free(auth_reply);
> +
> +	return 0;
> +}

piglit code tends to use a bool return value with "true" indicating
"success", rather than the libc/kernel convention of negative values vs
0.  Switch this around, and patches 1-3 are:

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130521/be0953b9/attachment.pgp>


More information about the Piglit mailing list