Pull up following revision(s) (requested by nonaka in ticket #1647): sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch) sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch) sys/dev/hyperv/vmbus.c: revision 1.12 (via patch) hvkbd(4): Don't wait forever. vmbus(4): Don't wait forever. hvn(4): Don't wait forever.diff -r1.1.4.6 -r1.1.4.7 src/sys/dev/hyperv/hvkbd.c
(martin)
--- src/sys/dev/hyperv/hvkbd.c 2019/11/24 08:11:06 1.1.4.6
+++ src/sys/dev/hyperv/hvkbd.c 2021/01/29 18:18:25 1.1.4.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $ */ | 1 | /* $NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2017 Microsoft Corp. | 4 | * Copyright (c) 2017 Microsoft Corp. | |
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 unmodified, this list of conditions, and the following | 11 | * notice unmodified, this list of conditions, and the following | |
12 | * disclaimer. | 12 | * disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | * | 27 | * | |
28 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbd.c 317821 2017-05-05 03:28:30Z sephe $ | 28 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbd.c 317821 2017-05-05 03:28:30Z sephe $ | |
29 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbdc.c 320490 2017-06-30 03:01:22Z sephe $ | 29 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbdc.c 320490 2017-06-30 03:01:22Z sephe $ | |
30 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbdc.h 316515 2017-04-05 05:01:23Z sephe $ | 30 | * $FreeBSD: head/sys/dev/hyperv/input/hv_kbdc.h 316515 2017-04-05 05:01:23Z sephe $ | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #ifdef _KERNEL_OPT | 33 | #ifdef _KERNEL_OPT | |
34 | #include "opt_pckbd_layout.h" | 34 | #include "opt_pckbd_layout.h" | |
35 | #include "opt_wsdisplay_compat.h" | 35 | #include "opt_wsdisplay_compat.h" | |
36 | #endif /* _KERNEL_OPT */ | 36 | #endif /* _KERNEL_OPT */ | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | __KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $"); | 39 | __KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $"); | |
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/device.h> | 43 | #include <sys/device.h> | |
44 | #include <sys/mutex.h> | 44 | #include <sys/mutex.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/kmem.h> | 46 | #include <sys/kmem.h> | |
47 | #include <sys/module.h> | 47 | #include <sys/module.h> | |
48 | #include <sys/pmf.h> | 48 | #include <sys/pmf.h> | |
49 | #include <sys/proc.h> | 49 | #include <sys/proc.h> | |
50 | #include <sys/queue.h> | 50 | #include <sys/queue.h> | |
51 | 51 | |||
52 | #include <dev/hyperv/vmbusvar.h> | 52 | #include <dev/hyperv/vmbusvar.h> | |
@@ -353,27 +353,28 @@ hvkbd_connect(struct hvkbd_softc *sc) | @@ -353,27 +353,28 @@ hvkbd_connect(struct hvkbd_softc *sc) | |||
353 | if (error) { | 353 | if (error) { | |
354 | aprint_error_dev(sc->sc_dev, "failed to send connect: %d\n", | 354 | aprint_error_dev(sc->sc_dev, "failed to send connect: %d\n", | |
355 | error); | 355 | error); | |
356 | return error; | 356 | return error; | |
357 | } | 357 | } | |
358 | 358 | |||
359 | do { | 359 | do { | |
360 | if (cold) { | 360 | if (cold) { | |
361 | delay(1000); | 361 | delay(1000); | |
362 | s = spltty(); | 362 | s = spltty(); | |
363 | hvkbd_intr(sc); | 363 | hvkbd_intr(sc); | |
364 | splx(s); | 364 | splx(s); | |
365 | } else | 365 | } else | |
366 | tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1)); | 366 | tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", | |
367 | max(1, mstohz(1))); | |||
367 | } while (--timo > 0 && sc->sc_connected == 0); | 368 | } while (--timo > 0 && sc->sc_connected == 0); | |
368 | 369 | |||
369 | if (timo == 0 && sc->sc_connected == 0) { | 370 | if (timo == 0 && sc->sc_connected == 0) { | |
370 | aprint_error_dev(sc->sc_dev, "connect timed out\n"); | 371 | aprint_error_dev(sc->sc_dev, "connect timed out\n"); | |
371 | return ETIMEDOUT; | 372 | return ETIMEDOUT; | |
372 | } | 373 | } | |
373 | 374 | |||
374 | if (!(sc->sc_connect_status & RESP_STATUS_ACCEPTED)) { | 375 | if (!(sc->sc_connect_status & RESP_STATUS_ACCEPTED)) { | |
375 | aprint_error_dev(sc->sc_dev, "protocol request failed\n"); | 376 | aprint_error_dev(sc->sc_dev, "protocol request failed\n"); | |
376 | return ENODEV; | 377 | return ENODEV; | |
377 | } | 378 | } | |
378 | 379 | |||
379 | return 0; | 380 | return 0; |
--- src/sys/dev/hyperv/if_hvn.c 2020/12/11 15:48:02 1.2.2.8
+++ src/sys/dev/hyperv/if_hvn.c 2021/01/29 18:18:25 1.2.2.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $ */ | 1 | /* $NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 martin Exp $ */ | |
2 | /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ | 2 | /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2009-2012,2016 Microsoft Corp. | 5 | * Copyright (c) 2009-2012,2016 Microsoft Corp. | |
6 | * Copyright (c) 2010-2012 Citrix Inc. | 6 | * Copyright (c) 2010-2012 Citrix Inc. | |
7 | * Copyright (c) 2012 NetApp Inc. | 7 | * Copyright (c) 2012 NetApp Inc. | |
8 | * Copyright (c) 2016 Mike Belopuhov <mike@esdenera.com> | 8 | * Copyright (c) 2016 Mike Belopuhov <mike@esdenera.com> | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
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 | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * The OpenBSD port was done under funding by Esdenera Networks GmbH. | 34 | * The OpenBSD port was done under funding by Esdenera Networks GmbH. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 martin Exp $"); | |
39 | 39 | |||
40 | #ifdef _KERNEL_OPT | 40 | #ifdef _KERNEL_OPT | |
41 | #include "opt_inet.h" | 41 | #include "opt_inet.h" | |
42 | #include "opt_inet6.h" | 42 | #include "opt_inet6.h" | |
43 | #include "opt_net_mpsafe.h" | 43 | #include "opt_net_mpsafe.h" | |
44 | #endif | 44 | #endif | |
45 | 45 | |||
46 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/kernel.h> | 48 | #include <sys/kernel.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | #include <sys/atomic.h> | 50 | #include <sys/atomic.h> | |
51 | #include <sys/bus.h> | 51 | #include <sys/bus.h> | |
@@ -1055,52 +1055,53 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * | @@ -1055,52 +1055,53 @@ hvn_nvs_cmd(struct hvn_softc *sc, void * | |||
1055 | int tries = 10; | 1055 | int tries = 10; | |
1056 | int rv, s; | 1056 | int rv, s; | |
1057 | 1057 | |||
1058 | sc->sc_nvsdone = 0; | 1058 | sc->sc_nvsdone = 0; | |
1059 | 1059 | |||
1060 | do { | 1060 | do { | |
1061 | rv = vmbus_channel_send(sc->sc_chan, cmd, cmdsize, | 1061 | rv = vmbus_channel_send(sc->sc_chan, cmd, cmdsize, | |
1062 | tid, VMBUS_CHANPKT_TYPE_INBAND, | 1062 | tid, VMBUS_CHANPKT_TYPE_INBAND, | |
1063 | timo ? VMBUS_CHANPKT_FLAG_RC : 0); | 1063 | timo ? VMBUS_CHANPKT_FLAG_RC : 0); | |
1064 | if (rv == EAGAIN) { | 1064 | if (rv == EAGAIN) { | |
1065 | if (cold) | 1065 | if (cold) | |
1066 | delay(1000); | 1066 | delay(1000); | |
1067 | else | 1067 | else | |
1068 | tsleep(cmd, PRIBIO, "nvsout", mstohz(1)); | 1068 | tsleep(cmd, PRIBIO, "nvsout", | |
1069 | max(1, mstohz(1))); | |||
1069 | } else if (rv) { | 1070 | } else if (rv) { | |
1070 | DPRINTF("%s: NVSP operation %u send error %d\n", | 1071 | DPRINTF("%s: NVSP operation %u send error %d\n", | |
1071 | device_xname(sc->sc_dev), hdr->nvs_type, rv); | 1072 | device_xname(sc->sc_dev), hdr->nvs_type, rv); | |
1072 | return rv; | 1073 | return rv; | |
1073 | } | 1074 | } | |
1074 | } while (rv != 0 && --tries > 0); | 1075 | } while (rv != 0 && --tries > 0); | |
1075 | 1076 | |||
1076 | if (tries == 0 && rv != 0) { | 1077 | if (tries == 0 && rv != 0) { | |
1077 | device_printf(sc->sc_dev, | 1078 | device_printf(sc->sc_dev, | |
1078 | "NVSP operation %u send error %d\n", hdr->nvs_type, rv); | 1079 | "NVSP operation %u send error %d\n", hdr->nvs_type, rv); | |
1079 | return rv; | 1080 | return rv; | |
1080 | } | 1081 | } | |
1081 | 1082 | |||
1082 | if (timo == 0) | 1083 | if (timo == 0) | |
1083 | return 0; | 1084 | return 0; | |
1084 | 1085 | |||
1085 | do { | 1086 | do { | |
1086 | if (cold) { | 1087 | if (cold) { | |
1087 | delay(1000); | 1088 | delay(1000); | |
1088 | s = splnet(); | 1089 | s = splnet(); | |
1089 | hvn_nvs_intr(sc); | 1090 | hvn_nvs_intr(sc); | |
1090 | splx(s); | 1091 | splx(s); | |
1091 | } else | 1092 | } else | |
1092 | tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd", | 1093 | tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd", | |
1093 | mstohz(1)); | 1094 | max(1, mstohz(1))); | |
1094 | } while (--timo > 0 && sc->sc_nvsdone != 1); | 1095 | } while (--timo > 0 && sc->sc_nvsdone != 1); | |
1095 | 1096 | |||
1096 | if (timo == 0 && sc->sc_nvsdone != 1) { | 1097 | if (timo == 0 && sc->sc_nvsdone != 1) { | |
1097 | device_printf(sc->sc_dev, "NVSP operation %u timed out\n", | 1098 | device_printf(sc->sc_dev, "NVSP operation %u timed out\n", | |
1098 | hdr->nvs_type); | 1099 | hdr->nvs_type); | |
1099 | return ETIMEDOUT; | 1100 | return ETIMEDOUT; | |
1100 | } | 1101 | } | |
1101 | return 0; | 1102 | return 0; | |
1102 | } | 1103 | } | |
1103 | 1104 | |||
1104 | static int | 1105 | static int | |
1105 | hvn_nvs_ack(struct hvn_softc *sc, uint64_t tid) | 1106 | hvn_nvs_ack(struct hvn_softc *sc, uint64_t tid) | |
1106 | { | 1107 | { | |
@@ -1378,52 +1379,54 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru | @@ -1378,52 +1379,54 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru | |||
1378 | sgl[0].gpa_ofs = 0; | 1379 | sgl[0].gpa_ofs = 0; | |
1379 | 1380 | |||
1380 | rc->rc_done = 0; | 1381 | rc->rc_done = 0; | |
1381 | 1382 | |||
1382 | hvn_submit_cmd(sc, rc); | 1383 | hvn_submit_cmd(sc, rc); | |
1383 | 1384 | |||
1384 | do { | 1385 | do { | |
1385 | rv = vmbus_channel_send_sgl(sc->sc_chan, sgl, 1, &rc->rc_msg, | 1386 | rv = vmbus_channel_send_sgl(sc->sc_chan, sgl, 1, &rc->rc_msg, | |
1386 | sizeof(*msg), rc->rc_id); | 1387 | sizeof(*msg), rc->rc_id); | |
1387 | if (rv == EAGAIN) { | 1388 | if (rv == EAGAIN) { | |
1388 | if (cold) | 1389 | if (cold) | |
1389 | delay(1000); | 1390 | delay(1000); | |
1390 | else | 1391 | else | |
1391 | tsleep(rc, PRIBIO, "rndisout", mstohz(1)); | 1392 | tsleep(rc, PRIBIO, "rndisout", | |
1393 | max(1, mstohz(1))); | |||
1392 | } else if (rv) { | 1394 | } else if (rv) { | |
1393 | DPRINTF("%s: RNDIS operation %u send error %d\n", | 1395 | DPRINTF("%s: RNDIS operation %u send error %d\n", | |
1394 | device_xname(sc->sc_dev), hdr->rm_type, rv); | 1396 | device_xname(sc->sc_dev), hdr->rm_type, rv); | |
1395 | hvn_rollback_cmd(sc, rc); | 1397 | hvn_rollback_cmd(sc, rc); | |
1396 | return rv; | 1398 | return rv; | |
1397 | } | 1399 | } | |
1398 | } while (rv != 0 && --tries > 0); | 1400 | } while (rv != 0 && --tries > 0); | |
1399 | 1401 | |||
1400 | if (tries == 0 && rv != 0) { | 1402 | if (tries == 0 && rv != 0) { | |
1401 | device_printf(sc->sc_dev, | 1403 | device_printf(sc->sc_dev, | |
1402 | "RNDIS operation %u send error %d\n", hdr->rm_type, rv); | 1404 | "RNDIS operation %u send error %d\n", hdr->rm_type, rv); | |
1403 | return rv; | 1405 | return rv; | |
1404 | } | 1406 | } | |
1405 | 1407 | |||
1406 | bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE, | 1408 | bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE, | |
1407 | BUS_DMASYNC_POSTWRITE); | 1409 | BUS_DMASYNC_POSTWRITE); | |
1408 | 1410 | |||
1409 | do { | 1411 | do { | |
1410 | if (cold) { | 1412 | if (cold) { | |
1411 | delay(1000); | 1413 | delay(1000); | |
1412 | s = splnet(); | 1414 | s = splnet(); | |
1413 | hvn_nvs_intr(sc); | 1415 | hvn_nvs_intr(sc); | |
1414 | splx(s); | 1416 | splx(s); | |
1415 | } else | 1417 | } else | |
1416 | tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1)); | 1418 | tsleep(rc, PRIBIO | PCATCH, "rndiscmd", | |
1419 | max(1, mstohz(1))); | |||
1417 | } while (--timo > 0 && rc->rc_done != 1); | 1420 | } while (--timo > 0 && rc->rc_done != 1); | |
1418 | 1421 | |||
1419 | bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE, | 1422 | bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE, | |
1420 | BUS_DMASYNC_POSTREAD); | 1423 | BUS_DMASYNC_POSTREAD); | |
1421 | 1424 | |||
1422 | if (rc->rc_done != 1) { | 1425 | if (rc->rc_done != 1) { | |
1423 | rv = timo == 0 ? ETIMEDOUT : EINTR; | 1426 | rv = timo == 0 ? ETIMEDOUT : EINTR; | |
1424 | if (hvn_rollback_cmd(sc, rc)) { | 1427 | if (hvn_rollback_cmd(sc, rc)) { | |
1425 | hvn_release_cmd(sc, rc); | 1428 | hvn_release_cmd(sc, rc); | |
1426 | rv = 0; | 1429 | rv = 0; | |
1427 | } else if (rv == ETIMEDOUT) { | 1430 | } else if (rv == ETIMEDOUT) { | |
1428 | device_printf(sc->sc_dev, | 1431 | device_printf(sc->sc_dev, | |
1429 | "RNDIS operation %u timed out\n", hdr->rm_type); | 1432 | "RNDIS operation %u timed out\n", hdr->rm_type); |
--- src/sys/dev/hyperv/vmbus.c 2019/11/24 08:11:06 1.2.2.5
+++ src/sys/dev/hyperv/vmbus.c 2021/01/29 18:18:25 1.2.2.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $ */ | 1 | /* $NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $ */ | |
2 | /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ | 2 | /* $OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2009-2012 Microsoft Corp. | 5 | * Copyright (c) 2009-2012 Microsoft Corp. | |
6 | * Copyright (c) 2012 NetApp Inc. | 6 | * Copyright (c) 2012 NetApp Inc. | |
7 | * Copyright (c) 2012 Citrix Inc. | 7 | * Copyright (c) 2012 Citrix Inc. | |
8 | * Copyright (c) 2016 Mike Belopuhov <mike@esdenera.com> | 8 | * Copyright (c) 2016 Mike Belopuhov <mike@esdenera.com> | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
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 | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * The OpenBSD port was done under funding by Esdenera Networks GmbH. | 34 | * The OpenBSD port was done under funding by Esdenera Networks GmbH. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $"); | |
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | #include <sys/atomic.h> | 43 | #include <sys/atomic.h> | |
44 | #include <sys/bitops.h> | 44 | #include <sys/bitops.h> | |
45 | #include <sys/bus.h> | 45 | #include <sys/bus.h> | |
46 | #include <sys/cpu.h> | 46 | #include <sys/cpu.h> | |
47 | #include <sys/intr.h> | 47 | #include <sys/intr.h> | |
48 | #include <sys/kmem.h> | 48 | #include <sys/kmem.h> | |
49 | #include <sys/module.h> | 49 | #include <sys/module.h> | |
50 | #include <sys/mutex.h> | 50 | #include <sys/mutex.h> | |
51 | #include <sys/xcall.h> | 51 | #include <sys/xcall.h> | |
@@ -594,27 +594,28 @@ vmbus_start(struct vmbus_softc *sc, stru | @@ -594,27 +594,28 @@ vmbus_start(struct vmbus_softc *sc, stru | |||
594 | 594 | |||
595 | for (i = 0; i < __arraycount(delays); i++) { | 595 | for (i = 0; i < __arraycount(delays); i++) { | |
596 | status = hyperv_hypercall_post_message( | 596 | status = hyperv_hypercall_post_message( | |
597 | msg_pa + offsetof(struct vmbus_msg, msg_req)); | 597 | msg_pa + offsetof(struct vmbus_msg, msg_req)); | |
598 | if (status == HYPERCALL_STATUS_SUCCESS) | 598 | if (status == HYPERCALL_STATUS_SUCCESS) | |
599 | break; | 599 | break; | |
600 | 600 | |||
601 | if (msg->msg_flags & MSGF_NOSLEEP) { | 601 | if (msg->msg_flags & MSGF_NOSLEEP) { | |
602 | delay(delays[i]); | 602 | delay(delays[i]); | |
603 | s = splnet(); | 603 | s = splnet(); | |
604 | hyperv_intr(); | 604 | hyperv_intr(); | |
605 | splx(s); | 605 | splx(s); | |
606 | } else | 606 | } else | |
607 | tsleep(wchan, PRIBIO, wchan, mstohz(delays[i])); | 607 | tsleep(wchan, PRIBIO, wchan, | |
608 | max(1, mstohz(delays[i] / 1000))); | |||
608 | } | 609 | } | |
609 | if (status != HYPERCALL_STATUS_SUCCESS) { | 610 | if (status != HYPERCALL_STATUS_SUCCESS) { | |
610 | device_printf(sc->sc_dev, | 611 | device_printf(sc->sc_dev, | |
611 | "posting vmbus message failed with %d\n", status); | 612 | "posting vmbus message failed with %d\n", status); | |
612 | if (!(msg->msg_flags & MSGF_NOQUEUE)) { | 613 | if (!(msg->msg_flags & MSGF_NOQUEUE)) { | |
613 | mutex_enter(&sc->sc_req_lock); | 614 | mutex_enter(&sc->sc_req_lock); | |
614 | TAILQ_REMOVE(&sc->sc_reqs, msg, msg_entry); | 615 | TAILQ_REMOVE(&sc->sc_reqs, msg, msg_entry); | |
615 | mutex_exit(&sc->sc_req_lock); | 616 | mutex_exit(&sc->sc_req_lock); | |
616 | } | 617 | } | |
617 | return EIO; | 618 | return EIO; | |
618 | } | 619 | } | |
619 | 620 | |||
620 | return 0; | 621 | return 0; | |
@@ -657,27 +658,27 @@ vmbus_wait(struct vmbus_softc *sc, | @@ -657,27 +658,27 @@ vmbus_wait(struct vmbus_softc *sc, | |||
657 | int (*cond)(struct vmbus_softc *, struct vmbus_msg *), | 658 | int (*cond)(struct vmbus_softc *, struct vmbus_msg *), | |
658 | struct vmbus_msg *msg, void *wchan, const char *wmsg) | 659 | struct vmbus_msg *msg, void *wchan, const char *wmsg) | |
659 | { | 660 | { | |
660 | int s; | 661 | int s; | |
661 | 662 | |||
662 | while (!cond(sc, msg)) { | 663 | while (!cond(sc, msg)) { | |
663 | if (msg->msg_flags & MSGF_NOSLEEP) { | 664 | if (msg->msg_flags & MSGF_NOSLEEP) { | |
664 | delay(1000); | 665 | delay(1000); | |
665 | s = splnet(); | 666 | s = splnet(); | |
666 | hyperv_intr(); | 667 | hyperv_intr(); | |
667 | splx(s); | 668 | splx(s); | |
668 | } else | 669 | } else | |
669 | tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait", | 670 | tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait", | |
670 | mstohz(1)); | 671 | max(1, mstohz(1))); | |
671 | } | 672 | } | |
672 | } | 673 | } | |
673 | 674 | |||
674 | static uint16_t | 675 | static uint16_t | |
675 | vmbus_intr_signal(struct vmbus_softc *sc, paddr_t con_pa) | 676 | vmbus_intr_signal(struct vmbus_softc *sc, paddr_t con_pa) | |
676 | { | 677 | { | |
677 | uint64_t status; | 678 | uint64_t status; | |
678 | 679 | |||
679 | status = hyperv_hypercall_signal_event(con_pa); | 680 | status = hyperv_hypercall_signal_event(con_pa); | |
680 | return (uint16_t)status; | 681 | return (uint16_t)status; | |
681 | } | 682 | } | |
682 | 683 | |||
683 | #if LONG_BIT == 64 | 684 | #if LONG_BIT == 64 |