iommu/vt-d: Don't disable preemption while accessing deferred_flush()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tue, 27 Jun 2017 16:16:48 +0000 (18:16 +0200)
committerJoerg Roedel <jroedel@suse.de>
Wed, 28 Jun 2017 10:24:40 +0000 (12:24 +0200)
commit58c4a95f90839624b67f67acdb8a129f4383b569
tree44e773e9f149411b27fe80cbfecb87fc78feb572
parent71bb620df634b22a08efd62a0f93c3f2aceaa8e2
iommu/vt-d: Don't disable preemption while accessing deferred_flush()

get_cpu() disables preemption and returns the current CPU number. The
CPU number is only used once while retrieving the address of the local's
CPU deferred_flush pointer.
We can instead use raw_cpu_ptr() while we remain preemptible. The worst
thing that can happen is that flush_unmaps_timeout() is invoked multiple
times: once by taskA after seeing HIGH_WATER_MARK and then preempted to
another CPU and then by taskB which saw HIGH_WATER_MARK on the same CPU
as taskA. It is also likely that ->size got from HIGH_WATER_MARK to 0
right after its read because another CPU invoked flush_unmaps_timeout()
for this CPU.
The access to flush_data is protected by a spinlock so even if we get
migrated to another CPU or preempted - the data structure is protected.

While at it, I marked deferred_flush static since I can't find a
reference to it outside of this file.

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: iommu@lists.linux-foundation.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-iommu.c