* [PATCH v2 02/13] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
@ 2022-09-14 5:14 Nicolin Chen
2022-09-14 14:46 ` Vasant Hegde
0 siblings, 1 reply; 2+ messages in thread
From: Nicolin Chen @ 2022-09-14 5:14 UTC (permalink / raw)
To: joro, suravee.suthikulpanit, will, robin.murphy
Cc: jgg, kevin.tian, iommu, linux-kernel
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 any more.
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
drivers/iommu/amd/iommu.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 828672a46a3d..930d9946b9f7 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2135,21 +2135,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);
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2 02/13] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
2022-09-14 5:14 [PATCH v2 02/13] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() Nicolin Chen
@ 2022-09-14 14:46 ` Vasant Hegde
0 siblings, 0 replies; 2+ messages in thread
From: Vasant Hegde @ 2022-09-14 14:46 UTC (permalink / raw)
To: Nicolin Chen, joro, suravee.suthikulpanit, will, robin.murphy
Cc: jgg, kevin.tian, iommu, linux-kernel
On 9/14/2022 10:44 AM, Nicolin Chen wrote:
> 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 any more.
>
> Suggested-by: Robin Murphy <robin.murphy@arm.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Looks good to me.
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
-Vasant
> ---
> drivers/iommu/amd/iommu.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 828672a46a3d..930d9946b9f7 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2135,21 +2135,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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-14 14:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 5:14 [PATCH v2 02/13] iommu/amd: Drop unnecessary checks in amd_iommu_attach_device() Nicolin Chen
2022-09-14 14:46 ` Vasant Hegde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®