[Beignet] [PATCH V2] remove requirment as drm master in non-x environment
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Jul 16 18:57:05 PDT 2014
LGTM, pushed, thanks.
On Thu, Jul 17, 2014 at 01:26:23AM +0800, Guo Yejun wrote:
> Signed-off-by: Guo Yejun <yejun.guo at intel.com>
> ---
> src/intel/intel_driver.c | 33 ++++++++++++++++-----------------
> src/intel/intel_driver.h | 2 +-
> 2 files changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
> index 4a33661..61d1410 100644
> --- a/src/intel/intel_driver.c
> +++ b/src/intel/intel_driver.c
> @@ -262,10 +262,13 @@ intel_driver_close(intel_driver_t *intel)
> {
> if(intel->dri_ctx) dri_state_release(intel->dri_ctx);
> if(intel->x11_display) XCloseDisplay(intel->x11_display);
> - if(intel->fd) close(intel->fd);
> + if(intel->need_close) {
> + close(intel->fd);
> + intel->need_close = 0;
> + }
> intel->dri_ctx = NULL;
> intel->x11_display = NULL;
> - intel->fd = 0;
> + intel->fd = -1;
> }
>
> LOCAL int
> @@ -294,7 +297,7 @@ intel_driver_init_shared(intel_driver_t *driver, dri_state_t *state)
> if(state->driConnectedFlag != DRI2)
> return 0;
> intel_driver_init(driver, state->fd);
> - driver->master = 0;
> + driver->need_close = 0;
> return 1;
> }
>
> @@ -312,27 +315,23 @@ intel_driver_init_master(intel_driver_t *driver, const char* dev_name)
> return 0;
> }
>
> - // Check that we're authenticated and the only opener
> + // Check that we're authenticated
> memset(&client, 0, sizeof(drm_client_t));
> int ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client);
> - assert (ret == 0);
> -
> - if (!client.auth) {
> - printf("%s not authenticated\n", dev_name);
> + if (ret == -1) {
> + printf("ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client) failed: %s\n", strerror(errno));
> close(dev_fd);
> return 0;
> }
>
> - client.idx = 1;
> - ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client);
> - if (ret != -1 || errno != EINVAL) {
> - printf("%s is already in use\n", dev_name);
> + if (!client.auth) {
> + printf("%s not authenticated\n", dev_name);
> close(dev_fd);
> return 0;
> }
>
> intel_driver_init(driver, dev_fd);
> - driver->master = 1;
> + driver->need_close = 1;
>
> return 1;
> }
> @@ -350,7 +349,7 @@ intel_driver_init_render(intel_driver_t *driver, const char* dev_name)
> }
>
> intel_driver_init(driver, dev_fd);
> - driver->master = 1;
> + driver->need_close = 1;
>
> return 1;
> }
> @@ -360,8 +359,10 @@ intel_driver_terminate(intel_driver_t *driver)
> {
> pthread_mutex_destroy(&driver->ctxmutex);
>
> - if(driver->master)
> + if(driver->need_close) {
> close(driver->fd);
> + driver->need_close = 0;
> + }
> driver->fd = -1;
> return 1;
> }
> @@ -385,7 +386,6 @@ intel_driver_unlock_hardware(intel_driver_t *driver)
> LOCAL dri_bo*
> intel_driver_share_buffer(intel_driver_t *driver, const char *sname, uint32_t name)
> {
> - assert(!driver->master);
> dri_bo *bo = intel_bo_gem_create_from_name(driver->bufmgr,
> sname,
> name);
> @@ -396,7 +396,6 @@ LOCAL uint32_t
> intel_driver_shared_name(intel_driver_t *driver, dri_bo *bo)
> {
> uint32_t name;
> - assert(!driver->master);
> assert(bo);
> dri_bo_flink(bo, &name);
> return name;
> diff --git a/src/intel/intel_driver.h b/src/intel/intel_driver.h
> index 1ad0500..107fdfc 100644
> --- a/src/intel/intel_driver.h
> +++ b/src/intel/intel_driver.h
> @@ -85,7 +85,7 @@ typedef struct intel_driver
> sigset_t sa_mask;
> pthread_mutex_t ctxmutex;
> int locked;
> - int master;
> + int need_close;
> Display *x11_display;
> struct dri_state *dri_ctx;
> } intel_driver_t;
> --
> 1.8.3.2
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list