diff options
author | Rebecca N. Palmer <rebecca_palmer@zoho.com> | 2015-02-26 17:14:12 +0000 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-02-27 14:10:38 +0800 |
commit | f858dc200d09e6c445349367f76cad893ea73eb3 (patch) | |
tree | da997affd489023f641e12c829ed852c4f8a7b64 | |
parent | d0496e65006002a75090bdc2c4099ff2cb3d8d44 (diff) |
Crash when hardware inaccessible
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=779213
Summary: On hardware where the Intel GPU is disabled, beignet was found
to assert-fail on load, taking the application down with it before it
can do anything (including checking for hardware via clGetDeviceIDs).
This fixes this crash, allowing existing error handling to return
CL_DEVICE_NOT_FOUND, and the application to then try other ICDs until
it finds the right one for the hardware.
Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | src/intel/intel_driver.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c index 21546d98..ea71cfe4 100644 --- a/src/intel/intel_driver.c +++ b/src/intel/intel_driver.c @@ -124,14 +124,15 @@ intel_driver_aub_dump(intel_driver_t *driver) } } -static void +static int intel_driver_memman_init(intel_driver_t *driver) { driver->bufmgr = drm_intel_bufmgr_gem_init(driver->fd, BATCH_SIZE); - assert(driver->bufmgr); + if (!driver->bufmgr) return 0; drm_intel_bufmgr_gem_enable_reuse(driver->bufmgr); driver->device_id = drm_intel_bufmgr_gem_get_devid(driver->bufmgr); intel_driver_aub_dump(driver); + return 1; } static void @@ -149,14 +150,14 @@ intel_driver_context_destroy(intel_driver_t *driver) driver->ctx = NULL; } -static void +static int intel_driver_init(intel_driver_t *driver, int dev_fd) { driver->fd = dev_fd; driver->locked = 0; pthread_mutex_init(&driver->ctxmutex, NULL); - intel_driver_memman_init(driver); + if (!intel_driver_memman_init(driver)) return 0; intel_driver_context_init(driver); #if EMULATE_GEN @@ -183,6 +184,7 @@ intel_driver_init(intel_driver_t *driver, int dev_fd) else driver->gen_ver = 4; #endif /* EMULATE_GEN */ + return 1; } static cl_int @@ -271,19 +273,20 @@ intel_driver_is_active(intel_driver_t *driver) { LOCAL int intel_driver_init_shared(intel_driver_t *driver, dri_state_t *state) { + int ret; assert(state); if(state->driConnectedFlag != DRI2) return 0; - intel_driver_init(driver, state->fd); + ret = intel_driver_init(driver, state->fd); driver->need_close = 0; - return 1; + return ret; } #endif LOCAL int intel_driver_init_master(intel_driver_t *driver, const char* dev_name) { - int dev_fd; + int dev_fd, ret; drm_client_t client; @@ -296,7 +299,7 @@ intel_driver_init_master(intel_driver_t *driver, const char* dev_name) // Check that we're authenticated memset(&client, 0, sizeof(drm_client_t)); - int ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client); + ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client); if (ret == -1) { fprintf(stderr, "ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client) failed: %s\n", strerror(errno)); close(dev_fd); @@ -309,26 +312,26 @@ intel_driver_init_master(intel_driver_t *driver, const char* dev_name) return 0; } - intel_driver_init(driver, dev_fd); + ret = intel_driver_init(driver, dev_fd); driver->need_close = 1; - return 1; + return ret; } LOCAL int intel_driver_init_render(intel_driver_t *driver, const char* dev_name) { - int dev_fd; + int dev_fd, ret; // usually dev_name = "/dev/dri/renderD%d" dev_fd = open(dev_name, O_RDWR); if (dev_fd == -1) return 0; - intel_driver_init(driver, dev_fd); + ret = intel_driver_init(driver, dev_fd); driver->need_close = 1; - return 1; + return ret; } LOCAL int |