Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1163152
| From | Feng Wu <feng.wu@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [v4 09/16] VFIO: external user API for interaction |
| Date | 2015-06-11 13:10 +0200 |
| Message-ID | <pA8wX-3OV-49@gated-at.bofh.it> (permalink) |
| References | <pA8wV-3OV-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Eric Auger <eric.auger@linaro.org>
The VFIO external user API is enriched with 3 new functions that
allows a kernel user external to VFIO to retrieve some information
from a VFIO device.
- vfio_device_get_external_user enables to get a vfio device from
its fd and increments its reference counter
- vfio_device_put_external_user decrements the reference counter
- vfio_external_base_device returns a handle to the struct device
Signed-off-by: Eric Auger <eric.auger@linaro.org>
---
drivers/vfio/vfio.c | 24 ++++++++++++++++++++++++
include/linux/vfio.h | 3 +++
2 files changed, 27 insertions(+)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index e1278fe..c10b3cb 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1504,6 +1504,30 @@ void vfio_group_put_external_user(struct vfio_group *group)
}
EXPORT_SYMBOL_GPL(vfio_group_put_external_user);
+struct vfio_device *vfio_device_get_external_user(struct file *filep)
+{
+ struct vfio_device *vdev = filep->private_data;
+
+ if (filep->f_op != &vfio_device_fops)
+ return ERR_PTR(-EINVAL);
+
+ vfio_device_get(vdev);
+ return vdev;
+}
+EXPORT_SYMBOL_GPL(vfio_device_get_external_user);
+
+void vfio_device_put_external_user(struct vfio_device *vdev)
+{
+ vfio_device_put(vdev);
+}
+EXPORT_SYMBOL_GPL(vfio_device_put_external_user);
+
+struct device *vfio_external_base_device(struct vfio_device *vdev)
+{
+ return vdev->dev;
+}
+EXPORT_SYMBOL_GPL(vfio_external_base_device);
+
int vfio_external_user_iommu_id(struct vfio_group *group)
{
return iommu_group_id(group->iommu_group);
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index ddb4409..e120e9a 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -88,6 +88,9 @@ extern void vfio_group_put_external_user(struct vfio_group *group);
extern int vfio_external_user_iommu_id(struct vfio_group *group);
extern long vfio_external_check_extension(struct vfio_group *group,
unsigned long arg);
+extern struct vfio_device *vfio_device_get_external_user(struct file *filep);
+extern void vfio_device_put_external_user(struct vfio_device *vdev);
+extern struct device *vfio_external_base_device(struct vfio_device *vdev);
struct pci_dev;
#ifdef CONFIG_EEH
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[v4 00/16] Add VT-d Posted-Interrupts support Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 12/16] KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
RE: [v4 12/16] KVM: kvm-vfio: implement the VFIO skeleton for VT-d Posted-Interrupts "Wu, Feng" <feng.wu@intel.com> - 2015-06-12 07:00 +0200
[v4 13/16] KVM: x86: kvm-vfio: VT-d posted-interrupts setup Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
RE: [v4 13/16] KVM: x86: kvm-vfio: VT-d posted-interrupts setup "Wu, Feng" <feng.wu@intel.com> - 2015-06-12 07:00 +0200
[v4 15/16] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 07/16] KVM: make kvm_set_msi_irq() public Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 10/16] KVM: kvm-vfio: wrappers to VFIO external API device helpers Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 11/16] KVM: kvm-vfio: User API for VT-d Posted-Interrupts Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 05/16] KVM: Add interfaces to control PI outside vmx Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 14/16] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 02/16] KVM: Add some helper functions for Posted-Interrupts Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 16/16] KVM: Warn if 'SN' is set during posting interrupts by software Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 04/16] KVM: Get Posted-Interrupts descriptor address from struct kvm_vcpu Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
[v4 09/16] VFIO: external user API for interaction Feng Wu <feng.wu@intel.com> - 2015-06-11 13:10 +0200
csiph-web