@@ -548,6 +548,11 @@ struct arm_smmu_cmdq {
548
548
atomic_t lock ;
549
549
};
550
550
551
+ struct arm_smmu_cmdq_batch {
552
+ u64 cmds [CMDQ_BATCH_ENTRIES * CMDQ_ENT_DWORDS ];
553
+ int num ;
554
+ };
555
+
551
556
struct arm_smmu_evtq {
552
557
struct arm_smmu_queue q ;
553
558
u32 max_stalls ;
@@ -1482,6 +1487,24 @@ static int arm_smmu_cmdq_issue_sync(struct arm_smmu_device *smmu)
1482
1487
return arm_smmu_cmdq_issue_cmdlist (smmu , NULL , 0 , true);
1483
1488
}
1484
1489
1490
+ static void arm_smmu_cmdq_batch_add (struct arm_smmu_device * smmu ,
1491
+ struct arm_smmu_cmdq_batch * cmds ,
1492
+ struct arm_smmu_cmdq_ent * cmd )
1493
+ {
1494
+ if (cmds -> num == CMDQ_BATCH_ENTRIES ) {
1495
+ arm_smmu_cmdq_issue_cmdlist (smmu , cmds -> cmds , cmds -> num , false);
1496
+ cmds -> num = 0 ;
1497
+ }
1498
+ arm_smmu_cmdq_build_cmd (& cmds -> cmds [cmds -> num * CMDQ_ENT_DWORDS ], cmd );
1499
+ cmds -> num ++ ;
1500
+ }
1501
+
1502
+ static int arm_smmu_cmdq_batch_submit (struct arm_smmu_device * smmu ,
1503
+ struct arm_smmu_cmdq_batch * cmds )
1504
+ {
1505
+ return arm_smmu_cmdq_issue_cmdlist (smmu , cmds -> cmds , cmds -> num , true);
1506
+ }
1507
+
1485
1508
/* Context descriptor manipulation functions */
1486
1509
static void arm_smmu_sync_cd (struct arm_smmu_domain * smmu_domain ,
1487
1510
int ssid , bool leaf )
@@ -2220,10 +2243,9 @@ static void arm_smmu_tlb_inv_range(unsigned long iova, size_t size,
2220
2243
size_t granule , bool leaf ,
2221
2244
struct arm_smmu_domain * smmu_domain )
2222
2245
{
2223
- u64 cmds [CMDQ_BATCH_ENTRIES * CMDQ_ENT_DWORDS ];
2224
2246
struct arm_smmu_device * smmu = smmu_domain -> smmu ;
2225
2247
unsigned long start = iova , end = iova + size ;
2226
- int i = 0 ;
2248
+ struct arm_smmu_cmdq_batch cmds = {} ;
2227
2249
struct arm_smmu_cmdq_ent cmd = {
2228
2250
.tlbi = {
2229
2251
.leaf = leaf ,
@@ -2242,18 +2264,11 @@ static void arm_smmu_tlb_inv_range(unsigned long iova, size_t size,
2242
2264
}
2243
2265
2244
2266
while (iova < end ) {
2245
- if (i == CMDQ_BATCH_ENTRIES ) {
2246
- arm_smmu_cmdq_issue_cmdlist (smmu , cmds , i , false);
2247
- i = 0 ;
2248
- }
2249
-
2250
2267
cmd .tlbi .addr = iova ;
2251
- arm_smmu_cmdq_build_cmd ( & cmds [ i * CMDQ_ENT_DWORDS ] , & cmd );
2268
+ arm_smmu_cmdq_batch_add ( smmu , & cmds , & cmd );
2252
2269
iova += granule ;
2253
- i ++ ;
2254
2270
}
2255
-
2256
- arm_smmu_cmdq_issue_cmdlist (smmu , cmds , i , true);
2271
+ arm_smmu_cmdq_batch_submit (smmu , & cmds );
2257
2272
2258
2273
/*
2259
2274
* Unfortunately, this can't be leaf-only since we may have
0 commit comments