drmVersionPtr version;
int fd;
int master_fd = -1;
- struct fd_pipe *tmp_pipe = NULL;
uint64_t val;
fd = open(path, O_RDWR | O_CLOEXEC);
device->drm_device = fd_device_new_dup(fd);
if (!device->drm_device) {
+ if (instance->debug_flags & TU_DEBUG_STARTUP)
+ tu_logi("Could not create the libdrm device");
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not create the libdrm device");
goto fail;
}
- tmp_pipe = fd_pipe_new(device->drm_device, FD_PIPE_3D);
- if (!tmp_pipe) {
- result = vk_errorf(
- instance, VK_ERROR_INITIALIZATION_FAILED, "could not open the 3D pipe");
- goto fail;
- }
-
- if (fd_pipe_get_param(tmp_pipe, FD_GPU_ID, &val)) {
+ if (tu_drm_query_param(device, MSM_PARAM_GPU_ID, &val)) {
+ if (instance->debug_flags & TU_DEBUG_STARTUP)
+ tu_logi("Could not query the GPU ID");
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GPU ID");
goto fail;
}
device->gpu_id = val;
- if (fd_pipe_get_param(tmp_pipe, FD_GMEM_SIZE, &val)) {
+ if (tu_drm_query_param(device, MSM_PARAM_GMEM_SIZE, &val)) {
+ if (instance->debug_flags & TU_DEBUG_STARTUP)
+ tu_logi("Could not query the GMEM size");
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size");
goto fail;
}
device->gmem_size = val;
- fd_pipe_del(tmp_pipe);
- tmp_pipe = NULL;
-
memset(device->name, 0, sizeof(device->name));
sprintf(device->name, "FD%d", device->gpu_id);
return VK_SUCCESS;
fail:
- if (tmp_pipe)
- fd_pipe_del(tmp_pipe);
if (device->drm_device)
fd_device_del(device->drm_device);
close(fd);
{
return tu_gem_info(dev, gem_handle, MSM_INFO_IOVA);
}
+
+
+int
+tu_drm_query_param(struct tu_physical_device *dev, uint32_t param, uint64_t *value)
+{
+ /* Technically this requires a pipe, but the kernel only supports one pipe anyway
+ * at the time of writing and most of these are clearly pipe independent. */
+ struct drm_msm_param req = {
+ .pipe = MSM_PIPE_3D0,
+ .param = param,
+ };
+
+ int ret = drmCommandWriteRead(dev->local_fd, DRM_MSM_GET_PARAM,
+ &req, sizeof(req));
+ if (ret)
+ return ret;
+
+ *value = req.value;
+
+ return 0;
+}
tu_gem_info_offset(struct tu_device *dev, uint32_t gem_handle);
uint64_t
tu_gem_info_iova(struct tu_device *dev, uint32_t gem_handle);
+int
+tu_drm_query_param(struct tu_physical_device *dev, uint32_t param, uint64_t *value);
#define TU_DEFINE_HANDLE_CASTS(__tu_type, __VkType) \
\