summaryrefslogtreecommitdiffstats
path: root/drivers/vfio
diff options
context:
space:
mode:
authorEric Auger <eric.auger@linaro.org>2015-06-15 05:09:43 -0400
committerAlex Williamson <alex.williamson@redhat.com>2015-06-22 11:35:22 -0400
commit813ae66008aeb97a48f20efefeb962179b642dbe (patch)
treeabc7911b21ac87c15f8614d5618e680456b0309c /drivers/vfio
parent9f85d8f9fa342b22f01b8b4416c850bac00c2b4a (diff)
VFIO: platform: add reset callback
A new reset callback is introduced. If this callback is populated, the reset is invoked on device first open/last close or upon userspace ioctl. The modality is exposed on VFIO_DEVICE_GET_INFO. Signed-off-by: Eric Auger <eric.auger@linaro.org> Acked-by: Baptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: Baptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r--drivers/vfio/platform/vfio_platform_common.c15
-rw-r--r--drivers/vfio/platform/vfio_platform_private.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index 611597e65f44..63935811cbd9 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -103,6 +103,8 @@ static void vfio_platform_release(void *device_data)
103 mutex_lock(&driver_lock); 103 mutex_lock(&driver_lock);
104 104
105 if (!(--vdev->refcnt)) { 105 if (!(--vdev->refcnt)) {
106 if (vdev->reset)
107 vdev->reset(vdev);
106 vfio_platform_regions_cleanup(vdev); 108 vfio_platform_regions_cleanup(vdev);
107 vfio_platform_irq_cleanup(vdev); 109 vfio_platform_irq_cleanup(vdev);
108 } 110 }
@@ -130,6 +132,9 @@ static int vfio_platform_open(void *device_data)
130 ret = vfio_platform_irq_init(vdev); 132 ret = vfio_platform_irq_init(vdev);
131 if (ret) 133 if (ret)
132 goto err_irq; 134 goto err_irq;
135
136 if (vdev->reset)
137 vdev->reset(vdev);
133 } 138 }
134 139
135 vdev->refcnt++; 140 vdev->refcnt++;
@@ -162,6 +167,8 @@ static long vfio_platform_ioctl(void *device_data,
162 if (info.argsz < minsz) 167 if (info.argsz < minsz)
163 return -EINVAL; 168 return -EINVAL;
164 169
170 if (vdev->reset)
171 vdev->flags |= VFIO_DEVICE_FLAGS_RESET;
165 info.flags = vdev->flags; 172 info.flags = vdev->flags;
166 info.num_regions = vdev->num_regions; 173 info.num_regions = vdev->num_regions;
167 info.num_irqs = vdev->num_irqs; 174 info.num_irqs = vdev->num_irqs;
@@ -255,8 +262,12 @@ static long vfio_platform_ioctl(void *device_data,
255 262
256 return ret; 263 return ret;
257 264
258 } else if (cmd == VFIO_DEVICE_RESET) 265 } else if (cmd == VFIO_DEVICE_RESET) {
259 return -EINVAL; 266 if (vdev->reset)
267 return vdev->reset(vdev);
268 else
269 return -EINVAL;
270 }
260 271
261 return -ENOTTY; 272 return -ENOTTY;
262} 273}
diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h
index 9e37b9fda483..1c9b3d59543c 100644
--- a/drivers/vfio/platform/vfio_platform_private.h
+++ b/drivers/vfio/platform/vfio_platform_private.h
@@ -67,6 +67,7 @@ struct vfio_platform_device {
67 struct resource* 67 struct resource*
68 (*get_resource)(struct vfio_platform_device *vdev, int i); 68 (*get_resource)(struct vfio_platform_device *vdev, int i);
69 int (*get_irq)(struct vfio_platform_device *vdev, int i); 69 int (*get_irq)(struct vfio_platform_device *vdev, int i);
70 int (*reset)(struct vfio_platform_device *vdev);
70}; 71};
71 72
72struct vfio_platform_reset_combo { 73struct vfio_platform_reset_combo {