[Beignet] [PATCH] Use libdrm interface to get device id
Zhigang Gong
zhigang.gong at linux.intel.com
Sun Dec 28 17:42:05 PST 2014
This patch LGTM, will push latter. Thanks.
On Thu, Dec 25, 2014 at 04:22:42PM +0800, Zhenyu Wang wrote:
> Remove own ioctl call for device id but use libdrm interface instead.
> This not only saves one extra ioctl call as it's already been read
> when gem bufmgr inits, and also would allow to override device id with
> libdrm helper environment 'INTEL_DEVID_OVERRIDE'.
>
> To combine with aub dump, you can do device debugging with fulsim
> emulator by choosing any device you want and don't need hw metal at
> all.
>
> Signed-off-by: Zhenyu Wang <zhenyuw at linux.intel.com>
> ---
> src/intel/intel_driver.c | 21 ++-------------------
> src/intel/intel_driver.h | 3 ---
> 2 files changed, 2 insertions(+), 22 deletions(-)
>
> diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
> index 4ed1e25..21546d9 100644
> --- a/src/intel/intel_driver.c
> +++ b/src/intel/intel_driver.c
> @@ -130,6 +130,7 @@ intel_driver_memman_init(intel_driver_t *driver)
> driver->bufmgr = drm_intel_bufmgr_gem_init(driver->fd, BATCH_SIZE);
> assert(driver->bufmgr);
> drm_intel_bufmgr_gem_enable_reuse(driver->bufmgr);
> + driver->device_id = drm_intel_bufmgr_gem_get_devid(driver->bufmgr);
> intel_driver_aub_dump(driver);
> }
>
> @@ -154,11 +155,7 @@ intel_driver_init(intel_driver_t *driver, int dev_fd)
> driver->fd = dev_fd;
> driver->locked = 0;
> pthread_mutex_init(&driver->ctxmutex, NULL);
> -#ifndef NDEBUG
> - int res =
> -#endif /* NDEBUG */
> - intel_driver_get_param(driver, I915_PARAM_CHIPSET_ID, &driver->device_id);
> - assert(res);
> +
> intel_driver_memman_init(driver);
> intel_driver_context_init(driver);
>
> @@ -266,20 +263,6 @@ intel_driver_close(intel_driver_t *intel)
> }
>
> LOCAL int
> -intel_driver_get_param(intel_driver_t *driver, int param, int *value)
> -{
> - int ret;
> - struct drm_i915_getparam gp;
> -
> - memset(&gp, 0, sizeof(struct drm_i915_getparam));
> - gp.param = param;
> - gp.value = value;
> -
> - ret = drmCommandWriteRead(driver->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
> - return ret == 0;
> -}
> -
> -LOCAL int
> intel_driver_is_active(intel_driver_t *driver) {
> return driver->fd >= 0;
> }
> diff --git a/src/intel/intel_driver.h b/src/intel/intel_driver.h
> index 31ebdad..f972ec8 100644
> --- a/src/intel/intel_driver.h
> +++ b/src/intel/intel_driver.h
> @@ -141,9 +141,6 @@ extern int intel_driver_terminate(intel_driver_t*);
> /* simple check if driver was initialized (checking fd should suffice) */
> extern int intel_driver_is_active(intel_driver_t*);
>
> -/* query device parameters using driver ioctl */
> -extern int intel_driver_get_param(intel_driver_t*, int param, int *value);
> -
> /* init the call backs used by the ocl driver */
> extern void intel_setup_callbacks(void);
>
> --
> 2.1.4
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list