iommu/iova: Simplify cached node logic
authorRobin Murphy <robin.murphy@arm.com>
Thu, 21 Sep 2017 15:52:47 +0000 (16:52 +0100)
committerJoerg Roedel <jroedel@suse.de>
Wed, 27 Sep 2017 15:09:58 +0000 (17:09 +0200)
commit973f5fbedb0721ab964386a5fe5120998e71580c
treedcd0cc4b5513ef9b19732b66e1274e0afd5cae43
parentbb68b2fbfbd643d4407541f9c7a16a2c9b3a57c7
iommu/iova: Simplify cached node logic

The logic of __get_cached_rbnode() is a little obtuse, but then
__get_prev_node_of_cached_rbnode_or_last_node_and_update_limit_pfn()
wouldn't exactly roll off the tongue...

Now that we have the invariant that there is always a valid node to
start searching downwards from, everything gets a bit easier to follow
if we simplify that function to do what it says on the tin and return
the cached node (or anchor node as appropriate) directly. In turn, we
can then deduplicate the rb_prev() and limit_pfn logic into the main
loop itself, further reduce the amount of code under the lock, and
generally make the inner workings a bit less subtle.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iova.c