hv: vtd: allocate drhd_dev_scope based on board file

Determine the size of drhd_dev_scope based on DRHD_MAX_DEVSCOPE_COUNT
in board file instead of hardcoding. The current default value 16 will
be used if it is not defined in board file to keep compatibility, a
warning will be raised in this case.

Tracked-On: #8494
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Jiaqing Zhao 2024-08-01 08:06:15 +00:00 committed by acrnsi-robot
parent 65f84d6ae6
commit 5c351bee0f
2 changed files with 15 additions and 2 deletions

View File

@ -473,7 +473,7 @@ static inline uint16_t dma_frcd_up_sid(uint64_t up_sid)
}
#define MAX_DRHDS DRHD_COUNT
#define MAX_DRHD_DEVSCOPES 16U
#define MAX_DRHD_DEVSCOPES DRHD_MAX_DEVSCOPE_COUNT
#define DMAR_CONTEXT_TRANSLATION_TYPE_TRANSLATED 0x00U
#define DMAR_CONTEXT_TRANSLATION_TYPE_RESERVED 0x01U

View File

@ -3,6 +3,8 @@
# SPDX-License-Identifier: BSD-3-Clause
#
import logging
import board_cfg_lib
import acrn_config_utilities
@ -190,7 +192,7 @@ def drhd_info_parser(config):
Parse DRHD information
:param config: it is a file pointer to write acpi information
"""
prev_num = 0
has_drhd_max_devscope_count = False
drhd_lines = board_cfg_lib.get_info(
acrn_config_utilities.BOARD_INFO_FILE, "<DRHD_INFO>", "</DRHD_INFO>")
@ -200,7 +202,18 @@ def drhd_info_parser(config):
if not drhd_lines:
print("\n#define DRHD_COUNT\t\t8U", file=config)
print("\n#define DRHD_MAX_DEVSCOPE_COUNT\t16U", file=config)
return
for drhd in drhd_lines:
if "DRHD_MAX_DEVSCOPE_COUNT" in drhd:
has_drhd_max_devscope_count = True
break
if not has_drhd_max_devscope_count:
logging.warning("DRHD_MAX_DEVSCOPE_COUNT is not defined in board.xml, using default 16U. "
"Generate board.xml with latest board inspector to remove this warning.")
print("\n#define DRHD_MAX_DEVSCOPE_COUNT\t16U", file=config)
for drhd in drhd_lines:
print(drhd.strip(), file=config)