Date 1 - 2 of 2
[PATCH] config-tools: reserve the secondary PCI bus mmio windows
From: "Yang,Yu-chu" <yu-chu.yang@...>
Prevent allocator to allocate PCI bus mmio windows to other devices.
Signed-off-by: Yang,Yu-chu <yu-chu.yang@...>
misc/config_tools/static_allocators/gpa.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/misc/config_tools/static_allocators/gpa.py b/misc/config_tools/static_allocators/gpa.py
index 43935bebd..79780b73b 100644
@@ -224,8 +224,21 @@ def insert_vmsix_to_dev_dict(pt_dev_node, devdict):
def get_devs_mem_native(board_etree, mems):
nodes = board_etree.xpath(f"//resource[@type = 'memory' and @len != '0x0' and @id and @width]")
+ secondary_pci_nodes = board_etree.xpath(f"//resource[../capability[@id = 'Secondary PCI Express'] and @type = 'memory' and @len != '0x0']")
+ secondary_pci_windows = [AddrWindow(int(node.get('min'), 16), int(node.get('max'), 16)) for node in secondary_pci_nodes]
+ #nodes = board_etree.xpath(f"//resource[@type = 'memory' and @len != '0x0' and @width]")
dev_list = 
+ new_nodes_list = secondary_pci_nodes
for node in nodes:
+ start = node.get('min')
+ end = node.get('max')
+ if start is not None and end is not None:
+ node_window = AddrWindow(int(start, 16), int(end, 16))
+ if all(not(node_window.overlaps(w)) for w in secondary_pci_windows):
+ for node in new_nodes_list:
start = node.get('min')
end = node.get('max')
if start is not None and end is not None:
toggle quoted message Show quoted text
-----Original Message-----The presence of "Secondary PCI Express" capability may not be a reliable test (though most of the times it will work). You can instead check whether the device has a `bus[@type='pci']` node as a child.
+ secondary_pci_windows = [AddrWindow(int(node.get('min'), 16), int(node.get('max'),Null check is not applied to the attributes above. Instead of adding null checks in Python, you can add constraints in the XPATH to get only the resource nodes with 'min' and 'max' attributes. If you choose to do that, please also drop the null check on those attributes in the loop body below.
+ #nodes = board_etree.xpath(f"//resource[@type = 'memory' and @len != '0x0' andPlease remove comments you added only for debugging.
dev_list = This is not quite right when there are multiple levels of secondary busses. You may want to add a `contains` method to `AddrWindow` and use `contains` rather than `overlaps` here.
Also using two loops with an intermediate list `new_nodes_list` makes the logic quite hard to read. You can use the following algorithm (in pseudo code) to simplify that:
for node in (all PCI BARs or resources of root ports):
get the address window of node
if the address window is not contained by any secondary_pci_windows:
add the address window to dev_list
|1 - 2 of 2|