Skip to content

Commit c690257

Browse files
committed
drivers: intc_gicv3_its: fix incorrect RDbase when PE number is used
For RDbase used by its command, When GITS_TYPER.PTA = 1, physicall address is used, the RDbase field consist of bits[51:16] of the address, so need to left shift the address by 16 bits. But when GITS_TYPER.PTA = 0, PE number is used, no need to shit anymore. Signed-off-by: Jiafei Pan <[email protected]>
1 parent 8f425d2 commit c690257

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/interrupt_controller/intc_gicv3_its.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int its_send_sync_cmd(struct gicv3_its_data *data, uintptr_t rd_addr)
352352
}
353353

354354
cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_SYNC, GITS_CMD_ID);
355-
cmd->raw_cmd[2] = MASK_SET(rd_addr >> GITS_CMD_RDBASE_ALIGN, GITS_CMD_RDBASE);
355+
cmd->raw_cmd[2] = MASK_SET(rd_addr, GITS_CMD_RDBASE);
356356

357357
return its_post_command(data, cmd);
358358
}
@@ -367,8 +367,7 @@ static int its_send_mapc_cmd(struct gicv3_its_data *data, uint32_t icid,
367367
}
368368

369369
cmd->raw_cmd[0] = MASK_SET(GITS_CMD_ID_MAPC, GITS_CMD_ID);
370-
cmd->raw_cmd[2] = MASK_SET(icid, GITS_CMD_ICID) |
371-
MASK_SET(rd_addr >> GITS_CMD_RDBASE_ALIGN, GITS_CMD_RDBASE) |
370+
cmd->raw_cmd[2] = MASK_SET(icid, GITS_CMD_ICID) | MASK_SET(rd_addr, GITS_CMD_RDBASE) |
372371
MASK_SET(valid ? 1 : 0, GITS_CMD_VALID);
373372

374373
return its_post_command(data, cmd);
@@ -489,12 +488,18 @@ static uintptr_t gicv3_rdist_get_rdbase(const struct device *dev, unsigned int c
489488
{
490489
struct gicv3_its_data *data = dev->data;
491490
uint64_t typer = sys_read64(data->base + GITS_TYPER);
491+
uintptr_t rdbase;
492492

493493
if (GITS_TYPER_PTA_GET(typer)) {
494-
return gic_rdists[cpuid];
494+
rdbase = gic_rdists[cpuid];
495+
/* RDbase must be 64KB aligned, only return bits[51:16] of the address */
496+
rdbase = rdbase >> GITS_CMD_RDBASE_ALIGN;
495497
} else {
496-
return GICR_TYPER_PROCESSOR_NUMBER_GET(sys_read64(gic_rdists[cpuid] + GICR_TYPER));
498+
rdbase =
499+
GICR_TYPER_PROCESSOR_NUMBER_GET(sys_read64(gic_rdists[cpuid] + GICR_TYPER));
497500
}
501+
502+
return rdbase;
498503
}
499504

500505
static int gicv3_its_map_intid(const struct device *dev, uint32_t device_id, uint32_t event_id,

0 commit comments

Comments
 (0)