]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
virtio: Allocate drive_s storage in low memory
authorKevin O'Connor <kevin@koconnor.net>
Tue, 11 Jul 2017 16:30:26 +0000 (12:30 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 27 Sep 2017 23:02:34 +0000 (19:02 -0400)
Use the "low" memory segment instead of the f-segment for the drive_s
storage.  This can help avoid running out of memory in the f-segment.

Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/virtio-blk.c
src/hw/virtio-ring.c
src/hw/virtio-scsi.c

index ad162007ec133226cb39a20c0240013418bc49fc..88d7e54a2a92d2bbbb4ff1f2916d119963fbb553 100644 (file)
@@ -32,9 +32,9 @@ struct virtiodrive_s {
 static int
 virtio_blk_op(struct disk_op_s *op, int write)
 {
-    struct virtiodrive_s *vdrive_gf =
+    struct virtiodrive_s *vdrive =
         container_of(op->drive_fl, struct virtiodrive_s, drive);
-    struct vring_virtqueue *vq = vdrive_gf->vq;
+    struct vring_virtqueue *vq = vdrive->vq;
     struct virtio_blk_outhdr hdr = {
         .type = write ? VIRTIO_BLK_T_OUT : VIRTIO_BLK_T_IN,
         .ioprio = 0,
@@ -48,7 +48,7 @@ virtio_blk_op(struct disk_op_s *op, int write)
         },
         {
             .addr       = op->buf_fl,
-            .length     = vdrive_gf->drive.blksize * op->count,
+            .length     = vdrive->drive.blksize * op->count,
         },
         {
             .addr       = (void*)(&status),
@@ -61,7 +61,7 @@ virtio_blk_op(struct disk_op_s *op, int write)
         vring_add_buf(vq, sg, 2, 1, 0, 0);
     else
         vring_add_buf(vq, sg, 1, 2, 0, 0);
-    vring_kick(&vdrive_gf->vp, vq, 1);
+    vring_kick(&vdrive->vp, vq, 1);
 
     /* Wait for reply */
     while (!vring_more_used(vq))
@@ -73,7 +73,7 @@ virtio_blk_op(struct disk_op_s *op, int write)
     /* Clear interrupt status register.  Avoid leaving interrupts stuck if
      * VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised.
      */
-    vp_get_isr(&vdrive_gf->vp);
+    vp_get_isr(&vdrive->vp);
 
     return status == VIRTIO_BLK_S_OK ? DISK_RET_SUCCESS : DISK_RET_EBADTRACK;
 }
@@ -99,7 +99,7 @@ init_virtio_blk(void *data)
     struct pci_device *pci = data;
     u8 status = VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER;
     dprintf(1, "found virtio-blk at %pP\n", pci);
-    struct virtiodrive_s *vdrive = malloc_fseg(sizeof(*vdrive));
+    struct virtiodrive_s *vdrive = malloc_low(sizeof(*vdrive));
     if (!vdrive) {
         warn_noalloc();
         return;
index 7205a0acd55b62efa923fd48de62af45bcecfe1f..0ed3189ee2c92fc297243cd68e6dae14b3954d4a 100644 (file)
@@ -16,7 +16,6 @@
  *
  */
 
-#include "biosvar.h" // GET_GLOBAL
 #include "output.h" // panic
 #include "virtio-ring.h"
 #include "virtio-pci.h"
index 466b3058d46bd0d5944a9b65cf4f07a1e6efcdb2..a87cad88e1520ed5f7898f0a66654e48f4b6ead1 100644 (file)
@@ -7,7 +7,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "biosvar.h" // GET_GLOBALFLAT
 #include "block.h" // struct drive_s
 #include "blockcmd.h" // scsi_drive_setup
 #include "config.h" // CONFIG_*
@@ -114,7 +113,7 @@ virtio_scsi_add_lun(u32 lun, struct drive_s *tmpl_drv)
 {
     struct virtio_lun_s *tmpl_vlun =
         container_of(tmpl_drv, struct virtio_lun_s, drive);
-    struct virtio_lun_s *vlun = malloc_fseg(sizeof(*vlun));
+    struct virtio_lun_s *vlun = malloc_low(sizeof(*vlun));
     if (!vlun) {
         warn_noalloc();
         return -1;