iommu/arm-smmu-v3: Stop pre-zeroing batch commands
Subsystems (2)
PATCH 1/1 iommu/arm-smmu-v3: Stop pre-zeroing batch commands
Pre-zeroing the batched commands structure is inefficient, as individual commands are zeroed later in arm_smmu_cmdq_build_cmd(). The size is quite large and commonly most commands won't even be used:
struct arm_smmu_cmdq_batch cmds = {};345c: 52800001 mov w1, #0x0 // #0
3460: d2808102 mov x2, #0x408 // #1032
3464: 910143a0 add x0, x29, #0x50
3468: 94000000 bl 0 <memset>
Stop pre-zeroing the complete structure and only zero the num member.
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +9 -3
@@ -1082,7 +1082,7 @@ static void arm_smmu_sync_cd(struct arm_smmu_domain *smmu_domain,size_t i;unsigned long flags;struct arm_smmu_master *master; -struct arm_smmu_cmdq_batch cmds = {}; +struct arm_smmu_cmdq_batch cmds;struct arm_smmu_device *smmu = smmu_domain->smmu;struct arm_smmu_cmdq_ent cmd = { .opcode =CMDQ_OP_CFGI_CD ,
@@ -1092,6 +1092,8 @@ static void arm_smmu_sync_cd(struct arm_smmu_domain *smmu_domain, }, }; + cmds.num =0 ; +spin_lock_irqsave (&smmu_domain->devices_lock, flags);list_for_each_entry (master, &smmu_domain->devices, domain_head) {for (i =0 ; i < master->num_streams; i++) {
@@ -1908,7 +1910,7 @@ int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,unsigned long flags;struct arm_smmu_cmdq_ent cmd;struct arm_smmu_master *master; -struct arm_smmu_cmdq_batch cmds = {}; +struct arm_smmu_cmdq_batch cmds;if (!(smmu_domain->smmu->features &ARM_SMMU_FEAT_ATS ))return 0 ;
@@ -1932,6 +1934,8 @@ int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,arm_smmu_atc_inv_to_cmd (ssid, iova, size, &cmd); + cmds.num =0 ; +spin_lock_irqsave (&smmu_domain->devices_lock, flags);list_for_each_entry (master, &smmu_domain->devices, domain_head) {if (!master->ats_enabled)
@@ -1980,7 +1984,7 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,struct arm_smmu_device *smmu = smmu_domain->smmu;unsigned long end = iova + size, num_pages =0 , tg =0 ;size_t inv_range = granule; -struct arm_smmu_cmdq_batch cmds = {}; +struct arm_smmu_cmdq_batch cmds;if (!size)return ;
@@ -1998,6 +2002,8 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd, num_pages = size >> tg; } + cmds.num =0 ; +while (iova < end) {if (smmu->features &ARM_SMMU_FEAT_RANGE_INV ) {/*
Signature · 6 lines
2.26.2 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 11 lines · John Garry
Pre-zeroing the batched commands structure is inefficient, as individual commands are zeroed later in
arm_smmu_cmdq_build_cmd(). The size is quite large and commonly most commands won't even be used:struct arm_smmu_cmdq_batch cmds = {};345c: 52800001 mov w1, #0x0 // #0
3460:d2808102mov x2, #0x408 // #1032
3464:910143a0add x0, x29, #0x50
3468: 94000000 bl 0 <memset>[...]
Applied to will (for-joerg/arm-smmu/updates), thanks!
[1/1] iommu/arm-smmu-v3: Stop pre-zeroing batch commands
https://git.kernel.org/will/c/fac956710ab0
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev