intel/tools: load json device info in drm_shim

Enable drm_shim to parse a serialized intel_device_info structure from
json.  When overriding the gpu hardware, drm_shim provides the stubbed
intel_device_info structure to mesa through an unused ioctl.

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27557>
This commit is contained in:
Mark Janes
2023-09-19 15:20:33 -07:00
committed by Marge Bot
parent 56da473b6f
commit f95b87a3dc
4 changed files with 76 additions and 14 deletions
+17
View File
@@ -35,6 +35,7 @@
#include "i915/intel_device_info.h"
#include "xe/intel_device_info.h"
#include "common/intel_gem.h"
#include "util/u_debug.h"
#include "util/log.h"
#include "util/macros.h"
@@ -1631,6 +1632,21 @@ intel_device_info_calc_engine_prefetch(const struct intel_device_info *devinfo,
bool
intel_get_device_info_from_fd(int fd, struct intel_device_info *devinfo, int min_ver, int max_ver)
{
if (NULL != getenv("INTEL_STUB_GPU_JSON")) {
/* This call will succeed when shim-drm has been initialized with a
* serialized intel_device_info structure.
*/
struct drm_intel_stub_devinfo arg = {
.addr = (uintptr_t)devinfo,
.size = sizeof(*devinfo),
};
if (0 == intel_ioctl(fd, DRM_IOCTL_INTEL_STUB_DEVINFO, &arg)) {
intel_device_info_init_was(devinfo);
intel_device_info_apply_workarounds(devinfo);
return true;
}
}
/* Get PCI info.
*
* Some callers may already have a valid drm device which holds values of
@@ -1780,3 +1796,4 @@ intel_device_info_wa_stepping(struct intel_device_info *devinfo)
/* all other platforms support only released steppings */
return INTEL_STEPPING_RELEASE;
}