Skip to content

Commit 9e773ae

Browse files
robherringwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Batch ATC invalidation commands
Similar to commit 2af2e72 ("iommu/arm-smmu-v3: Defer TLB invalidation until ->iotlb_sync()"), build up a list of ATC invalidation commands and submit them all at once to the command queue instead of one-by-one. As there is only one caller of arm_smmu_atc_inv_master() left, we can simplify it and avoid passing in struct arm_smmu_cmdq_ent. Cc: Jean-Philippe Brucker <[email protected]> Cc: Will Deacon <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Joerg Roedel <[email protected]> Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Jean-Philippe Brucker <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent edd0351 commit 9e773ae

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

drivers/iommu/arm-smmu-v3.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,17 +2158,16 @@ arm_smmu_atc_inv_to_cmd(int ssid, unsigned long iova, size_t size,
21582158
cmd->atc.size = log2_span;
21592159
}
21602160

2161-
static int arm_smmu_atc_inv_master(struct arm_smmu_master *master,
2162-
struct arm_smmu_cmdq_ent *cmd)
2161+
static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
21632162
{
21642163
int i;
2164+
struct arm_smmu_cmdq_ent cmd;
21652165

2166-
if (!master->ats_enabled)
2167-
return 0;
2166+
arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd);
21682167

21692168
for (i = 0; i < master->num_sids; i++) {
2170-
cmd->atc.sid = master->sids[i];
2171-
arm_smmu_cmdq_issue_cmd(master->smmu, cmd);
2169+
cmd.atc.sid = master->sids[i];
2170+
arm_smmu_cmdq_issue_cmd(master->smmu, &cmd);
21722171
}
21732172

21742173
return arm_smmu_cmdq_issue_sync(master->smmu);
@@ -2177,10 +2176,11 @@ static int arm_smmu_atc_inv_master(struct arm_smmu_master *master,
21772176
static int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain,
21782177
int ssid, unsigned long iova, size_t size)
21792178
{
2180-
int ret = 0;
2179+
int i;
21812180
unsigned long flags;
21822181
struct arm_smmu_cmdq_ent cmd;
21832182
struct arm_smmu_master *master;
2183+
struct arm_smmu_cmdq_batch cmds = {};
21842184

21852185
if (!(smmu_domain->smmu->features & ARM_SMMU_FEAT_ATS))
21862186
return 0;
@@ -2205,11 +2205,18 @@ static int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain,
22052205
arm_smmu_atc_inv_to_cmd(ssid, iova, size, &cmd);
22062206

22072207
spin_lock_irqsave(&smmu_domain->devices_lock, flags);
2208-
list_for_each_entry(master, &smmu_domain->devices, domain_head)
2209-
ret |= arm_smmu_atc_inv_master(master, &cmd);
2208+
list_for_each_entry(master, &smmu_domain->devices, domain_head) {
2209+
if (!master->ats_enabled)
2210+
continue;
2211+
2212+
for (i = 0; i < master->num_sids; i++) {
2213+
cmd.atc.sid = master->sids[i];
2214+
arm_smmu_cmdq_batch_add(smmu_domain->smmu, &cmds, &cmd);
2215+
}
2216+
}
22102217
spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);
22112218

2212-
return ret ? -ETIMEDOUT : 0;
2219+
return arm_smmu_cmdq_batch_submit(smmu_domain->smmu, &cmds);
22132220
}
22142221

22152222
/* IO_PGTABLE API */
@@ -2629,7 +2636,6 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master)
26292636

26302637
static void arm_smmu_disable_ats(struct arm_smmu_master *master)
26312638
{
2632-
struct arm_smmu_cmdq_ent cmd;
26332639
struct arm_smmu_domain *smmu_domain = master->domain;
26342640

26352641
if (!master->ats_enabled)
@@ -2641,8 +2647,7 @@ static void arm_smmu_disable_ats(struct arm_smmu_master *master)
26412647
* ATC invalidation via the SMMU.
26422648
*/
26432649
wmb();
2644-
arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd);
2645-
arm_smmu_atc_inv_master(master, &cmd);
2650+
arm_smmu_atc_inv_master(master);
26462651
atomic_dec(&smmu_domain->nr_ats_masters);
26472652
}
26482653

0 commit comments

Comments
 (0)