Skip to content

Commit 79218fd

Browse files
nicolincjgunthorpe
authored andcommitted
iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
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 <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Suravee Suthikulpanit <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 30a0b95 commit 79218fd

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,21 +2155,13 @@ static void amd_iommu_detach_device(struct iommu_domain *dom,
21552155
static int amd_iommu_attach_device(struct iommu_domain *dom,
21562156
struct device *dev)
21572157
{
2158+
struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
21582159
struct protection_domain *domain = to_pdomain(dom);
2159-
struct iommu_dev_data *dev_data;
2160-
struct amd_iommu *iommu;
2160+
struct amd_iommu *iommu = rlookup_amd_iommu(dev);
21612161
int ret;
21622162

2163-
if (!check_device(dev))
2164-
return -EINVAL;
2165-
2166-
dev_data = dev_iommu_priv_get(dev);
21672163
dev_data->defer_attach = false;
21682164

2169-
iommu = rlookup_amd_iommu(dev);
2170-
if (!iommu)
2171-
return -EINVAL;
2172-
21732165
if (dev_data->domain)
21742166
detach_device(dev);
21752167

0 commit comments

Comments
 (0)