Skip to contentSkip to conversation

iommu: Implement generic_iommu_put_resv_regions()

PATCH In review Thierry Reding 3 participants 15 messages Dec 18, 2019 – Dec 19, 2019

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH v3 1/5 iommu: Implement generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Implement a generic function for removing reserved regions. This can be used by drivers that don't do anything fancy with these regions other than allocating memory for them.

---
 drivers/iommu/iommu.c | 19 +++++++++++++++++++
 include/linux/iommu.h |  2 ++
 2 files changed, 21 insertions(+)
drivers/iommu/iommu.c +19 -0
index fdd40756dbc1..101f2d68eb6e 100644
@@ -2229,6 +2229,25 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
 		ops->put_resv_regions(dev, list);
 }
 
+/**
+ * generic_iommu_put_resv_regions - Reserved region driver helper
+ * @dev: device for which to free reserved regions
+ * @list: reserved region list for device
+ *
+ * IOMMU drivers can use this to implement their .put_resv_regions() callback
+ * for simple reservations. Memory allocated for each reserved region will be
+ * freed. If an IOMMU driver allocates additional resources per region, it is
+ * going to have to implement a custom callback.
+ */
+void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
+{
+	struct iommu_resv_region *entry, *next;
+
+	list_for_each_entry_safe(entry, next, list, list)
+		kfree(entry);
+}
+EXPORT_SYMBOL(generic_iommu_put_resv_regions);
+
 struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start,
 						  size_t length, int prot,
 						  enum iommu_resv_type type)
include/linux/iommu.h +2 -0
index 1b4fbe703950..2e06b31579c2 100644
@@ -477,6 +477,8 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
 
 extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
 extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
+extern void generic_iommu_put_resv_regions(struct device *dev,
+					   struct list_head *list);
 extern int iommu_request_dm_for_dev(struct device *dev);
 extern int iommu_request_dma_domain_for_dev(struct device *dev);
 extern void iommu_set_default_passthrough(bool cmd_line);
Signature · 1 line
2.24.1
#3 lore raw

PATCH v3 2/5 iommu: arm: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/arm-smmu-v3.c | 11 +----------
 drivers/iommu/arm-smmu.c    | 11 +----------
 2 files changed, 2 insertions(+), 20 deletions(-)
drivers/iommu/arm-smmu-v3.c +1 -10
index effe72eb89e7..7f5b74a418de 100644
@@ -2710,15 +2710,6 @@ static void arm_smmu_get_resv_regions(struct device *dev,
 	iommu_dma_get_resv_regions(dev, head);
 }
 
