Skip to content

Commit ae3ff39

Browse files
Christoph Hellwigjoergroedel
authored andcommitted
iommu: remove the put_resv_regions method
All drivers that implement get_resv_regions just use generic_put_resv_regions to implement the put side. Remove the indirections and document the allocations constraints. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/20220708080616.238833-4-hch@lst.de Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent a871765 commit ae3ff39

9 files changed

Lines changed: 6 additions & 30 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2280,7 +2280,6 @@ const struct iommu_ops amd_iommu_ops = {
22802280
.probe_finalize = amd_iommu_probe_finalize,
22812281
.device_group = amd_iommu_device_group,
22822282
.get_resv_regions = amd_iommu_get_resv_regions,
2283-
.put_resv_regions = generic_iommu_put_resv_regions,
22842283
.is_attach_deferred = amd_iommu_is_attach_deferred,
22852284
.pgsize_bitmap = AMD_IOMMU_PGSIZES,
22862285
.def_domain_type = amd_iommu_def_domain_type,

drivers/iommu/apple-dart.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ static const struct iommu_ops apple_dart_iommu_ops = {
768768
.of_xlate = apple_dart_of_xlate,
769769
.def_domain_type = apple_dart_def_domain_type,
770770
.get_resv_regions = apple_dart_get_resv_regions,
771-
.put_resv_regions = generic_iommu_put_resv_regions,
772771
.pgsize_bitmap = -1UL, /* Restricted during dart probe */
773772
.owner = THIS_MODULE,
774773
.default_domain_ops = &(const struct iommu_domain_ops) {

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,6 @@ static struct iommu_ops arm_smmu_ops = {
28522852
.device_group = arm_smmu_device_group,
28532853
.of_xlate = arm_smmu_of_xlate,
28542854
.get_resv_regions = arm_smmu_get_resv_regions,
2855-
.put_resv_regions = generic_iommu_put_resv_regions,
28562855
.dev_enable_feat = arm_smmu_dev_enable_feature,
28572856
.dev_disable_feat = arm_smmu_dev_disable_feature,
28582857
.sva_bind = arm_smmu_sva_bind,

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,6 @@ static struct iommu_ops arm_smmu_ops = {
15841584
.device_group = arm_smmu_device_group,
15851585
.of_xlate = arm_smmu_of_xlate,
15861586
.get_resv_regions = arm_smmu_get_resv_regions,
1587-
.put_resv_regions = generic_iommu_put_resv_regions,
15881587
.def_domain_type = arm_smmu_def_domain_type,
15891588
.pgsize_bitmap = -1UL, /* Restricted during device attach */
15901589
.owner = THIS_MODULE,

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4911,7 +4911,6 @@ const struct iommu_ops intel_iommu_ops = {
49114911
.probe_finalize = intel_iommu_probe_finalize,
49124912
.release_device = intel_iommu_release_device,
49134913
.get_resv_regions = intel_iommu_get_resv_regions,
4914-
.put_resv_regions = generic_iommu_put_resv_regions,
49154914
.device_group = intel_iommu_device_group,
49164915
.dev_enable_feat = intel_iommu_dev_enable_feat,
49174916
.dev_disable_feat = intel_iommu_dev_disable_feat,

drivers/iommu/iommu.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,27 +2579,14 @@ void iommu_get_resv_regions(struct device *dev, struct list_head *list)
25792579
ops->get_resv_regions(dev, list);
25802580
}
25812581

2582-
void iommu_put_resv_regions(struct device *dev, struct list_head *list)
2583-
{
2584-
const struct iommu_ops *ops = dev_iommu_ops(dev);
2585-
2586-
if (ops->put_resv_regions)
2587-
ops->put_resv_regions(dev, list);
2588-
}
2589-
25902582
/**
2591-
* generic_iommu_put_resv_regions - Reserved region driver helper
2583+
* iommu_put_resv_regions - release resered regions
25922584
* @dev: device for which to free reserved regions
25932585
* @list: reserved region list for device
25942586
*
2595-
* IOMMU drivers can use this to implement their .put_resv_regions() callback
2596-
* for simple reservations. If a per region callback is provided that will be
2597-
* used to free all memory allocations associated with the reserved region or
2598-
* else just free up the memory for the regions. If an IOMMU driver allocates
2599-
* additional resources per region, it is going to have to implement a custom
2600-
* callback.
2587+
* This releases a reserved region list acquired by iommu_get_resv_regions().
26012588
*/
2602-
void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
2589+
void iommu_put_resv_regions(struct device *dev, struct list_head *list)
26032590
{
26042591
struct iommu_resv_region *entry, *next;
26052592

@@ -2610,7 +2597,7 @@ void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
26102597
kfree(entry);
26112598
}
26122599
}
2613-
EXPORT_SYMBOL(generic_iommu_put_resv_regions);
2600+
EXPORT_SYMBOL(iommu_put_resv_regions);
26142601

26152602
struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start,
26162603
size_t length, int prot,

drivers/iommu/mtk_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,6 @@ static const struct iommu_ops mtk_iommu_ops = {
928928
.device_group = mtk_iommu_device_group,
929929
.of_xlate = mtk_iommu_of_xlate,
930930
.get_resv_regions = mtk_iommu_get_resv_regions,
931-
.put_resv_regions = generic_iommu_put_resv_regions,
932931
.pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M,
933932
.owner = THIS_MODULE,
934933
.default_domain_ops = &(const struct iommu_domain_ops) {

drivers/iommu/virtio-iommu.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ static struct iommu_device *viommu_probe_device(struct device *dev)
964964
return &viommu->iommu;
965965

966966
err_free_dev:
967-
generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
967+
iommu_put_resv_regions(dev, &vdev->resv_regions);
968968
kfree(vdev);
969969

970970
return ERR_PTR(ret);
@@ -983,7 +983,7 @@ static void viommu_release_device(struct device *dev)
983983
{
984984
struct viommu_endpoint *vdev = dev_iommu_priv_get(dev);
985985

986-
generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
986+
iommu_put_resv_regions(dev, &vdev->resv_regions);
987987
kfree(vdev);
988988
}
989989

@@ -1007,7 +1007,6 @@ static struct iommu_ops viommu_ops = {
10071007
.release_device = viommu_release_device,
10081008
.device_group = viommu_device_group,
10091009
.get_resv_regions = viommu_get_resv_regions,
1010-
.put_resv_regions = generic_iommu_put_resv_regions,
10111010
.of_xlate = viommu_of_xlate,
10121011
.owner = THIS_MODULE,
10131012
.default_domain_ops = &(const struct iommu_domain_ops) {

include/linux/iommu.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ struct iommu_iotlb_gather {
209209
* group and attached to the groups domain
210210
* @device_group: find iommu group for a particular device
211211
* @get_resv_regions: Request list of reserved regions for a device
212-
* @put_resv_regions: Free list of reserved regions for a device
213212
* @of_xlate: add OF master IDs to iommu grouping
214213
* @is_attach_deferred: Check if domain attach should be deferred from iommu
215214
* driver init to device driver init (default no)
@@ -240,7 +239,6 @@ struct iommu_ops {
240239

241240
/* Request/Free a list of reserved regions for a device */
242241
void (*get_resv_regions)(struct device *dev, struct list_head *list);
243-
void (*put_resv_regions)(struct device *dev, struct list_head *list);
244242

245243
int (*of_xlate)(struct device *dev, struct of_phandle_args *args);
246244
bool (*is_attach_deferred)(struct device *dev);
@@ -454,8 +452,6 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
454452

455453
extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
456454
extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
457-
extern void generic_iommu_put_resv_regions(struct device *dev,
458-
struct list_head *list);
459455
extern void iommu_set_default_passthrough(bool cmd_line);
460456
extern void iommu_set_default_translated(bool cmd_line);
461457
extern bool iommu_default_passthrough(void);

0 commit comments

Comments
 (0)