spapr/irq: Introduce an ics_irq_free() helper

It will help us to discard interrupt numbers which have not been
claimed in the next patch.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190911133937.2716-2-clg@kaod.org>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Cédric Le Goater 2019-09-11 15:39:36 +02:00 committed by David Gibson
parent 3887d24123
commit 4a99d40551
2 changed files with 8 additions and 6 deletions

View File

@ -114,9 +114,6 @@ static void spapr_irq_init_xics(SpaprMachineState *spapr, int nr_irqs,
xics_spapr_init(spapr); xics_spapr_init(spapr);
} }
#define ICS_IRQ_FREE(ics, srcno) \
(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi, static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi,
Error **errp) Error **errp)
{ {
@ -129,7 +126,7 @@ static int spapr_irq_claim_xics(SpaprMachineState *spapr, int irq, bool lsi,
return -1; return -1;
} }
if (!ICS_IRQ_FREE(ics, irq - ics->offset)) { if (!ics_irq_free(ics, irq - ics->offset)) {
error_setg(errp, "IRQ %d is not free", irq); error_setg(errp, "IRQ %d is not free", irq);
return -1; return -1;
} }
@ -147,7 +144,7 @@ static void spapr_irq_free_xics(SpaprMachineState *spapr, int irq, int num)
if (ics_valid_irq(ics, irq)) { if (ics_valid_irq(ics, irq)) {
trace_spapr_irq_free(0, irq, num); trace_spapr_irq_free(0, irq, num);
for (i = srcno; i < srcno + num; ++i) { for (i = srcno; i < srcno + num; ++i) {
if (ICS_IRQ_FREE(ics, i)) { if (ics_irq_free(ics, i)) {
trace_spapr_irq_free_warn(0, i); trace_spapr_irq_free_warn(0, i);
} }
memset(&ics->irqs[i], 0, sizeof(ICSIRQState)); memset(&ics->irqs[i], 0, sizeof(ICSIRQState));
@ -767,7 +764,7 @@ static int ics_find_free_block(ICSState *ics, int num, int alignnum)
return -1; return -1;
} }
for (i = first; i < first + num; ++i) { for (i = first; i < first + num; ++i) {
if (!ICS_IRQ_FREE(ics, i)) { if (!ics_irq_free(ics, i)) {
break; break;
} }
} }

View File

@ -179,6 +179,11 @@ void ics_simple_write_xive(ICSState *ics, int nr, int server,
uint8_t priority, uint8_t saved_priority); uint8_t priority, uint8_t saved_priority);
void ics_simple_set_irq(void *opaque, int srcno, int val); void ics_simple_set_irq(void *opaque, int srcno, int val);
static inline bool ics_irq_free(ICSState *ics, uint32_t srcno)
{
return !(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK);
}
void ics_set_irq_type(ICSState *ics, int srcno, bool lsi); void ics_set_irq_type(ICSState *ics, int srcno, bool lsi);
void icp_pic_print_info(ICPState *icp, Monitor *mon); void icp_pic_print_info(ICPState *icp, Monitor *mon);
void ics_pic_print_info(ICSState *ics, Monitor *mon); void ics_pic_print_info(ICSState *ics, Monitor *mon);