Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / vdpa / virtio_pci / vp_vdpa.c
blob16380764275ea019bc1a741e16f61d424077cccc
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * vDPA bridge driver for modern virtio-pci device
5 * Copyright (c) 2020, Red Hat Inc. All rights reserved.
6 * Author: Jason Wang <jasowang@redhat.com>
8 * Based on virtio_pci_modern.c.
9 */
11 #include <linux/interrupt.h>
12 #include <linux/module.h>
13 #include <linux/pci.h>
14 #include <linux/vdpa.h>
15 #include <linux/virtio.h>
16 #include <linux/virtio_config.h>
17 #include <linux/virtio_ring.h>
18 #include <linux/virtio_pci.h>
19 #include <linux/virtio_pci_modern.h>
20 #include <uapi/linux/vdpa.h>
22 #define VP_VDPA_QUEUE_MAX 256
23 #define VP_VDPA_DRIVER_NAME "vp_vdpa"
24 #define VP_VDPA_NAME_SIZE 256
26 struct vp_vring {
27 void __iomem *notify;
28 char msix_name[VP_VDPA_NAME_SIZE];
29 struct vdpa_callback cb;
30 resource_size_t notify_pa;
31 int irq;
34 struct vp_vdpa {
35 struct vdpa_device vdpa;
36 struct virtio_pci_modern_device *mdev;
37 struct vp_vring *vring;
38 struct vdpa_callback config_cb;
39 u64 device_features;
40 char msix_name[VP_VDPA_NAME_SIZE];
41 int config_irq;
42 int queues;
43 int vectors;
46 struct vp_vdpa_mgmtdev {
47 struct vdpa_mgmt_dev mgtdev;
48 struct virtio_pci_modern_device *mdev;
49 struct vp_vdpa *vp_vdpa;
52 static struct vp_vdpa *vdpa_to_vp(struct vdpa_device *vdpa)
54 return container_of(vdpa, struct vp_vdpa, vdpa);
57 static struct virtio_pci_modern_device *vdpa_to_mdev(struct vdpa_device *vdpa)
59 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
61 return vp_vdpa->mdev;
64 static struct virtio_pci_modern_device *vp_vdpa_to_mdev(struct vp_vdpa *vp_vdpa)
66 return vp_vdpa->mdev;
69 static u64 vp_vdpa_get_device_features(struct vdpa_device *vdpa)
71 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
73 return vp_vdpa->device_features;
76 static int vp_vdpa_set_driver_features(struct vdpa_device *vdpa, u64 features)
78 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
80 vp_modern_set_features(mdev, features);
82 return 0;
85 static u64 vp_vdpa_get_driver_features(struct vdpa_device *vdpa)
87 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
89 return vp_modern_get_driver_features(mdev);
92 static u8 vp_vdpa_get_status(struct vdpa_device *vdpa)
94 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
96 return vp_modern_get_status(mdev);
99 static int vp_vdpa_get_vq_irq(struct vdpa_device *vdpa, u16 idx)
101 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
102 int irq = vp_vdpa->vring[idx].irq;
104 if (irq == VIRTIO_MSI_NO_VECTOR)
105 return -EINVAL;
107 return irq;
110 static void vp_vdpa_free_irq(struct vp_vdpa *vp_vdpa)
112 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
113 struct pci_dev *pdev = mdev->pci_dev;
114 int i;
116 for (i = 0; i < vp_vdpa->queues; i++) {
117 if (vp_vdpa->vring[i].irq != VIRTIO_MSI_NO_VECTOR) {
118 vp_modern_queue_vector(mdev, i, VIRTIO_MSI_NO_VECTOR);
119 devm_free_irq(&pdev->dev, vp_vdpa->vring[i].irq,
120 &vp_vdpa->vring[i]);
121 vp_vdpa->vring[i].irq = VIRTIO_MSI_NO_VECTOR;
125 if (vp_vdpa->config_irq != VIRTIO_MSI_NO_VECTOR) {
126 vp_modern_config_vector(mdev, VIRTIO_MSI_NO_VECTOR);
127 devm_free_irq(&pdev->dev, vp_vdpa->config_irq, vp_vdpa);
128 vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR;
131 if (vp_vdpa->vectors) {
132 pci_free_irq_vectors(pdev);
133 vp_vdpa->vectors = 0;
137 static irqreturn_t vp_vdpa_vq_handler(int irq, void *arg)
139 struct vp_vring *vring = arg;
141 if (vring->cb.callback)
142 return vring->cb.callback(vring->cb.private);
144 return IRQ_HANDLED;
147 static irqreturn_t vp_vdpa_config_handler(int irq, void *arg)
149 struct vp_vdpa *vp_vdpa = arg;
151 if (vp_vdpa->config_cb.callback)
152 return vp_vdpa->config_cb.callback(vp_vdpa->config_cb.private);
154 return IRQ_HANDLED;
157 static int vp_vdpa_request_irq(struct vp_vdpa *vp_vdpa)
159 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
160 struct pci_dev *pdev = mdev->pci_dev;
161 int i, ret, irq;
162 int queues = vp_vdpa->queues;
163 int vectors = 1;
164 int msix_vec = 0;
166 for (i = 0; i < queues; i++) {
167 if (vp_vdpa->vring[i].cb.callback)
168 vectors++;
171 ret = pci_alloc_irq_vectors(pdev, vectors, vectors, PCI_IRQ_MSIX);
172 if (ret != vectors) {
173 dev_err(&pdev->dev,
174 "vp_vdpa: fail to allocate irq vectors want %d but %d\n",
175 vectors, ret);
176 return ret;
179 vp_vdpa->vectors = vectors;
181 for (i = 0; i < queues; i++) {
182 if (!vp_vdpa->vring[i].cb.callback)
183 continue;
185 snprintf(vp_vdpa->vring[i].msix_name, VP_VDPA_NAME_SIZE,
186 "vp-vdpa[%s]-%d\n", pci_name(pdev), i);
187 irq = pci_irq_vector(pdev, msix_vec);
188 ret = devm_request_irq(&pdev->dev, irq,
189 vp_vdpa_vq_handler,
190 0, vp_vdpa->vring[i].msix_name,
191 &vp_vdpa->vring[i]);
192 if (ret) {
193 dev_err(&pdev->dev,
194 "vp_vdpa: fail to request irq for vq %d\n", i);
195 goto err;
197 vp_modern_queue_vector(mdev, i, msix_vec);
198 vp_vdpa->vring[i].irq = irq;
199 msix_vec++;
202 snprintf(vp_vdpa->msix_name, VP_VDPA_NAME_SIZE, "vp-vdpa[%s]-config\n",
203 pci_name(pdev));
204 irq = pci_irq_vector(pdev, msix_vec);
205 ret = devm_request_irq(&pdev->dev, irq, vp_vdpa_config_handler, 0,
206 vp_vdpa->msix_name, vp_vdpa);
207 if (ret) {
208 dev_err(&pdev->dev,
209 "vp_vdpa: fail to request irq for config: %d\n", ret);
210 goto err;
212 vp_modern_config_vector(mdev, msix_vec);
213 vp_vdpa->config_irq = irq;
215 return 0;
216 err:
217 vp_vdpa_free_irq(vp_vdpa);
218 return ret;
221 static void vp_vdpa_set_status(struct vdpa_device *vdpa, u8 status)
223 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
224 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
225 u8 s = vp_vdpa_get_status(vdpa);
227 if (status & VIRTIO_CONFIG_S_DRIVER_OK &&
228 !(s & VIRTIO_CONFIG_S_DRIVER_OK)) {
229 if (vp_vdpa_request_irq(vp_vdpa)) {
230 WARN_ON(1);
231 return;
235 vp_modern_set_status(mdev, status);
238 static int vp_vdpa_reset(struct vdpa_device *vdpa)
240 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
241 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
242 u8 s = vp_vdpa_get_status(vdpa);
244 vp_modern_set_status(mdev, 0);
246 if (s & VIRTIO_CONFIG_S_DRIVER_OK)
247 vp_vdpa_free_irq(vp_vdpa);
249 return 0;
252 static u16 vp_vdpa_get_vq_num_max(struct vdpa_device *vdpa)
254 return VP_VDPA_QUEUE_MAX;
257 static int vp_vdpa_get_vq_state(struct vdpa_device *vdpa, u16 qid,
258 struct vdpa_vq_state *state)
260 /* Note that this is not supported by virtio specification, so
261 * we return -EOPNOTSUPP here. This means we can't support live
262 * migration, vhost device start/stop.
264 return -EOPNOTSUPP;
267 static int vp_vdpa_set_vq_state_split(struct vdpa_device *vdpa,
268 const struct vdpa_vq_state *state)
270 const struct vdpa_vq_state_split *split = &state->split;
272 if (split->avail_index == 0)
273 return 0;
275 return -EOPNOTSUPP;
278 static int vp_vdpa_set_vq_state_packed(struct vdpa_device *vdpa,
279 const struct vdpa_vq_state *state)
281 const struct vdpa_vq_state_packed *packed = &state->packed;
283 if (packed->last_avail_counter == 1 &&
284 packed->last_avail_idx == 0 &&
285 packed->last_used_counter == 1 &&
286 packed->last_used_idx == 0)
287 return 0;
289 return -EOPNOTSUPP;
292 static int vp_vdpa_set_vq_state(struct vdpa_device *vdpa, u16 qid,
293 const struct vdpa_vq_state *state)
295 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
297 /* Note that this is not supported by virtio specification.
298 * But if the state is by chance equal to the device initial
299 * state, we can let it go.
301 if ((vp_modern_get_status(mdev) & VIRTIO_CONFIG_S_FEATURES_OK) &&
302 !vp_modern_get_queue_enable(mdev, qid)) {
303 if (vp_modern_get_driver_features(mdev) &
304 BIT_ULL(VIRTIO_F_RING_PACKED))
305 return vp_vdpa_set_vq_state_packed(vdpa, state);
306 else
307 return vp_vdpa_set_vq_state_split(vdpa, state);
310 return -EOPNOTSUPP;
313 static void vp_vdpa_set_vq_cb(struct vdpa_device *vdpa, u16 qid,
314 struct vdpa_callback *cb)
316 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
318 vp_vdpa->vring[qid].cb = *cb;
321 static void vp_vdpa_set_vq_ready(struct vdpa_device *vdpa,
322 u16 qid, bool ready)
324 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
326 vp_modern_set_queue_enable(mdev, qid, ready);
329 static bool vp_vdpa_get_vq_ready(struct vdpa_device *vdpa, u16 qid)
331 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
333 return vp_modern_get_queue_enable(mdev, qid);
336 static void vp_vdpa_set_vq_num(struct vdpa_device *vdpa, u16 qid,
337 u32 num)
339 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
341 vp_modern_set_queue_size(mdev, qid, num);
344 static u16 vp_vdpa_get_vq_size(struct vdpa_device *vdpa, u16 qid)
346 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
348 return vp_modern_get_queue_size(mdev, qid);
351 static int vp_vdpa_set_vq_address(struct vdpa_device *vdpa, u16 qid,
352 u64 desc_area, u64 driver_area,
353 u64 device_area)
355 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
357 vp_modern_queue_address(mdev, qid, desc_area,
358 driver_area, device_area);
360 return 0;
363 static void vp_vdpa_kick_vq(struct vdpa_device *vdpa, u16 qid)
365 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
367 vp_iowrite16(qid, vp_vdpa->vring[qid].notify);
370 static u32 vp_vdpa_get_generation(struct vdpa_device *vdpa)
372 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
374 return vp_modern_generation(mdev);
377 static u32 vp_vdpa_get_device_id(struct vdpa_device *vdpa)
379 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
381 return mdev->id.device;
384 static u32 vp_vdpa_get_vendor_id(struct vdpa_device *vdpa)
386 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
388 return mdev->id.vendor;
391 static u32 vp_vdpa_get_vq_align(struct vdpa_device *vdpa)
393 return PAGE_SIZE;
396 static size_t vp_vdpa_get_config_size(struct vdpa_device *vdpa)
398 struct virtio_pci_modern_device *mdev = vdpa_to_mdev(vdpa);
400 return mdev->device_len;
403 static void vp_vdpa_get_config(struct vdpa_device *vdpa,
404 unsigned int offset,
405 void *buf, unsigned int len)
407 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
408 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
409 u8 old, new;
410 u8 *p;
411 int i;
413 do {
414 old = vp_ioread8(&mdev->common->config_generation);
415 p = buf;
416 for (i = 0; i < len; i++)
417 *p++ = vp_ioread8(mdev->device + offset + i);
419 new = vp_ioread8(&mdev->common->config_generation);
420 } while (old != new);
423 static void vp_vdpa_set_config(struct vdpa_device *vdpa,
424 unsigned int offset, const void *buf,
425 unsigned int len)
427 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
428 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
429 const u8 *p = buf;
430 int i;
432 for (i = 0; i < len; i++)
433 vp_iowrite8(*p++, mdev->device + offset + i);
436 static void vp_vdpa_set_config_cb(struct vdpa_device *vdpa,
437 struct vdpa_callback *cb)
439 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
441 vp_vdpa->config_cb = *cb;
444 static struct vdpa_notification_area
445 vp_vdpa_get_vq_notification(struct vdpa_device *vdpa, u16 qid)
447 struct vp_vdpa *vp_vdpa = vdpa_to_vp(vdpa);
448 struct virtio_pci_modern_device *mdev = vp_vdpa_to_mdev(vp_vdpa);
449 struct vdpa_notification_area notify;
451 notify.addr = vp_vdpa->vring[qid].notify_pa;
452 notify.size = mdev->notify_offset_multiplier;
454 return notify;
457 static const struct vdpa_config_ops vp_vdpa_ops = {
458 .get_device_features = vp_vdpa_get_device_features,
459 .set_driver_features = vp_vdpa_set_driver_features,
460 .get_driver_features = vp_vdpa_get_driver_features,
461 .get_status = vp_vdpa_get_status,
462 .set_status = vp_vdpa_set_status,
463 .reset = vp_vdpa_reset,
464 .get_vq_num_max = vp_vdpa_get_vq_num_max,
465 .get_vq_state = vp_vdpa_get_vq_state,
466 .get_vq_notification = vp_vdpa_get_vq_notification,
467 .set_vq_state = vp_vdpa_set_vq_state,
468 .set_vq_cb = vp_vdpa_set_vq_cb,
469 .set_vq_ready = vp_vdpa_set_vq_ready,
470 .get_vq_ready = vp_vdpa_get_vq_ready,
471 .set_vq_num = vp_vdpa_set_vq_num,
472 .get_vq_size = vp_vdpa_get_vq_size,
473 .set_vq_address = vp_vdpa_set_vq_address,
474 .kick_vq = vp_vdpa_kick_vq,
475 .get_generation = vp_vdpa_get_generation,
476 .get_device_id = vp_vdpa_get_device_id,
477 .get_vendor_id = vp_vdpa_get_vendor_id,
478 .get_vq_align = vp_vdpa_get_vq_align,
479 .get_config_size = vp_vdpa_get_config_size,
480 .get_config = vp_vdpa_get_config,
481 .set_config = vp_vdpa_set_config,
482 .set_config_cb = vp_vdpa_set_config_cb,
483 .get_vq_irq = vp_vdpa_get_vq_irq,
486 static void vp_vdpa_free_irq_vectors(void *data)
488 pci_free_irq_vectors(data);
491 static int vp_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
492 const struct vdpa_dev_set_config *add_config)
494 struct vp_vdpa_mgmtdev *vp_vdpa_mgtdev =
495 container_of(v_mdev, struct vp_vdpa_mgmtdev, mgtdev);
497 struct virtio_pci_modern_device *mdev = vp_vdpa_mgtdev->mdev;
498 struct pci_dev *pdev = mdev->pci_dev;
499 struct device *dev = &pdev->dev;
500 struct vp_vdpa *vp_vdpa = NULL;
501 u64 device_features;
502 int ret, i;
504 vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa,
505 dev, &vp_vdpa_ops, 1, 1, name, false);
507 if (IS_ERR(vp_vdpa)) {
508 dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n");
509 return PTR_ERR(vp_vdpa);
512 vp_vdpa_mgtdev->vp_vdpa = vp_vdpa;
514 vp_vdpa->vdpa.dma_dev = &pdev->dev;
515 vp_vdpa->queues = vp_modern_get_num_queues(mdev);
516 vp_vdpa->mdev = mdev;
518 device_features = vp_modern_get_features(mdev);
519 if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_FEATURES)) {
520 if (add_config->device_features & ~device_features) {
521 ret = -EINVAL;
522 dev_err(&pdev->dev, "Try to provision features "
523 "that are not supported by the device: "
524 "device_features 0x%llx provisioned 0x%llx\n",
525 device_features, add_config->device_features);
526 goto err;
528 device_features = add_config->device_features;
530 vp_vdpa->device_features = device_features;
532 ret = devm_add_action_or_reset(dev, vp_vdpa_free_irq_vectors, pdev);
533 if (ret) {
534 dev_err(&pdev->dev,
535 "Failed for adding devres for freeing irq vectors\n");
536 goto err;
539 vp_vdpa->vring = devm_kcalloc(&pdev->dev, vp_vdpa->queues,
540 sizeof(*vp_vdpa->vring),
541 GFP_KERNEL);
542 if (!vp_vdpa->vring) {
543 ret = -ENOMEM;
544 dev_err(&pdev->dev, "Fail to allocate virtqueues\n");
545 goto err;
548 for (i = 0; i < vp_vdpa->queues; i++) {
549 vp_vdpa->vring[i].irq = VIRTIO_MSI_NO_VECTOR;
550 vp_vdpa->vring[i].notify =
551 vp_modern_map_vq_notify(mdev, i,
552 &vp_vdpa->vring[i].notify_pa);
553 if (!vp_vdpa->vring[i].notify) {
554 ret = -EINVAL;
555 dev_warn(&pdev->dev, "Fail to map vq notify %d\n", i);
556 goto err;
559 vp_vdpa->config_irq = VIRTIO_MSI_NO_VECTOR;
561 vp_vdpa->vdpa.mdev = &vp_vdpa_mgtdev->mgtdev;
562 ret = _vdpa_register_device(&vp_vdpa->vdpa, vp_vdpa->queues);
563 if (ret) {
564 dev_err(&pdev->dev, "Failed to register to vdpa bus\n");
565 goto err;
568 return 0;
570 err:
571 put_device(&vp_vdpa->vdpa.dev);
572 return ret;
575 static void vp_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev,
576 struct vdpa_device *dev)
578 struct vp_vdpa_mgmtdev *vp_vdpa_mgtdev =
579 container_of(v_mdev, struct vp_vdpa_mgmtdev, mgtdev);
581 struct vp_vdpa *vp_vdpa = vp_vdpa_mgtdev->vp_vdpa;
583 _vdpa_unregister_device(&vp_vdpa->vdpa);
584 vp_vdpa_mgtdev->vp_vdpa = NULL;
587 static const struct vdpa_mgmtdev_ops vp_vdpa_mdev_ops = {
588 .dev_add = vp_vdpa_dev_add,
589 .dev_del = vp_vdpa_dev_del,
592 static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id)
594 struct vp_vdpa_mgmtdev *vp_vdpa_mgtdev = NULL;
595 struct vdpa_mgmt_dev *mgtdev;
596 struct device *dev = &pdev->dev;
597 struct virtio_pci_modern_device *mdev = NULL;
598 struct virtio_device_id *mdev_id = NULL;
599 int err;
601 vp_vdpa_mgtdev = kzalloc(sizeof(*vp_vdpa_mgtdev), GFP_KERNEL);
602 if (!vp_vdpa_mgtdev)
603 return -ENOMEM;
605 mgtdev = &vp_vdpa_mgtdev->mgtdev;
606 mgtdev->ops = &vp_vdpa_mdev_ops;
607 mgtdev->device = dev;
609 mdev = kzalloc(sizeof(struct virtio_pci_modern_device), GFP_KERNEL);
610 if (!mdev) {
611 err = -ENOMEM;
612 goto mdev_err;
616 * id_table should be a null terminated array, so allocate one additional
617 * entry here, see vdpa_mgmtdev_get_classes().
619 mdev_id = kcalloc(2, sizeof(struct virtio_device_id), GFP_KERNEL);
620 if (!mdev_id) {
621 err = -ENOMEM;
622 goto mdev_id_err;
625 vp_vdpa_mgtdev->mdev = mdev;
626 mdev->pci_dev = pdev;
628 err = pcim_enable_device(pdev);
629 if (err) {
630 goto probe_err;
633 err = vp_modern_probe(mdev);
634 if (err) {
635 dev_err(&pdev->dev, "Failed to probe modern PCI device\n");
636 goto probe_err;
639 mdev_id[0].device = mdev->id.device;
640 mdev_id[0].vendor = mdev->id.vendor;
641 mgtdev->id_table = mdev_id;
642 mgtdev->max_supported_vqs = vp_modern_get_num_queues(mdev);
643 mgtdev->supported_features = vp_modern_get_features(mdev);
644 mgtdev->config_attr_mask = (1 << VDPA_ATTR_DEV_FEATURES);
645 pci_set_master(pdev);
646 pci_set_drvdata(pdev, vp_vdpa_mgtdev);
648 err = vdpa_mgmtdev_register(mgtdev);
649 if (err) {
650 dev_err(&pdev->dev, "Failed to register vdpa mgmtdev device\n");
651 goto register_err;
654 return 0;
656 register_err:
657 vp_modern_remove(vp_vdpa_mgtdev->mdev);
658 probe_err:
659 kfree(mdev_id);
660 mdev_id_err:
661 kfree(mdev);
662 mdev_err:
663 kfree(vp_vdpa_mgtdev);
664 return err;
667 static void vp_vdpa_remove(struct pci_dev *pdev)
669 struct vp_vdpa_mgmtdev *vp_vdpa_mgtdev = pci_get_drvdata(pdev);
670 struct virtio_pci_modern_device *mdev = NULL;
672 mdev = vp_vdpa_mgtdev->mdev;
673 vdpa_mgmtdev_unregister(&vp_vdpa_mgtdev->mgtdev);
674 vp_modern_remove(mdev);
675 kfree(vp_vdpa_mgtdev->mgtdev.id_table);
676 kfree(mdev);
677 kfree(vp_vdpa_mgtdev);
680 static struct pci_driver vp_vdpa_driver = {
681 .name = "vp-vdpa",
682 .id_table = NULL, /* only dynamic ids */
683 .probe = vp_vdpa_probe,
684 .remove = vp_vdpa_remove,
687 module_pci_driver(vp_vdpa_driver);
689 MODULE_AUTHOR("Jason Wang <jasowang@redhat.com>");
690 MODULE_DESCRIPTION("vp-vdpa");
691 MODULE_LICENSE("GPL");
692 MODULE_VERSION("1");