Mesa (main): intel: Parse INTEL_NO_HW for devinfo construction

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 24 00:23:36 UTC 2021


Module: Mesa
Branch: main
Commit: 2944f49610e7f0d627a257216210afa668eb7a88
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2944f49610e7f0d627a257216210afa668eb7a88

Author: Nanley Chery <nanley.g.chery at intel.com>
Date:   Wed Jul 21 16:50:32 2021 -0700

intel: Parse INTEL_NO_HW for devinfo construction

This commit does several things:

* Unify code common to several drivers by evaluating INTEL_NO_HW within
  intel_get_device_info_from_fd (suggested by Jordan).
* For drivers that keep a copy of the intel_device_info struct, a
  separate copy of the no_hw field is now unnecessary. Remove them.
* Minimize kernel queries when INTEL_NO_HW is true. This is done for
  code simplification, but we may find reason to undo this later on.

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12007>

---

 src/gallium/drivers/crocus/crocus_batch.c  | 2 +-
 src/gallium/drivers/crocus/crocus_query.c  | 2 +-
 src/gallium/drivers/crocus/crocus_screen.c | 3 ---
 src/gallium/drivers/crocus/crocus_screen.h | 2 --
 src/gallium/drivers/iris/iris_batch.c      | 2 +-
 src/gallium/drivers/iris/iris_query.c      | 2 +-
 src/gallium/drivers/iris/iris_screen.c     | 3 ---
 src/gallium/drivers/iris/iris_screen.h     | 2 --
 src/intel/dev/intel_device_info.c          | 3 ++-
 src/intel/vulkan/anv_batch_chain.c         | 4 ++--
 src/intel/vulkan/anv_device.c              | 4 ----
 src/intel/vulkan/anv_private.h             | 2 --
 src/intel/vulkan/anv_queue.c               | 8 ++++----
 src/mesa/drivers/dri/i965/brw_batch.c      | 2 +-
 src/mesa/drivers/dri/i965/brw_screen.c     | 5 +----
 src/mesa/drivers/dri/i965/brw_screen.h     | 1 -
 16 files changed, 14 insertions(+), 33 deletions(-)

diff --git a/src/gallium/drivers/crocus/crocus_batch.c b/src/gallium/drivers/crocus/crocus_batch.c
index 0cf32c69e58..e4e132fd11a 100644
--- a/src/gallium/drivers/crocus/crocus_batch.c
+++ b/src/gallium/drivers/crocus/crocus_batch.c
@@ -881,7 +881,7 @@ submit_batch(struct crocus_batch *batch)
    }
 
    int ret = 0;
