| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ld_virtio.c,v 1.12 2016/09/27 03:33:32 pgoyette Exp $ */ | | 1 | /* $NetBSD: ld_virtio.c,v 1.13 2016/11/30 01:36:38 christos 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.12 2016/09/27 03:33:32 pgoyette Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: ld_virtio.c,v 1.13 2016/11/30 01:36:38 christos 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> |
| @@ -389,27 +389,26 @@ ld_virtio_start(struct ld_softc *ld, str | | | @@ -389,27 +389,26 @@ ld_virtio_start(struct ld_softc *ld, str |
389 | bp->b_data, bp->b_bcount, NULL, | | 389 | bp->b_data, bp->b_bcount, NULL, |
390 | ((isread?BUS_DMA_READ:BUS_DMA_WRITE) | | 390 | ((isread?BUS_DMA_READ:BUS_DMA_WRITE) |
391 | |BUS_DMA_NOWAIT)); | | 391 | |BUS_DMA_NOWAIT)); |
392 | if (r != 0) { | | 392 | if (r != 0) { |
393 | aprint_error_dev(sc->sc_dev, | | 393 | aprint_error_dev(sc->sc_dev, |
394 | "payload dmamap failed, error code %d\n", r); | | 394 | "payload dmamap failed, error code %d\n", r); |
395 | virtio_enqueue_abort(vsc, vq, slot); | | 395 | virtio_enqueue_abort(vsc, vq, slot); |
396 | return r; | | 396 | return r; |
397 | } | | 397 | } |
398 | | | 398 | |
399 | r = virtio_enqueue_reserve(vsc, vq, slot, vr->vr_payload->dm_nsegs + | | 399 | r = virtio_enqueue_reserve(vsc, vq, slot, vr->vr_payload->dm_nsegs + |
400 | VIRTIO_BLK_MIN_SEGMENTS); | | 400 | VIRTIO_BLK_MIN_SEGMENTS); |
401 | if (r != 0) { | | 401 | if (r != 0) { |
402 | virtio_enqueue_abort(vsc, vq, slot); | | | |
403 | bus_dmamap_unload(vsc->sc_dmat, vr->vr_payload); | | 402 | bus_dmamap_unload(vsc->sc_dmat, vr->vr_payload); |
404 | return r; | | 403 | return r; |
405 | } | | 404 | } |
406 | | | 405 | |
407 | vr->vr_bp = bp; | | 406 | vr->vr_bp = bp; |
408 | vr->vr_hdr.type = isread?VIRTIO_BLK_T_IN:VIRTIO_BLK_T_OUT; | | 407 | vr->vr_hdr.type = isread?VIRTIO_BLK_T_IN:VIRTIO_BLK_T_OUT; |
409 | vr->vr_hdr.ioprio = 0; | | 408 | vr->vr_hdr.ioprio = 0; |
410 | vr->vr_hdr.sector = bp->b_rawblkno * sc->sc_ld.sc_secsize / 512; | | 409 | vr->vr_hdr.sector = bp->b_rawblkno * sc->sc_ld.sc_secsize / 512; |
411 | | | 410 | |
412 | bus_dmamap_sync(vsc->sc_dmat, vr->vr_cmdsts, | | 411 | bus_dmamap_sync(vsc->sc_dmat, vr->vr_cmdsts, |
413 | 0, sizeof(struct virtio_blk_req_hdr), | | 412 | 0, sizeof(struct virtio_blk_req_hdr), |
414 | BUS_DMASYNC_PREWRITE); | | 413 | BUS_DMASYNC_PREWRITE); |
415 | bus_dmamap_sync(vsc->sc_dmat, vr->vr_payload, | | 414 | bus_dmamap_sync(vsc->sc_dmat, vr->vr_payload, |