[PATCH v2 1/2] misc: add the define of MAX_IR_ENTRIES


chenli.wei
 

The current code align MAX_IR_ENTRIES with the roundup to 2^n of the
CONFIG_MAX_PT_IRQ_ENTRIES, there is an issue of the powerof2_roundup to
calculate the macro, and the code style is very ugly when we use macro
to fix it.

So this patch move the calculate and define of MAX_IR_ENTRIES to offline
tool.

v1-->v2:
1. Simplify the powerof2_roundup and XSL
2. code format

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>
---
.../static_allocators/board_capability.py | 14 ++++++++++++++
misc/config_tools/xforms/vm_configurations.h.xsl | 1 +
2 files changed, 15 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..1d9981f43 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,20 @@

import common

+def powerof2_roundup(value):
+ return 0 if value == 0 else (1 << (value - 1).bit_length())
+
+# Make sure all PT IRQs work w/ interrupt remapping or post interrupt
+def create_max_ir_entries(scenario_etree, allocation_etree):
+ pt_irq_entries = common.get_node(f"//MAX_PT_IRQ_ENTRIES/text()", scenario_etree)
+ if (pt_irq_entries is not None) and (int(pt_irq_entries) > 256):
+ ir_entries = powerof2_roundup(int(pt_irq_entries))
+ else:
+ ir_entries = 256
+
+ common.append_node("/acrn-config/hv/MAX_IR_ENTRIES", ir_entries, allocation_etree)
+
def fn(board_etree, scenario_etree, allocation_etree):
pci_bus_nums = board_etree.xpath("//bus[@type='pci']/@address")
common.append_node("/acrn-config/platform/MAX_PCI_BUS_NUM", hex(max(map(lambda x: int(x, 16), pci_bus_nums)) + 1), allocation_etree)
+ create_max_ir_entries(scenario_etree, allocation_etree)
diff --git a/misc/config_tools/xforms/vm_configurations.h.xsl b/misc/config_tools/xforms/vm_configurations.h.xsl
index f91c2720c..1ef0f3dd2 100644
--- a/misc/config_tools/xforms/vm_configurations.h.xsl
+++ b/misc/config_tools/xforms/vm_configurations.h.xsl
@@ -34,6 +34,7 @@
<xsl:call-template name="vm_count" />
<xsl:call-template name="sos_vm_bootarges" />
<xsl:call-template name="vm_vuart_num" />
+ <xsl:value-of select = "acrn:define('MAX_IR_ENTRIES', //MAX_IR_ENTRIES, 'U')" />
</xsl:template>

<xsl:template name ="vm_vuart_num">
--
2.17.1