hv: move the define of MAX_IR_ENTRIES to offline tool

There is an issue of calculate 2^n roundup of CONFIG_MAX_PT_IRQ_ENTRIES,
and the code style is very ugly when we use macro to fix it.

So this patch move MAX_IR_ENTRIES to offline tool which could do align
check and calculate it automatically.

Signed-off-by: Chenli Wei <chenli.wei@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
This commit is contained in:
Chenli Wei 2022-05-13 17:28:52 +08:00 committed by acrnsi-robot
parent f7094466cb
commit 5f0588b5f8
3 changed files with 1 additions and 28 deletions

View File

@ -128,6 +128,7 @@ struct dmar_drhd_rt {
uint64_t root_table_addr; uint64_t root_table_addr;
uint64_t ir_table_addr; uint64_t ir_table_addr;
/* MAX_IR_ENTRIES is roundup (to power of 2) of CONFIG_MAX_PT_IRQ_ENTRIES. */
uint64_t irte_alloc_bitmap[MAX_IR_ENTRIES / 64U]; uint64_t irte_alloc_bitmap[MAX_IR_ENTRIES / 64U];
uint64_t irte_reserved_bitmap[MAX_IR_ENTRIES / 64U]; uint64_t irte_reserved_bitmap[MAX_IR_ENTRIES / 64U];
uint64_t qi_queue; uint64_t qi_queue;

View File

@ -42,13 +42,6 @@
#define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */ #define DMAR_ICS_REG 0x9cU /* Invalidation complete status register */
#define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */ #define DMAR_IRTA_REG 0xb8U /* Interrupt remapping table addr register */
/* Make sure all PT IRQs work w/ interrupt remapping or post interrupt */
#if (CONFIG_MAX_PT_IRQ_ENTRIES <= 256)
#define MAX_IR_ENTRIES 256
#else
#define MAX_IR_ENTRIES powerof2_roundup(CONFIG_MAX_PT_IRQ_ENTRIES)
#endif
/* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */ /* Values for entry_type in ACPI_DMAR_DEVICE_SCOPE - device types */
enum acpi_dmar_scope_type { enum acpi_dmar_scope_type {
ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0, ACPI_DMAR_SCOPE_TYPE_NOT_USED = 0,

View File

@ -25,27 +25,6 @@
/** Replaces 'x' by the string "x". */ /** Replaces 'x' by the string "x". */
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
/*
* This algorithm get the round up 2^n
*
* n = input - 1; 0x1002 ----> 0x1001
* n |= n >> 1; 0x1001 | 0x800
* n |= n >> 2; 0x1801 | 0x600
* n |= n >> 4; 0x1e01 | 0x1e0
* n |= n >> 8; 0x1fe1 | 0x1f
* n |= n >> 16; 0x1fff
* n |= n >> 32; 0x1fff
* n += 1; 0x2000
*/
#define ROUND0(x) ((x)-1)
#define ROUND1(x) (ROUND0(x) |(ROUND0(x)>>1))
#define ROUND2(x) (ROUND1(x) |(ROUND1(x)>>2))
#define ROUND4(x) (ROUND2(x) |(ROUND2(x)>>4))
#define ROUND8(x) (ROUND4(x) |(ROUND4(x)>>8))
#define ROUND16(x) (ROUND8(x) |(ROUND8(x)>>16))
#define ROUND32(x) (ROUND16(x) |(ROUND16(x)>>32))
#define powerof2_roundup(x) ((ROUND32(x) == (~0UL)) ? ~0UL : (ROUND32(x) +1))
/* Macro used to check if a value is aligned to the required boundary. /* Macro used to check if a value is aligned to the required boundary.
* Returns TRUE if aligned; FALSE if not aligned * Returns TRUE if aligned; FALSE if not aligned
* NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) * NOTE: The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc)