| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ld_virtio.c,v 1.18 2018/06/03 19:47:35 jakllsch Exp $ */ | | 1 | /* $NetBSD: ld_virtio.c,v 1.19 2018/06/03 19:50:20 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2010 Minoura Makoto. | | 4 | * Copyright (c) 2010 Minoura Makoto. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.18 2018/06/03 19:47:35 jakllsch Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.19 2018/06/03 19:50:20 jakllsch Exp $"); |
30 | | | 30 | |
31 | #include <sys/param.h> | | 31 | #include <sys/param.h> |
32 | #include <sys/systm.h> | | 32 | #include <sys/systm.h> |
33 | #include <sys/kernel.h> | | 33 | #include <sys/kernel.h> |
34 | #include <sys/buf.h> | | 34 | #include <sys/buf.h> |
35 | #include <sys/bufq.h> | | 35 | #include <sys/bufq.h> |
36 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
37 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
38 | #include <sys/disk.h> | | 38 | #include <sys/disk.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | #include <sys/module.h> | | 40 | #include <sys/module.h> |
41 | | | 41 | |
42 | #include <dev/pci/pcidevs.h> | | 42 | #include <dev/pci/pcidevs.h> |
| @@ -437,26 +437,27 @@ ld_virtio_vq_done1(struct ld_virtio_soft | | | @@ -437,26 +437,27 @@ ld_virtio_vq_done1(struct ld_virtio_soft |
437 | { | | 437 | { |
438 | struct virtio_blk_req *vr = &sc->sc_reqs[slot]; | | 438 | struct virtio_blk_req *vr = &sc->sc_reqs[slot]; |
439 | struct buf *bp = vr->vr_bp; | | 439 | struct buf *bp = vr->vr_bp; |
440 | | | 440 | |
441 | vr->vr_bp = NULL; | | 441 | vr->vr_bp = NULL; |
442 | | | 442 | |
443 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_cmdsts, | | 443 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_cmdsts, |
444 | 0, sizeof(struct virtio_blk_req_hdr), | | 444 | 0, sizeof(struct virtio_blk_req_hdr), |
445 | BUS_DMASYNC_POSTWRITE); | | 445 | BUS_DMASYNC_POSTWRITE); |
446 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_payload, | | 446 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_payload, |
447 | 0, bp->b_bcount, | | 447 | 0, bp->b_bcount, |
448 | (bp->b_flags & B_READ)?BUS_DMASYNC_POSTREAD | | 448 | (bp->b_flags & B_READ)?BUS_DMASYNC_POSTREAD |
449 | :BUS_DMASYNC_POSTWRITE); | | 449 | :BUS_DMASYNC_POSTWRITE); |
| | | 450 | bus_dmamap_unload(virtio_dmat(vsc), vr->vr_payload); |
450 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_cmdsts, | | 451 | bus_dmamap_sync(virtio_dmat(vsc), vr->vr_cmdsts, |
451 | sizeof(struct virtio_blk_req_hdr), sizeof(uint8_t), | | 452 | sizeof(struct virtio_blk_req_hdr), sizeof(uint8_t), |
452 | BUS_DMASYNC_POSTREAD); | | 453 | BUS_DMASYNC_POSTREAD); |
453 | | | 454 | |
454 | if (vr->vr_status != VIRTIO_BLK_S_OK) { | | 455 | if (vr->vr_status != VIRTIO_BLK_S_OK) { |
455 | bp->b_error = EIO; | | 456 | bp->b_error = EIO; |
456 | bp->b_resid = bp->b_bcount; | | 457 | bp->b_resid = bp->b_bcount; |
457 | } else { | | 458 | } else { |
458 | bp->b_error = 0; | | 459 | bp->b_error = 0; |
459 | bp->b_resid = 0; | | 460 | bp->b_resid = 0; |
460 | } | | 461 | } |
461 | | | 462 | |
462 | virtio_dequeue_commit(vsc, vq, slot); | | 463 | virtio_dequeue_commit(vsc, vq, slot); |