summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2023-07-17 15:12:02 -0300
committerJason Gunthorpe <jgg@nvidia.com>2023-07-26 10:19:37 -0300
commit269c5238c5b134ca8b18b98814b87ec995a59968 (patch)
tree36ec13e10cb4ae1a8498d1fdee54b9cc2dd4f2ac
parent34f327a985ff11e538aa52b3e4842328815ce5de (diff)
downloadlinux-stable-269c5238c5b134ca8b18b98814b87ec995a59968.tar.gz
linux-stable-269c5238c5b134ca8b18b98814b87ec995a59968.tar.bz2
linux-stable-269c5238c5b134ca8b18b98814b87ec995a59968.zip
iommufd: Use the iommufd_group to avoid duplicate MSI setup
This only needs to be done once per group, not once per device. The once per device was a way to make the device list work. Since we are abandoning this we can optimize things a bit. Link: https://lore.kernel.org/r/6-v8-6659224517ea+532-iommufd_alloc_jgg@nvidia.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-rw-r--r--drivers/iommu/iommufd/device.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index 7fd5c184b560..eb90d6f9e10f 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -361,10 +361,6 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
if (rc)
goto err_unlock;
- rc = iommufd_device_setup_msi(idev, hwpt, sw_msi_start);
- if (rc)
- goto err_unresv;
-
/*
* Only attach to the group once for the first device that is in the
* group. All the other devices will follow this attachment. The user
@@ -373,6 +369,10 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
* attachment.
*/
if (list_empty(&idev->igroup->device_list)) {
+ rc = iommufd_device_setup_msi(idev, hwpt, sw_msi_start);
+ if (rc)
+ goto err_unresv;
+
rc = iommu_attach_group(hwpt->domain, idev->igroup->group);
if (rc)
goto err_unresv;