@samitouri / QOSamiQemu / commits / 576891bc31

hw/intc/arm_gicv5: Implement Deactivate command

Implement the equivalent of the GICv5 stream protocol's Deactivate command, which lets the cpuif tell the IRS to deactivate the specified interrupt. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Message-id: 20260327111700.795099-51-peter.maydell@linaro.org

Peter Maydell committed Mar 27, 2026 at 11:16 UTC 576891bc313ebfdff04b3428818404c3be3a264e
3 files changed +67
hw/intc/arm_gicv5.c
+52
@@ -1153,6 +1153,58 @@ void gicv5_activate(GICv5Common *cs, uint32_t id, GICv5Domain domain,
1153 irs_recalc_hppi(s, domain, iaffid);
1154 }
1155
1156 +void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain,
1157 + GICv5IntType type, bool virtual)
1158 +{
1159 + GICv5 *s = ARM_GICV5(cs);
1160 + uint32_t iaffid;
1161 +
1162 + trace_gicv5_deactivate(domain_name[domain], inttype_name(type), virtual, id);
1163 +
1164 + if (virtual) {
1165 + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to "
1166 + "deactivate a virtual interrupt\n");
1167 + return;
1168 + }
1169 +
1170 + switch (type) {
1171 + case GICV5_LPI:
1172 + {
1173 + const GICv5ISTConfig *cfg = &s->phys_lpi_config[domain];
1174 + L2_ISTE_Handle h;
1175 + uint32_t *l2_iste_p = get_l2_iste(cs, cfg, id, &h);
1176 +
1177 + if (!l2_iste_p) {
1178 + return;
1179 + }
1180 + *l2_iste_p = FIELD_DP32(*l2_iste_p, L2_ISTE, ACTIVE, false);
1181 + iaffid = FIELD_EX32(*l2_iste_p, L2_ISTE, IAFFID);
1182 + put_l2_iste(cs, cfg, &h);
1183 + break;
1184 + }
1185 + case GICV5_SPI:
1186 + {
1187 + GICv5SPIState *spi = gicv5_spi_state(cs, id, domain);
1188 +
1189 + if (!spi) {
1190 + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to "
1191 + "deactivate unreachable SPI %d\n", id);
1192 + return;
1193 + }
1194 +
1195 + spi->active = false;
1196 + iaffid = spi->iaffid;
1197 + break;
1198 + }
1199 + default:
1200 + qemu_log_mask(LOG_GUEST_ERROR, "gicv5_deactivate: tried to "
1201 + "deactivate bad interrupt type %d\n", type);
1202 + return;
1203 + }
1204 +
1205 + irs_recalc_hppi(s, domain, iaffid);
1206 +}
1207 +
1208 static void irs_map_l2_istr_write(GICv5 *s, GICv5Domain domain, uint64_t value)
1209 {
1210 GICv5Common *cs = ARM_GICV5_COMMON(s);
hw/intc/trace-events
+1
@@ -242,6 +242,7 @@ gicv5_set_handling(const char *domain, const char *type, bool virtual, uint32_t
242 gicv5_set_target(const char *domain, const char *type, bool virtual, uint32_t id, uint32_t iaffid, int irm) "GICv5 IRS SetTarget %s %s virtual:%d ID %u IAFFID %u routingmode %d"
243 gicv5_request_config(const char *domain, const char *type, bool virtual, uint32_t id, uint64_t icsr) "GICv5 IRS RequestConfig %s %s virtual:%d ID %u ICSR 0x%" PRIx64
244 gicv5_activate(const char *domain, const char *type, bool virtual, uint32_t id) "GICv5 IRS Activate %s %s virtual:%d ID %u"
245 +gicv5_deactivate(const char *domain, const char *type, bool virtual, uint32_t id) "GICv5 IRS Deactivate %s %s virtual:%d ID %u"
246 gicv5_spi_state(uint32_t spi_id, bool level, bool pending, bool active) "GICv5 IRS SPI ID %u now level %d pending %d active %d"
247 gicv5_irs_recalc_hppi_fail(const char *domain, uint32_t iaffid, const char *reason) "GICv5 IRS %s IAFFID %u: no HPPI: %s"
248 gicv5_irs_recalc_hppi(const char *domain, uint32_t iaffid, uint32_t id, uint8_t prio) "GICv5 IRS %s IAFFID %u: new HPPI ID 0x%x prio %u"
include/hw/intc/arm_gicv5_stream.h
+14
@@ -211,4 +211,18 @@ void gicv5_forward_interrupt(ARMCPU *cpu, GICv5Domain domain);
211 GICv5PendingIrq gicv5_get_hppi(GICv5Common *cs, GICv5Domain domain,
212 uint32_t iaffid);
213
214 +/**
215 + * gicv5_deactivate
216 + * @cs: GIC IRS to send command to
217 + * @id: interrupt ID
218 + * @domain: interrupt Domain to act on
219 + * @type: interrupt type (LPI or SPI)
220 + * @virtual: true if this is a virtual interrupt
221 + *
222 + * Deactivate the specified interrupt. There is no report back of
223 + * success/failure to the CPUIF in the protocol.
224 + */
225 +void gicv5_deactivate(GICv5Common *cs, uint32_t id, GICv5Domain domain,
226 + GICv5IntType type, bool virtual);
227 +
228 #endif