From d86989bf73ed342acc5a7db882676909a186d6d4 Mon Sep 17 00:00:00 2001 From: Jianxun Zhang Date: Thu, 6 Jan 2022 10:12:13 -0800 Subject: [PATCH] intel: use PCI info to compute device uuid With the new input from PCI bus and device fields, we can compute device uuids in a multi-gpu system. Signed-off-by: Jianxun Zhang Reviewed-by: Lionel Landwerlin Reviewed-by: Rohan Garg Part-of: --- src/gallium/drivers/crocus/crocus_screen.c | 3 +-- src/gallium/drivers/iris/iris_screen.c | 3 +-- src/intel/common/intel_uuid.c | 33 +++++++++++++++++++----------- src/intel/common/intel_uuid.h | 2 +- src/intel/vulkan/anv_device.c | 2 +- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c index b1e1054..e77b535 100644 --- a/src/gallium/drivers/crocus/crocus_screen.c +++ b/src/gallium/drivers/crocus/crocus_screen.c @@ -109,9 +109,8 @@ static void crocus_get_device_uuid(struct pipe_screen *pscreen, char *uuid) { struct crocus_screen *screen = (struct crocus_screen *)pscreen; - const struct isl_device *isldev = &screen->isl_dev; - intel_uuid_compute_device_id((uint8_t *)uuid, isldev, PIPE_UUID_SIZE); + intel_uuid_compute_device_id((uint8_t *)uuid, &screen->devinfo, PIPE_UUID_SIZE); } static void diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 09c6959..1caae8c 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -105,9 +105,8 @@ static void iris_get_device_uuid(struct pipe_screen *pscreen, char *uuid) { struct iris_screen *screen = (struct iris_screen *)pscreen; - const struct isl_device *isldev = &screen->isl_dev; - intel_uuid_compute_device_id((uint8_t *)uuid, isldev, PIPE_UUID_SIZE); + intel_uuid_compute_device_id((uint8_t *)uuid, &screen->devinfo, PIPE_UUID_SIZE); } static void diff --git a/src/intel/common/intel_uuid.c b/src/intel/common/intel_uuid.c index 661a31e..df24715 100644 --- a/src/intel/common/intel_uuid.c +++ b/src/intel/common/intel_uuid.c @@ -27,26 +27,35 @@ void intel_uuid_compute_device_id(uint8_t *uuid, - const struct isl_device *isldev, + const struct intel_device_info *devinfo, size_t size) { struct mesa_sha1 sha1_ctx; uint8_t sha1[20]; - const struct intel_device_info *devinfo = isldev->info; - + const char *vendor = "INTEL"; assert(size <= sizeof(sha1)); - /* The device UUID uniquely identifies the given device within the machine. - * Since we never have more than one device, this doesn't need to be a real - * UUID. However, on the off-chance that someone tries to use this to - * cache pre-tiled images or something of the like, we use the PCI ID and - * some bits of ISL info to ensure that this is safe. + /* The device UUID uniquely identifies the given device within the + * machine. We use the device information along with PCI information + * to make sure we have different UUIDs on a system with multiple + * identical (discrete) GPUs. */ _mesa_sha1_init(&sha1_ctx); - _mesa_sha1_update(&sha1_ctx, &devinfo->chipset_id, - sizeof(devinfo->chipset_id)); - _mesa_sha1_update(&sha1_ctx, &isldev->has_bit6_swizzling, - sizeof(isldev->has_bit6_swizzling)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_domain, + sizeof(devinfo->pci_domain)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_bus, + sizeof(devinfo->pci_bus)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_dev, + sizeof(devinfo->pci_dev)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_func, + sizeof(devinfo->pci_func)); + _mesa_sha1_update(&sha1_ctx, vendor, strlen(vendor)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_device_id, + sizeof(devinfo->pci_device_id)); + _mesa_sha1_update(&sha1_ctx, &devinfo->pci_revision_id, + sizeof(devinfo->pci_revision_id)); + _mesa_sha1_update(&sha1_ctx, &devinfo->revision, + sizeof(devinfo->revision)); _mesa_sha1_final(&sha1_ctx, sha1); memcpy(uuid, sha1, size); } diff --git a/src/intel/common/intel_uuid.h b/src/intel/common/intel_uuid.h index 28edc44..f5d8d8d 100644 --- a/src/intel/common/intel_uuid.h +++ b/src/intel/common/intel_uuid.h @@ -33,7 +33,7 @@ extern "C" { #endif void intel_uuid_compute_device_id(uint8_t *uuid, - const struct isl_device *isldev, + const struct intel_device_info *devinfo, size_t size); void intel_uuid_compute_driver_id(uint8_t *uuid, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 22e6da5..2ff5667 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -576,7 +576,7 @@ anv_physical_device_init_uuids(struct anv_physical_device *device) memcpy(device->pipeline_cache_uuid, sha1, VK_UUID_SIZE); intel_uuid_compute_driver_id(device->driver_uuid, &device->info, VK_UUID_SIZE); - intel_uuid_compute_device_id(device->device_uuid, &device->isl_dev, VK_UUID_SIZE); + intel_uuid_compute_device_id(device->device_uuid, &device->info, VK_UUID_SIZE); return VK_SUCCESS; } -- 2.7.4