]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
virtio: use LGUEST_VRING_ALIGN instead of relying on pagesize
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 30 Dec 2008 15:25:58 +0000 (09:25 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 29 Dec 2008 22:56:02 +0000 (09:26 +1030)
This doesn't really matter, since lguest is i386 only at the moment,
but we could actually choose a different value.  (lguest doesn't have
a guarenteed ABI).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Documentation/lguest/lguest.c
drivers/lguest/lguest_device.c
include/linux/lguest_launcher.h

index 804520633fcf6ad7697b56a2ad18726d1af31cc1..aa2574ca94c73e50593b0422738f612b3e4e7dc6 100644 (file)
@@ -1030,7 +1030,7 @@ static void update_device_status(struct device *dev)
                /* Zero out the virtqueues. */
                for (vq = dev->vq; vq; vq = vq->next) {
                        memset(vq->vring.desc, 0,
-                              vring_size(vq->config.num, getpagesize()));
+                              vring_size(vq->config.num, LGUEST_VRING_ALIGN));
                        lg_last_avail(vq) = 0;
                }
        } else if (dev->desc->status & VIRTIO_CONFIG_S_FAILED) {
@@ -1211,7 +1211,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
        void *p;
 
        /* First we need some memory for this virtqueue. */
-       pages = (vring_size(num_descs, getpagesize()) + getpagesize() - 1)
+       pages = (vring_size(num_descs, LGUEST_VRING_ALIGN) + getpagesize() - 1)
                / getpagesize();
        p = get_pages(pages);
 
@@ -1228,7 +1228,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
        vq->config.pfn = to_guest_phys(p) / getpagesize();
 
        /* Initialize the vring. */
-       vring_init(&vq->vring, num_descs, p, getpagesize());
+       vring_init(&vq->vring, num_descs, p, LGUEST_VRING_ALIGN);
 
        /* Append virtqueue to this device's descriptor.  We use
         * device_config() to get the end of the device's current virtqueues;
index a661bbdae3d62f657fc801eceb80d9afefc3e4bf..f062dc55c573530aa65e051c9f46ca1d4f139926 100644 (file)
@@ -250,7 +250,7 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
        /* Figure out how many pages the ring will take, and map that memory */
        lvq->pages = lguest_map((unsigned long)lvq->config.pfn << PAGE_SHIFT,
                                DIV_ROUND_UP(vring_size(lvq->config.num,
-                                                       PAGE_SIZE),
+                                                       LGUEST_VRING_ALIGN),
                                             PAGE_SIZE));
        if (!lvq->pages) {
                err = -ENOMEM;
index e7217dc58f398fb7e6d11897faf2e7ac3d0dbfae..bd0eba760522077094fac0f08aff08b1d094d3e2 100644 (file)
@@ -59,4 +59,8 @@ enum lguest_req
        LHREQ_IRQ, /* + irq */
        LHREQ_BREAK, /* + on/off flag (on blocks until someone does off) */
 };
+
+/* The alignment to use between consumer and producer parts of vring.
+ * x86 pagesize for historical reasons. */
+#define LGUEST_VRING_ALIGN     4096
 #endif /* _LINUX_LGUEST_LAUNCHER */