提交 9fcb8428 编写于 作者: T tianyi 提交者: Shile Zhang

iommu/amd: Check for busy devices earlier in attach_device()

fix #26319040

commit 45e528d9c479aeef2d3d1db1e619b243f91e324f upstream.

Check early in attach_device whether the device is already attached to a
domain. This also simplifies the code path so that __attach_device() can
be removed.

Fixes: 92d420ec ("iommu/amd: Relax locking in dma_ops path")
Reviewed-by: NFilippo Sironi <sironi@amazon.de>
Reviewed-by: NJerry Snitselaar <jsnitsel@redhat.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
Signed-off-by: Ntianyi <fujunkang@linux.alibaba.com>
Reviewed-by: Nzhangliguang <zhangliguang@linux.alibaba.com>
Acked-by: Nzhangliguang <zhangliguang@linux.alibaba.com>
上级 19082e2a
......@@ -1997,23 +1997,6 @@ static void do_detach(struct iommu_dev_data *dev_data)
domain->dev_cnt -= 1;
}
/*
* If a device is not yet associated with a domain, this function makes the
* device visible in the domain
*/
static int __attach_device(struct iommu_dev_data *dev_data,
struct protection_domain *domain)
{
if (dev_data->domain != NULL)
return -EBUSY;
/* Attach alias group root */
do_attach(dev_data, domain);
return 0;
}
static void pdev_iommuv2_disable(struct pci_dev *pdev)
{
pci_disable_ats(pdev);
......@@ -2116,6 +2099,10 @@ static int attach_device(struct device *dev,
dev_data = get_dev_data(dev);
ret = -EBUSY;
if (dev_data->domain != NULL)
goto out;
if (!dev_is_pci(dev))
goto skip_ats_check;
......@@ -2140,7 +2127,9 @@ static int attach_device(struct device *dev,
}
skip_ats_check:
ret = __attach_device(dev_data, domain);
ret = 0;
do_attach(dev_data, domain);
/*
* We might boot into a crash-kernel here. The crashed kernel
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册