-static void arm_smmu_put_resv_regions(struct device *dev,
-				      struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static struct iommu_ops arm_smmu_ops = {
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
@@ -2736,7 +2727,7 @@ static struct iommu_ops arm_smmu_ops = {
 	.domain_set_attr	= arm_smmu_domain_set_attr,
 	.of_xlate		= arm_smmu_of_xlate,
 	.get_resv_regions	= arm_smmu_get_resv_regions,
-	.put_resv_regions	= arm_smmu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.pgsize_bitmap		= -1UL, /* Restricted during device attach */
 };
 
drivers/iommu/arm-smmu.c +1 -10
index 31ad3fe9a6d1..7a5978bbeca8 100644
@@ -1576,15 +1576,6 @@ static void arm_smmu_get_resv_regions(struct device *dev,
 	iommu_dma_get_resv_regions(dev, head);
 }
 
-static void arm_smmu_put_resv_regions(struct device *dev,
-				      struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static struct iommu_ops arm_smmu_ops = {
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
@@ -1602,7 +1593,7 @@ static struct iommu_ops arm_smmu_ops = {
 	.domain_set_attr	= arm_smmu_domain_set_attr,
 	.of_xlate		= arm_smmu_of_xlate,
 	.get_resv_regions	= arm_smmu_get_resv_regions,
-	.put_resv_regions	= arm_smmu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.pgsize_bitmap		= -1UL, /* Restricted during device attach */
 };
 
Signature · 1 line
2.24.1
#5 lore raw

PATCH v3 3/5 iommu: amd: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/amd_iommu.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/amd_iommu.c +1 -10
index 7a6c056b9b9c..9ea6c4b8e402 100644
@@ -2638,15 +2638,6 @@ static void amd_iommu_get_resv_regions(struct device *dev,
 	list_add_tail(&region->list, head);
 }
 
-static void amd_iommu_put_resv_regions(struct device *dev,
-				     struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static bool amd_iommu_is_attach_deferred(struct iommu_domain *domain,
 					 struct device *dev)
 {
@@ -2685,7 +2676,7 @@ const struct iommu_ops amd_iommu_ops = {
 	.device_group = amd_iommu_device_group,
 	.domain_get_attr = amd_iommu_domain_get_attr,
 	.get_resv_regions = amd_iommu_get_resv_regions,
-	.put_resv_regions = amd_iommu_put_resv_regions,
+	.put_resv_regions = generic_iommu_put_resv_regions,
 	.is_attach_deferred = amd_iommu_is_attach_deferred,
 	.pgsize_bitmap	= AMD_IOMMU_PGSIZES,
 	.flush_iotlb_all = amd_iommu_flush_iotlb_all,
Signature · 1 line
2.24.1
#7 lore raw

PATCH v3 4/5 iommu: intel: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/intel-iommu.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +1 -10
index 42966611a192..a6d5b7cf9183 100644
@@ -5744,15 +5744,6 @@ static void intel_iommu_get_resv_regions(struct device *device,
 	list_add_tail(&reg->list, head);
 }
 
-static void intel_iommu_put_resv_regions(struct device *dev,
-					 struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct device *dev)
 {
 	struct device_domain_info *info;
@@ -5987,7 +5978,7 @@ const struct iommu_ops intel_iommu_ops = {
 	.add_device		= intel_iommu_add_device,
 	.remove_device		= intel_iommu_remove_device,
 	.get_resv_regions	= intel_iommu_get_resv_regions,
-	.put_resv_regions	= intel_iommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.apply_resv_region	= intel_iommu_apply_resv_region,
 	.device_group		= pci_device_group,
 	.dev_has_feat		= intel_iommu_dev_has_feat,
Signature · 1 line
2.24.1
#14 lore raw

PATCH v3 5/5 iommu: virtio: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/virtio-iommu.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/iommu/virtio-iommu.c +3 -11
index 315c7cc4f99d..cce329d71fba 100644
@@ -837,14 +837,6 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)
 	iommu_dma_get_resv_regions(dev, head);
 }
 
-static void viommu_put_resv_regions(struct device *dev, struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static struct iommu_ops viommu_ops;
 static struct virtio_driver virtio_iommu_drv;
 
@@ -914,7 +906,7 @@ static int viommu_add_device(struct device *dev)
 err_unlink_dev:
 	iommu_device_unlink(&viommu->iommu, dev);
 err_free_dev:
-	viommu_put_resv_regions(dev, &vdev->resv_regions);
+	generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
 	kfree(vdev);
 
 	return ret;
@@ -932,7 +924,7 @@ static void viommu_remove_device(struct device *dev)
 
 	iommu_group_remove_device(dev);
 	iommu_device_unlink(&vdev->viommu->iommu, dev);
-	viommu_put_resv_regions(dev, &vdev->resv_regions);
+	generic_iommu_put_resv_regions(dev, &vdev->resv_regions);
 	kfree(vdev);
 }
 
@@ -961,7 +953,7 @@ static struct iommu_ops viommu_ops = {
 	.remove_device		= viommu_remove_device,
 	.device_group		= viommu_device_group,
 	.get_resv_regions	= viommu_get_resv_regions,
-	.put_resv_regions	= viommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.of_xlate		= viommu_of_xlate,
 };
 
Signature · 1 line
2.24.1
#0 lore raw

v3 cover iommu: Implement generic_iommu_put_resv_regions()

From: Thierry Reding <[email protected]>

Most IOMMU drivers only need to free the memory allocated for each reserved region. Instead of open-coding the loop to do this in each driver, extract the code into a common function that can be used by all these drivers.

Changes in v3:
- add Reviewed-by from Jean-Philippe Brucker on virtio patch
- add Acked-by from Will Deacon on ARM SMMU patch
- rename to generic_iommu_put_resv_regions()

Changes in v2:
- change subject prefix to "iommu: virtio: " for virtio-iommu.c driver

Thierry

Thierry Reding (5):
iommu: Implement generic_iommu_put_resv_regions()
iommu: arm: Use generic_iommu_put_resv_regions()
iommu: amd: Use generic_iommu_put_resv_regions()
iommu: intel: Use generic_iommu_put_resv_regions()
iommu: virtio: Use generic_iommu_put_resv_regions()

 drivers/iommu/amd_iommu.c    | 11 +----------
 drivers/iommu/arm-smmu-v3.c  | 11 +----------
 drivers/iommu/arm-smmu.c     | 11 +----------
 drivers/iommu/intel-iommu.c  | 11 +----------
 drivers/iommu/iommu.c        | 19 +++++++++++++++++++
 drivers/iommu/virtio-iommu.c | 14 +++-----------
 include/linux/iommu.h        |  2 ++
 7 files changed, 28 insertions(+), 51 deletions(-)
Signature · 1 line
2.24.1
#2 lore raw

PATCH v3 1/5 iommu: Implement generic_iommu_put_resv_regions()

From: Thierry Reding <[email protected]>

Implement a generic function for removing reserved regions. This can be used by drivers that don't do anything fancy with these regions other than allocating memory for them.

---
 drivers/iommu/iommu.c | 19 +++++++++++++++++++
 include/linux/iommu.h |  2 ++
 2 files changed, 21 insertions(+)
drivers/iommu/iommu.c +19 -0
index fdd40756dbc1..101f2d68eb6e 100644
@@ -2229,6 +2229,25 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
 		ops->put_resv_regions(dev, list);
 }
 
+/**
+ * generic_iommu_put_resv_regions - Reserved region driver helper
+ * @dev: device for which to free reserved regions
+ * @list: reserved region list for device
+ *
+ * IOMMU drivers can use this to implement their .put_resv_regions() callback
+ * for simple reservations. Memory allocated for each reserved region will be
+ * freed. If an IOMMU driver allocates additional resources per region, it is
+ * going to have to implement a custom callback.
+ */
+void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
+{
+	struct iommu_resv_region *entry, *next;
+
+	list_for_each_entry_safe(entry, next, list, list)
+		kfree(entry);
+}
+EXPORT_SYMBOL(generic_iommu_put_resv_regions);
+
 struct iommu_resv_region *iommu_alloc_resv_region(phys_addr_t start,
 						  size_t length, int prot,
 						  enum iommu_resv_type type)
include/linux/iommu.h +2 -0
index 1b4fbe703950..2e06b31579c2 100644
@@ -477,6 +477,8 @@ extern void iommu_set_fault_handler(struct iommu_domain *domain,
 
 extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
 extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
+extern void generic_iommu_put_resv_regions(struct device *dev,
+					   struct list_head *list);
 extern int iommu_request_dm_for_dev(struct device *dev);
 extern int iommu_request_dma_domain_for_dev(struct device *dev);
 extern void iommu_set_default_passthrough(bool cmd_line);
Signature · 1 line
2.24.1
#4 lore raw

PATCH v3 2/5 iommu: arm: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/arm-smmu-v3.c | 11 +----------
 drivers/iommu/arm-smmu.c    | 11 +----------
 2 files changed, 2 insertions(+), 20 deletions(-)
drivers/iommu/arm-smmu-v3.c +1 -10
index effe72eb89e7..7f5b74a418de 100644
@@ -2710,15 +2710,6 @@ static void arm_smmu_get_resv_regions(struct device *dev,
 	iommu_dma_get_resv_regions(dev, head);
 }
 
-static void arm_smmu_put_resv_regions(struct device *dev,
-				      struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static struct iommu_ops arm_smmu_ops = {
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
@@ -2736,7 +2727,7 @@ static struct iommu_ops arm_smmu_ops = {
 	.domain_set_attr	= arm_smmu_domain_set_attr,
 	.of_xlate		= arm_smmu_of_xlate,
 	.get_resv_regions	= arm_smmu_get_resv_regions,
-	.put_resv_regions	= arm_smmu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.pgsize_bitmap		= -1UL, /* Restricted during device attach */
 };
 
drivers/iommu/arm-smmu.c +1 -10
index 31ad3fe9a6d1..7a5978bbeca8 100644
@@ -1576,15 +1576,6 @@ static void arm_smmu_get_resv_regions(struct device *dev,
 	iommu_dma_get_resv_regions(dev, head);
 }
 
-static void arm_smmu_put_resv_regions(struct device *dev,
-				      struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static struct iommu_ops arm_smmu_ops = {
 	.capable		= arm_smmu_capable,
 	.domain_alloc		= arm_smmu_domain_alloc,
@@ -1602,7 +1593,7 @@ static struct iommu_ops arm_smmu_ops = {
 	.domain_set_attr	= arm_smmu_domain_set_attr,
 	.of_xlate		= arm_smmu_of_xlate,
 	.get_resv_regions	= arm_smmu_get_resv_regions,
-	.put_resv_regions	= arm_smmu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.pgsize_bitmap		= -1UL, /* Restricted during device attach */
 };
 
Signature · 1 line
2.24.1
#6 lore raw

PATCH v3 3/5 iommu: amd: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/amd_iommu.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/amd_iommu.c +1 -10
index 7a6c056b9b9c..9ea6c4b8e402 100644
@@ -2638,15 +2638,6 @@ static void amd_iommu_get_resv_regions(struct device *dev,
 	list_add_tail(&region->list, head);
 }
 
-static void amd_iommu_put_resv_regions(struct device *dev,
-				     struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 static bool amd_iommu_is_attach_deferred(struct iommu_domain *domain,
 					 struct device *dev)
 {
@@ -2685,7 +2676,7 @@ const struct iommu_ops amd_iommu_ops = {
 	.device_group = amd_iommu_device_group,
 	.domain_get_attr = amd_iommu_domain_get_attr,
 	.get_resv_regions = amd_iommu_get_resv_regions,
-	.put_resv_regions = amd_iommu_put_resv_regions,
+	.put_resv_regions = generic_iommu_put_resv_regions,
 	.is_attach_deferred = amd_iommu_is_attach_deferred,
 	.pgsize_bitmap	= AMD_IOMMU_PGSIZES,
 	.flush_iotlb_all = amd_iommu_flush_iotlb_all,
Signature · 6 lines
2.24.1

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#8 lore raw

PATCH v3 4/5 iommu: intel: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
 drivers/iommu/intel-iommu.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +1 -10
index 42966611a192..a6d5b7cf9183 100644
@@ -5744,15 +5744,6 @@ static void intel_iommu_get_resv_regions(struct device *device,
 	list_add_tail(&reg->list, head);
 }
 
-static void intel_iommu_put_resv_regions(struct device *dev,
-					 struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
 int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct device *dev)
 {
 	struct device_domain_info *info;
@@ -5987,7 +5978,7 @@ const struct iommu_ops intel_iommu_ops = {
 	.add_device		= intel_iommu_add_device,
 	.remove_device		= intel_iommu_remove_device,
 	.get_resv_regions	= intel_iommu_get_resv_regions,
-	.put_resv_regions	= intel_iommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
 	.apply_resv_region	= intel_iommu_apply_resv_region,
 	.device_group		= pci_device_group,
 	.dev_has_feat		= intel_iommu_dev_has_feat,
Signature · 1 line
2.24.1
Acked-by on v3 4/5
#9 lore raw

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

Please tweak the title to

"iommu/vt-d: Use generic_iommu_put_resv_regions()"

then,

Best regards,
baolu

Quoted 40 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
  drivers/iommu/intel-iommu.c | 11 +----------
  1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +1 -10
index 42966611a192..a6d5b7cf9183 100644
@@ -5744,15 +5744,6 @@ static void intel_iommu_get_resv_regions(struct device *device,
  	list_add_tail(&reg->list, head);
  }
 
-static void intel_iommu_put_resv_regions(struct device *dev,
-					 struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
  int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct device *dev)
  {
  	struct device_domain_info *info;
@@ -5987,7 +5978,7 @@ const struct iommu_ops intel_iommu_ops = {
  	.add_device		= intel_iommu_add_device,
  	.remove_device		= intel_iommu_remove_device,
  	.get_resv_regions	= intel_iommu_get_resv_regions,
-	.put_resv_regions	= intel_iommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
  	.apply_resv_region	= intel_iommu_apply_resv_region,
  	.device_group		= pci_device_group,
  	.dev_has_feat		= intel_iommu_dev_has_feat,
#10 lore raw

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

Quoted 10 lines · Lu Baolu

Please tweak the title to

"iommu/vt-d: Use generic_iommu_put_resv_regions()"

then,

Best regards,
baolu

Joerg, do you want me to resend with this change or is it more efficient if you fix up the subject while applying?

Thierry

Quoted 32 lines · Thierry Reding
Quoted 31 lines

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
  drivers/iommu/intel-iommu.c | 11 +----------
  1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +0 -9
index 42966611a192..a6d5b7cf9183 100644
@@ -5744,15 +5744,6 @@ static void intel_iommu_get_resv_regions(struct device *device,
  	list_add_tail(&reg->list, head);
  }
-static void intel_iommu_put_resv_regions(struct device *dev,
-					 struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
  int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct device *dev)
  {
  	struct device_domain_info *info;
@@ -5987,7 +5978,7 @@ const struct iommu_ops intel_iommu_ops = {
  	.add_device		= intel_iommu_add_device,
Quoted 8 lines

drivers/iommu/intel-iommu.c const struct iommu_ops intel_iommu_ops = { · line 5984

Quoted 8 lines
drivers/iommu/intel-iommu.c +1 -1
  	.remove_device		= intel_iommu_remove_device,
  	.get_resv_regions	= intel_iommu_get_resv_regions,
-	.put_resv_regions	= intel_iommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
  	.apply_resv_region	= intel_iommu_apply_resv_region,
  	.device_group		= pci_device_group,
  	.dev_has_feat		= intel_iommu_dev_has_feat,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#11 lore raw

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

In reply to Lu Baolu
Quoted 10 lines · Lu Baolu

Please tweak the title to

"iommu/vt-d: Use generic_iommu_put_resv_regions()"

then,

Best regards,
baolu

Joerg, do you want me to resend with this change or is it more efficient if you fix up the subject while applying?

Thierry

Quoted 40 lines · Thierry Reding
Quoted 39 lines

From: Thierry Reding <[email protected]>

Use the new standard function instead of open-coding it.

---
  drivers/iommu/intel-iommu.c | 11 +----------
  1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +1 -10
index 42966611a192..a6d5b7cf9183 100644
@@ -5744,15 +5744,6 @@ static void intel_iommu_get_resv_regions(struct device *device,
  	list_add_tail(&reg->list, head);
  }
-static void intel_iommu_put_resv_regions(struct device *dev,
-					 struct list_head *head)
-{
-	struct iommu_resv_region *entry, *next;
-
-	list_for_each_entry_safe(entry, next, head, list)
-		kfree(entry);
-}
-
  int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct device *dev)
  {
  	struct device_domain_info *info;
@@ -5987,7 +5978,7 @@ const struct iommu_ops intel_iommu_ops = {
  	.add_device		= intel_iommu_add_device,
  	.remove_device		= intel_iommu_remove_device,
  	.get_resv_regions	= intel_iommu_get_resv_regions,
-	.put_resv_regions	= intel_iommu_put_resv_regions,
+	.put_resv_regions	= generic_iommu_put_resv_regions,
  	.apply_resv_region	= intel_iommu_apply_resv_region,
  	.device_group		= pci_device_group,
  	.dev_has_feat		= intel_iommu_dev_has_feat,
maintainer
#12 lore raw

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

Quoted 7 lines · Thierry Reding
Quoted 6 lines · Lu Baolu

Please tweak the title to

"iommu/vt-d: Use generic_iommu_put_resv_regions()"

then,

Quoted 7 lines
Quoted 4 lines

Best regards,
baolu

Joerg, do you want me to resend with this change or is it more efficient if you fix up the subject while applying?

No need to re-send, I'll fix it up in this patch and in the others too.

Joerg

maintainer
#13 lore raw

Re: [PATCH v3 4/5] iommu: intel: Use generic_iommu_put_resv_regions()

In reply to Thierry Reding
Quoted 7 lines · Thierry Reding
Quoted 6 lines · Lu Baolu

Please tweak the title to

"iommu/vt-d: Use generic_iommu_put_resv_regions()"

then,

Quoted 7 lines
Quoted 4 lines

Best regards,
baolu

Joerg, do you want me to resend with this change or is it more efficient if you fix up the subject while applying?

No need to re-send, I'll fix it up in this patch and in the others too.

Joerg