Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Allow kmem_alloc(9) to sleep when attaching



details:   https://anonhg.NetBSD.org/src/rev/ed879fcb11ec
branches:  trunk
changeset: 365114:ed879fcb11ec
user:      khorben <khorben%NetBSD.org@localhost>
date:      Wed Aug 01 12:36:56 2018 +0000

description:
Allow kmem_alloc(9) to sleep when attaching

Without this, umb(4) may needlessly fail to attach, like when under memory
pressure.

Thanks skrll@ for the heads-up!

diffstat:

 sys/dev/usb/if_umb.c |  17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diffs (38 lines):

diff -r 494d092bcc95 -r ed879fcb11ec sys/dev/usb/if_umb.c
--- a/sys/dev/usb/if_umb.c      Wed Aug 01 12:25:50 2018 +0000
+++ b/sys/dev/usb/if_umb.c      Wed Aug 01 12:36:56 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_umb.c,v 1.2 2018/08/01 12:25:50 khorben Exp $ */
+/*     $NetBSD: if_umb.c,v 1.3 2018/08/01 12:36:56 khorben Exp $ */
 /*     $OpenBSD: if_umb.c,v 1.18 2018/02/19 08:59:52 mpi Exp $ */
 
 /*
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.2 2018/08/01 12:25:50 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.3 2018/08/01 12:36:56 khorben Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -498,16 +498,9 @@
                aprint_error_dev(self, "failed to open control pipe\n");
                goto fail;
        }
-       sc->sc_resp_buf = kmem_alloc(sc->sc_ctrl_len, KM_NOSLEEP);
-       if (sc->sc_resp_buf == NULL) {
-               aprint_error_dev(self, "allocation of resp buffer failed\n");
-               goto fail;
-       }
-       sc->sc_ctrl_msg = kmem_alloc(sc->sc_ctrl_len, KM_NOSLEEP);
-       if (sc->sc_ctrl_msg == NULL) {
-               aprint_error_dev(self, "allocation of ctrl msg buffer failed\n");
-               goto fail;
-       }
+
+       sc->sc_resp_buf = kmem_alloc(sc->sc_ctrl_len, KM_SLEEP);
+       sc->sc_ctrl_msg = kmem_alloc(sc->sc_ctrl_len, KM_SLEEP);
 
        sc->sc_info.regstate = MBIM_REGSTATE_UNKNOWN;
        sc->sc_info.pin_attempts_left = UMB_VALUE_UNKNOWN;



Home | Main Index | Thread Index | Old Index