mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
hw/intc: GICv3 redistributor ITS processing
Implemented lpi processing at redistributor to get lpi config info from lpi configuration table,determine priority,set pending state in lpi pending table and forward the lpi to cpuif.Added logic to invoke redistributor lpi processing with translated LPI which set/clear LPI from ITS device as part of ITS INT,CLEAR,DISCARD command and GITS_TRANSLATER processing. Signed-off-by: Shashi Mallela <shashi.mallela@linaro.org> Tested-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20210910143951.92242-7-shashi.mallela@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
ac30dec396
commit
17fb5e36aa
7 changed files with 200 additions and 2 deletions
|
@ -254,6 +254,9 @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset,
|
|||
if (cs->gicr_typer & GICR_TYPER_PLPIS) {
|
||||
if (value & GICR_CTLR_ENABLE_LPIS) {
|
||||
cs->gicr_ctlr |= GICR_CTLR_ENABLE_LPIS;
|
||||
/* Check for any pending interr in pending table */
|
||||
gicv3_redist_update_lpi(cs);
|
||||
gicv3_redist_update(cs);
|
||||
} else {
|
||||
cs->gicr_ctlr &= ~GICR_CTLR_ENABLE_LPIS;
|
||||
}
|
||||
|
@ -532,6 +535,144 @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
|
|||
return r;
|
||||
}
|
||||
|
||||
static void gicv3_redist_check_lpi_priority(GICv3CPUState *cs, int irq)
|
||||
{
|
||||
AddressSpace *as = &cs->gic->dma_as;
|
||||
uint64_t lpict_baddr;
|
||||
uint8_t lpite;
|
||||
uint8_t prio;
|
||||
|
||||
lpict_baddr = cs->gicr_propbaser & R_GICR_PROPBASER_PHYADDR_MASK;
|
||||
|
||||
address_space_read(as, lpict_baddr + ((irq - GICV3_LPI_INTID_START) *
|
||||
sizeof(lpite)), MEMTXATTRS_UNSPECIFIED, &lpite,
|
||||
sizeof(lpite));
|
||||
|
||||
if (!(lpite & LPI_CTE_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cs->gic->gicd_ctlr & GICD_CTLR_DS) {
|
||||
prio = lpite & LPI_PRIORITY_MASK;
|
||||
} else {
|
||||
prio = ((lpite & LPI_PRIORITY_MASK) >> 1) | 0x80;
|
||||
}
|
||||
|
||||
if ((prio < cs->hpplpi.prio) ||
|
||||
((prio == cs->hpplpi.prio) && (irq <= cs->hpplpi.irq))) {
|
||||
cs->hpplpi.irq = irq;
|
||||
cs->hpplpi.prio = prio;
|
||||
/* LPIs are always non-secure Grp1 interrupts */
|
||||
cs->hpplpi.grp = GICV3_G1NS;
|
||||
}
|
||||
}
|
||||
|
||||
void gicv3_redist_update_lpi(GICv3CPUState *cs)
|
||||
{
|
||||
/*
|
||||
* This function scans the LPI pending table and for each pending
|
||||
* LPI, reads the corresponding entry from LPI configuration table
|
||||
* to extract the priority info and determine if the current LPI
|
||||
* priority is lower than the last computed high priority lpi interrupt.
|
||||
* If yes, replace current LPI as the new high priority lpi interrupt.
|
||||
*/
|
||||
AddressSpace *as = &cs->gic->dma_as;
|
||||
uint64_t lpipt_baddr;
|
||||
uint32_t pendt_size = 0;
|
||||
uint8_t pend;
|
||||
int i, bit;
|
||||
uint64_t idbits;
|
||||
|
||||
idbits = MIN(FIELD_EX64(cs->gicr_propbaser, GICR_PROPBASER, IDBITS),
|
||||
GICD_TYPER_IDBITS);
|
||||
|
||||
if (!(cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) || !cs->gicr_propbaser ||
|
||||
!cs->gicr_pendbaser) {
|
||||
return;
|
||||
}
|
||||
|
||||
cs->hpplpi.prio = 0xff;
|
||||
|
||||
lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK;
|
||||
|
||||
/* Determine the highest priority pending interrupt among LPIs */
|
||||
pendt_size = (1ULL << (idbits + 1));
|
||||
|
||||
for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) {
|
||||
address_space_read(as, lpipt_baddr + i, MEMTXATTRS_UNSPECIFIED, &pend,
|
||||
sizeof(pend));
|
||||
|
||||
while (pend) {
|
||||
bit = ctz32(pend);
|
||||
gicv3_redist_check_lpi_priority(cs, i * 8 + bit);
|
||||
pend &= ~(1 << bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level)
|
||||
{
|
||||
/*
|
||||
* This function updates the pending bit in lpi pending table for
|
||||
* the irq being activated or deactivated.
|
||||
*/
|
||||
AddressSpace *as = &cs->gic->dma_as;
|
||||
uint64_t lpipt_baddr;
|
||||
bool ispend = false;
|
||||
uint8_t pend;
|
||||
|
||||
/*
|
||||
* get the bit value corresponding to this irq in the
|
||||
* lpi pending table
|
||||
*/
|
||||
lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK;
|
||||
|
||||
address_space_read(as, lpipt_baddr + ((irq / 8) * sizeof(pend)),
|
||||
MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend));
|
||||
|
||||
ispend = extract32(pend, irq % 8, 1);
|
||||
|
||||
/* no change in the value of pending bit, return */
|
||||
if (ispend == level) {
|
||||
return;
|
||||
}
|
||||
pend = deposit32(pend, irq % 8, 1, level ? 1 : 0);
|
||||
|
||||
address_space_write(as, lpipt_baddr + ((irq / 8) * sizeof(pend)),
|
||||
MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend));
|
||||
|
||||
/*
|
||||
* check if this LPI is better than the current hpplpi, if yes
|
||||
* just set hpplpi.prio and .irq without doing a full rescan
|
||||
*/
|
||||
if (level) {
|
||||
gicv3_redist_check_lpi_priority(cs, irq);
|
||||
} else {
|
||||
if (irq == cs->hpplpi.irq) {
|
||||
gicv3_redist_update_lpi(cs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gicv3_redist_process_lpi(GICv3CPUState *cs, int irq, int level)
|
||||
{
|
||||
uint64_t idbits;
|
||||
|
||||
idbits = MIN(FIELD_EX64(cs->gicr_propbaser, GICR_PROPBASER, IDBITS),
|
||||
GICD_TYPER_IDBITS);
|
||||
|
||||
if (!(cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) || !cs->gicr_propbaser ||
|
||||
!cs->gicr_pendbaser || (irq > (1ULL << (idbits + 1)) - 1) ||
|
||||
irq < GICV3_LPI_INTID_START) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* set/clear the pending bit for this irq */
|
||||
gicv3_redist_lpi_pending(cs, irq, level);
|
||||
|
||||
gicv3_redist_update(cs);
|
||||
}
|
||||
|
||||
void gicv3_redist_set_irq(GICv3CPUState *cs, int irq, int level)
|
||||
{
|
||||
/* Update redistributor state for a change in an external PPI input line */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue