From 086c486a75fe64440cb1e76de47b3838215246b1 Mon Sep 17 00:00:00 2001 From: Mark Janes Date: Thu, 25 Jul 2019 15:57:30 -0700 Subject: [PATCH] intel/device: rename gen_get_device_info Rename the original device info initialization routine so callers don't mistakenly call the wrong one: gen_get_device_info_from_fd: Queries kernel for full device info, including topology details. gen_get_device_info_from_pci_id: Partially initializes device info based on PCI ID lookup, when the kernel is not available. Reviewed-by: Kenneth Graunke Reviewed-by: Lionel Landwerlin --- src/intel/common/tests/gen_mi_builder_test.cpp | 2 +- src/intel/compiler/test_eu_validate.cpp | 2 +- src/intel/dev/gen_device_info.c | 13 +++++++------ src/intel/dev/gen_device_info.h | 3 ++- src/intel/dev/gen_device_info_test.c | 2 +- .../isl/tests/isl_surf_get_image_offset_test.c | 6 +++--- src/intel/tools/aub_read.c | 4 ++-- src/intel/tools/aub_write.c | 2 +- src/intel/tools/aubinator.c | 2 +- src/intel/tools/aubinator_error_decode.c | 2 +- src/intel/tools/i965_asm.c | 2 +- src/intel/tools/i965_disasm.c | 2 +- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/intel/common/tests/gen_mi_builder_test.cpp b/src/intel/common/tests/gen_mi_builder_test.cpp index c0902294931..4002619dc8e 100644 --- a/src/intel/common/tests/gen_mi_builder_test.cpp +++ b/src/intel/common/tests/gen_mi_builder_test.cpp @@ -182,7 +182,7 @@ gen_mi_builder_test::SetUp() ASSERT_EQ(drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, (void *)&getparam), 0) << strerror(errno); - ASSERT_TRUE(gen_get_device_info(device_id, &devinfo)); + ASSERT_TRUE(gen_get_device_info_from_pci_id(device_id, &devinfo)); if (devinfo.gen != GEN_GEN || devinfo.is_haswell != GEN_IS_HASWELL) { close(fd); fd = -1; diff --git a/src/intel/compiler/test_eu_validate.cpp b/src/intel/compiler/test_eu_validate.cpp index efdae4fd79b..7a1cc5216fc 100644 --- a/src/intel/compiler/test_eu_validate.cpp +++ b/src/intel/compiler/test_eu_validate.cpp @@ -75,7 +75,7 @@ void validation_test::SetUp() struct gen_info info = GetParam(); int devid = gen_device_name_to_pci_device_id(info.name); - gen_get_device_info(devid, &devinfo); + gen_get_device_info_from_pci_id(devid, &devinfo); brw_init_codegen(&devinfo, p, p); } diff --git a/src/intel/dev/gen_device_info.c b/src/intel/dev/gen_device_info.c index 79ec4e0262d..462a906d08d 100644 --- a/src/intel/dev/gen_device_info.c +++ b/src/intel/dev/gen_device_info.c @@ -1202,15 +1202,16 @@ getparam(int fd, uint32_t param, int *value) } bool -gen_get_device_info(int devid, struct gen_device_info *devinfo) +gen_get_device_info_from_pci_id(int pci_id, + struct gen_device_info *devinfo) { - switch (devid) { + switch (pci_id) { #undef CHIPSET #define CHIPSET(id, family, name) \ case id: *devinfo = gen_device_info_##family; break; #include "pci_ids/i965_pci_ids.h" default: - fprintf(stderr, "Driver does not support the 0x%x PCI ID.\n", devid); + fprintf(stderr, "Driver does not support the 0x%x PCI ID.\n", pci_id); return false; } @@ -1248,7 +1249,7 @@ gen_get_device_info(int devid, struct gen_device_info *devinfo) assert(devinfo->num_slices <= ARRAY_SIZE(devinfo->num_subslices)); - devinfo->chipset_id = devid; + devinfo->chipset_id = pci_id; return true; } @@ -1328,14 +1329,14 @@ gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) { int devid = gen_get_pci_device_id_override(); if (devid > 0) { - if (!gen_get_device_info(devid, devinfo)) + if (!gen_get_device_info_from_pci_id(devid, devinfo)) return false; devinfo->no_hw = true; } else { /* query the device id */ if (!getparam(fd, I915_PARAM_CHIPSET_ID, &devid)) return false; - if (!gen_get_device_info(devid, devinfo)) + if (!gen_get_device_info_from_pci_id(devid, devinfo)) return false; devinfo->no_hw = false; } diff --git a/src/intel/dev/gen_device_info.h b/src/intel/dev/gen_device_info.h index d1c7230b0ff..bf5347432a5 100644 --- a/src/intel/dev/gen_device_info.h +++ b/src/intel/dev/gen_device_info.h @@ -273,7 +273,6 @@ gen_device_info_subslice_available(const struct gen_device_info *devinfo, int gen_get_pci_device_id_override(void); int gen_device_name_to_pci_device_id(const char *name); -bool gen_get_device_info(int devid, struct gen_device_info *devinfo); const char *gen_get_device_name(int devid); /* Used with SLICE_MASK/SUBSLICE_MASK values from DRM_I915_GETPARAM. */ @@ -293,6 +292,8 @@ gen_device_info_timebase_scale(const struct gen_device_info *devinfo, } bool gen_get_device_info_from_fd(int fh, struct gen_device_info *devinfo); +bool gen_get_device_info_from_pci_id(int pci_id, + struct gen_device_info *devinfo); #ifdef __cplusplus } diff --git a/src/intel/dev/gen_device_info_test.c b/src/intel/dev/gen_device_info_test.c index 6d7d279f98c..495772f1848 100644 --- a/src/intel/dev/gen_device_info_test.c +++ b/src/intel/dev/gen_device_info_test.c @@ -20,7 +20,7 @@ main(int argc, char *argv[]) for (uint32_t i = 0; i < ARRAY_SIZE(chipsets); i++) { struct gen_device_info devinfo = { 0, }; - assert(gen_get_device_info(chipsets[i].pci_id, &devinfo)); + assert(gen_get_device_info_from_pci_id(chipsets[i].pci_id, &devinfo)); assert(devinfo.gen != 0); assert(devinfo.urb.size != 0); diff --git a/src/intel/isl/tests/isl_surf_get_image_offset_test.c b/src/intel/isl/tests/isl_surf_get_image_offset_test.c index 703f176c6b3..6e5a76e7736 100644 --- a/src/intel/isl/tests/isl_surf_get_image_offset_test.c +++ b/src/intel/isl/tests/isl_surf_get_image_offset_test.c @@ -125,7 +125,7 @@ test_bdw_2d_r8g8b8a8_unorm_512x512_array01_samples01_noaux_tiley0(void) bool ok; struct gen_device_info devinfo; - t_assert(gen_get_device_info(BDW_GT2_DEVID, &devinfo)); + t_assert(gen_get_device_info_from_pci_id(BDW_GT2_DEVID, &devinfo)); struct isl_device dev; isl_device_init(&dev, &devinfo, /*bit6_swizzle*/ false); @@ -173,7 +173,7 @@ test_bdw_2d_r8g8b8a8_unorm_1024x1024_array06_samples01_noaux_tiley0(void) bool ok; struct gen_device_info devinfo; - t_assert(gen_get_device_info(BDW_GT2_DEVID, &devinfo)); + t_assert(gen_get_device_info_from_pci_id(BDW_GT2_DEVID, &devinfo)); struct isl_device dev; isl_device_init(&dev, &devinfo, /*bit6_swizzle*/ false); @@ -234,7 +234,7 @@ test_bdw_3d_r8g8b8a8_unorm_256x256x256_levels09_tiley0(void) bool ok; struct gen_device_info devinfo; - t_assert(gen_get_device_info(BDW_GT2_DEVID, &devinfo)); + t_assert(gen_get_device_info_from_pci_id(BDW_GT2_DEVID, &devinfo)); struct isl_device dev; isl_device_init(&dev, &devinfo, /*bit6_swizzle*/ false); diff --git a/src/intel/tools/aub_read.c b/src/intel/tools/aub_read.c index de1057b7fe4..a98e2c38180 100644 --- a/src/intel/tools/aub_read.c +++ b/src/intel/tools/aub_read.c @@ -87,7 +87,7 @@ handle_trace_header(struct aub_read *read, const uint32_t *p) if (end > &p[12] && p[12] > 0) { if (sscanf((char *)&p[13], "PCI-ID=%i", &aub_pci_id) > 0) { - if (!gen_get_device_info(aub_pci_id, &read->devinfo)) { + if (!gen_get_device_info_from_pci_id(aub_pci_id, &read->devinfo)) { parse_error(read, p, "can't find device information: pci_id=0x%x\n", aub_pci_id); return false; @@ -118,7 +118,7 @@ handle_memtrace_version(struct aub_read *read, const uint32_t *p) app_name[app_name_len] = 0; if (sscanf(app_name, "PCI-ID=%i %n", &aub_pci_id, &pci_id_len) > 0) { - if (!gen_get_device_info(aub_pci_id, &read->devinfo)) { + if (!gen_get_device_info_from_pci_id(aub_pci_id, &read->devinfo)) { parse_error(read, p, "can't find device information: pci_id=0x%x\n", aub_pci_id); return false; } diff --git a/src/intel/tools/aub_write.c b/src/intel/tools/aub_write.c index dcbde639214..c4d1cbbbfb7 100644 --- a/src/intel/tools/aub_write.c +++ b/src/intel/tools/aub_write.c @@ -172,7 +172,7 @@ aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, co aub->verbose_log_file = debug; aub->file = file; aub->pci_id = pci_id; - fail_if(!gen_get_device_info(pci_id, &aub->devinfo), + fail_if(!gen_get_device_info_from_pci_id(pci_id, &aub->devinfo), "failed to identify chipset=0x%x\n", pci_id); aub->addr_bits = aub->devinfo.gen >= 8 ? 48 : 32; diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c index e8c3db71f0e..4b4ba48445e 100644 --- a/src/intel/tools/aubinator.c +++ b/src/intel/tools/aubinator.c @@ -78,7 +78,7 @@ aubinator_init(void *user_data, int aub_pci_id, const char *app_name) { pci_id = aub_pci_id; - if (!gen_get_device_info(pci_id, &devinfo)) { + if (!gen_get_device_info_from_pci_id(pci_id, &devinfo)) { fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id); exit(EXIT_FAILURE); } diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index 147b580de3b..35e049cfad9 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -490,7 +490,7 @@ read_data_file(FILE *file) matched = sscanf(pci_id_start, "PCI ID: 0x%04x\n", ®); } if (matched == 1) { - if (!gen_get_device_info(reg, &devinfo)) { + if (!gen_get_device_info_from_pci_id(reg, &devinfo)) { printf("Unable to identify devid=%x\n", reg); exit(EXIT_FAILURE); } diff --git a/src/intel/tools/i965_asm.c b/src/intel/tools/i965_asm.c index a8e7fe6eff0..74891d145cf 100644 --- a/src/intel/tools/i965_asm.c +++ b/src/intel/tools/i965_asm.c @@ -79,7 +79,7 @@ i965_disasm_init(uint16_t pci_id) if (devinfo == NULL) return NULL; - if (!gen_get_device_info(pci_id, devinfo)) { + if (!gen_get_device_info_from_pci_id(pci_id, devinfo)) { fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id); free(devinfo); diff --git a/src/intel/tools/i965_disasm.c b/src/intel/tools/i965_disasm.c index 5fe4afa35ff..bf9aee7b355 100644 --- a/src/intel/tools/i965_disasm.c +++ b/src/intel/tools/i965_disasm.c @@ -74,7 +74,7 @@ i965_disasm_init(uint16_t pci_id) if (devinfo == NULL) return NULL; - if (!gen_get_device_info(pci_id, devinfo)) { + if (!gen_get_device_info_from_pci_id(pci_id, devinfo)) { fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id); exit(EXIT_FAILURE); -- 2.30.2