1
From ea8ac63a06bf621408d65fbfc17d77fa4a19be6f Mon Sep 17 00:00:00 2001
2
From: Kevin O'Connor <kevin@koconnor.net>
3
Date: Sun, 16 May 2010 11:34:38 -0400
4
Subject: [PATCH 18/54] Minor improvements to virtio (allow irqs, allocate page aligned).
6
Allow irqs to be handled while waiting for virtio reads to complete.
8
Use native page aligned allocations instead of manually aligning the
9
data. This reduces the amount of low memory virtio requires.
11
Also, some minor white space cleanups.
13
src/virtio-blk.c | 9 ++++-----
14
src/virtio-ring.h | 2 +-
15
2 files changed, 5 insertions(+), 6 deletions(-)
17
diff --git a/src/virtio-blk.c b/src/virtio-blk.c
18
index 6c3f8a5..7cc2edb 100644
19
--- a/src/virtio-blk.c
20
+++ b/src/virtio-blk.c
21
@@ -58,7 +58,7 @@ virtio_blk_read(struct disk_op_s *op)
24
while (!vring_more_used(vq))
28
/* Reclaim virtqueue element */
29
vring_get_buf(vq, NULL);
30
@@ -104,7 +104,7 @@ virtio_blk_setup(void)
32
char *desc = malloc_tmphigh(MAXDESCSIZE);
33
struct virtiodrive_s *vdrive_g = malloc_fseg(sizeof(*vdrive_g));
34
- struct vring_virtqueue *vq = malloc_low(sizeof(*vq));
35
+ struct vring_virtqueue *vq = memalign_low(PAGE_SIZE, sizeof(*vq));
36
if (!vdrive_g || !desc || !vq) {
39
@@ -131,7 +131,7 @@ virtio_blk_setup(void)
42
dprintf(1, "fail to find vq for virtio-blk %x:%x\n",
43
- pci_bdf_to_bus (bdf), pci_bdf_to_dev(bdf));
44
+ pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf));
48
@@ -141,7 +141,7 @@ virtio_blk_setup(void)
49
vdrive_g->drive.blksize = cfg.blk_size;
50
vdrive_g->drive.sectors = cfg.capacity;
51
dprintf(3, "virtio-blk %x:%x blksize=%d sectors=%u\n",
52
- pci_bdf_to_bus (bdf), pci_bdf_to_dev(bdf),
53
+ pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf),
54
vdrive_g->drive.blksize, (u32)vdrive_g->drive.sectors);
56
vdrive_g->drive.pchs.cylinders = cfg.cylinders;
57
@@ -160,4 +160,3 @@ virtio_blk_setup(void)
58
VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK);
62
diff --git a/src/virtio-ring.h b/src/virtio-ring.h
63
index 95ae85b..3fb86fe 100644
64
--- a/src/virtio-ring.h
65
+++ b/src/virtio-ring.h
66
@@ -72,7 +72,7 @@ struct vring {
67
+ PAGE_MASK) & ~PAGE_MASK) + \
68
(sizeof(struct vring_used) + sizeof(struct vring_used_elem) * num))
70
-typedef unsigned char virtio_queue_t[PAGE_MASK + vring_size(MAX_QUEUE_NUM)];
71
+typedef unsigned char virtio_queue_t[vring_size(MAX_QUEUE_NUM)];
73
struct vring_virtqueue {