2 * Virtio PCI driver - modern (virtio 1.0) device support
4 * This module allows virtio devices to be used over a virtual PCI device.
5 * This can be used with QEMU based VMMs like KVM or Xen.
7 * Copyright IBM Corp. 2007
8 * Copyright Red Hat, Inc. 2014
11 * Anthony Liguori <aliguori@us.ibm.com>
12 * Rusty Russell <rusty@rustcorp.com.au>
13 * Michael S. Tsirkin <mst@redhat.com>
15 * This work is licensed under the terms of the GNU GPL, version 2 or later.
16 * See the COPYING file in the top-level directory.
20 #define VIRTIO_PCI_NO_LEGACY
21 #include "virtio_pci_common.h"
24 * Type-safe wrappers for io accesses.
25 * Use these to enforce at compile time the following spec requirement:
27 * The driver MUST access each field using the “natural” access
28 * method, i.e. 32-bit accesses for 32-bit fields, 16-bit accesses
29 * for 16-bit fields and 8-bit accesses for 8-bit fields.
31 static inline u8
vp_ioread8(u8 __iomem
*addr
)
35 static inline u16
vp_ioread16 (u16 __iomem
*addr
)
37 return ioread16(addr
);
40 static inline u32
vp_ioread32(u32 __iomem
*addr
)
42 return ioread32(addr
);
45 static inline void vp_iowrite8(u8 value
, u8 __iomem
*addr
)
47 iowrite8(value
, addr
);
50 static inline void vp_iowrite16(u16 value
, u16 __iomem
*addr
)
52 iowrite16(value
, addr
);
55 static inline void vp_iowrite32(u32 value
, u32 __iomem
*addr
)
57 iowrite32(value
, addr
);
60 static void vp_iowrite64_twopart(u64 val
,
61 __le32 __iomem
*lo
, __le32 __iomem
*hi
)
63 vp_iowrite32((u32
)val
, lo
);
64 vp_iowrite32(val
>> 32, hi
);
67 static void __iomem
*map_capability(struct pci_dev
*dev
, int off
,
77 pci_read_config_byte(dev
, off
+ offsetof(struct virtio_pci_cap
,
80 pci_read_config_dword(dev
, off
+ offsetof(struct virtio_pci_cap
, offset
),
82 pci_read_config_dword(dev
, off
+ offsetof(struct virtio_pci_cap
, length
),
85 if (length
<= start
) {
87 "virtio_pci: bad capability len %u (>%u expected)\n",
92 if (length
- start
< minlen
) {
94 "virtio_pci: bad capability len %u (>=%zu expected)\n",
101 if (start
+ offset
< offset
) {
103 "virtio_pci: map wrap-around %u+%u\n",
110 if (offset
& (align
- 1)) {
112 "virtio_pci: offset %u not aligned to %u\n",
123 if (minlen
+ offset
< minlen
||
124 minlen
+ offset
> pci_resource_len(dev
, bar
)) {
126 "virtio_pci: map virtio %zu@%u "
127 "out of range on bar %i length %lu\n",
129 bar
, (unsigned long)pci_resource_len(dev
, bar
));
133 p
= pci_iomap_range(dev
, bar
, offset
, length
);
136 "virtio_pci: unable to map virtio %u@%u on bar %i\n",
137 length
, offset
, bar
);
141 /* virtio config->get_features() implementation */
142 static u64
vp_get_features(struct virtio_device
*vdev
)
144 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
147 vp_iowrite32(0, &vp_dev
->common
->device_feature_select
);
148 features
= vp_ioread32(&vp_dev
->common
->device_feature
);
149 vp_iowrite32(1, &vp_dev
->common
->device_feature_select
);
150 features
|= ((u64
)vp_ioread32(&vp_dev
->common
->device_feature
) << 32);
155 /* virtio config->finalize_features() implementation */
156 static int vp_finalize_features(struct virtio_device
*vdev
)
158 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
160 /* Give virtio_ring a chance to accept features. */
161 vring_transport_features(vdev
);
163 if (!__virtio_test_bit(vdev
, VIRTIO_F_VERSION_1
)) {
164 dev_err(&vdev
->dev
, "virtio: device uses modern interface "
165 "but does not have VIRTIO_F_VERSION_1\n");
169 vp_iowrite32(0, &vp_dev
->common
->guest_feature_select
);
170 vp_iowrite32((u32
)vdev
->features
, &vp_dev
->common
->guest_feature
);
171 vp_iowrite32(1, &vp_dev
->common
->guest_feature_select
);
172 vp_iowrite32(vdev
->features
>> 32, &vp_dev
->common
->guest_feature
);
177 /* virtio config->get() implementation */
178 static void vp_get(struct virtio_device
*vdev
, unsigned offset
,
179 void *buf
, unsigned len
)
181 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
186 BUG_ON(offset
+ len
> vp_dev
->device_len
);
190 b
= ioread8(vp_dev
->device
+ offset
);
191 memcpy(buf
, &b
, sizeof b
);
194 w
= cpu_to_le16(ioread16(vp_dev
->device
+ offset
));
195 memcpy(buf
, &w
, sizeof w
);
198 l
= cpu_to_le32(ioread32(vp_dev
->device
+ offset
));
199 memcpy(buf
, &l
, sizeof l
);
202 l
= cpu_to_le32(ioread32(vp_dev
->device
+ offset
));
203 memcpy(buf
, &l
, sizeof l
);
204 l
= cpu_to_le32(ioread32(vp_dev
->device
+ offset
+ sizeof l
));
205 memcpy(buf
+ sizeof l
, &l
, sizeof l
);
212 /* the config->set() implementation. it's symmetric to the config->get()
214 static void vp_set(struct virtio_device
*vdev
, unsigned offset
,
215 const void *buf
, unsigned len
)
217 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
222 BUG_ON(offset
+ len
> vp_dev
->device_len
);
226 memcpy(&b
, buf
, sizeof b
);
227 iowrite8(b
, vp_dev
->device
+ offset
);
230 memcpy(&w
, buf
, sizeof w
);
231 iowrite16(le16_to_cpu(w
), vp_dev
->device
+ offset
);
234 memcpy(&l
, buf
, sizeof l
);
235 iowrite32(le32_to_cpu(l
), vp_dev
->device
+ offset
);
238 memcpy(&l
, buf
, sizeof l
);
239 iowrite32(le32_to_cpu(l
), vp_dev
->device
+ offset
);
240 memcpy(&l
, buf
+ sizeof l
, sizeof l
);
241 iowrite32(le32_to_cpu(l
), vp_dev
->device
+ offset
+ sizeof l
);
248 static u32
vp_generation(struct virtio_device
*vdev
)
250 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
251 return vp_ioread8(&vp_dev
->common
->config_generation
);
254 /* config->{get,set}_status() implementations */
255 static u8
vp_get_status(struct virtio_device
*vdev
)
257 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
258 return vp_ioread8(&vp_dev
->common
->device_status
);
261 static void vp_set_status(struct virtio_device
*vdev
, u8 status
)
263 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
264 /* We should never be setting status to 0. */
266 vp_iowrite8(status
, &vp_dev
->common
->device_status
);
269 static void vp_reset(struct virtio_device
*vdev
)
271 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
272 /* 0 status means a reset. */
273 vp_iowrite8(0, &vp_dev
->common
->device_status
);
274 /* Flush out the status write, and flush in device writes,
275 * including MSI-X interrupts, if any. */
276 vp_ioread8(&vp_dev
->common
->device_status
);
277 /* Flush pending VQ/configuration callbacks. */
278 vp_synchronize_vectors(vdev
);
281 static u16
vp_config_vector(struct virtio_pci_device
*vp_dev
, u16 vector
)
283 /* Setup the vector used for configuration events */
284 vp_iowrite16(vector
, &vp_dev
->common
->msix_config
);
285 /* Verify we had enough resources to assign the vector */
286 /* Will also flush the write out to device */
287 return vp_ioread16(&vp_dev
->common
->msix_config
);
290 static size_t vring_pci_size(u16 num
)
292 /* We only need a cacheline separation. */
293 return PAGE_ALIGN(vring_size(num
, SMP_CACHE_BYTES
));
296 static void *alloc_virtqueue_pages(int *num
)
300 /* TODO: allocate each queue chunk individually */
301 for (; *num
&& vring_pci_size(*num
) > PAGE_SIZE
; *num
/= 2) {
302 pages
= alloc_pages_exact(vring_pci_size(*num
),
303 GFP_KERNEL
|__GFP_ZERO
|__GFP_NOWARN
);
311 /* Try to get a single page. You are my only hope! */
312 return alloc_pages_exact(vring_pci_size(*num
), GFP_KERNEL
|__GFP_ZERO
);
315 static struct virtqueue
*setup_vq(struct virtio_pci_device
*vp_dev
,
316 struct virtio_pci_vq_info
*info
,
318 void (*callback
)(struct virtqueue
*vq
),
322 struct virtio_pci_common_cfg __iomem
*cfg
= vp_dev
->common
;
323 struct virtqueue
*vq
;
327 if (index
>= vp_ioread16(&cfg
->num_queues
))
328 return ERR_PTR(-ENOENT
);
330 /* Select the queue we're interested in */
331 vp_iowrite16(index
, &cfg
->queue_select
);
333 /* Check if queue is either not available or already active. */
334 num
= vp_ioread16(&cfg
->queue_size
);
335 if (!num
|| vp_ioread16(&cfg
->queue_enable
))
336 return ERR_PTR(-ENOENT
);
338 if (num
& (num
- 1)) {
339 dev_warn(&vp_dev
->pci_dev
->dev
, "bad queue size %u", num
);
340 return ERR_PTR(-EINVAL
);
343 /* get offset of notification word for this vq */
344 off
= vp_ioread16(&cfg
->queue_notify_off
);
347 info
->msix_vector
= msix_vec
;
349 info
->queue
= alloc_virtqueue_pages(&info
->num
);
350 if (info
->queue
== NULL
)
351 return ERR_PTR(-ENOMEM
);
353 /* create the vring */
354 vq
= vring_new_virtqueue(index
, info
->num
,
355 SMP_CACHE_BYTES
, &vp_dev
->vdev
,
356 true, info
->queue
, vp_notify
, callback
, name
);
362 /* activate the queue */
363 vp_iowrite16(num
, &cfg
->queue_size
);
364 vp_iowrite64_twopart(virt_to_phys(info
->queue
),
365 &cfg
->queue_desc_lo
, &cfg
->queue_desc_hi
);
366 vp_iowrite64_twopart(virt_to_phys(virtqueue_get_avail(vq
)),
367 &cfg
->queue_avail_lo
, &cfg
->queue_avail_hi
);
368 vp_iowrite64_twopart(virt_to_phys(virtqueue_get_used(vq
)),
369 &cfg
->queue_used_lo
, &cfg
->queue_used_hi
);
371 if (vp_dev
->notify_base
) {
372 /* offset should not wrap */
373 if ((u64
)off
* vp_dev
->notify_offset_multiplier
+ 2
374 > vp_dev
->notify_len
) {
375 dev_warn(&vp_dev
->pci_dev
->dev
,
376 "bad notification offset %u (x %u) "
377 "for queue %u > %zd",
378 off
, vp_dev
->notify_offset_multiplier
,
379 index
, vp_dev
->notify_len
);
383 vq
->priv
= (void __force
*)vp_dev
->notify_base
+
384 off
* vp_dev
->notify_offset_multiplier
;
386 vq
->priv
= (void __force
*)map_capability(vp_dev
->pci_dev
,
387 vp_dev
->notify_map_cap
, 2, 2,
388 off
* vp_dev
->notify_offset_multiplier
, 2,
397 if (msix_vec
!= VIRTIO_MSI_NO_VECTOR
) {
398 vp_iowrite16(msix_vec
, &cfg
->queue_msix_vector
);
399 msix_vec
= vp_ioread16(&cfg
->queue_msix_vector
);
400 if (msix_vec
== VIRTIO_MSI_NO_VECTOR
) {
402 goto err_assign_vector
;
409 if (!vp_dev
->notify_base
)
410 pci_iounmap(vp_dev
->pci_dev
, (void __iomem __force
*)vq
->priv
);
412 vring_del_virtqueue(vq
);
414 free_pages_exact(info
->queue
, vring_pci_size(info
->num
));
418 static int vp_modern_find_vqs(struct virtio_device
*vdev
, unsigned nvqs
,
419 struct virtqueue
*vqs
[],
420 vq_callback_t
*callbacks
[],
423 struct virtio_pci_device
*vp_dev
= to_vp_device(vdev
);
424 struct virtqueue
*vq
;
425 int rc
= vp_find_vqs(vdev
, nvqs
, vqs
, callbacks
, names
);
430 /* Select and activate all queues. Has to be done last: once we do
431 * this, there's no way to go back except reset.
433 list_for_each_entry(vq
, &vdev
->vqs
, list
) {
434 vp_iowrite16(vq
->index
, &vp_dev
->common
->queue_select
);
435 vp_iowrite16(1, &vp_dev
->common
->queue_enable
);
441 static void del_vq(struct virtio_pci_vq_info
*info
)
443 struct virtqueue
*vq
= info
->vq
;
444 struct virtio_pci_device
*vp_dev
= to_vp_device(vq
->vdev
);
446 vp_iowrite16(vq
->index
, &vp_dev
->common
->queue_select
);
448 if (vp_dev
->msix_enabled
) {
449 vp_iowrite16(VIRTIO_MSI_NO_VECTOR
,
450 &vp_dev
->common
->queue_msix_vector
);
451 /* Flush the write out to device */
452 vp_ioread16(&vp_dev
->common
->queue_msix_vector
);
455 if (!vp_dev
->notify_base
)
456 pci_iounmap(vp_dev
->pci_dev
, (void __force __iomem
*)vq
->priv
);
458 vring_del_virtqueue(vq
);
460 free_pages_exact(info
->queue
, vring_pci_size(info
->num
));
463 static const struct virtio_config_ops virtio_pci_config_nodev_ops
= {
466 .generation
= vp_generation
,
467 .get_status
= vp_get_status
,
468 .set_status
= vp_set_status
,
470 .find_vqs
= vp_modern_find_vqs
,
471 .del_vqs
= vp_del_vqs
,
472 .get_features
= vp_get_features
,
473 .finalize_features
= vp_finalize_features
,
474 .bus_name
= vp_bus_name
,
475 .set_vq_affinity
= vp_set_vq_affinity
,
478 static const struct virtio_config_ops virtio_pci_config_ops
= {
481 .generation
= vp_generation
,
482 .get_status
= vp_get_status
,
483 .set_status
= vp_set_status
,
485 .find_vqs
= vp_modern_find_vqs
,
486 .del_vqs
= vp_del_vqs
,
487 .get_features
= vp_get_features
,
488 .finalize_features
= vp_finalize_features
,
489 .bus_name
= vp_bus_name
,
490 .set_vq_affinity
= vp_set_vq_affinity
,
494 * virtio_pci_find_capability - walk capabilities to find device info.
495 * @dev: the pci device
496 * @cfg_type: the VIRTIO_PCI_CAP_* value we seek
497 * @ioresource_types: IORESOURCE_MEM and/or IORESOURCE_IO.
499 * Returns offset of the capability, or 0.
501 static inline int virtio_pci_find_capability(struct pci_dev
*dev
, u8 cfg_type
,
502 u32 ioresource_types
)
506 for (pos
= pci_find_capability(dev
, PCI_CAP_ID_VNDR
);
508 pos
= pci_find_next_capability(dev
, pos
, PCI_CAP_ID_VNDR
)) {
510 pci_read_config_byte(dev
, pos
+ offsetof(struct virtio_pci_cap
,
513 pci_read_config_byte(dev
, pos
+ offsetof(struct virtio_pci_cap
,
517 /* Ignore structures with reserved BAR values */
521 if (type
== cfg_type
) {
522 if (pci_resource_len(dev
, bar
) &&
523 pci_resource_flags(dev
, bar
) & ioresource_types
)
530 /* This is part of the ABI. Don't screw with it. */
531 static inline void check_offsets(void)
533 /* Note: disk space was harmed in compilation of this function. */
534 BUILD_BUG_ON(VIRTIO_PCI_CAP_VNDR
!=
535 offsetof(struct virtio_pci_cap
, cap_vndr
));
536 BUILD_BUG_ON(VIRTIO_PCI_CAP_NEXT
!=
537 offsetof(struct virtio_pci_cap
, cap_next
));
538 BUILD_BUG_ON(VIRTIO_PCI_CAP_LEN
!=
539 offsetof(struct virtio_pci_cap
, cap_len
));
540 BUILD_BUG_ON(VIRTIO_PCI_CAP_CFG_TYPE
!=
541 offsetof(struct virtio_pci_cap
, cfg_type
));
542 BUILD_BUG_ON(VIRTIO_PCI_CAP_BAR
!=
543 offsetof(struct virtio_pci_cap
, bar
));
544 BUILD_BUG_ON(VIRTIO_PCI_CAP_OFFSET
!=
545 offsetof(struct virtio_pci_cap
, offset
));
546 BUILD_BUG_ON(VIRTIO_PCI_CAP_LENGTH
!=
547 offsetof(struct virtio_pci_cap
, length
));
548 BUILD_BUG_ON(VIRTIO_PCI_NOTIFY_CAP_MULT
!=
549 offsetof(struct virtio_pci_notify_cap
,
550 notify_off_multiplier
));
551 BUILD_BUG_ON(VIRTIO_PCI_COMMON_DFSELECT
!=
552 offsetof(struct virtio_pci_common_cfg
,
553 device_feature_select
));
554 BUILD_BUG_ON(VIRTIO_PCI_COMMON_DF
!=
555 offsetof(struct virtio_pci_common_cfg
, device_feature
));
556 BUILD_BUG_ON(VIRTIO_PCI_COMMON_GFSELECT
!=
557 offsetof(struct virtio_pci_common_cfg
,
558 guest_feature_select
));
559 BUILD_BUG_ON(VIRTIO_PCI_COMMON_GF
!=
560 offsetof(struct virtio_pci_common_cfg
, guest_feature
));
561 BUILD_BUG_ON(VIRTIO_PCI_COMMON_MSIX
!=
562 offsetof(struct virtio_pci_common_cfg
, msix_config
));
563 BUILD_BUG_ON(VIRTIO_PCI_COMMON_NUMQ
!=
564 offsetof(struct virtio_pci_common_cfg
, num_queues
));
565 BUILD_BUG_ON(VIRTIO_PCI_COMMON_STATUS
!=
566 offsetof(struct virtio_pci_common_cfg
, device_status
));
567 BUILD_BUG_ON(VIRTIO_PCI_COMMON_CFGGENERATION
!=
568 offsetof(struct virtio_pci_common_cfg
, config_generation
));
569 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_SELECT
!=
570 offsetof(struct virtio_pci_common_cfg
, queue_select
));
571 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_SIZE
!=
572 offsetof(struct virtio_pci_common_cfg
, queue_size
));
573 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_MSIX
!=
574 offsetof(struct virtio_pci_common_cfg
, queue_msix_vector
));
575 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_ENABLE
!=
576 offsetof(struct virtio_pci_common_cfg
, queue_enable
));
577 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_NOFF
!=
578 offsetof(struct virtio_pci_common_cfg
, queue_notify_off
));
579 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_DESCLO
!=
580 offsetof(struct virtio_pci_common_cfg
, queue_desc_lo
));
581 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_DESCHI
!=
582 offsetof(struct virtio_pci_common_cfg
, queue_desc_hi
));
583 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_AVAILLO
!=
584 offsetof(struct virtio_pci_common_cfg
, queue_avail_lo
));
585 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_AVAILHI
!=
586 offsetof(struct virtio_pci_common_cfg
, queue_avail_hi
));
587 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_USEDLO
!=
588 offsetof(struct virtio_pci_common_cfg
, queue_used_lo
));
589 BUILD_BUG_ON(VIRTIO_PCI_COMMON_Q_USEDHI
!=
590 offsetof(struct virtio_pci_common_cfg
, queue_used_hi
));
593 /* the PCI probing function */
594 int virtio_pci_modern_probe(struct virtio_pci_device
*vp_dev
)
596 struct pci_dev
*pci_dev
= vp_dev
->pci_dev
;
597 int err
, common
, isr
, notify
, device
;
603 /* We only own devices >= 0x1000 and <= 0x107f: leave the rest. */
604 if (pci_dev
->device
< 0x1000 || pci_dev
->device
> 0x107f)
607 if (pci_dev
->device
< 0x1040) {
608 /* Transitional devices: use the PCI subsystem device id as
609 * virtio device id, same as legacy driver always did.
611 vp_dev
->vdev
.id
.device
= pci_dev
->subsystem_device
;
613 /* Modern devices: simply use PCI device id, but start from 0x1040. */
614 vp_dev
->vdev
.id
.device
= pci_dev
->device
- 0x1040;
616 vp_dev
->vdev
.id
.vendor
= pci_dev
->subsystem_vendor
;
618 /* check for a common config: if not, use legacy mode (bar 0). */
619 common
= virtio_pci_find_capability(pci_dev
, VIRTIO_PCI_CAP_COMMON_CFG
,
620 IORESOURCE_IO
| IORESOURCE_MEM
);
622 dev_info(&pci_dev
->dev
,
623 "virtio_pci: leaving for legacy driver\n");
627 /* If common is there, these should be too... */
628 isr
= virtio_pci_find_capability(pci_dev
, VIRTIO_PCI_CAP_ISR_CFG
,
629 IORESOURCE_IO
| IORESOURCE_MEM
);
630 notify
= virtio_pci_find_capability(pci_dev
, VIRTIO_PCI_CAP_NOTIFY_CFG
,
631 IORESOURCE_IO
| IORESOURCE_MEM
);
632 if (!isr
|| !notify
) {
633 dev_err(&pci_dev
->dev
,
634 "virtio_pci: missing capabilities %i/%i/%i\n",
635 common
, isr
, notify
);
639 /* Device capability is only mandatory for devices that have
640 * device-specific configuration.
642 device
= virtio_pci_find_capability(pci_dev
, VIRTIO_PCI_CAP_DEVICE_CFG
,
643 IORESOURCE_IO
| IORESOURCE_MEM
);
646 vp_dev
->common
= map_capability(pci_dev
, common
,
647 sizeof(struct virtio_pci_common_cfg
), 4,
648 0, sizeof(struct virtio_pci_common_cfg
),
652 vp_dev
->isr
= map_capability(pci_dev
, isr
, sizeof(u8
), 1,
658 /* Read notify_off_multiplier from config space. */
659 pci_read_config_dword(pci_dev
,
660 notify
+ offsetof(struct virtio_pci_notify_cap
,
661 notify_off_multiplier
),
662 &vp_dev
->notify_offset_multiplier
);
663 /* Read notify length and offset from config space. */
664 pci_read_config_dword(pci_dev
,
665 notify
+ offsetof(struct virtio_pci_notify_cap
,
669 pci_read_config_dword(pci_dev
,
670 notify
+ offsetof(struct virtio_pci_notify_cap
,
674 /* We don't know how many VQs we'll map, ahead of the time.
675 * If notify length is small, map it all now.
676 * Otherwise, map each VQ individually later.
678 if ((u64
)notify_length
+ (notify_offset
% PAGE_SIZE
) <= PAGE_SIZE
) {
679 vp_dev
->notify_base
= map_capability(pci_dev
, notify
, 2, 2,
681 &vp_dev
->notify_len
);
682 if (!vp_dev
->notify_base
)
685 vp_dev
->notify_map_cap
= notify
;
688 /* Again, we don't know how much we should map, but PAGE_SIZE
689 * is more than enough for all existing devices.
692 vp_dev
->device
= map_capability(pci_dev
, device
, 0, 4,
694 &vp_dev
->device_len
);
698 vp_dev
->vdev
.config
= &virtio_pci_config_ops
;
700 vp_dev
->vdev
.config
= &virtio_pci_config_nodev_ops
;
703 vp_dev
->config_vector
= vp_config_vector
;
704 vp_dev
->setup_vq
= setup_vq
;
705 vp_dev
->del_vq
= del_vq
;
710 if (vp_dev
->notify_base
)
711 pci_iounmap(pci_dev
, vp_dev
->notify_base
);
713 pci_iounmap(pci_dev
, vp_dev
->isr
);
715 pci_iounmap(pci_dev
, vp_dev
->common
);
720 void virtio_pci_modern_remove(struct virtio_pci_device
*vp_dev
)
722 struct pci_dev
*pci_dev
= vp_dev
->pci_dev
;
725 pci_iounmap(pci_dev
, vp_dev
->device
);
726 if (vp_dev
->notify_base
)
727 pci_iounmap(pci_dev
, vp_dev
->notify_base
);
728 pci_iounmap(pci_dev
, vp_dev
->isr
);
729 pci_iounmap(pci_dev
, vp_dev
->common
);