]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout
authorZhen Lei <thunder.leizhen@huawei.com>
Tue, 5 Mar 2019 19:36:54 +0000 (12:36 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Tue, 12 Mar 2019 21:49:32 +0000 (17:49 -0400)
commitdb8bba71136a2f663e2b2cee06a8cf9b2d2b4c70
treea29d1426c3f072068227dafdc356342c426caeca
parentfdcd1de91fe8a252b9bd0ed2c0c0f5b2c4dae80d
iommu/arm-smmu-v3: Fix unexpected CMD_SYNC timeout

BugLink: https://bugs.launchpad.net/bugs/1818162
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>
(cherry picked from commit 0f02477d16980938a84aba8688a4e3a303306116)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/iommu/arm-smmu-v3.c