Skip to contentSkip to conversation

vfio: platform: use vfio_iommu_group_get/put

PATCH In review Peng Fan 4 participants 10 messages May 9, 2016 – May 20, 2016

Subsystems (3)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 vfio: platform: use vfio_iommu_group_get/put

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	vdev->device = dev;
 
-	group = iommu_group_get(dev);
+	group = vfio_iommu_group_get(dev);
 	if (!group) {
 		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
 		return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
 	if (ret) {
-		iommu_group_put(group);
+		vfio_iommu_group_put(group);
 		return ret;
 	}
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
 	if (vdev) {
 		vfio_platform_put_reset(vdev);
-		iommu_group_put(dev->iommu_group);
+		vfio_iommu_group_put(dev->iommu_group, dev);
 	}
 
 	return vdev;
Signature · 1 line
2.6.2
#1 lore raw
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	vdev->device = dev;
 
-	group = iommu_group_get(dev);
+	group = vfio_iommu_group_get(dev);
 	if (!group) {
 		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
 		return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
 	if (ret) {
-		iommu_group_put(group);
+		vfio_iommu_group_put(group);
 		return ret;
 	}
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
 	if (vdev) {
 		vfio_platform_put_reset(vdev);
-		iommu_group_put(dev->iommu_group);
+		vfio_iommu_group_put(dev->iommu_group, dev);
 	}
 
 	return vdev;
author
#2 lore raw

Hi Alex,

Quoted 9 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Thanks,
Peng.

Quoted 41 lines
Quoted 40 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	vdev->device = dev;
 
-	group = iommu_group_get(dev);
+	group = vfio_iommu_group_get(dev);
 	if (!group) {
 		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
 		return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
 	if (ret) {
-		iommu_group_put(group);
+		vfio_iommu_group_put(group);
 		return ret;
 	}
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
 	if (vdev) {
 		vfio_platform_put_reset(vdev);
-		iommu_group_put(dev->iommu_group);
+		vfio_iommu_group_put(dev->iommu_group, dev);
 	}
 
 	return vdev;
#3 lore raw
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	vdev->device = dev;
 
-	group = iommu_group_get(dev);
+	group = vfio_iommu_group_get(dev);
 	if (!group) {
 		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
 		return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
 	if (ret) {
-		iommu_group_put(group);
+		vfio_iommu_group_put(group);
 		return ret;
 	}
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
 	if (vdev) {
 		vfio_platform_put_reset(vdev);
-		iommu_group_put(dev->iommu_group);
+		vfio_iommu_group_put(dev->iommu_group, dev);
 	}
 
 	return vdev;  
#4 lore raw

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	vdev->device = dev;
 
-	group = iommu_group_get(dev);
+	group = vfio_iommu_group_get(dev);
 	if (!group) {
 		pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
 		return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
 	ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
 	if (ret) {
-		iommu_group_put(group);
+		vfio_iommu_group_put(group);
 		return ret;
 	}
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
 	if (vdev) {
 		vfio_platform_put_reset(vdev);
-		iommu_group_put(dev->iommu_group);
+		vfio_iommu_group_put(dev->iommu_group, dev);
 	}
 
 	return vdev;  
#5 lore raw

Hi,

Quoted 31 lines · Eric Auger

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

Quoted 4 lines

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Since safety issues have already been addressed for the PCI patch series, I don't see any reason not to enable it. You might extend the commit message to remind those issues.

Best regards,
Baptiste

Quoted 49 lines

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   vdev->device = dev;
 
-  group = iommu_group_get(dev);
+  group = vfio_iommu_group_get(dev);
   if (!group) {
           pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
           return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
   if (ret) {
-          iommu_group_put(group);
+          vfio_iommu_group_put(group);
           return ret;
   }
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
   if (vdev) {
           vfio_platform_put_reset(vdev);
-          iommu_group_put(dev->iommu_group);
+          vfio_iommu_group_put(dev->iommu_group, dev);
   }
 
   return vdev;
author
#6 lore raw

Hi,

Quoted 38 lines · Baptiste Reynal

Hi,

Quoted 35 lines · Eric Auger

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Yeah. Initially I would like to try vfio on my i.MX6/7 boards which does not have HW iommu. I am new to this, so just wrote this simple patch when I was reading the source code.

Quoted 4 lines

Since safety issues have already been addressed for the PCI patch series, I don't see any reason not to enable it. You might extend the commit message to remind those issues.

Eric, Baptiste,

Is vfio-platform no-iommu on your TODO list? I am happy to help test. If not, I can try work on this if you could guide me -:)

Thanks,
Peng.

Quoted 53 lines

Best regards,
Baptiste

Quoted 49 lines

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   vdev->device = dev;
 
-  group = iommu_group_get(dev);
+  group = vfio_iommu_group_get(dev);
   if (!group) {
           pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
           return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
   if (ret) {
-          iommu_group_put(group);
+          vfio_iommu_group_put(group);
           return ret;
   }
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
   if (vdev) {
           vfio_platform_put_reset(vdev);
-          iommu_group_put(dev->iommu_group);
+          vfio_iommu_group_put(dev->iommu_group, dev);
   }
 
   return vdev;
#7 lore raw

Hi Peng,

Quoted 47 lines · Peng Fan

Hi,

Quoted 38 lines · Baptiste Reynal

Hi,

Quoted 35 lines · Eric Auger

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Yeah. Initially I would like to try vfio on my i.MX6/7 boards which does not have HW iommu. I am new to this, so just wrote this simple patch when I was reading the source code.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Since safety issues have already been addressed for the PCI patch series, I don't see any reason not to enable it. You might extend the commit message to remind those issues.

Eric, Baptiste,

Is vfio-platform no-iommu on your TODO list? I am happy to help test. If not, I can try work on this if you could guide me -:)

No it is not at the moment. shouldn't it work already with this very patch? I will be happy to bring support to you if needed.

Best Regards

Eric

Quoted 56 lines

Thanks,
Peng.

Quoted 53 lines

Best regards,
Baptiste

Quoted 49 lines

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   vdev->device = dev;
 
-  group = iommu_group_get(dev);
+  group = vfio_iommu_group_get(dev);
   if (!group) {
           pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
           return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
   if (ret) {
-          iommu_group_put(group);
+          vfio_iommu_group_put(group);
           return ret;
   }
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
   if (vdev) {
           vfio_platform_put_reset(vdev);
-          iommu_group_put(dev->iommu_group);
+          vfio_iommu_group_put(dev->iommu_group, dev);
   }
 
   return vdev;
author
#8 lore raw

Hi Eric,

Quoted 53 lines · Eric Auger

Hi Peng,

Quoted 51 lines · Peng Fan

Hi,

Quoted 38 lines · Baptiste Reynal

Hi,

Quoted 35 lines · Eric Auger

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Yeah. Initially I would like to try vfio on my i.MX6/7 boards which does not have HW iommu. I am new to this, so just wrote this simple patch when I was reading the source code.

Quoted 4 lines

Since safety issues have already been addressed for the PCI patch series, I don't see any reason not to enable it. You might extend the commit message to remind those issues.

Quoted 6 lines
Quoted 4 lines

Eric, Baptiste,

Is vfio-platform no-iommu on your TODO list? I am happy to help test. If not, I can try work on this if you could guide me -:)

No it is not at the moment. shouldn't it work already with this very patch? I will be happy to bring support to you if needed.

This patch was code inspection work. Since it did not break vfio-platform iommu, I sent it out. I have not played well with userspace test code/step or qemu (:

Is it ok for me to test vfio-platform no-iommu using a platform device withou DMA capability, such as simple UART?

If it's ok, I'll follow the test code[1] to write my test code and do some test.

Regards,
Peng.

[1] https://github.com/virtualopensystems/vfio-host-test/tree/master/src_test

Quoted 61 lines

Best Regards

Eric

Quoted 56 lines

Thanks,
Peng.

Quoted 53 lines

Best regards,
Baptiste

Quoted 49 lines

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   vdev->device = dev;
 
-  group = iommu_group_get(dev);
+  group = vfio_iommu_group_get(dev);
   if (!group) {
           pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
           return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
   if (ret) {
-          iommu_group_put(group);
+          vfio_iommu_group_put(group);
           return ret;
   }
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
   if (vdev) {
           vfio_platform_put_reset(vdev);
-          iommu_group_put(dev->iommu_group);
+          vfio_iommu_group_put(dev->iommu_group, dev);
   }
 
   return vdev;
#9 lore raw

Hi Peng,

Quoted 63 lines · Peng Fan

Hi Eric,

Quoted 53 lines · Eric Auger

Hi Peng,

Quoted 51 lines · Peng Fan

Hi,

Quoted 38 lines · Baptiste Reynal

Hi,

Quoted 35 lines · Eric Auger

Hi,

Quoted 20 lines · Alex Williamson
Quoted 9 lines · On Tue, 10 May 2016 15:40:28 +0800 Peng Fan <[email protected]> wrote:

Hi Alex,

Quoted 6 lines · Alex Williamson
Quoted 2 lines · On Mon, 9 May 2016 18:01:43 +0800 Peng Fan <[email protected]> wrote:

Use vfio_iommu_group_get and vfio_iommu_group_put, but not iommu_group_get or iommu_group_put.

Quoted 7 lines
Quoted 3 lines

I assume you're trying to duplicate the vfio_pci changes from commit 03a76b60f8ba to enable no-iommu mode. That would be really relevant information for the commit log.

This is not to support non-iommu for vfio platform. I just think vfio_iommu_group_get/put is vfio core API and should be used by vfio-pci and vfio-platform.

Quoted 8 lines

Hi Peng,

I suppose I would consider this an optional part of the internal vfio API, it's only real purpose it to provide the ability to create fake groups which are only used for no-iommu. It's perfectly legitimate to use iommu_group_get/put if there is no desire to enable no-iommu. Baptiste, Eric, do you have an opinion whether enabling no-iommu in vfio/platform is something we should do? Thanks,

I think it would make sense to introduce that no-iommu feature for vfio-platform because it allows potential users to get familiar with VFIO platform without having the proper HW. I also thought the primary purpose of this patch was to introduce that support.

Yeah. Initially I would like to try vfio on my i.MX6/7 boards which does not have HW iommu. I am new to this, so just wrote this simple patch when I was reading the source code.

Quoted 4 lines

Since safety issues have already been addressed for the PCI patch series, I don't see any reason not to enable it. You might extend the commit message to remind those issues.

Quoted 6 lines
Quoted 4 lines

Eric, Baptiste,

Is vfio-platform no-iommu on your TODO list? I am happy to help test. If not, I can try work on this if you could guide me -:)

No it is not at the moment. shouldn't it work already with this very patch? I will be happy to bring support to you if needed.

Quoted 6 lines

This patch was code inspection work. Since it did not break vfio-platform iommu, I sent it out. I have not played well with userspace test code/step or qemu (:

Is it ok for me to test vfio-platform no-iommu using a platform device withou DMA capability, such as simple UART?

My feeling is that it is a reasonable start.

Best Regards

Eric

Quoted 69 lines

If it's ok, I'll follow the test code[1] to write my test code and do some test.

Regards,
Peng.

[1] https://github.com/virtualopensystems/vfio-host-test/tree/master/src_test

Quoted 61 lines

Best Regards

Eric

Quoted 56 lines

Thanks,
Peng.

Quoted 53 lines

Best regards,
Baptiste

Quoted 49 lines

Best Regards

Eric

Quoted 44 lines

Alex

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
Cc Baptiste Reynal <[email protected]>
Cc Alex Williamson <[email protected]>
---
 drivers/vfio/platform/vfio_platform_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +3 -3
index e65b142..582885e 100644
@@ -561,7 +561,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   vdev->device = dev;
 
-  group = iommu_group_get(dev);
+  group = vfio_iommu_group_get(dev);
   if (!group) {
           pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
           return -EINVAL;
@@ -569,7 +569,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
   ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
   if (ret) {
-          iommu_group_put(group);
+          vfio_iommu_group_put(group);
           return ret;
   }
 
@@ -589,7 +589,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
 
   if (vdev) {
           vfio_platform_put_reset(vdev);
-          iommu_group_put(dev->iommu_group);
+          vfio_iommu_group_put(dev->iommu_group, dev);
   }
 
   return vdev;