From bcc8358d93ad92dd0c95e353bd2cc1ff0fb174b5 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Mon, 9 Aug 2021 16:22:36 +0800 Subject: [PATCH] board-inspector: fixes to issues when parsing host-bridge objects When parsing an AML object representing a host bridge, the current board inspector may encounter the following issues: 1. The host DSDT may contain multiple host bridge instances, with some of them not being present. In this case the _BBN of these instances may evaluate to the same value that coincide with the bus assigned to an existing host bridge, leading to multiple PCI bus nodes with the same bus number and thus confusion in later information extraction phases. 2. Methods of a host bridge may refer to the PCI configuration space of itself (which is typically Device 0, Function 0 under that bus). However, such objects may not have an _ADR object as the bus number is encoded by the _BBN object instead. This patch fixes the issues above. Tracked-On: #6287 Signed-off-by: Junjie Mao --- .../board_inspector/acpiparser/aml/interpreter.py | 6 +++++- misc/config_tools/board_inspector/extractors/50-acpi.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/config_tools/board_inspector/acpiparser/aml/interpreter.py b/misc/config_tools/board_inspector/acpiparser/aml/interpreter.py index d1106c626..a3f901ec9 100644 --- a/misc/config_tools/board_inspector/acpiparser/aml/interpreter.py +++ b/misc/config_tools/board_inspector/acpiparser/aml/interpreter.py @@ -329,7 +329,11 @@ class ConcreteInterpreter(Interpreter): self.context.change_scope(tree.scope) device_path = self.context.parent(sym.name) bus_id = self.interpret_method_call(f"_BBN").get() - device_id = self.interpret_method_call(f"{device_path}._ADR").get() + if self.context.has_symbol(f"{device_path}._ADR"): + device_id = self.interpret_method_call(f"{device_path}._ADR").get() + elif self.context.has_symbol(f"{device_path}._BBN"): + # Device objects representing PCI host bridges may not have an _ADR object + device_id = 0 self.context.pop_scope() op_region = OperationRegion.open_pci_configuration_space(bus_id, device_id, offset, length) pass diff --git a/misc/config_tools/board_inspector/extractors/50-acpi.py b/misc/config_tools/board_inspector/extractors/50-acpi.py index df7869239..5c970483c 100644 --- a/misc/config_tools/board_inspector/extractors/50-acpi.py +++ b/misc/config_tools/board_inspector/extractors/50-acpi.py @@ -474,7 +474,9 @@ def fetch_device_info(devices_node, interpreter, namepath, args): bus_number = result.get() if isinstance(bus_number, int): bus_number = hex(bus_number) - element.set("address", bus_number) + # To avoid confusion to the later extractors, do not recognize _BBN for non-present host bridges. + if sta == None or (sta & 0x1) != 0: + element.set("address", bus_number) add_object_to_device(interpreter, namepath, "_BBN", result) # Status