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


chenli.wei
 

On 5/16/2022 12:47 PM, Junjie Mao wrote:
"Junjie Mao" <junjie.mao@...> writes:

Chenli Wei <chenli.wei@...> writes:

The current code align MAX_IR_ENTRIE with the CONFIG_MAX_PT_IRQ_ENTRIE
roundup to 2^n, 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_ENTRIE to offline
tool.

Signed-off-by: Chenli Wei <chenli.wei@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

Some minor comments below.

---
.../static_allocators/board_capability.py | 17 +++++++++++++++++
.../config_tools/xforms/vm_configurations.h.xsl | 5 +++++
2 files changed, 22 insertions(+)

diff --git a/misc/config_tools/static_allocators/board_capability.py b/misc/config_tools/static_allocators/board_capability.py
index 5a98f472d..75f72afc2 100644
--- a/misc/config_tools/static_allocators/board_capability.py
+++ b/misc/config_tools/static_allocators/board_capability.py
@@ -7,6 +7,23 @@
import common
+def powerof2_roundup(value):
+ result = value
+ for i in [1, 2, 4, 8, 16]:
+ result = result | result >> i
+ return result + 1
`1 << value.bit_length()` is simpler and more straightforward.
Need take care about the boundary values:

`0 if value == 0 else (1 << (value - 1).bit_length())`
Thanks, I have send again with the V2 of HV patch

Join {acrn-dev@lists.projectacrn.org to automatically receive all group messages.