-   if (!batch->screen->no_hw &&
+   if (!batch->screen->devinfo.no_hw &&
        intel_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
       ret = -errno;
 
diff --git a/src/gallium/drivers/crocus/crocus_query.c b/src/gallium/drivers/crocus/crocus_query.c
index df3f3103647..e31f2ef668b 100644
--- a/src/gallium/drivers/crocus/crocus_query.c
+++ b/src/gallium/drivers/crocus/crocus_query.c
@@ -659,7 +659,7 @@ crocus_get_query_result(struct pipe_context *ctx,
    struct crocus_screen *screen = (void *) ctx->screen;
    const struct intel_device_info *devinfo = &screen->devinfo;
 
-   if (unlikely(screen->no_hw)) {
+   if (unlikely(screen->devinfo.no_hw)) {
       result->u64 = 0;
       return true;
    }
diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c
index e91bd62f5bd..ebd8af75c88 100644
--- a/src/gallium/drivers/crocus/crocus_screen.c
+++ b/src/gallium/drivers/crocus/crocus_screen.c
@@ -746,7 +746,6 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
    if (!intel_get_device_info_from_fd(fd, &screen->devinfo))
       return NULL;
    screen->pci_id = screen->devinfo.chipset_id;
-   screen->no_hw = screen->devinfo.no_hw;
 
    if (screen->devinfo.ver > 8)
       return NULL;
@@ -762,8 +761,6 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
 
    screen->aperture_bytes = get_aperture_size(fd);
 
-   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
-
    driParseConfigFiles(config->options, config->options_info, 0, "crocus",
                        NULL, NULL, NULL, 0, NULL, 0);
 
diff --git a/src/gallium/drivers/crocus/crocus_screen.h b/src/gallium/drivers/crocus/crocus_screen.h
index 652f81388b8..5e6c4179647 100644
--- a/src/gallium/drivers/crocus/crocus_screen.h
+++ b/src/gallium/drivers/crocus/crocus_screen.h
@@ -185,8 +185,6 @@ struct crocus_screen {
    /** PCI ID for our GPU device */
    int pci_id;
 
-   bool no_hw;
-
    struct crocus_vtable vtbl;
 
    /** Global program_string_id counter (see get_program_string_id()) */
diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c
index bc5b58670dc..c600ee55e8e 100644
--- a/src/gallium/drivers/iris/iris_batch.c
+++ b/src/gallium/drivers/iris/iris_batch.c
@@ -667,7 +667,7 @@ submit_batch(struct iris_batch *batch)
    }
 
    int ret = 0;
-   if (!batch->screen->no_hw &&
+   if (!batch->screen->devinfo.no_hw &&
        intel_ioctl(batch->screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
       ret = -errno;
 
diff --git a/src/gallium/drivers/iris/iris_query.c b/src/gallium/drivers/iris/iris_query.c
index ee80b2ff2cd..e497b71a45d 100644
--- a/src/gallium/drivers/iris/iris_query.c
+++ b/src/gallium/drivers/iris/iris_query.c
@@ -612,7 +612,7 @@ iris_get_query_result(struct pipe_context *ctx,
    struct iris_screen *screen = (void *) ctx->screen;
    const struct intel_device_info *devinfo = &screen->devinfo;
 
-   if (unlikely(screen->no_hw)) {
+   if (unlikely(screen->devinfo.no_hw)) {
       result->u64 = 0;
       return true;
    }
diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
index f45b414c274..bd6ed55d677 100644
--- a/src/gallium/drivers/iris/iris_screen.c
+++ b/src/gallium/drivers/iris/iris_screen.c
@@ -804,7 +804,6 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
    if (!intel_get_device_info_from_fd(fd, &screen->devinfo))
       return NULL;
    screen->pci_id = screen->devinfo.chipset_id;
-   screen->no_hw = screen->devinfo.no_hw;
 
    p_atomic_set(&screen->refcount, 1);
 
@@ -831,8 +830,6 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
    screen->fd = iris_bufmgr_get_fd(screen->bufmgr);
    screen->winsys_fd = fd;
 
-   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
-
    screen->workaround_bo =
       iris_bo_alloc(screen->bufmgr, "workaround", 4096, 1,
                     IRIS_MEMZONE_OTHER, 0);
diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h
index a1c0588ecdf..82fd1d31e62 100644
--- a/src/gallium/drivers/iris/iris_screen.h
+++ b/src/gallium/drivers/iris/iris_screen.h
@@ -164,8 +164,6 @@ struct iris_screen {
    /** PCI ID for our GPU device */
    int pci_id;
 
-   bool no_hw;
-
    struct iris_vtable vtbl;
 
    /** Global program_string_id counter (see get_program_string_id()) */
diff --git a/src/intel/dev/intel_device_info.c b/src/intel/dev/intel_device_info.c
index 6dccd94707f..01c85aed2b5 100644
--- a/src/intel/dev/intel_device_info.c
+++ b/src/intel/dev/intel_device_info.c
@@ -31,6 +31,7 @@
 #include "compiler/shader_enums.h"
 #include "intel/common/intel_gem.h"
 #include "util/bitscan.h"
+#include "util/debug.h"
 #include "util/log.h"
 #include "util/macros.h"
 
@@ -1495,7 +1496,7 @@ intel_get_device_info_from_fd(int fd, struct intel_device_info *devinfo)
          return false;
       if (!intel_get_device_info_from_pci_id(devid, devinfo))
          return false;
-      devinfo->no_hw = false;
+      devinfo->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
    }
 
    if (devinfo->ver == 10) {
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 128fba79e9e..e7eda9bf9fa 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -2040,13 +2040,13 @@ anv_queue_execbuf_locked(struct anv_queue *queue,
          .rsvd1 = device->context_id,
       };
 
-      int ret = queue->device->no_hw ? 0 :
+      int ret = queue->device->info.no_hw ? 0 :
          anv_gem_execbuffer(queue->device, &query_pass_execbuf);
       if (ret)
          result = anv_queue_set_lost(queue, "execbuf2 failed: %m");
    }
 
-   int ret = queue->device->no_hw ? 0 :
+   int ret = queue->device->info.no_hw ? 0 :
       anv_gem_execbuffer(queue->device, &execbuf.execbuf);
    if (ret)
       result = anv_queue_set_lost(queue, "execbuf2 failed: %m");
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index d60c03ac726..d466a6197c2 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -812,9 +812,6 @@ anv_physical_device_try_create(struct anv_instance *instance,
 
    device->info = devinfo;
 
-   device->no_hw =
-      device->info.no_hw || env_var_as_boolean("INTEL_NO_HW", false);
-
    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;
@@ -3238,7 +3235,6 @@ VkResult anv_CreateDevice(
    }
 
    device->physical = physical_device;
-   device->no_hw = physical_device->no_hw;
    device->_lost = false;
 
    /* XXX(chadv): Can we dup() physicalDevice->fd here? */
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 801c8e8f57f..6888b63eb92 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -893,7 +893,6 @@ struct anv_physical_device {
     struct list_head                            link;
 
     struct anv_instance *                       instance;
-    bool                                        no_hw;
     char                                        path[20];
     struct {
        uint16_t                                 domain;
@@ -1190,7 +1189,6 @@ struct anv_device {
     struct vk_device                            vk;
 
     struct anv_physical_device *                physical;
-    bool                                        no_hw;
     struct intel_device_info                      info;
     struct isl_device                           isl_dev;
     int                                         context_id;
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index bbeb5056c8e..f94223b1a30 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -389,7 +389,7 @@ anv_queue_task(void *_queue)
           * fail because the dma-fence it depends on hasn't materialized yet.
           */
          if (!queue->lost && submit->wait_timeline_count > 0) {
-            int ret = queue->device->no_hw ? 0 :
+            int ret = queue->device->info.no_hw ? 0 :
                anv_gem_syncobj_timeline_wait(
                   queue->device, submit->wait_timeline_syncobjs,
                   submit->wait_timeline_values, submit->wait_timeline_count,
@@ -734,7 +734,7 @@ VkResult
 anv_queue_submit_simple_batch(struct anv_queue *queue,
                               struct anv_batch *batch)
 {
-   if (queue->device->no_hw)
+   if (queue->device->info.no_hw)
       return VK_SUCCESS;
 
    struct anv_device *device = queue->device;
@@ -1223,7 +1223,7 @@ VkResult anv_QueueSubmit(
    ANV_FROM_HANDLE(anv_fence, fence, _fence);
    struct anv_device *device = queue->device;
 
-   if (device->no_hw)
+   if (device->info.no_hw)
       return VK_SUCCESS;
 
    /* Query for device status prior to submitting.  Technically, we don't need
@@ -1846,7 +1846,7 @@ VkResult anv_WaitForFences(
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
 
-   if (device->no_hw)
+   if (device->info.no_hw)
       return VK_SUCCESS;
 
    if (anv_device_is_lost(device))
diff --git a/src/mesa/drivers/dri/i965/brw_batch.c b/src/mesa/drivers/dri/i965/brw_batch.c
index c3c1267b0ad..b51704f54e8 100644
--- a/src/mesa/drivers/dri/i965/brw_batch.c
+++ b/src/mesa/drivers/dri/i965/brw_batch.c
@@ -791,7 +791,7 @@ submit_batch(struct brw_context *brw, int in_fence_fd, int *out_fence_fd)
    brw_bo_unmap(batch->batch.bo);
    brw_bo_unmap(batch->state.bo);
 
-   if (!brw->screen->no_hw) {
+   if (!brw->screen->devinfo.no_hw) {
       /* The requirement for using I915_EXEC_NO_RELOC are:
        *
        *   The addresses written in the objects must match the corresponding
diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c
index 8d032797e8f..08f86ab7e3b 100644
--- a/src/mesa/drivers/dri/i965/brw_screen.c
+++ b/src/mesa/drivers/dri/i965/brw_screen.c
@@ -1889,8 +1889,6 @@ brw_init_bufmgr(struct brw_screen *screen)
 {
    __DRIscreen *dri_screen = screen->driScrnPriv;
 
-   screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false);
-
    bool bo_reuse = false;
    int bo_reuse_mode = driQueryOptioni(&screen->optionCache, "bo_reuse");
    switch (bo_reuse_mode) {
@@ -2003,7 +2001,7 @@ static bool
 brw_detect_pipelined_register(struct brw_screen *screen,
                                 int reg, uint32_t expected_value, bool reset)
 {
-   if (screen->no_hw)
+   if (screen->devinfo.no_hw)
       return false;
 
    struct brw_bo *results, *bo;
@@ -2553,7 +2551,6 @@ __DRIconfig **brw_init_screen(__DRIscreen *dri_screen)
 
    const struct intel_device_info *devinfo = &screen->devinfo;
    screen->deviceID = devinfo->chipset_id;
-   screen->no_hw = devinfo->no_hw;
 
    if (devinfo->ver >= 12) {
       fprintf(stderr, "gfx12 and newer are not supported on i965\n");
diff --git a/src/mesa/drivers/dri/i965/brw_screen.h b/src/mesa/drivers/dri/i965/brw_screen.h
index cb3d34f148e..9ee24d06a11 100644
--- a/src/mesa/drivers/dri/i965/brw_screen.h
+++ b/src/mesa/drivers/dri/i965/brw_screen.h
@@ -59,7 +59,6 @@ struct brw_screen
    /** DRM fd associated with this screen. Not owned by this object. Do not close. */
    int fd;
 
-   bool no_hw;
    bool hw_has_swizzling;
    bool has_exec_fence; /**< I915_PARAM_HAS_EXEC_FENCE */
 



More information about the mesa-commit mailing list