iommu/arm-smmu-v3: Use command queue batching helpers to improve performance
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 11 Aug 2021 11:48:49 +0000 (19:48 +0800)
committerWill Deacon <will@kernel.org>
Fri, 13 Aug 2021 13:17:16 +0000 (14:17 +0100)
The obvious key to the performance optimization of commit 587e6c10a7ce
("iommu/arm-smmu-v3: Reduce contention during command-queue insertion") is
to allow multiple cores to insert commands in parallel after a brief mutex
contention.

Obviously, inserting as many commands at a time as possible can reduce the
number of times the mutex contention participates, thereby improving the
overall performance. At least it reduces the number of calls to function
arm_smmu_cmdq_issue_cmdlist().

Therefore, use command queue batching helpers to insert multiple commands
at a time.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210811114852.2429-2-thunder.leizhen@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

index 952291840c763b5f8d89a7a4d83b216d2adaf2d1..ac0c4b21cfa8e975726856c8acef374ab0de5412 100644 (file)
@@ -1747,15 +1747,16 @@ static int arm_smmu_atc_inv_master(struct arm_smmu_master *master)
 {
        int i;
        struct arm_smmu_cmdq_ent cmd;
+       struct arm_smmu_cmdq_batch cmds = {};
 
        arm_smmu_atc_inv_to_cmd(0, 0, 0, &cmd);
 
        for (i = 0; i < master->num_streams; i++) {
                cmd.atc.sid = master->streams[i].id;
-               arm_smmu_cmdq_issue_cmd(master->smmu, &cmd);
+               arm_smmu_cmdq_batch_add(master->smmu, &cmds, &cmd);
        }
 
-       return arm_smmu_cmdq_issue_sync(master->smmu);
+       return arm_smmu_cmdq_batch_submit(master->smmu, &cmds);
 }
 
 int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,