iommu/arm-smmu: Reintroduce locking around TLB sync operations
authorWill Deacon <will.deacon@arm.com>
Thu, 6 Jul 2017 14:55:48 +0000 (15:55 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 20 Jul 2017 09:30:26 +0000 (10:30 +0100)
commit8e517e762a826d16451fb6ffb0a8722e4265582e
tree6cc0c59ccd7770892d5bddb8c23afc381c853d8c
parent5771a8c08880cdca3bfb4a3fc6d309d6bba20877
iommu/arm-smmu: Reintroduce locking around TLB sync operations

Commit 523d7423e21b ("iommu/arm-smmu: Remove io-pgtable spinlock")
removed the locking used to serialise map/unmap calls into the io-pgtable
code from the ARM SMMU driver. This is good for performance, but opens
us up to a nasty race with TLB syncs because the TLB sync register is
shared within a context bank (or even globally for stage-2 on SMMUv1).

There are two cases to consider:

  1. A CPU can be spinning on the completion of a TLB sync, take an
     interrupt which issues a subsequent TLB sync, and then report a
     timeout on return from the interrupt.

  2. A CPU can be spinning on the completion of a TLB sync, but other
     CPUs can continuously issue additional TLB syncs in such a way that
     the backoff logic reports a timeout.

Rather than fix this by spinning for completion of prior TLB syncs before
issuing a new one (which may suffer from fairness issues on large systems),
instead reintroduce locking around TLB sync operations in the ARM SMMU
driver.

Fixes: 523d7423e21b ("iommu/arm-smmu: Remove io-pgtable spinlock")
Cc: Robin Murphy <robin.murphy@arm.com>
Reported-by: Ray Jui <ray.jui@broadcom.com>
Tested-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/arm-smmu.c