hv: pirq: add static irq:vector mappings

Since vector is x86 specific concept, we'd like to hide it from common irq APIs.
This commit
 - adds static irq:vector mappings for special interrupt such as timer
and cpu notification;
 - reserves the irq and vector at initialization;
 - removed the vector argument in pri_register_handler(), get reserved vector
   from irq_desc in common_register_handler().

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yan, Like 2018-08-07 15:19:56 +08:00 committed by lijinxia
parent f6e45c9b13
commit 8fda0d8c5f
5 changed files with 26 additions and 19 deletions

View File

@ -14,6 +14,12 @@ static uint32_t vector_to_irq[NR_MAX_VECTOR + 1];
spurious_handler_t spurious_handler;
#define NR_STATIC_MAPPINGS (2U)
static uint32_t irq_static_mappings[NR_STATIC_MAPPINGS][2] = {
{TIMER_IRQ, VECTOR_TIMER},
{NOTIFY_IRQ, VECTOR_NOTIFY_VCPU},
};
static void init_irq_desc(void)
{
uint32_t i;
@ -28,6 +34,15 @@ static void init_irq_desc(void)
vector_to_irq[i] = IRQ_INVALID;
}
/* init fixed mapping for specific irq and vector */
for (i = 0U; i < NR_STATIC_MAPPINGS; i++) {
uint32_t irq = irq_static_mappings[i][0];
uint32_t vr = irq_static_mappings[i][1];
irq_desc_array[irq].vector = vr;
irq_desc_array[irq].used = IRQ_ASSIGNED;
vector_to_irq[vr] = irq;
}
}
/*
@ -155,7 +170,7 @@ static int32_t common_register_handler(uint32_t irq_arg,
struct irq_request_info *info)
{
struct irq_desc *desc;
uint32_t irq = irq_arg;
uint32_t irq = irq_arg, vector;
spinlock_rflags;
/* ======================================================
@ -206,10 +221,11 @@ static int32_t common_register_handler(uint32_t irq_arg,
desc->irq_handler = common_handler_edge;
}
if (info->vector >= VECTOR_FIXED_START &&
info->vector <= VECTOR_FIXED_END) {
irq_desc_set_vector(irq, info->vector);
} else if (info->vector > NR_MAX_VECTOR) {
vector = desc->vector;
if (vector >= VECTOR_FIXED_START &&
vector <= VECTOR_FIXED_END) {
irq_desc_set_vector(irq, vector);
} else if (vector > NR_MAX_VECTOR) {
irq_desc_alloc_vector(irq);
}
@ -574,7 +590,6 @@ int32_t normal_register_handler(uint32_t irq,
{
struct irq_request_info info;
info.vector = VECTOR_INVALID;
info.func = func;
info.priv_data = priv_data;
info.name = (char *)name;
@ -589,18 +604,12 @@ int32_t normal_register_handler(uint32_t irq,
* times
*/
int32_t pri_register_handler(uint32_t irq,
uint32_t vector,
irq_action_t func,
void *priv_data,
const char *name)
{
struct irq_request_info info;
if (vector < VECTOR_FIXED_START || vector > VECTOR_FIXED_END) {
return -EINVAL;
}
info.vector = vector;
info.func = func;
info.priv_data = priv_data;
info.name = (char *)name;

View File

@ -20,7 +20,6 @@ static int kick_notification(__unused uint32_t irq, __unused void *data)
static int request_notification_irq(irq_action_t func, void *data,
const char *name)
{
uint32_t irq = IRQ_INVALID; /* system allocate */
int32_t retval;
if (notification_irq != IRQ_INVALID) {
@ -30,7 +29,7 @@ static int request_notification_irq(irq_action_t func, void *data,
}
/* all cpu register the same notification vector */
retval = pri_register_handler(irq, VECTOR_NOTIFY_VCPU, func, data, name);
retval = pri_register_handler(NOTIFY_IRQ, func, data, name);
if (retval < 0) {
pr_err("Failed to add notify isr");
return -ENODEV;

View File

@ -8,7 +8,6 @@
#include <softirq.h>
#define MAX_TIMER_ACTIONS 32U
#define TIMER_IRQ (NR_IRQS - 1U)
#define CAL_MS 10U
#define MIN_TIMER_PERIOD_US 500U
@ -112,8 +111,7 @@ static int request_timer_irq(irq_action_t func, const char *name)
{
int32_t retval;
retval = pri_register_handler(TIMER_IRQ, VECTOR_TIMER,
func, NULL, name);
retval = pri_register_handler(TIMER_IRQ, func, NULL, name);
if (retval >= 0) {
update_irq_handler(TIMER_IRQ, quick_handler_nolock);
} else {

View File

@ -27,6 +27,9 @@
#define NR_IRQS (256U + 16U)
#define IRQ_INVALID 0xffffffffU
#define TIMER_IRQ (NR_IRQS - 1U)
#define NOTIFY_IRQ (NR_IRQS - 2U)
#define DEFAULT_DEST_MODE IOAPIC_RTE_DESTLOG
#define DEFAULT_DELIVERY_MODE IOAPIC_RTE_DELLOPRI
#define ALL_CPUS_MASK ((1U << phys_cpu_num) - 1U)

View File

@ -28,7 +28,6 @@ struct irq_request_info {
/* vector set to 0xE0 ~ 0xFF for pri_register_handler
* and set to VECTOR_INVALID for normal_register_handler
*/
uint32_t vector;
irq_action_t func;
void *priv_data;
char *name;
@ -60,7 +59,6 @@ void irq_desc_try_free_vector(uint32_t irq);
uint32_t irq_to_vector(uint32_t irq);
int32_t pri_register_handler(uint32_t irq,
uint32_t vector,
irq_action_t func,
void *priv_data,
const char *name);