iommu/iova: Add flush counters to Flush-Queue implementation
authorJoerg Roedel <jroedel@suse.de>
Thu, 10 Aug 2017 14:14:59 +0000 (16:14 +0200)
committerJoerg Roedel <jroedel@suse.de>
Tue, 15 Aug 2017 16:23:51 +0000 (18:23 +0200)
commitfb418dab8a4f01dde0c025d15145c589ec02796b
treea3248e1152ca546661147605d2480528a8775af6
parent1928210107edd4fa786199fef6b875d3af3bef88
iommu/iova: Add flush counters to Flush-Queue implementation

There are two counters:

* fq_flush_start_cnt  - Increased when a TLB flush
                        is started.

* fq_flush_finish_cnt - Increased when a TLB flush
is finished.

The fq_flush_start_cnt is assigned to every Flush-Queue
entry on its creation. When freeing entries from the
Flush-Queue, the value in the entry is compared to the
fq_flush_finish_cnt. The entry can only be freed when its
value is less than the value of fq_flush_finish_cnt.

The reason for these counters it to take advantage of IOMMU
TLB flushes that happened on other CPUs. These already
flushed the TLB for Flush-Queue entries on other CPUs so
that they can already be freed without flushing the TLB
again.

This makes it less likely that the Flush-Queue is full and
saves IOMMU TLB flushes.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iova.c
include/linux/iova.h