iommu/vt-d: Clear PRQ overflow only when PRQ is empty
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 26 Jan 2021 08:07:29 +0000 (16:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Mar 2021 16:06:23 +0000 (17:06 +0100)
commit1e5ac057b05c4d41a0168d1b746e51ef30e86270
tree3909561340bb7ae3bb313d9e8d032dc79f1e29bf
parent82d6c12899e2645bd17d6f9c7d494f360e1089e1
iommu/vt-d: Clear PRQ overflow only when PRQ is empty

[ Upstream commit 28a77185f1cd0650b664f54614143aaaa3a7a615 ]

It is incorrect to always clear PRO when it's set w/o first checking
whether the overflow condition has been cleared. Current code assumes
that if an overflow condition occurs it must have been cleared by earlier
loop. However since the code runs in a threaded context, the overflow
condition could occur even after setting the head to the tail under some
extreme condition. To be sane, we should read both head/tail again when
seeing a pending PRO and only clear PRO after all pending PRs have been
handled.

Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/linux-iommu/MWHPR11MB18862D2EA5BD432BF22D99A48CA09@MWHPR11MB1886.namprd11.prod.outlook.com/
Link: https://lore.kernel.org/r/20210126080730.2232859-2-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/intel/svm.c