linux-stable/drivers/iommu
Zhen Lei bae080e72e iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout
[ Upstream commit 0f02477d16 ]

The condition break condition of:

	(int)(VAL - sync_idx) >= 0

in the __arm_smmu_sync_poll_msi() polling loop requires that sync_idx
must be increased monotonically according to the sequence of the CMDs in
the cmdq.

However, since the msidata is populated using atomic_inc_return_relaxed()
before taking the command-queue spinlock, then the following scenario
can occur:

CPU0			CPU1
msidata=0
			msidata=1
			insert cmd1
insert cmd0
			smmu execute cmd1
smmu execute cmd0
			poll timeout, because msidata=1 is overridden by
			cmd0, that means VAL=0, sync_idx=1.

This is not a functional problem, since the caller will eventually either
timeout or exit due to another CMD_SYNC, however it's clearly not what
the code is supposed to be doing. Fix it, by incrementing the sequence
count with the command-queue lock held, allowing us to drop the atomic
operations altogether.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
[will: dropped the specialised cmd building routine for now]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-24 08:19:30 +01:00
..
amd_iommu.c iommu/amd: Silence warnings under memory pressure 2019-10-05 13:09:52 +02:00
amd_iommu.h iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-10-05 13:09:59 +02:00
amd_iommu_debugfs.c
amd_iommu_init.c iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-10-05 13:09:59 +02:00
amd_iommu_proto.h
amd_iommu_quirks.c iommu/amd: Apply the same IVRS IOAPIC workaround to Acer Aspire A315-41 2019-11-12 19:21:14 +01:00
amd_iommu_types.h iommu/amd: Reserve exclusion range in iova-domain 2019-05-04 09:20:22 +02:00
amd_iommu_v2.c
arm-smmu-regs.h
arm-smmu-v3.c iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout 2019-11-24 08:19:30 +01:00
arm-smmu.c iommu/arm-smmu: Avoid constant zero in TLBI writes 2019-06-19 08:18:00 +02:00
dma-iommu.c iommu/dma: Handle SG length overflow better 2019-09-06 10:21:57 +02:00
dmar.c iommu/dmar: Fix buffer overflow during PCI bus notification 2019-04-20 09:16:03 +02:00
exynos-iommu.c
fsl_pamu.c
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
intel-iommu.c iommu/vt-d: Don't queue_iova() if there is no flush queue 2019-08-04 09:30:54 +02:00
intel-pasid.c
intel-pasid.h
intel-svm.c
intel_irq_remapping.c
io-pgtable-arm-v7s.c iommu/io-pgtable-arm-v7s: Only kmemleak_ignore L2 tables 2019-04-05 22:33:02 +02:00
io-pgtable-arm.c iommu/io-pgtable-arm: Fix race handling in split_blk_unmap() 2019-11-24 08:19:30 +01:00
io-pgtable.c
io-pgtable.h
iommu-debugfs.c
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Fix a leak in iommu_insert_resv_region 2019-07-26 09:14:06 +02:00
iova.c iommu/iova: Avoid false sharing on fq_timer_on 2019-10-05 13:09:53 +02:00
ipmmu-vmsa.c iommu/ipmmu-vmsa: Fix crash on early domain free 2018-12-13 09:16:10 +01:00
irq_remapping.c
irq_remapping.h
Kconfig
Makefile iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-10-05 13:09:59 +02:00
msm_iommu.c
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c
mtk_iommu.h
mtk_iommu_v1.c
of_iommu.c
omap-iommu-debug.c
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c
rockchip-iommu.c
s390-iommu.c
tegra-gart.c
tegra-smmu.c iommu/tegra-smmu: Fix invalid ASID bits on Tegra30/114 2019-05-25 18:23:30 +02:00