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@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12007>
This commit is contained in:
Nanley Chery 2021-07-21 16:50:32 -07:00 committed by Marge Bot
parent 7d59a66e3a
commit 2944f49610
16 changed files with 14 additions and 33 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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()) */

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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()) */

View File

@ -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) {

View File

@ -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");

View File

@ -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? */

View File

@ -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;

View File

@ -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))

View File

@ -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

View File

@ -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");

View File

@ -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 */