Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci According to "Virtio PCI Card Specification v0.9...



details:   https://anonhg.NetBSD.org/src/rev/b8cd51c1fe18
branches:  trunk
changeset: 771499:b8cd51c1fe18
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Nov 23 19:40:42 2011 +0000

description:
According to "Virtio PCI Card Specification v0.9.2 DRAFT" there is no
feature named VIRTIO_BLK_F_SECTOR_MAX so remove it.  Linux seems to use
this feature bit as VIRTIO_BLK_F_TOPOLOGY.

Use VIRTIO_BLK_F_BLK_SIZE * VIRTIO_BLK_F_SEG_MAX as the drivers maxxfer
and reorder so sc_secsize gets set before use.

As maxxfer may not be a multiple of page size add one more segment to
the dma maps.

Tested on Linux 3.1.1 host by Guillaume Lasmayous.

diffstat:

 sys/dev/pci/ld_virtio.c |  25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diffs (81 lines):

diff -r 97a16ae04a93 -r b8cd51c1fe18 sys/dev/pci/ld_virtio.c
--- a/sys/dev/pci/ld_virtio.c   Wed Nov 23 19:39:11 2011 +0000
+++ b/sys/dev/pci/ld_virtio.c   Wed Nov 23 19:40:42 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $    */
+/*     $NetBSD: ld_virtio.c,v 1.3 2011/11/23 19:40:42 hannken Exp $    */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.2 2011/11/02 14:34:09 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.3 2011/11/23 19:40:42 hannken Exp $");
 
 #include "rnd.h"
 
@@ -61,7 +61,6 @@
 #define VIRTIO_BLK_CONFIG_GEOMETRY_H   18 /* 8bit */
 #define VIRTIO_BLK_CONFIG_GEOMETRY_S   19 /* 8bit */
 #define VIRTIO_BLK_CONFIG_BLK_SIZE     20 /* 32bit */
-#define VIRTIO_BLK_CONFIG_SECTORS_MAX  24 /* 32bit */
 
 /* Feature bits */
 #define VIRTIO_BLK_F_BARRIER   (1<<0)
@@ -72,7 +71,6 @@
 #define VIRTIO_BLK_F_BLK_SIZE  (1<<6)
 #define VIRTIO_BLK_F_SCSI      (1<<7)
 #define VIRTIO_BLK_F_FLUSH     (1<<9)
-#define VIRTIO_BLK_F_SECTOR_MAX        (1<<10)
 
 /* Command */
 #define VIRTIO_BLK_T_IN                0
@@ -194,7 +192,7 @@
                }
                r = bus_dmamap_create(sc->sc_virtio->sc_dmat,
                                      ld->sc_maxxfer,
-                                     (ld->sc_maxxfer / NBPG) + 1,
+                                     (ld->sc_maxxfer / NBPG) + 2,
                                      ld->sc_maxxfer,
                                      0,
                                      BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW,
@@ -262,17 +260,21 @@
                                              VIRTIO_BLK_F_SEG_MAX |
                                              VIRTIO_BLK_F_GEOMETRY |
                                              VIRTIO_BLK_F_RO |
-                                             VIRTIO_BLK_F_BLK_SIZE |
-                                             VIRTIO_BLK_F_SECTOR_MAX));
+                                             VIRTIO_BLK_F_BLK_SIZE));
        if (features & VIRTIO_BLK_F_RO)
                sc->sc_readonly = 1;
        else
                sc->sc_readonly = 0;
 
+       ld->sc_secsize = 512;
+       if (features & VIRTIO_BLK_F_BLK_SIZE) {
+               ld->sc_secsize = virtio_read_device_config_4(vsc,
+                                       VIRTIO_BLK_CONFIG_BLK_SIZE);
+       }
        maxxfersize = MAXPHYS;
-       if (features & VIRTIO_BLK_F_SECTOR_MAX) {
+       if (features & VIRTIO_BLK_F_SEG_MAX) {
                maxxfersize = virtio_read_device_config_4(vsc,
-                                       VIRTIO_BLK_CONFIG_SECTORS_MAX)
+                                       VIRTIO_BLK_CONFIG_SEG_MAX)
                                * ld->sc_secsize;
                if (maxxfersize > MAXPHYS)
                        maxxfersize = MAXPHYS;
@@ -289,11 +291,6 @@
        ld->sc_dv = self;
        ld->sc_secperunit = virtio_read_device_config_8(vsc,
                                VIRTIO_BLK_CONFIG_CAPACITY);
-       ld->sc_secsize = 512;
-       if (features & VIRTIO_BLK_F_BLK_SIZE) {
-               ld->sc_secsize = virtio_read_device_config_4(vsc,
-                                       VIRTIO_BLK_CONFIG_BLK_SIZE);
-       }
        ld->sc_maxxfer = maxxfersize;
        if (features & VIRTIO_BLK_F_GEOMETRY) {
                ld->sc_ncylinders = virtio_read_device_config_2(vsc,



Home | Main Index | Thread Index | Old Index