summaryrefslogtreecommitdiff
path: root/sys/dev/hyperv
diff options
context:
space:
mode:
authorchs <chs@NetBSD.org>2019-10-01 18:00:07 +0000
committerchs <chs@NetBSD.org>2019-10-01 18:00:07 +0000
commit68befe26cc9d9b793852833794a256113bf7caa6 (patch)
tree6ddf33f9c9e75114697f2a7c9005a614417ecbb9 /sys/dev/hyperv
parente3b5e434bf80b327067ef158330762d70b75396e (diff)
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
Diffstat (limited to 'sys/dev/hyperv')
-rw-r--r--sys/dev/hyperv/hvkbd.c26
-rw-r--r--sys/dev/hyperv/hvs.c19
-rw-r--r--sys/dev/hyperv/if_hvn.c12
-rw-r--r--sys/dev/hyperv/vmbusic.c6
4 files changed, 15 insertions, 48 deletions
diff --git a/sys/dev/hyperv/hvkbd.c b/sys/dev/hyperv/hvkbd.c
index 322695809ad..b0ce5abc082 100644
--- a/sys/dev/hyperv/hvkbd.c
+++ b/sys/dev/hyperv/hvkbd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hvkbd.c,v 1.2 2019/07/21 16:08:13 rin Exp $ */
+/* $NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $ */
/*-
* Copyright (c) 2017 Microsoft Corp.
@@ -36,7 +36,7 @@
#endif /* _KERNEL_OPT */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.2 2019/07/21 16:08:13 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -209,13 +209,7 @@ hvkbd_attach(device_t parent, device_t self, void *aux)
STAILQ_INIT(&sc->sc_ks_queue);
hvkbd_alloc_keybuf(sc);
- sc->sc_buf = kmem_zalloc(HVKBD_BUFSIZE, cold ? KM_NOSLEEP : KM_SLEEP);
- if (sc->sc_buf == NULL) {
- aprint_error_dev(self,
- "failed to allocate channel data buffer\n");
- return;
- }
-
+ sc->sc_buf = kmem_zalloc(HVKBD_BUFSIZE, KM_SLEEP);
if (vmbus_channel_setdeferred(sc->sc_chan, device_xname(self))) {
aprint_error_dev(self,
"failed to create the interrupt thread\n");
@@ -266,18 +260,8 @@ hvkbd_alloc_keybuf(struct hvkbd_softc *sc)
int i;
for (i = 0; i < HVKBD_KEYBUF_SIZE; i++) {
- ksi = kmem_zalloc(sizeof(*ksi), cold ? KM_NOSLEEP : KM_SLEEP);
- if (ksi != NULL) {
- LIST_INSERT_HEAD(&sc->sc_ks_free, ksi, link);
- continue;
- }
-
- while ((ksi = LIST_FIRST(&sc->sc_ks_free)) != NULL) {
- LIST_REMOVE(ksi, link);
- kmem_free(ksi, sizeof(*ksi));
- }
- return ENOMEM;
-
+ ksi = kmem_zalloc(sizeof(*ksi), KM_SLEEP);
+ LIST_INSERT_HEAD(&sc->sc_ks_free, ksi, link);
}
return 0;
diff --git a/sys/dev/hyperv/hvs.c b/sys/dev/hyperv/hvs.c
index 2bce33458ec..6a86452a358 100644
--- a/sys/dev/hyperv/hvs.c
+++ b/sys/dev/hyperv/hvs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hvs.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $ */
+/* $NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $ */
/* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */
/*-
@@ -37,7 +37,7 @@
/* #define HVS_DEBUG_IO */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1040,7 +1040,6 @@ hvs_empty_done(struct hvs_ccb *ccb)
static int
hvs_alloc_ccbs(struct hvs_softc *sc)
{
- const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP;
const int dmaflags = cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK;
int i, error;
@@ -1049,11 +1048,7 @@ hvs_alloc_ccbs(struct hvs_softc *sc)
sc->sc_nccb = HVS_MAX_CCB;
sc->sc_ccbs = kmem_zalloc(sc->sc_nccb * sizeof(struct hvs_ccb),
- kmemflags);
- if (sc->sc_ccbs == NULL) {
- aprint_error_dev(sc->sc_dev, "failed to allocate CCBs\n");
- return -1;
- }
+ KM_SLEEP);
for (i = 0; i < sc->sc_nccb; i++) {
error = bus_dmamap_create(sc->sc_dmat, MAXPHYS, HVS_MAX_SGE,
@@ -1066,13 +1061,7 @@ hvs_alloc_ccbs(struct hvs_softc *sc)
sc->sc_ccbs[i].ccb_sgl = kmem_zalloc(
sizeof(struct vmbus_gpa_range) * (HVS_MAX_SGE + 1),
- kmemflags);
- if (sc->sc_ccbs[i].ccb_sgl == NULL) {
- aprint_error_dev(sc->sc_dev,
- "failed to allocate SGL array\n");
- goto errout;
- }
-
+ KM_SLEEP);
sc->sc_ccbs[i].ccb_rid = i;
hvs_put_ccb(sc, &sc->sc_ccbs[i]);
}
diff --git a/sys/dev/hyperv/if_hvn.c b/sys/dev/hyperv/if_hvn.c
index be7dbe2d9fa..add6aac6b23 100644
--- a/sys/dev/hyperv/if_hvn.c
+++ b/sys/dev/hyperv/if_hvn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_hvn.c,v 1.4 2019/07/09 08:46:58 msaitoh Exp $ */
+/* $NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $ */
/* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */
/*-
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -904,7 +904,6 @@ hvn_nvs_attach(struct hvn_softc *sc)
HVN_NVS_PROTO_VERSION_2,
HVN_NVS_PROTO_VERSION_1
};
- const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP;
struct hvn_nvs_init cmd;
struct hvn_nvs_init_resp *rsp;
struct hvn_nvs_ndis_init ncmd;
@@ -913,12 +912,7 @@ hvn_nvs_attach(struct hvn_softc *sc)
uint64_t tid;
int i;
- sc->sc_nvsbuf = kmem_zalloc(HVN_NVS_BUFSIZE, kmemflags);
- if (sc->sc_nvsbuf == NULL) {
- DPRINTF("%s: failed to allocate channel data buffer\n",
- device_xname(sc->sc_dev));
- return -1;
- }
+ sc->sc_nvsbuf = kmem_zalloc(HVN_NVS_BUFSIZE, KM_SLEEP);
/* We need to be able to fit all RNDIS control and data messages */
ringsize = HVN_RNDIS_CTLREQS *
diff --git a/sys/dev/hyperv/vmbusic.c b/sys/dev/hyperv/vmbusic.c
index 8743759e5f6..964d7c3c76c 100644
--- a/sys/dev/hyperv/vmbusic.c
+++ b/sys/dev/hyperv/vmbusic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vmbusic.c,v 1.1 2019/02/15 08:54:02 nonaka Exp $ */
+/* $NetBSD: vmbusic.c,v 1.2 2019/10/01 18:00:08 chs Exp $ */
/*-
* Copyright (c) 2014,2016 Microsoft Corp.
* All rights reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#ifdef __KERNEL_RCSID
-__KERNEL_RCSID(0, "$NetBSD: vmbusic.c,v 1.1 2019/02/15 08:54:02 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbusic.c,v 1.2 2019/10/01 18:00:08 chs Exp $");
#endif
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/sys/dev/hyperv/utilities/vmbus_ic.c 310317 2016-12-20 07:14:24Z sephe $");
@@ -71,7 +71,7 @@ vmbusic_attach(device_t dv, struct vmbus_attach_args *aa,
sc->sc_chan = aa->aa_chan;
sc->sc_buflen = VMBUS_IC_BRSIZE;
- sc->sc_buf = kmem_alloc(sc->sc_buflen, cold ? KM_NOSLEEP : KM_SLEEP);
+ sc->sc_buf = kmem_alloc(sc->sc_buflen, KM_SLEEP);
/*
* These services are not performance critical and do not need