From a931229888ce8c83dd0019e5bf4c53d51312aa57 Mon Sep 17 00:00:00 2001 From: Shiqing Gao Date: Thu, 22 Nov 2018 12:16:22 +0800 Subject: [PATCH] hv: irq: clean up HV_DEBUG usage remove the usage of HV_DEBUG in irq.c Tracked-On: #861 Signed-off-by: Shiqing Gao Acked-by: Eddie Dong --- hypervisor/arch/x86/irq.c | 57 +---------------------------- hypervisor/debug/shell.c | 60 +++++++++++++++++++++++++++++++ hypervisor/include/arch/x86/irq.h | 15 ++------ 3 files changed, 64 insertions(+), 68 deletions(-) diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index b0cfa3f8e..22a2a1828 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -10,8 +10,7 @@ static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, }; static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, }; -#define IRQ_ALLOC_BITMAP_SIZE INT_DIV_ROUNDUP(NR_IRQS, 64U) -static uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE]; +uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE]; struct irq_desc irq_desc_array[NR_IRQS]; static uint32_t vector_to_irq[NR_MAX_VECTOR + 1]; @@ -402,60 +401,6 @@ void partition_mode_dispatch_interrupt(struct intr_excp_ctx *ctx) } #endif -#ifdef HV_DEBUG -void get_cpu_interrupt_info(char *str_arg, size_t str_max) -{ - char *str = str_arg; - uint16_t pcpu_id; - uint32_t irq, vector; - size_t len, size = str_max; - - len = snprintf(str, size, "\r\nIRQ\tVECTOR"); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - - for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) { - len = snprintf(str, size, "\tCPU%d", pcpu_id); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - } - - for (irq = 0U; irq < NR_IRQS; irq++) { - vector = irq_to_vector(irq); - if (bitmap_test((uint16_t)(irq & 0x3FU), - irq_alloc_bitmap + (irq >> 6U)) - && (vector != VECTOR_INVALID)) { - len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - - for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) { - len = snprintf(str, size, "\t%d", per_cpu(irq_count, pcpu_id)[irq]); - if (len >= size) { - goto overflow; - } - size -= len; - str += len; - } - } - } - snprintf(str, size, "\r\n"); - return; - -overflow: - printf("buffer size could not be enough! please check!\n"); -} -#endif /* HV_DEBUG */ - static void init_irq_descs(void) { uint32_t i; diff --git a/hypervisor/debug/shell.c b/hypervisor/debug/shell.c index 57c3556cf..f5293fadf 100644 --- a/hypervisor/debug/shell.c +++ b/hypervisor/debug/shell.c @@ -841,6 +841,66 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv) return 0; } +/** + * @brief Get the interrupt statistics + * + * It's for debug only. + * + * @param[in] str_max The max size of the string containing interrupt info + * @param[inout] str_arg Pointer to the output interrupt info + */ +static void get_cpu_interrupt_info(char *str_arg, size_t str_max) +{ + char *str = str_arg; + uint16_t pcpu_id; + uint32_t irq, vector; + size_t len, size = str_max; + + len = snprintf(str, size, "\r\nIRQ\tVECTOR"); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + + for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) { + len = snprintf(str, size, "\tCPU%d", pcpu_id); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + } + + for (irq = 0U; irq < NR_IRQS; irq++) { + vector = irq_to_vector(irq); + if (bitmap_test((uint16_t)(irq & 0x3FU), + irq_alloc_bitmap + (irq >> 6U)) + && (vector != VECTOR_INVALID)) { + len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + + for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) { + len = snprintf(str, size, "\t%d", per_cpu(irq_count, pcpu_id)[irq]); + if (len >= size) { + goto overflow; + } + size -= len; + str += len; + } + } + } + snprintf(str, size, "\r\n"); + return; + +overflow: + printf("buffer size could not be enough! please check!\n"); +} + static int shell_show_cpu_int(__unused int argc, __unused char **argv) { get_cpu_interrupt_info(shell_log_buf, SHELL_LOG_BUF_SIZE); diff --git a/hypervisor/include/arch/x86/irq.h b/hypervisor/include/arch/x86/irq.h index 6316e4c89..a7437c92e 100644 --- a/hypervisor/include/arch/x86/irq.h +++ b/hypervisor/include/arch/x86/irq.h @@ -52,6 +52,8 @@ #define DEFAULT_DELIVERY_MODE IOAPIC_RTE_DELLOPRI #define ALL_CPUS_MASK ((1U << phys_cpu_num) - 1U) +#define IRQ_ALLOC_BITMAP_SIZE INT_DIV_ROUNDUP(NR_IRQS, 64U) + /* * Definition of the stack frame layout */ @@ -243,19 +245,8 @@ void interrupt_init(uint16_t pcpu_id); void cancel_event_injection(struct acrn_vcpu *vcpu); -#ifdef HV_DEBUG -/** - * @brief Get the interupt statistics - * - * It's for debug only. - * - * @param[in] str_max The max size of the string containing interrupt info - * @param[inout] str_arg Pointer to the output interrupt info - */ -void get_cpu_interrupt_info(char *str_arg, size_t str_max); -#endif /* HV_DEBUG */ - extern uint32_t acrn_vhm_vector; +extern uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE]; /** * @}