@samitouri / QOSamiQemu / commits / 43585524a7

hw/arm/smmuv3: Introduce a helper function for event propagation

Factor out the code that propagates event records to the guest into a helper function. The accelerated SMMUv3 path can use this to propagate host events in a subsequent patch. Take the mutex inside the helper before accessing the Event Queue. Today event propagation occurs only in the core SMMUv3 path and is effectively serialized. A subsequent patch will also invoke this helper from the accelerated event read path, which may run concurrently. Therefore serialization is required here. No functional change intended. Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Tested-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com> Message-id: 20260226084456.112142-5-skolothumtho@nvidia.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Shameer Kolothum committed Mar 6, 2026 at 09:01 UTC 43585524a7c628c0ebace5c33ba865c4e2c55177
3 files changed +19 -7
hw/arm/smmuv3-internal.h
+4
@@ -352,7 +352,11 @@ typedef struct SMMUEventInfo {
352 (x)->word[6] = (uint32_t)(addr & 0xffffffff); \
353 } while (0)
354
355 +#define EVT_GET_TYPE(x) extract32((x)->word[0], 0, 8)
356 +#define EVT_GET_SID(x) ((x)->word[1])
357 +
358 void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event);
359 +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt);
360 int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event);
361
362 static inline int oas2bits(int oas_field)
hw/arm/smmuv3.c
+14 -6
@@ -168,10 +168,22 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, Evt *evt)
168 return MEMTX_OK;
169 }
170
171 +void smmuv3_propagate_event(SMMUv3State *s, Evt *evt)
172 +{
173 + MemTxResult r;
174 +
175 + trace_smmuv3_propagate_event(smmu_event_string(EVT_GET_TYPE(evt)),
176 + EVT_GET_SID(evt));
177 + QEMU_LOCK_GUARD(&s->mutex);
178 + r = smmuv3_write_eventq(s, evt);
179 + if (r != MEMTX_OK) {
180 + smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, R_GERROR_EVENTQ_ABT_ERR_MASK);
181 + }
182 +}
183 +
184 void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
185 {
186 Evt evt = {};
174 - MemTxResult r;
187
188 if (!smmuv3_eventq_enabled(s)) {
189 return;
@@ -251,11 +263,7 @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info)
263 g_assert_not_reached();
264 }
265
254 - trace_smmuv3_record_event(smmu_event_string(info->type), info->sid);
255 - r = smmuv3_write_eventq(s, &evt);
256 - if (r != MEMTX_OK) {
257 - smmuv3_trigger_irq(s, SMMU_IRQ_GERROR, R_GERROR_EVENTQ_ABT_ERR_MASK);
258 - }
266 + smmuv3_propagate_event(s, &evt);
267 info->recorded = true;
268 }
269
hw/arm/trace-events
+1 -1
@@ -40,7 +40,7 @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s"
40 smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d "
41 smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d"
42 smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
43 -smmuv3_record_event(const char *type, uint32_t sid) "%s sid=0x%x"
43 +smmuv3_propagate_event(const char *type, uint32_t sid) "%s sid=0x%x"
44 smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x"
45 smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d"
46 smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64