| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: viornd.c,v 1.3 2014/11/06 00:42:18 pooka Exp $ */ | | 1 | /* $NetBSD: viornd.c,v 1.4 2014/11/06 01:29:25 pooka Exp $ */ |
2 | /* $OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $ */ | | 2 | /* $OpenBSD: viornd.c,v 1.1 2014/01/21 21:14:58 sf Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 2014 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Thor Lancelot Simon (tls@NetBSD.org). | | 9 | * by Thor Lancelot Simon (tls@NetBSD.org). |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -92,30 +92,30 @@ viornd_get(size_t bytes, void *priv) | | | @@ -92,30 +92,30 @@ viornd_get(size_t bytes, void *priv) |
92 | int slot; | | 92 | int slot; |
93 | | | 93 | |
94 | aprint_normal("%s: asked for %d bytes of entropy\n", __func__, | | 94 | aprint_normal("%s: asked for %d bytes of entropy\n", __func__, |
95 | VIORND_BUFSIZE); | | 95 | VIORND_BUFSIZE); |
96 | mutex_enter(&sc->sc_mutex); | | 96 | mutex_enter(&sc->sc_mutex); |
97 | | | 97 | |
98 | if (sc->sc_active) { | | 98 | if (sc->sc_active) { |
99 | goto out; | | 99 | goto out; |
100 | } | | 100 | } |
101 | | | 101 | |
102 | bus_dmamap_sync(vsc->sc_dmat, sc->sc_dmamap, 0, VIORND_BUFSIZE, | | 102 | bus_dmamap_sync(vsc->sc_dmat, sc->sc_dmamap, 0, VIORND_BUFSIZE, |
103 | BUS_DMASYNC_PREREAD); | | 103 | BUS_DMASYNC_PREREAD); |
104 | if (virtio_enqueue_prep(vsc, vq, &slot)) { | | 104 | if (virtio_enqueue_prep(vsc, vq, &slot)) { |
105 | virtio_enqueue_abort(vsc, vq, slot); | | | |
106 | goto out; | | 105 | goto out; |
107 | } | | 106 | } |
108 | if (virtio_enqueue_reserve(vsc, vq, slot, 1)) { | | 107 | if (virtio_enqueue_reserve(vsc, vq, slot, 1)) { |
| | | 108 | virtio_enqueue_abort(vsc, vq, slot); |
109 | goto out; | | 109 | goto out; |
110 | } | | 110 | } |
111 | virtio_enqueue(vsc, vq, slot, sc->sc_dmamap, 0); | | 111 | virtio_enqueue(vsc, vq, slot, sc->sc_dmamap, 0); |
112 | virtio_enqueue_commit(vsc, vq, slot, 1); | | 112 | virtio_enqueue_commit(vsc, vq, slot, 1); |
113 | sc->sc_active = true; | | 113 | sc->sc_active = true; |
114 | out: | | 114 | out: |
115 | mutex_exit(&sc->sc_mutex); | | 115 | mutex_exit(&sc->sc_mutex); |
116 | } | | 116 | } |
117 | | | 117 | |
118 | int | | 118 | int |
119 | viornd_match(device_t parent, cfdata_t match, void *aux) | | 119 | viornd_match(device_t parent, cfdata_t match, void *aux) |
120 | { | | 120 | { |
121 | struct virtio_softc *va = aux; | | 121 | struct virtio_softc *va = aux; |