diff options
Diffstat (limited to 'drivers/s390/kvm/kvm_virtio.c')
-rw-r--r-- | drivers/s390/kvm/kvm_virtio.c | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c index cbc8566fab70..e38e5d306faf 100644 --- a/drivers/s390/kvm/kvm_virtio.c +++ b/drivers/s390/kvm/kvm_virtio.c | |||
@@ -173,8 +173,9 @@ static void kvm_notify(struct virtqueue *vq) | |||
173 | * this device and sets it up. | 173 | * this device and sets it up. |
174 | */ | 174 | */ |
175 | static struct virtqueue *kvm_find_vq(struct virtio_device *vdev, | 175 | static struct virtqueue *kvm_find_vq(struct virtio_device *vdev, |
176 | unsigned index, | 176 | unsigned index, |
177 | void (*callback)(struct virtqueue *vq)) | 177 | void (*callback)(struct virtqueue *vq), |
178 | const char *name) | ||
178 | { | 179 | { |
179 | struct kvm_device *kdev = to_kvmdev(vdev); | 180 | struct kvm_device *kdev = to_kvmdev(vdev); |
180 | struct kvm_vqconfig *config; | 181 | struct kvm_vqconfig *config; |
@@ -194,7 +195,7 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev, | |||
194 | 195 | ||
195 | vq = vring_new_virtqueue(config->num, KVM_S390_VIRTIO_RING_ALIGN, | 196 | vq = vring_new_virtqueue(config->num, KVM_S390_VIRTIO_RING_ALIGN, |
196 | vdev, (void *) config->address, | 197 | vdev, (void *) config->address, |
197 | kvm_notify, callback); | 198 | kvm_notify, callback, name); |
198 | if (!vq) { | 199 | if (!vq) { |
199 | err = -ENOMEM; | 200 | err = -ENOMEM; |
200 | goto unmap; | 201 | goto unmap; |
@@ -226,6 +227,38 @@ static void kvm_del_vq(struct virtqueue *vq) | |||
226 | KVM_S390_VIRTIO_RING_ALIGN)); | 227 | KVM_S390_VIRTIO_RING_ALIGN)); |
227 | } | 228 | } |
228 | 229 | ||
230 | static void kvm_del_vqs(struct virtio_device *vdev) | ||
231 | { | ||
232 | struct virtqueue *vq, *n; | ||
233 | |||
234 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) | ||
235 | kvm_del_vq(vq); | ||
236 | } | ||
237 | |||
238 | static int kvm_find_vqs(struct virtio_device *vdev, unsigned nvqs, | ||
239 | struct virtqueue *vqs[], | ||
240 | vq_callback_t *callbacks[], | ||
241 | const char *names[]) | ||
242 | { | ||
243 | struct kvm_device *kdev = to_kvmdev(vdev); | ||
244 | int i; | ||
245 | |||
246 | /* We must have this many virtqueues. */ | ||
247 | if (nvqs > kdev->desc->num_vq) | ||
248 | return -ENOENT; | ||
249 | |||
250 | for (i = 0; i < nvqs; ++i) { | ||
251 | vqs[i] = kvm_find_vq(vdev, i, callbacks[i], names[i]); | ||
252 | if (IS_ERR(vqs[i])) | ||
253 | goto error; | ||
254 | } | ||
255 | return 0; | ||
256 | |||
257 | error: | ||
258 | kvm_del_vqs(vdev); | ||
259 | return PTR_ERR(vqs[i]); | ||
260 | } | ||
261 | |||
229 | /* | 262 | /* |
230 | * The config ops structure as defined by virtio config | 263 | * The config ops structure as defined by virtio config |
231 | */ | 264 | */ |
@@ -237,8 +270,8 @@ static struct virtio_config_ops kvm_vq_configspace_ops = { | |||
237 | .get_status = kvm_get_status, | 270 | .get_status = kvm_get_status, |
238 | .set_status = kvm_set_status, | 271 | .set_status = kvm_set_status, |
239 | .reset = kvm_reset, | 272 | .reset = kvm_reset, |
240 | .find_vq = kvm_find_vq, | 273 | .find_vqs = kvm_find_vqs, |
241 | .del_vq = kvm_del_vq, | 274 | .del_vqs = kvm_del_vqs, |
242 | }; | 275 | }; |
243 | 276 | ||
244 | /* | 277 | /* |