intel/dev: Put the device name in intel_device_info
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 13 Jul 2021 22:56:01 +0000 (17:56 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 14 Jul 2021 23:02:34 +0000 (23:02 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11861>

src/gallium/drivers/crocus/crocus_screen.c
src/gallium/drivers/iris/iris_screen.c
src/intel/dev/intel_dev_info.c
src/intel/dev/intel_device_info.c
src/intel/dev/intel_device_info.h
src/intel/tools/aubinator.c
src/intel/tools/aubinator_viewer.cpp
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h
src/mesa/drivers/dri/i965/brw_context.c

index 3e85b7d..c1e0cf3 100644 (file)
@@ -127,14 +127,10 @@ static const char *
 crocus_get_name(struct pipe_screen *pscreen)
 {
    struct crocus_screen *screen = (struct crocus_screen *)pscreen;
+   const struct intel_device_info *devinfo = &screen->devinfo;
    static char buf[128];
 
-   const char *name = intel_get_device_name(screen->pci_id);
-
-   if (!name)
-      name = "Intel Unknown";
-
-   snprintf(buf, sizeof(buf), "Mesa %s", name);
+   snprintf(buf, sizeof(buf), "Mesa %s", devinfo->name);
    return buf;
 }
 
index e5fe4ac..f9df596 100644 (file)
@@ -144,13 +144,10 @@ static const char *
 iris_get_name(struct pipe_screen *pscreen)
 {
    struct iris_screen *screen = (struct iris_screen *)pscreen;
+   const struct intel_device_info *devinfo = &screen->devinfo;
    static char buf[128];
-   const char *name = intel_get_device_name(screen->pci_id);
-
-   if (!name)
-      name = "Intel Unknown";
 
-   snprintf(buf, sizeof(buf), "Mesa %s", name);
+   snprintf(buf, sizeof(buf), "Mesa %s", devinfo->name);
    return buf;
 }
 
index 39da00b..2c06731 100644 (file)
@@ -72,7 +72,7 @@ main(int argc, char *argv[])
 
       fprintf(stdout, "%s:\n", path);
 
-      fprintf(stdout, "   name: %s\n", intel_get_device_name(devinfo.chipset_id));
+      fprintf(stdout, "   name: %s\n", devinfo.name);
       fprintf(stdout, "   gen: %u\n", devinfo.ver);
       fprintf(stdout, "   PCI id: 0x%x\n", devinfo.chipset_id);
       fprintf(stdout, "   revision: %u\n", devinfo.revision);
index c4279d2..442d7e9 100644 (file)
@@ -1249,6 +1249,21 @@ intel_get_device_info_from_pci_id(int pci_id,
       return false;
    }
 
+   switch (pci_id) {
+#undef CHIPSET
+#define CHIPSET(_id, _family, _fam_str, _name) \
+   case _id: \
+      /* sizeof(str_literal) includes the null */ \
+      STATIC_ASSERT(sizeof(_name) + sizeof(_fam_str) + 2 <= \
+                    sizeof(devinfo->name)); \
+      strncpy(devinfo->name, _name " (" _fam_str ")", sizeof(devinfo->name)); \
+      break;
+#include "pci_ids/i965_pci_ids.h"
+#include "pci_ids/iris_pci_ids.h"
+   default:
+      strncpy(devinfo->name, "Intel Unknown", sizeof(devinfo->name));
+   }
+
    fill_masks(devinfo);
 
    /* From the Skylake PRM, 3DSTATE_PS::Scratch Space Base Pointer:
@@ -1291,19 +1306,6 @@ intel_get_device_info_from_pci_id(int pci_id,
    return true;
 }
 
-const char *
-intel_get_device_name(int devid)
-{
-   switch (devid) {
-#undef CHIPSET
-#define CHIPSET(id, family, fam_str, name) case id: return name " (" fam_str ")"; break;
-#include "pci_ids/i965_pci_ids.h"
-#include "pci_ids/iris_pci_ids.h"
-   default:
-      return NULL;
-   }
-}
-
 /**
  * for gfx8/gfx9, SLICE_MASK/SUBSLICE_MASK can be used to compute the topology
  * (kernel 4.13+)
index ebb779e..12a62b7 100644 (file)
@@ -36,6 +36,7 @@ extern "C" {
 
 struct drm_i915_query_topology_info;
 
+#define INTEL_DEVICE_MAX_NAME_SIZE        64
 #define INTEL_DEVICE_MAX_SLICES           (6)  /* Maximum on gfx10 */
 #define INTEL_DEVICE_MAX_SUBSLICES        (8)  /* Maximum on gfx11 */
 #define INTEL_DEVICE_MAX_EUS_PER_SUBSLICE (16) /* Maximum on gfx12 */
@@ -279,6 +280,11 @@ struct intel_device_info
    uint32_t chipset_id;
 
    /**
+    * holds the name of the device
+    */
+   char name[INTEL_DEVICE_MAX_NAME_SIZE];
+
+   /**
     * no_hw is true when the chipset_id pci device id has been overridden
     */
    bool no_hw;
@@ -345,7 +351,6 @@ intel_device_info_num_dual_subslices(UNUSED
 }
 
 int intel_device_name_to_pci_device_id(const char *name);
-const char *intel_get_device_name(int devid);
 
 static inline uint64_t
 intel_device_info_timebase_scale(const struct intel_device_info *devinfo,
index 5c0885a..fb0a952 100644 (file)
@@ -122,7 +122,7 @@ aubinator_init(void *user_data, int aub_pci_id, const char *app_name)
 
    fprintf(outfile, "Application name: %s\n", app_name);
 
-   fprintf(outfile, "Decoding as:      %s\n", intel_get_device_name(pci_id));
+   fprintf(outfile, "Decoding as:      %s\n", devinfo.name);
 
    /* Throw in a new line before the first batch */
    fprintf(outfile, "\n");
index 8d68fdf..493eb9c 100644 (file)
@@ -1006,7 +1006,7 @@ display_aubfile_window(struct window *win)
    ImGui::Text("Execbufs          %u", context.file->n_execs);
    ImGui::Text("PCI ID:           0x%x", context.file->pci_id);
    ImGui::Text("Application name: %s", context.file->app_name);
-   ImGui::Text("%s", intel_get_device_name(context.file->pci_id));
+   ImGui::Text("%s", context.file->devinfo.name);
 
    ImGui::SetNextWindowContentWidth(500);
    if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
index f39b7f7..deb9c89 100644 (file)
@@ -741,8 +741,6 @@ anv_physical_device_try_create(struct anv_instance *instance,
       goto fail_fd;
    }
 
-   const char *device_name = intel_get_device_name(devinfo.chipset_id);
-
    if (devinfo.is_haswell) {
       mesa_logw("Haswell Vulkan support is incomplete");
    } else if (devinfo.ver == 7 && !devinfo.is_baytrail) {
@@ -753,7 +751,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
       /* Gfx8-12 fully supported */
    } else {
       result = vk_errorfi(instance, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,
-                          "Vulkan not yet supported on %s", device_name);
+                          "Vulkan not yet supported on %s", devinfo.name);
       goto fail_fd;
    }
 
@@ -782,7 +780,6 @@ anv_physical_device_try_create(struct anv_instance *instance,
    snprintf(device->path, ARRAY_SIZE(device->path), "%s", path);
 
    device->info = devinfo;
-   device->name = device_name;
 
    device->no_hw = device->info.no_hw;
    if (getenv("INTEL_NO_HW") != NULL)
@@ -2042,7 +2039,7 @@ void anv_GetPhysicalDeviceProperties(
    };
 
    snprintf(pProperties->deviceName, sizeof(pProperties->deviceName),
-            "%s", pdevice->name);
+            "%s", pdevice->info.name);
    memcpy(pProperties->pipelineCacheUUID,
           pdevice->pipeline_cache_uuid, VK_UUID_SIZE);
 }
index c2971de..3717f18 100644 (file)
@@ -893,7 +893,6 @@ struct anv_physical_device {
     struct anv_instance *                       instance;
     bool                                        no_hw;
     char                                        path[20];
-    const char *                                name;
     struct {
        uint16_t                                 domain;
        uint8_t                                  bus;
index 392c644..410412a 100644 (file)
@@ -106,7 +106,7 @@ const char *
 brw_get_renderer_string(const struct brw_screen *screen)
 {
    static char buf[128];
-   const char *name = intel_get_device_name(screen->deviceID);
+   const char *name = screen->devinfo.name;
 
    if (!name)
       name = "Intel Unknown";