Skip to content

Commit 1d149ab

Browse files
committed
iommufd: Make sw_msi_start a group global
The sw_msi_start is only set by the ARM drivers and it is always constant. Due to the way vfio/iommufd allow domains to be re-used between devices we have a built in assumption that there is only one value for sw_msi_start and it is global to the system. To make replace simpler where we may not reparse the iommu_get_resv_regions() move the sw_msi_start to the iommufd_group so it is always available once any HWPT has been attached. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kevin Tian <[email protected]> Tested-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 269c523 commit 1d149ab

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

drivers/iommu/iommufd/device.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ static struct iommufd_group *iommufd_get_group(struct iommufd_ctx *ictx,
8888
kref_init(&new_igroup->ref);
8989
mutex_init(&new_igroup->lock);
9090
INIT_LIST_HEAD(&new_igroup->device_list);
91+
new_igroup->sw_msi_start = PHYS_ADDR_MAX;
9192
/* group reference moves into new_igroup */
9293
new_igroup->group = group;
9394

@@ -292,10 +293,10 @@ u32 iommufd_device_to_id(struct iommufd_device *idev)
292293
}
293294
EXPORT_SYMBOL_NS_GPL(iommufd_device_to_id, IOMMUFD);
294295

295-
static int iommufd_device_setup_msi(struct iommufd_device *idev,
296-
struct iommufd_hw_pagetable *hwpt,
297-
phys_addr_t sw_msi_start)
296+
static int iommufd_group_setup_msi(struct iommufd_group *igroup,
297+
struct iommufd_hw_pagetable *hwpt)
298298
{
299+
phys_addr_t sw_msi_start = igroup->sw_msi_start;
299300
int rc;
300301

301302
/*
@@ -328,7 +329,6 @@ static int iommufd_device_setup_msi(struct iommufd_device *idev,
328329
int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
329330
struct iommufd_device *idev)
330331
{
331-
phys_addr_t sw_msi_start = PHYS_ADDR_MAX;
332332
int rc;
333333

334334
mutex_lock(&idev->igroup->lock);
@@ -356,8 +356,8 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
356356
}
357357
}
358358

359-
rc = iopt_table_enforce_dev_resv_regions(
360-
&hwpt->ioas->iopt, idev->dev, &sw_msi_start);
359+
rc = iopt_table_enforce_dev_resv_regions(&hwpt->ioas->iopt, idev->dev,
360+
&idev->igroup->sw_msi_start);
361361
if (rc)
362362
goto err_unlock;
363363

@@ -369,7 +369,7 @@ int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt,
369369
* attachment.
370370
*/
371371
if (list_empty(&idev->igroup->device_list)) {
372-
rc = iommufd_device_setup_msi(idev, hwpt, sw_msi_start);
372+
rc = iommufd_group_setup_msi(idev->igroup, hwpt);
373373
if (rc)
374374
goto err_unresv;
375375

drivers/iommu/iommufd/iommufd_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ struct iommufd_group {
267267
struct iommu_group *group;
268268
struct iommufd_hw_pagetable *hwpt;
269269
struct list_head device_list;
270+
phys_addr_t sw_msi_start;
270271
};
271272

272273
/*

0 commit comments

Comments
 (0)