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 <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2021-08-09 16:22:36 +08:00 committed by wenlingz
parent 171856c46b
commit bcc8358d93
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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