intel/dev: Split hwconfig i915 specific code

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20437>
This commit is contained in:
José Roberto de Souza 2022-09-22 11:31:01 -07:00 committed by Marge Bot
parent b3b769894e
commit c1d99283e6
5 changed files with 30 additions and 27 deletions

View file

@ -541,12 +541,15 @@ fixup_chv_device_info(struct intel_device_info *devinfo)
bool intel_device_info_i915_get_info_from_fd(int fd, struct intel_device_info *devinfo)
{
if (intel_get_and_process_hwconfig_table(fd, devinfo)) {
/* After applying hwconfig values, some items need to be recalculated. */
devinfo->max_cs_threads =
devinfo->max_eus_per_subslice * devinfo->num_thread_per_eu;
void *hwconfig_blob;
int32_t len;
intel_device_info_update_cs_workgroup_threads(devinfo);
hwconfig_blob = intel_i915_query_alloc(fd, DRM_I915_QUERY_HWCONFIG_BLOB, &len);
if (hwconfig_blob) {
if (intel_hwconfig_process_table(devinfo, hwconfig_blob, len))
intel_device_info_update_after_hwconfig(devinfo);
free(hwconfig_blob);
}
int val;

View file

@ -1557,3 +1557,13 @@ bool intel_device_info_update_memory_info(struct intel_device_info *devinfo, int
return intel_device_info_i915_query_regions(devinfo, fd, true) ||
intel_device_info_compute_system_memory(devinfo, true);
}
void
intel_device_info_update_after_hwconfig(struct intel_device_info *devinfo)
{
/* After applying hwconfig values, some items need to be recalculated. */
devinfo->max_cs_threads =
devinfo->max_eus_per_subslice * devinfo->num_thread_per_eu;
intel_device_info_update_cs_workgroup_threads(devinfo);
}

View file

@ -545,6 +545,7 @@ void intel_device_info_update_pixel_pipes(struct intel_device_info *devinfo, uin
void intel_device_info_update_l3_banks(struct intel_device_info *devinfo);
void intel_device_info_update_cs_workgroup_threads(struct intel_device_info *devinfo);
bool intel_device_info_compute_system_memory(struct intel_device_info *devinfo, bool update);
void intel_device_info_update_after_hwconfig(struct intel_device_info *devinfo);
#ifdef __cplusplus
}

View file

@ -131,10 +131,10 @@ typedef void (*hwconfig_item_cb)(struct intel_device_info *devinfo,
const struct hwconfig *item);
static void
intel_process_hwconfig_table(struct intel_device_info *devinfo,
const struct hwconfig *hwconfig,
int32_t hwconfig_len,
hwconfig_item_cb item_callback_func)
process_hwconfig_table(struct intel_device_info *devinfo,
const struct hwconfig *hwconfig,
int32_t hwconfig_len,
hwconfig_item_cb item_callback_func)
{
assert(hwconfig);
assert(hwconfig_len % 4 == 0);
@ -271,22 +271,12 @@ apply_hwconfig_item(struct intel_device_info *devinfo,
}
bool
intel_get_and_process_hwconfig_table(int fd,
struct intel_device_info *devinfo)
intel_hwconfig_process_table(struct intel_device_info *devinfo,
void *data, int32_t len)
{
struct hwconfig *hwconfig;
int32_t hwconfig_len = 0;
hwconfig = intel_i915_query_alloc(fd, DRM_I915_QUERY_HWCONFIG_BLOB,
&hwconfig_len);
if (hwconfig) {
intel_process_hwconfig_table(devinfo, hwconfig, hwconfig_len,
apply_hwconfig_item);
free(hwconfig);
if (devinfo->apply_hwconfig)
return true;
}
process_hwconfig_table(devinfo, data, len, apply_hwconfig_item);
return false;
return devinfo->apply_hwconfig;
}
static void
@ -304,8 +294,7 @@ static void
intel_print_hwconfig_table(const struct hwconfig *hwconfig,
int32_t hwconfig_len)
{
intel_process_hwconfig_table(NULL, hwconfig, hwconfig_len,
print_hwconfig_item);
process_hwconfig_table(NULL, hwconfig, hwconfig_len, print_hwconfig_item);
}
void

View file

@ -35,8 +35,8 @@ extern "C" {
struct intel_device_info;
bool
intel_get_and_process_hwconfig_table(int fd,
struct intel_device_info *devinfo);
intel_hwconfig_process_table(struct intel_device_info *devinfo, void *data,
int32_t len);
void
intel_get_and_print_hwconfig_table(int fd);