iommu/iova: Optimise the padding calculation
authorZhen Lei <thunder.leizhen@huawei.com>
Thu, 21 Sep 2017 15:52:43 +0000 (16:52 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 27 Sep 2017 15:09:56 +0000 (17:09 +0200)
commit086c83acb70fc6da044c9ca45c1c9780c64545b0
tree0f3e852600d7c60bad9b8bd0e8fbd1a710293de8
parent2070f940a6d5148cf2df0d0087ff0a64d9f15237
iommu/iova: Optimise the padding calculation

The mask for calculating the padding size doesn't change, so there's no
need to recalculate it every loop iteration. Furthermore, Once we've
done that, it becomes clear that we don't actually need to calculate a
padding size at all - by flipping the arithmetic around, we can just
combine the upper limit, size, and mask directly to check against the
lower limit.

For an arm64 build, this alone knocks 20% off the object code size of
the entire alloc_iova() function!

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Zhen Lei <thunder.leizhen@huawei.com>
Tested-by: Nate Watterson <nwatters@codeaurora.org>
[rm: simplified more of the arithmetic, rewrote commit message]
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iova.c