From 7d59a66e3a4d011880faa44aca662514ccf5fdd8 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Wed, 21 Jul 2021 14:37:04 -0700 Subject: [PATCH] intel: Use env_var_as_boolean for INTEL_NO_HW The prior method of checking the result of getenv() for NULL would cause the feature to be enabled for INTEL_NO_HW=0. Reviewed-by: Kenneth Graunke Reviewed-by: Caio Marcelo de Oliveira Filho Reviewed-by: Jordan Justen Part-of: --- docs/envvars.rst | 4 ++-- src/gallium/drivers/crocus/crocus_screen.c | 3 +-- src/gallium/drivers/iris/iris_screen.c | 3 +-- src/intel/vulkan/anv_device.c | 5 ++--- src/mesa/drivers/dri/i915/intel_screen.c | 3 ++- src/mesa/drivers/dri/i965/brw_screen.c | 3 +-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/envvars.rst b/docs/envvars.rst index 598d452b45d..34fe9f9a668 100644 --- a/docs/envvars.rst +++ b/docs/envvars.rst @@ -236,8 +236,8 @@ i945/i965 driver environment variables (non-Gallium) ---------------------------------------------------- :envvar:`INTEL_NO_HW` - if set to 1, prevents batches from being submitted to the hardware. - This is useful for debugging hangs, etc. + if set to 1, true or yes, prevents batches from being submitted to the + hardware. This is useful for debugging hangs, etc. :envvar:`INTEL_DEBUG` a comma-separated list of named flags, which do various things: diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c index 7a741e98f35..e91bd62f5bd 100644 --- a/src/gallium/drivers/crocus/crocus_screen.c +++ b/src/gallium/drivers/crocus/crocus_screen.c @@ -762,8 +762,7 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config) screen->aperture_bytes = get_aperture_size(fd); - if (getenv("INTEL_NO_HW") != NULL) - screen->no_hw = true; + 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/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 8ea97a2e2be..f45b414c274 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -831,8 +831,7 @@ iris_screen_create(int fd, const struct pipe_screen_config *config) screen->fd = iris_bufmgr_get_fd(screen->bufmgr); screen->winsys_fd = fd; - if (getenv("INTEL_NO_HW") != NULL) - screen->no_hw = true; + screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false); screen->workaround_bo = iris_bo_alloc(screen->bufmgr, "workaround", 4096, 1, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 3eb71eeb095..d60c03ac726 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -812,9 +812,8 @@ anv_physical_device_try_create(struct anv_instance *instance, device->info = devinfo; - device->no_hw = device->info.no_hw; - if (getenv("INTEL_NO_HW") != NULL) - device->no_hw = true; + 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; diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c index 6135357c2a0..5ac199c2c25 100644 --- a/src/mesa/drivers/dri/i915/intel_screen.c +++ b/src/mesa/drivers/dri/i915/intel_screen.c @@ -40,6 +40,7 @@ #include "swrast/s_renderbuffer.h" #include "utils.h" +#include "util/debug.h" #include "util/driconf.h" #include "util/u_memory.h" @@ -1019,7 +1020,7 @@ intel_init_bufmgr(struct intel_screen *intelScreen) { __DRIscreen *spriv = intelScreen->driScrnPriv; - intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL; + intelScreen->no_hw = env_var_as_boolean("INTEL_NO_HW", false); intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ); if (intelScreen->bufmgr == NULL) { diff --git a/src/mesa/drivers/dri/i965/brw_screen.c b/src/mesa/drivers/dri/i965/brw_screen.c index 227d31d59c3..8d032797e8f 100644 --- a/src/mesa/drivers/dri/i965/brw_screen.c +++ b/src/mesa/drivers/dri/i965/brw_screen.c @@ -1889,8 +1889,7 @@ brw_init_bufmgr(struct brw_screen *screen) { __DRIscreen *dri_screen = screen->driScrnPriv; - if (getenv("INTEL_NO_HW") != NULL) - screen->no_hw = true; + screen->no_hw = env_var_as_boolean("INTEL_NO_HW", false); bool bo_reuse = false; int bo_reuse_mode = driQueryOptioni(&screen->optionCache, "bo_reuse"); -- 2.34.1