As well as allowing a hexadecimal PCI ID number, the
INTEL_DEVID_OVERRIDE environment variable can now contain one of a few
short codenames. The codenames are stored in a small table to map them
to a corresponding PCI ID. This makes it easier to use without having
to look up the PCI IDs manually.

The PCI IDs used are the same as those chosen for the -p option of
run.c in shader-db but SKL has been added as well.
---
 intel/intel_bufmgr_gem.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index 63122d0..ad8ae5b 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -2866,6 +2866,33 @@ drm_intel_bufmgr_gem_set_vma_cache_size(drm_intel_bufmgr 
*bufmgr, int limit)
        drm_intel_gem_bo_purge_vma_cache(bufmgr_gem);
 }

+static int
+parse_devid_override(const char *devid_override)
+{
+       static const struct {
+               const char *name;
+               int pci_id;
+       } name_map[] = {
+               { "i965", PCI_CHIP_I965_GM },
+               { "g4x", PCI_CHIP_GM45_GM },
+               { "ilk", PCI_CHIP_ILD_G },
+               { "snb", PCI_CHIP_SANDYBRIDGE_M_GT2_PLUS },
+               { "ivb", PCI_CHIP_IVYBRIDGE_S_GT2 },
+               { "hsw", PCI_CHIP_HASWELL_CRW_E_GT3 },
+               { "byt", PCI_CHIP_VALLEYVIEW_3 },
+               { "bdw", 0x1620 | BDW_ULX },
+               { "skl", PCI_CHIP_SKYLAKE_DT_GT2 },
+       };
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(name_map); i++) {
+               if (!strcmp(name_map[i].name, devid_override))
+                       return name_map[i].pci_id;
+       }
+
+       return strtod(devid_override, NULL);
+}
+
 /**
  * Get the PCI ID for the device.  This can be overridden by setting the
  * INTEL_DEVID_OVERRIDE environment variable to the desired ID.
@@ -2882,7 +2909,7 @@ get_pci_device_id(drm_intel_bufmgr_gem *bufmgr_gem)
                devid_override = getenv("INTEL_DEVID_OVERRIDE");
                if (devid_override) {
                        bufmgr_gem->no_exec = true;
-                       return strtod(devid_override, NULL);
+                       return parse_devid_override(devid_override);
                }
        }

-- 
1.9.3

Reply via email to