summaryrefslogtreecommitdiff
path: root/src/intel/intel_driver.c
diff options
context:
space:
mode:
authorRebecca N. Palmer <rebecca_palmer@zoho.com>2015-02-26 17:14:12 +0000
committerZhigang Gong <zhigang.gong@intel.com>2015-02-27 14:15:57 +0800
commit065366d7dd04baa0fe7a3f2c2b262629491c9b92 (patch)
tree58eebdd1289a38755d862dae796977f5f64279bc /src/intel/intel_driver.c
parenta5cf29363f2e11cbe604b3861878b56cb238f407 (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>
Diffstat (limited to 'src/intel/intel_driver.c')
-rw-r--r--src/intel/intel_driver.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index 1862021e..ff0cf275 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
@@ -185,6 +186,7 @@ intel_driver_init(intel_driver_t *driver, int dev_fd)
else
driver->gen_ver = 4;
#endif /* EMULATE_GEN */
+ return 1;
}
static cl_int
@@ -273,19 +275,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;
@@ -298,7 +301,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);
@@ -311,26 +314,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