Reduced calls to drm devinfo for getting virtualization_mode

Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: I22a6a9ca15131b37a775e8d4f595fb13c0b043c7


[ROCm/amdsmi commit: 10f9aae0b3]
Этот коммит содержится в:
Maisam Arif
2025-07-11 11:37:23 -05:00
коммит произвёл Arif, Maisam
родитель 35b740f736
Коммит 6531fdd0fb
4 изменённых файлов: 25 добавлений и 9 удалений
+6 -2
Просмотреть файл
@@ -43,6 +43,7 @@ except ImportError as e:
try:
from amdsmi_init import *
from amdsmi_helpers import AMDSMIHelpers
from amdsmi_commands import AMDSMICommands
from amdsmi_parser import AMDSMIParser
from amdsmi_logger import AMDSMILogger
@@ -53,6 +54,7 @@ except ImportError:
sys.path.append(cli_files_path)
try:
from amdsmi_init import *
from amdsmi_helpers import AMDSMIHelpers
from amdsmi_commands import AMDSMICommands
from amdsmi_parser import AMDSMIParser
from amdsmi_logger import AMDSMILogger
@@ -79,7 +81,8 @@ if __name__ == "__main__":
else:
sys.tracebacklimit = -1
amd_smi_commands = AMDSMICommands()
amd_smi_helpers = AMDSMIHelpers()
amd_smi_commands = AMDSMICommands(helpers=amd_smi_helpers)
amd_smi_parser = AMDSMIParser(amd_smi_commands.version,
amd_smi_commands.list,
amd_smi_commands.static,
@@ -97,7 +100,8 @@ if __name__ == "__main__":
amd_smi_commands.partition,
amd_smi_commands.ras,
amd_smi_commands.default,
sys_argv=sys.argv)
sys_argv=sys.argv,
helpers=amd_smi_helpers)
try:
try:
argcomplete.autocomplete(amd_smi_parser)
+7 -3
Просмотреть файл
@@ -41,9 +41,13 @@ class AMDSMICommands():
displaying the output to the specified format and destination.
"""
def __init__(self, format='human_readable', destination='stdout') -> None:
self.helpers = AMDSMIHelpers()
self.logger = AMDSMILogger(format=format, destination=destination)
def __init__(self, format='human_readable', destination='stdout', helpers=None) -> None:
if helpers is None:
# If helpers is not provided, create a new instance
self.helpers = AMDSMIHelpers()
else:
self.helpers = helpers
self.logger = AMDSMILogger(format=format, destination=destination, helpers=self.helpers)
self.device_handles = []
self.cpu_handles = []
self.core_handles = []
+6 -2
Просмотреть файл
@@ -30,7 +30,7 @@ from amdsmi_helpers import AMDSMIHelpers
import amdsmi_cli_exceptions
class AMDSMILogger():
def __init__(self, format='human_readable', destination='stdout') -> None:
def __init__(self, format='human_readable', destination='stdout', helpers=None) -> None:
self.output = {}
self.multiple_device_output = []
self.watch_output = []
@@ -41,7 +41,11 @@ class AMDSMILogger():
self.secondary_table_title = ""
self.secondary_table_header = ""
self.warning_message = ""
self.helpers = AMDSMIHelpers()
if helpers is None:
# If helpers is not provided, create a new instance
self.helpers = AMDSMIHelpers()
else:
self.helpers = helpers
self._cper_exit_message = True
self.store_cpu_json_output = []
self.store_core_json_output = []
+6 -2
Просмотреть файл
@@ -69,10 +69,14 @@ class AMDSMIParser(argparse.ArgumentParser):
"""
def __init__(self, version, list, static, firmware, bad_pages, metric,
process, profile, event, topology, set_value, reset, monitor,
xgmi, partition, ras, default, sys_argv=None):
xgmi, partition, ras, default, sys_argv=None, helpers=None):
# Helper variables
self.helpers = AMDSMIHelpers()
if helpers is None:
# If helpers is not provided, create a new instance
self.helpers = AMDSMIHelpers()
else:
self.helpers = helpers
# Get choices based on driver initialized
if self.helpers.is_amdgpu_initialized():