intel: fix for a semantic change in libdrm 2.4.57 and later
When a client does
xglInitAndEnumerateGpus();
xglCreateDevice();
// do something
// reinitialize without xglDestroyDevice() first!
xglInitAndEnumerateGpus();
xglCreateDevice();
// do something else
the driver will
open()
close()
open()
close()
on the DRM device. The problem is that the two open()s may return the same
value and confuse libdrm since 2.4.57 (specifically, commit 743af59669).
Making intel_winsys intel_gpu-owned allows the driver to do this instead
open()
intel_winsys_create_for_fd()
intel_winsys_destroy()
close()
open()
intel_winsys_create_for_fd()
intel_winsys_destroy()
close()
diff --git a/icd/intel/dev.c b/icd/intel/dev.c
index a00914f..9c3766f 100644
--- a/icd/intel/dev.c
+++ b/icd/intel/dev.c
@@ -74,7 +74,7 @@
XGL_UINT i;
XGL_RESULT ret;
- if (gpu->device_fd >= 0)
+ if (gpu->winsys)
return XGL_ERROR_DEVICE_ALREADY_CREATED;
dev = (struct intel_dev *) intel_base_create(NULL, sizeof(*dev),
@@ -101,13 +101,7 @@
return ret;
}
- dev->winsys = intel_winsys_create_for_fd(gpu->device_fd);
- if (!dev->winsys) {
- icd_log(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, XGL_NULL_HANDLE,
- 0, 0, "failed to create device winsys");
- intel_dev_destroy(dev);
- return XGL_ERROR_UNKNOWN;
- }
+ dev->winsys = gpu->winsys;
dev->cmd_scratch_bo = intel_winsys_alloc_buffer(dev->winsys,
"command buffer scratch", 4096, false);
@@ -145,6 +139,7 @@
void intel_dev_destroy(struct intel_dev *dev)
{
+ struct intel_gpu *gpu = dev->gpu;
XGL_UINT i;
if (dev->base.dbg)
@@ -158,13 +153,10 @@
if (dev->cmd_scratch_bo)
intel_bo_unreference(dev->cmd_scratch_bo);
- if (dev->winsys)
- intel_winsys_destroy(dev->winsys);
-
- if (dev->gpu->device_fd >= 0)
- intel_gpu_close(dev->gpu);
-
intel_base_destroy(&dev->base);
+
+ if (gpu->winsys)
+ intel_gpu_close(dev->gpu);
}
void intel_dev_get_heap_props(const struct intel_dev *dev,