Commit 17479b77 authored by Yusuf Khan's avatar Yusuf Khan
Browse files

nvk: bring the duplicate fd creation out of the winsys



Signed-off-by: Yusuf Khan's avatarYusuf Khan <yusisamerican@gmail.com>
parent 165e9883
Pipeline #702754 waiting for manual action with stages
in 7 seconds
......@@ -8,6 +8,8 @@
#include "nvk_shader.h"
#include "nvk_wsi.h"
#include "util/os_file.h"
#include "vulkan/runtime/vk_device.h"
#include "vulkan/wsi/wsi_common.h"
......@@ -306,9 +308,10 @@ nvk_physical_device_try_create(struct nvk_instance *instance,
instance, VK_ERROR_INCOMPATIBLE_DRIVER, "Unable to open device %s: %m", path);
}
struct nouveau_ws_device *ndev = nouveau_ws_device_new(fd);
int dup_fd = os_dupfd_cloexec(fd);
struct nouveau_ws_device *ndev = nouveau_ws_device_new(dup_fd);
if (!ndev)
ndev = ogk_ws_device_new(fd);
ndev = ogk_ws_device_new(dup_fd);
if (!ndev) {
result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
......@@ -404,6 +407,7 @@ fail_dev_alloc:
fail_fd:
close(fd);
close(dup_fd);
return result;
}
......
......@@ -184,10 +184,9 @@ nouveau_ws_device_new(int fd)
{
struct nouveau_ws_device *device = CALLOC_STRUCT(nouveau_ws_device);
uint64_t value = 0;
int dup_fd = os_dupfd_cloexec(fd);
drmVersionPtr ver;
ver = drmGetVersion(dup_fd);
ver = drmGetVersion(fd);
if (!ver)
return NULL;
......@@ -200,22 +199,22 @@ nouveau_ws_device_new(int fd)
if (version < 0x01000301)
goto out_drm;
if (nouveau_ws_device_alloc(dup_fd, device))
if (nouveau_ws_device_alloc(fd, device))
goto out_drm;
if (nouveau_ws_device_info(dup_fd, device))
if (nouveau_ws_device_info(fd, device))
goto out_drm;
if (nouveau_ws_param(dup_fd, NOUVEAU_GETPARAM_PCI_DEVICE, &value))
if (nouveau_ws_param(fd, NOUVEAU_GETPARAM_PCI_DEVICE, &value))
goto out_dev;
device->device_id = value;
if (nouveau_ws_param(dup_fd, NOUVEAU_GETPARAM_AGP_SIZE, &value))
if (nouveau_ws_param(fd, NOUVEAU_GETPARAM_AGP_SIZE, &value))
goto out_dev;
os_get_available_system_memory(&device->gart_size);
device->gart_size = MIN2(device->gart_size, value);
device->fd = dup_fd;
device->fd = fd;
device->vendor_id = 0x10de;
device->winsys = NVK_WINSYS_NOUVEAU;
device->cm = sm_for_chipset(device->chipset);
......@@ -226,7 +225,7 @@ nouveau_ws_device_new(int fd)
else
device->local_mem_domain = NOUVEAU_WS_GEM_DOMAIN_VRAM;
if (nouveau_ws_param(dup_fd, NOUVEAU_GETPARAM_GRAPH_UNITS, &value))
if (nouveau_ws_param(fd, NOUVEAU_GETPARAM_GRAPH_UNITS, &value))
goto out_dev;
device->gpc_count = value & 0x000000ff;
device->mp_count = value >> 8;
......@@ -250,7 +249,6 @@ nouveau_ws_device_new(int fd)
out_dev:
FREE(device);
out_drm:
close(dup_fd);
return NULL;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment