Skip to content

Commit a931229

Browse files
shiqinggwenlingz
authored andcommitted
hv: irq: clean up HV_DEBUG usage
remove the usage of HV_DEBUG in irq.c Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent dfe4881 commit a931229

File tree

3 files changed

+64
-68
lines changed

3 files changed

+64
-68
lines changed

hypervisor/arch/x86/irq.c

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, };
1111
static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, };
1212

13-
#define IRQ_ALLOC_BITMAP_SIZE INT_DIV_ROUNDUP(NR_IRQS, 64U)
14-
static uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
13+
uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
1514
struct irq_desc irq_desc_array[NR_IRQS];
1615
static uint32_t vector_to_irq[NR_MAX_VECTOR + 1];
1716

@@ -402,60 +401,6 @@ void partition_mode_dispatch_interrupt(struct intr_excp_ctx *ctx)
402401
}
403402
#endif
404403

405-
#ifdef HV_DEBUG
406-
void get_cpu_interrupt_info(char *str_arg, size_t str_max)
407-
{
408-
char *str = str_arg;
409-
uint16_t pcpu_id;
410-
uint32_t irq, vector;
411-
size_t len, size = str_max;
412-
413-
len = snprintf(str, size, "\r\nIRQ\tVECTOR");
414-
if (len >= size) {
415-
goto overflow;
416-
}
417-
size -= len;
418-
str += len;
419-
420-
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
421-
len = snprintf(str, size, "\tCPU%d", pcpu_id);
422-
if (len >= size) {
423-
goto overflow;
424-
}
425-
size -= len;
426-
str += len;
427-
}
428-
429-
for (irq = 0U; irq < NR_IRQS; irq++) {
430-
vector = irq_to_vector(irq);
431-
if (bitmap_test((uint16_t)(irq & 0x3FU),
432-
irq_alloc_bitmap + (irq >> 6U))
433-
&& (vector != VECTOR_INVALID)) {
434-
len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector);
435-
if (len >= size) {
436-
goto overflow;
437-
}
438-
size -= len;
439-
str += len;
440-
441-
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
442-
len = snprintf(str, size, "\t%d", per_cpu(irq_count, pcpu_id)[irq]);
443-
if (len >= size) {
444-
goto overflow;
445-
}
446-
size -= len;
447-
str += len;
448-
}
449-
}
450-
}
451-
snprintf(str, size, "\r\n");
452-
return;
453-
454-
overflow:
455-
printf("buffer size could not be enough! please check!\n");
456-
}
457-
#endif /* HV_DEBUG */
458-
459404
static void init_irq_descs(void)
460405
{
461406
uint32_t i;

hypervisor/debug/shell.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,66 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv)
841841
return 0;
842842
}
843843

844+
/**
845+
* @brief Get the interrupt statistics
846+
*
847+
* It's for debug only.
848+
*
849+
* @param[in] str_max The max size of the string containing interrupt info
850+
* @param[inout] str_arg Pointer to the output interrupt info
851+
*/
852+
static void get_cpu_interrupt_info(char *str_arg, size_t str_max)
853+
{
854+
char *str = str_arg;
855+
uint16_t pcpu_id;
856+
uint32_t irq, vector;
857+
size_t len, size = str_max;
858+
859+
len = snprintf(str, size, "\r\nIRQ\tVECTOR");
860+
if (len >= size) {
861+
goto overflow;
862+
}
863+
size -= len;
864+
str += len;
865+
866+
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
867+
len = snprintf(str, size, "\tCPU%d", pcpu_id);
868+
if (len >= size) {
869+
goto overflow;
870+
}
871+
size -= len;
872+
str += len;
873+
}
874+
875+
for (irq = 0U; irq < NR_IRQS; irq++) {
876+
vector = irq_to_vector(irq);
877+
if (bitmap_test((uint16_t)(irq & 0x3FU),
878+
irq_alloc_bitmap + (irq >> 6U))
879+
&& (vector != VECTOR_INVALID)) {
880+
len = snprintf(str, size, "\r\n%d\t0x%X", irq, vector);
881+
if (len >= size) {
882+
goto overflow;
883+
}
884+
size -= len;
885+
str += len;
886+
887+
for (pcpu_id = 0U; pcpu_id < phys_cpu_num; pcpu_id++) {
888+
len = snprintf(str, size, "\t%d", per_cpu(irq_count, pcpu_id)[irq]);
889+
if (len >= size) {
890+
goto overflow;
891+
}
892+
size -= len;
893+
str += len;
894+
}
895+
}
896+
}
897+
snprintf(str, size, "\r\n");
898+
return;
899+
900+
overflow:
901+
printf("buffer size could not be enough! please check!\n");
902+
}
903+
844904
static int shell_show_cpu_int(__unused int argc, __unused char **argv)
845905
{
846906
get_cpu_interrupt_info(shell_log_buf, SHELL_LOG_BUF_SIZE);

hypervisor/include/arch/x86/irq.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#define DEFAULT_DELIVERY_MODE IOAPIC_RTE_DELLOPRI
5353
#define ALL_CPUS_MASK ((1U << phys_cpu_num) - 1U)
5454

55+
#define IRQ_ALLOC_BITMAP_SIZE INT_DIV_ROUNDUP(NR_IRQS, 64U)
56+
5557
/*
5658
* Definition of the stack frame layout
5759
*/
@@ -243,19 +245,8 @@ void interrupt_init(uint16_t pcpu_id);
243245

244246
void cancel_event_injection(struct acrn_vcpu *vcpu);
245247

246-
#ifdef HV_DEBUG
247-
/**
248-
* @brief Get the interupt statistics
249-
*
250-
* It's for debug only.
251-
*
252-
* @param[in] str_max The max size of the string containing interrupt info
253-
* @param[inout] str_arg Pointer to the output interrupt info
254-
*/
255-
void get_cpu_interrupt_info(char *str_arg, size_t str_max);
256-
#endif /* HV_DEBUG */
257-
258248
extern uint32_t acrn_vhm_vector;
249+
extern uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
259250

260251
/**
261252
* @}

0 commit comments

Comments
 (0)