[Beignet] [PATCH] remove requirment as drm master in non-x environment
Zhigang Gong
zhigang.gong at linux.intel.com
Tue Jul 15 20:25:30 PDT 2014
There is a major bug hided in the driver open/close code path.
It always close the fd 0 at intel_driver_terminate() incorrectly.
Please merge the following patch into your patch. And please also fix
the compilation warning. Check the return value of the IOCTL, and
print the error message in the error handling.
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index 2965bf7..00affca 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->fd) {
+ close(intel->fd);
+ intel->need_close = 0;
+ }
intel->dri_ctx = NULL;
intel->x11_display = NULL;
- intel->fd = 0;
+ intel->fd = -1;
}
LOCAL int
After this patch, we can get 100% utest pass rate under the non-X environment.
Thanks.
On Tue, Jul 15, 2014 at 07:19:02AM +0800, Guo Yejun wrote:
> Signed-off-by: Guo Yejun <yejun.guo at intel.com>
> ---
> src/intel/intel_driver.c | 20 +++++---------------
> src/intel/intel_driver.h | 2 +-
> 2 files changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
> index 4a33661..2965bf7 100644
> --- a/src/intel/intel_driver.c
> +++ b/src/intel/intel_driver.c
> @@ -294,7 +294,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,7 +312,7 @@ 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);
> @@ -323,16 +323,8 @@ intel_driver_init_master(intel_driver_t *driver, const char* dev_name)
> 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);
> - close(dev_fd);
> - return 0;
> - }
> -
> intel_driver_init(driver, dev_fd);
> - driver->master = 1;
> + driver->need_close = 1;
>
> return 1;
> }
> @@ -350,7 +342,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,7 +352,7 @@ intel_driver_terminate(intel_driver_t *driver)
> {
> pthread_mutex_destroy(&driver->ctxmutex);
>
> - if(driver->master)
> + if(driver->need_close)
> close(driver->fd);
> driver->fd = -1;
> return 1;
> @@ -385,7 +377,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 +387,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