Skip to content

Commit 8881b69

Browse files
JianChunfupm215
authored andcommitted
hw/arm/smmu: Introduce smmu_configs_inv_sid_range() helper
Use a similar terminology smmu_hash_remove_by_sid_range() as the one being used for other hash table matching functions since smmuv3_invalidate_ste() name is not self explanatory, and introduce a helper that invokes the g_hash_table_foreach_remove. No functional change intended. Signed-off-by: JianChunfu <[email protected]> Reviewed-by: Eric Auger <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
1 parent 84e5ce6 commit 8881b69

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

hw/arm/smmu-common.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,27 @@ static gboolean smmu_hash_remove_by_vmid_ipa(gpointer key, gpointer value,
225225
((entry->iova & ~info->mask) == info->iova);
226226
}
227227

228+
static gboolean
229+
smmu_hash_remove_by_sid_range(gpointer key, gpointer value, gpointer user_data)
230+
{
231+
SMMUDevice *sdev = (SMMUDevice *)key;
232+
uint32_t sid = smmu_get_sid(sdev);
233+
SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data;
234+
235+
if (sid < sid_range->start || sid > sid_range->end) {
236+
return false;
237+
}
238+
trace_smmu_config_cache_inv(sid);
239+
return true;
240+
}
241+
242+
void smmu_configs_inv_sid_range(SMMUState *s, SMMUSIDRange sid_range)
243+
{
244+
trace_smmu_configs_inv_sid_range(sid_range.start, sid_range.end);
245+
g_hash_table_foreach_remove(s->configs, smmu_hash_remove_by_sid_range,
246+
&sid_range);
247+
}
248+
228249
void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
229250
uint8_t tg, uint64_t num_pages, uint8_t ttl)
230251
{

hw/arm/smmu-internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,4 @@ typedef struct SMMUIOTLBPageInvInfo {
141141
uint64_t mask;
142142
} SMMUIOTLBPageInvInfo;
143143

144-
typedef struct SMMUSIDRange {
145-
uint32_t start;
146-
uint32_t end;
147-
} SMMUSIDRange;
148-
149144
#endif

hw/arm/smmuv3.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static void smmuv3_flush_config(SMMUDevice *sdev)
903903
SMMUv3State *s = sdev->smmu;
904904
SMMUState *bc = &s->smmu_state;
905905

906-
trace_smmuv3_config_cache_inv(smmu_get_sid(sdev));
906+
trace_smmu_config_cache_inv(smmu_get_sid(sdev));
907907
g_hash_table_remove(bc->configs, sdev);
908908
}
909909

@@ -1277,20 +1277,6 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd, SMMUStage stage)
12771277
}
12781278
}
12791279

1280-
static gboolean
1281-
smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
1282-
{
1283-
SMMUDevice *sdev = (SMMUDevice *)key;
1284-
uint32_t sid = smmu_get_sid(sdev);
1285-
SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data;
1286-
1287-
if (sid < sid_range->start || sid > sid_range->end) {
1288-
return false;
1289-
}
1290-
trace_smmuv3_config_cache_inv(sid);
1291-
return true;
1292-
}
1293-
12941280
static int smmuv3_cmdq_consume(SMMUv3State *s)
12951281
{
12961282
SMMUState *bs = ARM_SMMU(s);
@@ -1373,8 +1359,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
13731359
sid_range.end = sid_range.start + mask;
13741360

13751361
trace_smmuv3_cmdq_cfgi_ste_range(sid_range.start, sid_range.end);
1376-
g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste,
1377-
&sid_range);
1362+
smmu_configs_inv_sid_range(bs, sid_range);
13781363
break;
13791364
}
13801365
case SMMU_CMD_CFGI_CD:

hw/arm/trace-events

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ smmu_iotlb_inv_asid_vmid(int asid, int vmid) "IOTLB invalidate asid=%d vmid=%d"
2222
smmu_iotlb_inv_vmid(int vmid) "IOTLB invalidate vmid=%d"
2323
smmu_iotlb_inv_vmid_s1(int vmid) "IOTLB invalidate vmid=%d"
2424
smmu_iotlb_inv_iova(int asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64
25+
smmu_configs_inv_sid_range(uint32_t start, uint32_t end) "Config cache INV SID range from 0x%x to 0x%x"
26+
smmu_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
2527
smmu_inv_notifiers_mr(const char *name) "iommu mr=%s"
2628
smmu_iotlb_lookup_hit(int asid, int vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
2729
smmu_iotlb_lookup_miss(int asid, int vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d"
@@ -59,7 +61,6 @@ smmuv3_cmdq_tlbi_nh(int vmid) "vmid=%d"
5961
smmuv3_cmdq_tlbi_nsnh(void) ""
6062
smmuv3_cmdq_tlbi_nh_asid(int asid) "asid=%d"
6163
smmuv3_cmdq_tlbi_s12_vmid(int vmid) "vmid=%d"
62-
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
6364
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
6465
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
6566
smmuv3_inv_notifiers_iova(const char *name, int asid, int vmid, uint64_t iova, uint8_t tg, uint64_t num_pages, int stage) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" stage=%d"

include/hw/arm/smmu-common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ typedef struct SMMUIOTLBKey {
142142
uint8_t level;
143143
} SMMUIOTLBKey;
144144

145+
typedef struct SMMUSIDRange {
146+
uint32_t start;
147+
uint32_t end;
148+
} SMMUSIDRange;
149+
145150
struct SMMUState {
146151
/* <private> */
147152
SysBusDevice dev;
@@ -219,6 +224,7 @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova,
219224
uint8_t tg, uint64_t num_pages, uint8_t ttl);
220225
void smmu_iotlb_inv_ipa(SMMUState *s, int vmid, dma_addr_t ipa, uint8_t tg,
221226
uint64_t num_pages, uint8_t ttl);
227+
void smmu_configs_inv_sid_range(SMMUState *s, SMMUSIDRange sid_range);
222228
/* Unmap the range of all the notifiers registered to any IOMMU mr */
223229
void smmu_inv_notifiers_all(SMMUState *s);
224230

0 commit comments

Comments
 (0)