From 9846c4e13e07ac79284ff72e0b78b356339e2d08 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 20 Jul 2023 11:30:01 -0500 Subject: [PATCH] nouveau: Put PCI info in a pci substruct in nv_device_info We separate out device_id because even non-PCI devices have one. Part-of: --- src/nouveau/nvidia-headers/nv_device_info.h | 24 ++++++++++++++++-------- src/nouveau/vulkan/nvk_physical_device.c | 10 +++++----- src/nouveau/vulkan/nvk_private.h | 2 -- src/nouveau/winsys/nouveau_device.c | 21 ++++++++++++--------- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/nouveau/nvidia-headers/nv_device_info.h b/src/nouveau/nvidia-headers/nv_device_info.h index cc08702..7fc82e5 100644 --- a/src/nouveau/nvidia-headers/nv_device_info.h +++ b/src/nouveau/nvidia-headers/nv_device_info.h @@ -1,22 +1,30 @@ #ifndef NV_DEVINFO_H #define NV_DEVINFO_H -enum nv_device_type { +#include "util/macros.h" + +#define NVIDIA_VENDOR_ID 0x10de + +enum PACKED nv_device_type { NV_DEVICE_TYPE_IGP, NV_DEVICE_TYPE_DIS, NV_DEVICE_TYPE_SOC, }; struct nv_device_info { - uint16_t pci_domain; - uint8_t pci_bus; - uint8_t pci_dev; - uint8_t pci_func; - uint16_t pci_device_id; - uint8_t pci_revision_id; - enum nv_device_type type; + uint16_t device_id; + + /* Populated if type == NV_DEVICE_TYPE_DIS */ + struct { + uint16_t domain; + uint8_t bus; + uint8_t dev; + uint8_t func; + uint8_t revision_id; + } pci; + uint16_t cls_copy; uint16_t cls_eng2d; uint16_t cls_eng3d; diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 19fd445..3517a45 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -252,10 +252,10 @@ nvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: { VkPhysicalDevicePCIBusInfoPropertiesEXT *p = (void *)ext; assert(pdev->info.type == NV_DEVICE_TYPE_DIS); - p->pciDomain = pdev->info.pci_domain; - p->pciBus = pdev->info.pci_bus; - p->pciDevice = pdev->info.pci_dev; - p->pciFunction = pdev->info.pci_func; + p->pciDomain = pdev->info.pci.domain; + p->pciBus = pdev->info.pci.bus; + p->pciDevice = pdev->info.pci.dev; + p->pciFunction = pdev->info.pci.func; break; } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT: { @@ -658,7 +658,7 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, uint8_t pad[12]; } dev_uuid = { .vendor_id = NVIDIA_VENDOR_ID, - .device_id = pdev->info.pci_device_id, + .device_id = pdev->info.device_id, }; STATIC_ASSERT(sizeof(dev_uuid) == VK_UUID_SIZE); memcpy(pdev->device_uuid, &dev_uuid, VK_UUID_SIZE); diff --git a/src/nouveau/vulkan/nvk_private.h b/src/nouveau/vulkan/nvk_private.h index b86ed76..e322bfb 100644 --- a/src/nouveau/vulkan/nvk_private.h +++ b/src/nouveau/vulkan/nvk_private.h @@ -15,8 +15,6 @@ #include #include -#define NVIDIA_VENDOR_ID 0x10de - #define NVK_MAX_SETS 8 #define NVK_MAX_PUSH_SIZE 128 #define NVK_MAX_DYNAMIC_BUFFERS 64 diff --git a/src/nouveau/winsys/nouveau_device.c b/src/nouveau/winsys/nouveau_device.c index 56aa68a..32117ea 100644 --- a/src/nouveau/winsys/nouveau_device.c +++ b/src/nouveau/winsys/nouveau_device.c @@ -217,15 +217,6 @@ nouveau_ws_device_new(drmDevicePtr drm_device) if (version < 0x01000301) goto out_err; - device->info = (struct nv_device_info) { - .pci_domain = drm_device->businfo.pci->domain, - .pci_bus = drm_device->businfo.pci->bus, - .pci_dev = drm_device->businfo.pci->dev, - .pci_func = drm_device->businfo.pci->func, - .pci_device_id = drm_device->deviceinfo.pci->device_id, - .pci_revision_id = drm_device->deviceinfo.pci->revision_id, - }; - if (nouveau_ws_device_alloc(fd, device)) goto out_err; @@ -236,6 +227,18 @@ nouveau_ws_device_new(drmDevicePtr drm_device) goto out_err; device->device_id = value; + device->info.device_id = value; + if (drm_device->bustype == DRM_BUS_PCI) { + assert(device->info.type == NV_DEVICE_TYPE_DIS); + assert(device->info.device_id == drm_device->deviceinfo.pci->device_id); + + device->info.pci.domain = drm_device->businfo.pci->domain; + device->info.pci.bus = drm_device->businfo.pci->bus; + device->info.pci.dev = drm_device->businfo.pci->dev; + device->info.pci.func = drm_device->businfo.pci->func; + device->info.pci.revision_id = drm_device->deviceinfo.pci->revision_id; + }; + if (nouveau_ws_param(fd, NOUVEAU_GETPARAM_AGP_SIZE, &value)) goto out_err; os_get_available_system_memory(&device->gart_size); -- 2.7.4