Re: [Mesa-dev] [PATCH] anv: Implement VK_EXT_pci_bus_info
On Sun, 14 Oct 2018 at 13:56, Jason Ekstrand wrote: > > Here I was reveling in the triviality of my fixed-pci-path implementation > and you had to show me up by implementing it properly. :-P > > Implementing it properly is a better plan because we know discrete is coming. > You're welcome, that's amongst the reasons why I've introduced drmDevice. Even though hearing libdrm does makes us uneasy at times. Fwiw: Reviewed-by: Emil Velikov -Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] anv: Implement VK_EXT_pci_bus_info
Here I was reveling in the triviality of my fixed-pci-path implementation and you had to show me up by implementing it properly. :-P Implementing it properly is a better plan because we know discrete is coming. Reviewed-by: Jason Ekstrand On October 14, 2018 07:12:58 Lionel Landwerlin wrote: Even though the Intel GPU are always at the same PCI location, all the info we need is already provided by libdrm. Let's be future proof. Signed-off-by: Lionel Landwerlin --- src/intel/vulkan/anv_device.c | 24 +++- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_private.h | 6 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 6a24d1086d8..1c7942f1b8e 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -309,9 +309,10 @@ anv_physical_device_free_disk_cache(struct anv_physical_device *device) static VkResult anv_physical_device_init(struct anv_physical_device *device, struct anv_instance *instance, - const char *primary_path, - const char *path) + drmDevicePtr drm_device) { + const char *primary_path = drm_device->nodes[DRM_NODE_PRIMARY]; + const char *path = drm_device->nodes[DRM_NODE_RENDER]; VkResult result; int fd; int master_fd = -1; @@ -342,6 +343,11 @@ anv_physical_device_init(struct anv_physical_device *device, device->no_hw = true; } + device->pci_info.domain = drm_device->businfo.pci->domain; + device->pci_info.bus = drm_device->businfo.pci->bus; + device->pci_info.device = drm_device->businfo.pci->dev; + device->pci_info.function = drm_device->businfo.pci->func; + device->name = gen_get_device_name(device->chipset_id); if (!gen_get_device_info(device->chipset_id, &device->info)) { result = vk_error(VK_ERROR_INCOMPATIBLE_DRIVER); @@ -715,9 +721,7 @@ anv_enumerate_devices(struct anv_instance *instance) devices[i]->deviceinfo.pci->vendor_id == 0x8086) { result = anv_physical_device_init(&instance->physicalDevice, -instance, -devices[i]->nodes[DRM_NODE_PRIMARY], -devices[i]->nodes[DRM_NODE_RENDER]); + instance, devices[i]); if (result != VK_ERROR_INCOMPATIBLE_DRIVER) break; } @@ -1166,6 +1170,16 @@ void anv_GetPhysicalDeviceProperties2( break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: { + VkPhysicalDevicePCIBusInfoPropertiesEXT *properties = +(VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext; + properties->pciDomain = pdevice->pci_info.domain; + properties->pciBus = pdevice->pci_info.bus; + properties->pciDevice = pdevice->pci_info.device; + properties->pciFunction = pdevice->pci_info.function; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES: { VkPhysicalDevicePointClippingProperties *properties = (VkPhysicalDevicePointClippingProperties *) ext; diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index d4915c95013..1329ef74026 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -121,6 +121,7 @@ EXTENSIONS = [ Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_global_priority', 1, 'device->has_context_priority'), +Extension('VK_EXT_pci_bus_info', 1, True), Extension('VK_EXT_shader_viewport_index_layer', 1, True), Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen >= 9'), Extension('VK_EXT_vertex_attribute_divisor', 3, True), diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 5b4c286bf38..763dc9bb4ce 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -841,6 +841,12 @@ struct anv_physical_device { boolno_hw; charpath[20]; const char *name; +struct { + uint16_t domain; + uint8_t bus; + uint8_t device; + uint8_t function; +} pci_info; struct gen_device_info info; /** Amount of "GPU memory" we want to advertise * -- 2.19.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] anv: Implement VK_EXT_pci_bus_info
Even though the Intel GPU are always at the same PCI location, all the info we need is already provided by libdrm. Let's be future proof. Signed-off-by: Lionel Landwerlin --- src/intel/vulkan/anv_device.c | 24 +++- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_private.h | 6 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 6a24d1086d8..1c7942f1b8e 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -309,9 +309,10 @@ anv_physical_device_free_disk_cache(struct anv_physical_device *device) static VkResult anv_physical_device_init(struct anv_physical_device *device, struct anv_instance *instance, - const char *primary_path, - const char *path) + drmDevicePtr drm_device) { + const char *primary_path = drm_device->nodes[DRM_NODE_PRIMARY]; + const char *path = drm_device->nodes[DRM_NODE_RENDER]; VkResult result; int fd; int master_fd = -1; @@ -342,6 +343,11 @@ anv_physical_device_init(struct anv_physical_device *device, device->no_hw = true; } + device->pci_info.domain = drm_device->businfo.pci->domain; + device->pci_info.bus = drm_device->businfo.pci->bus; + device->pci_info.device = drm_device->businfo.pci->dev; + device->pci_info.function = drm_device->businfo.pci->func; + device->name = gen_get_device_name(device->chipset_id); if (!gen_get_device_info(device->chipset_id, &device->info)) { result = vk_error(VK_ERROR_INCOMPATIBLE_DRIVER); @@ -715,9 +721,7 @@ anv_enumerate_devices(struct anv_instance *instance) devices[i]->deviceinfo.pci->vendor_id == 0x8086) { result = anv_physical_device_init(&instance->physicalDevice, -instance, -devices[i]->nodes[DRM_NODE_PRIMARY], -devices[i]->nodes[DRM_NODE_RENDER]); + instance, devices[i]); if (result != VK_ERROR_INCOMPATIBLE_DRIVER) break; } @@ -1166,6 +1170,16 @@ void anv_GetPhysicalDeviceProperties2( break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: { + VkPhysicalDevicePCIBusInfoPropertiesEXT *properties = +(VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext; + properties->pciDomain = pdevice->pci_info.domain; + properties->pciBus = pdevice->pci_info.bus; + properties->pciDevice = pdevice->pci_info.device; + properties->pciFunction = pdevice->pci_info.function; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES: { VkPhysicalDevicePointClippingProperties *properties = (VkPhysicalDevicePointClippingProperties *) ext; diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index d4915c95013..1329ef74026 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -121,6 +121,7 @@ EXTENSIONS = [ Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_global_priority', 1, 'device->has_context_priority'), +Extension('VK_EXT_pci_bus_info', 1, True), Extension('VK_EXT_shader_viewport_index_layer', 1, True), Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen >= 9'), Extension('VK_EXT_vertex_attribute_divisor', 3, True), diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 5b4c286bf38..763dc9bb4ce 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -841,6 +841,12 @@ struct anv_physical_device { boolno_hw; charpath[20]; const char *name; +struct { + uint16_t domain; + uint8_t bus; + uint8_t device; + uint8_t function; +} pci_info; struct gen_device_info info; /** Amount of "GPU memory" we want to advertise * -- 2.19.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] anv: Implement VK_EXT_pci_bus_info
This is trivial for us to implement because Intel integrated GPUs have always been at :00:02.0. One of these days, when we actually ship a discrete GPU, we'll have to implement it for real but right now we can just hard code it. --- src/intel/vulkan/anv_device.c | 11 +++ src/intel/vulkan/anv_extensions.py | 1 + 2 files changed, 12 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 6a24d1086d8..92644778982 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1166,6 +1166,17 @@ void anv_GetPhysicalDeviceProperties2( break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: { + VkPhysicalDevicePCIBusInfoPropertiesEXT *properties = +(VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext; + /* Intel integrated GPUs have always been at :00:02.0 */ + properties->pciDomain = 0; + properties->pciBus = 0; + properties->pciDevice = 2; + properties->pciFunction = 0; + break; + } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES: { VkPhysicalDevicePointClippingProperties *properties = (VkPhysicalDevicePointClippingProperties *) ext; diff --git a/src/intel/vulkan/anv_extensions.py b/src/intel/vulkan/anv_extensions.py index d4915c95013..1329ef74026 100644 --- a/src/intel/vulkan/anv_extensions.py +++ b/src/intel/vulkan/anv_extensions.py @@ -121,6 +121,7 @@ EXTENSIONS = [ Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_global_priority', 1, 'device->has_context_priority'), +Extension('VK_EXT_pci_bus_info', 1, True), Extension('VK_EXT_shader_viewport_index_layer', 1, True), Extension('VK_EXT_shader_stencil_export', 1, 'device->info.gen >= 9'), Extension('VK_EXT_vertex_attribute_divisor', 3, True), -- 2.19.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev