| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xbdback_xenbus.c,v 1.79 2020/04/19 18:47:40 jdolecek Exp $ */ | | 1 | /* $NetBSD: xbdback_xenbus.c,v 1.80 2020/04/19 20:53:20 jdolecek Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006 Manuel Bouyer. | | 4 | * Copyright (c) 2006 Manuel Bouyer. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -16,27 +16,27 @@ | | | @@ -16,27 +16,27 @@ |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | * | | 25 | * |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | #include <sys/cdefs.h> | | 28 | #include <sys/cdefs.h> |
29 | __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.79 2020/04/19 18:47:40 jdolecek Exp $"); | | 29 | __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.80 2020/04/19 20:53:20 jdolecek Exp $"); |
30 | | | 30 | |
31 | #include <sys/atomic.h> | | 31 | #include <sys/atomic.h> |
32 | #include <sys/buf.h> | | 32 | #include <sys/buf.h> |
33 | #include <sys/condvar.h> | | 33 | #include <sys/condvar.h> |
34 | #include <sys/conf.h> | | 34 | #include <sys/conf.h> |
35 | #include <sys/disk.h> | | 35 | #include <sys/disk.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/fcntl.h> | | 37 | #include <sys/fcntl.h> |
38 | #include <sys/kauth.h> | | 38 | #include <sys/kauth.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/kthread.h> | | 41 | #include <sys/kthread.h> |
42 | #include <sys/mutex.h> | | 42 | #include <sys/mutex.h> |
| @@ -439,26 +439,27 @@ xbdback_xenbus_create(struct xenbus_devi | | | @@ -439,26 +439,27 @@ xbdback_xenbus_create(struct xenbus_devi |
439 | xbdi_get(xbdi); | | 439 | xbdi_get(xbdi); |
440 | | | 440 | |
441 | mutex_init(&xbdi->xbdi_lock, MUTEX_DEFAULT, IPL_BIO); | | 441 | mutex_init(&xbdi->xbdi_lock, MUTEX_DEFAULT, IPL_BIO); |
442 | cv_init(&xbdi->xbdi_cv, xbdi->xbdi_name); | | 442 | cv_init(&xbdi->xbdi_cv, xbdi->xbdi_name); |
443 | mutex_enter(&xbdback_lock); | | 443 | mutex_enter(&xbdback_lock); |
444 | SLIST_INSERT_HEAD(&xbdback_instances, xbdi, next); | | 444 | SLIST_INSERT_HEAD(&xbdback_instances, xbdi, next); |
445 | mutex_exit(&xbdback_lock); | | 445 | mutex_exit(&xbdback_lock); |
446 | | | 446 | |
447 | xbusd->xbusd_u.b.b_cookie = xbdi; | | 447 | xbusd->xbusd_u.b.b_cookie = xbdi; |
448 | xbusd->xbusd_u.b.b_detach = xbdback_xenbus_destroy; | | 448 | xbusd->xbusd_u.b.b_detach = xbdback_xenbus_destroy; |
449 | xbusd->xbusd_otherend_changed = xbdback_frontend_changed; | | 449 | xbusd->xbusd_otherend_changed = xbdback_frontend_changed; |
450 | xbdi->xbdi_xbusd = xbusd; | | 450 | xbdi->xbdi_xbusd = xbusd; |
451 | | | 451 | |
| | | 452 | SLIST_INIT(&xbdi->xbdi_va_free); |
452 | for (i = 0; i < BLKIF_RING_SIZE; i++) { | | 453 | for (i = 0; i < BLKIF_RING_SIZE; i++) { |
453 | xbdi->xbdi_va[i].xv_vaddr = uvm_km_alloc(kernel_map, | | 454 | xbdi->xbdi_va[i].xv_vaddr = uvm_km_alloc(kernel_map, |
454 | VBD_VA_SIZE, 0, UVM_KMF_VAONLY|UVM_KMF_WAITVA); | | 455 | VBD_VA_SIZE, 0, UVM_KMF_VAONLY|UVM_KMF_WAITVA); |
455 | SLIST_INSERT_HEAD(&xbdi->xbdi_va_free, &xbdi->xbdi_va[i], | | 456 | SLIST_INSERT_HEAD(&xbdi->xbdi_va_free, &xbdi->xbdi_va[i], |
456 | xv_next); | | 457 | xv_next); |
457 | } | | 458 | } |
458 | | | 459 | |
459 | error = xenbus_watch_path2(xbusd, xbusd->xbusd_path, "physical-device", | | 460 | error = xenbus_watch_path2(xbusd, xbusd->xbusd_path, "physical-device", |
460 | &xbdi->xbdi_watch, xbdback_backend_changed); | | 461 | &xbdi->xbdi_watch, xbdback_backend_changed); |
461 | if (error) { | | 462 | if (error) { |
462 | printf("failed to watch on %s/physical-device: %d\n", | | 463 | printf("failed to watch on %s/physical-device: %d\n", |
463 | xbusd->xbusd_path, error); | | 464 | xbusd->xbusd_path, error); |
464 | goto fail; | | 465 | goto fail; |