mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-28 20:30:25 +01:00
turnip: Implement pipe-less param query.
This commit is contained in:
parent
b0562e272f
commit
6401ad389e
3 changed files with 31 additions and 15 deletions
|
|
@ -149,7 +149,6 @@ tu_physical_device_init(struct tu_physical_device *device,
|
|||
drmVersionPtr version;
|
||||
int fd;
|
||||
int master_fd = -1;
|
||||
struct fd_pipe *tmp_pipe = NULL;
|
||||
uint64_t val;
|
||||
|
||||
fd = open(path, O_RDWR | O_CLOEXEC);
|
||||
|
|
@ -214,35 +213,31 @@ tu_physical_device_init(struct tu_physical_device *device,
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -285,8 +280,6 @@ tu_physical_device_init(struct tu_physical_device *device,
|
|||
return VK_SUCCESS;
|
||||
|
||||
fail:
|
||||
if (tmp_pipe)
|
||||
fd_pipe_del(tmp_pipe);
|
||||
if (device->drm_device)
|
||||
fd_device_del(device->drm_device);
|
||||
close(fd);
|
||||
|
|
|
|||
|
|
@ -92,3 +92,24 @@ tu_gem_info_iova(struct tu_device *dev, uint32_t gem_handle)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1203,6 +1203,8 @@ uint64_t
|
|||
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) \
|
||||
\
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue