Skip to content

Commit

Permalink
iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
Browse files Browse the repository at this point in the history
The same checks are done in amd_iommu_probe_device(). If any of them fails
there, then the device won't get a group, so there's no way for it to even
reach amd_iommu_attach_device anymore.

Link: https://lore.kernel.org/r/c054654a81f2b675c73108fe4bf10e45335a721a.1666042872.git.nicolinc@nvidia.com
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
  • Loading branch information
Nicolin Chen authored and Jason Gunthorpe committed Nov 1, 2022
1 parent 30a0b95 commit 79218fd
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/iommu/amd/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2155,21 +2155,13 @@ static void amd_iommu_detach_device(struct iommu_domain *dom,
static int amd_iommu_attach_device(struct iommu_domain *dom,
struct device *dev)
{
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
struct protection_domain *domain = to_pdomain(dom);
struct iommu_dev_data *dev_data;
struct amd_iommu *iommu;
struct amd_iommu *iommu = rlookup_amd_iommu(dev);
int ret;

if (!check_device(dev))
return -EINVAL;

dev_data = dev_iommu_priv_get(dev);
dev_data->defer_attach = false;

iommu = rlookup_amd_iommu(dev);
if (!iommu)
return -EINVAL;

if (dev_data->domain)
detach_device(dev);

Expand Down

0 comments on commit 79218fd

Please sign in to comment.