Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/opencrypto in many device attach paths, allocate memory ...
details: https://anonhg.NetBSD.org/src/rev/d6354ed7969e
branches: trunk
changeset: 1003813:d6354ed7969e
user: chs <chs%NetBSD.org@localhost>
date: Tue Oct 01 18:00:07 2019 +0000
description:
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:
sys/arch/aarch64/aarch64/cpufunc.c | 7 ++--
sys/arch/arm/altera/cycv_clkmgr.c | 12 ++------
sys/arch/arm/arm/undefined.c | 7 ++--
sys/arch/ia64/ia64/cpu.c | 10 ++----
sys/arch/luna68k/dev/siotty.c | 10 ++----
sys/arch/sgimips/mace/macekbc.c | 10 ++----
sys/arch/sparc/sparc/cpu.c | 6 ++--
sys/arch/sparc64/dev/ldc.c | 13 ++------
sys/arch/sparc64/dev/schizo.c | 33 +++++----------------
sys/arch/sparc64/dev/vdsk.c | 56 ++-----------------------------------
sys/arch/sparc64/sparc64/cpu.c | 6 ++--
sys/arch/x86/x86/genfb_machdep.c | 12 ++-----
sys/dev/acpi/acpi_srat.c | 27 ++++++------------
sys/dev/hyperv/hvkbd.c | 26 +++--------------
sys/dev/hyperv/hvs.c | 19 ++----------
sys/dev/hyperv/if_hvn.c | 12 ++------
sys/dev/hyperv/vmbusic.c | 6 ++--
sys/dev/i2c/ihidev.c | 12 ++-----
sys/dev/i2c/sdtemp.c | 11 ++-----
sys/dev/iscsi/iscsi_main.c | 9 +----
sys/dev/nand/nandemulator.c | 11 ++-----
sys/dev/pci/arcmsr.c | 9 ++----
sys/dev/pci/if_vioif.c | 31 +++++---------------
sys/dev/pci/pciconf.c | 11 ++----
sys/dev/pci/virtio.c | 11 ++-----
sys/dev/usb/uvideo.c | 17 ++--------
sys/netinet/tcp_vtw.c | 33 ++-------------------
sys/opencrypto/crypto.c | 51 ++++++----------------------------
28 files changed, 114 insertions(+), 364 deletions(-)
diffs (truncated from 1304 to 300 lines):
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/aarch64/aarch64/cpufunc.c
--- a/sys/arch/aarch64/aarch64/cpufunc.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/aarch64/aarch64/cpufunc.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.c,v 1.6 2019/09/12 09:05:28 jmcneill Exp $ */
+/* $NetBSD: cpufunc.c,v 1.7 2019/10/01 18:00:07 chs Exp $ */
/*
* Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -29,7 +29,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.6 2019/09/12 09:05:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.7 2019/10/01 18:00:07 chs Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -107,8 +107,7 @@
cinfo = aarch64_cacheinfo[curcpu()->ci_package_id] =
kmem_zalloc(sizeof(struct aarch64_cache_info) * MAX_CACHE_LEVEL,
- KM_NOSLEEP);
- KASSERT(cinfo != NULL);
+ KM_SLEEP);
curcpu()->ci_cacheinfo = cinfo;
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/arm/altera/cycv_clkmgr.c
--- a/sys/arch/arm/altera/cycv_clkmgr.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/arm/altera/cycv_clkmgr.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: cycv_clkmgr.c,v 1.2 2019/01/17 12:49:53 skrll Exp $ */
+/* $NetBSD: cycv_clkmgr.c,v 1.3 2019/10/01 18:00:07 chs Exp $ */
/* This file is in the public domain. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cycv_clkmgr.c,v 1.2 2019/01/17 12:49:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cycv_clkmgr.c,v 1.3 2019/10/01 18:00:07 chs Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -166,13 +166,7 @@
0);
sc->sc_clocks = kmem_zalloc(sc->sc_nclocks * sizeof *sc->sc_clocks,
- KM_NOSLEEP);
- if (sc->sc_clocks == NULL) {
- aprint_error_dev(sc->sc_dev, "no memory\n");
- sc->sc_nclocks = 0;
- return;
- }
-
+ KM_SLEEP);
cycv_clkmgr_clocks_traverse(sc, clocks_handle, cycv_clkmgr_clock_parse,
0);
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/arm/arm/undefined.c
--- a/sys/arch/arm/arm/undefined.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/arm/arm/undefined.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: undefined.c,v 1.65 2019/04/06 03:06:24 thorpej Exp $ */
+/* $NetBSD: undefined.c,v 1.66 2019/10/01 18:00:07 chs Exp $ */
/*
* Copyright (c) 2001 Ben Harris.
@@ -55,7 +55,7 @@
#include <sys/kgdb.h>
#endif
-__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.65 2019/04/06 03:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.66 2019/10/01 18:00:07 chs Exp $");
#include <sys/kmem.h>
#include <sys/queue.h>
@@ -98,8 +98,7 @@
KASSERT(coproc >= 0 && coproc < NUM_UNKNOWN_HANDLERS);
KASSERT(handler != NULL); /* Used to be legal. */
- uh = kmem_alloc(sizeof(*uh), KM_NOSLEEP);
- KASSERT(uh != NULL);
+ uh = kmem_alloc(sizeof(*uh), KM_SLEEP);
uh->uh_handler = handler;
install_coproc_handler_static(coproc, uh);
return uh;
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/ia64/ia64/cpu.c
--- a/sys/arch/ia64/ia64/cpu.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/ia64/ia64/cpu.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.15 2017/04/08 17:40:50 scole Exp $ */
+/* $NetBSD: cpu.c,v 1.16 2019/10/01 18:00:07 chs Exp $ */
/*
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15 2017/04/08 17:40:50 scole Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.16 2019/10/01 18:00:07 chs Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -94,11 +94,7 @@
if (id == sapic->Id && eid == sapic->Eid)
ci = curcpu();
else {
- ci = (struct cpu_info *)kmem_zalloc(sizeof(*ci), KM_NOSLEEP);
- if (ci == NULL) {
- aprint_error_dev(self, "memory alloc failed\n");
- return;
- }
+ ci = (struct cpu_info *)kmem_zalloc(sizeof(*ci), KM_SLEEP);
}
sc->sc_info = ci;
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/luna68k/dev/siotty.c
--- a/sys/arch/luna68k/dev/siotty.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/luna68k/dev/siotty.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.45 2019/06/30 02:11:56 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.46 2019/10/01 18:00:07 chs Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.45 2019/06/30 02:11:56 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.46 2019/10/01 18:00:07 chs Exp $");
#include "opt_ddb.h"
@@ -188,11 +188,7 @@
aprint_normal("\n");
- sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * 2, KM_NOSLEEP);
- if (sc->sc_rbuf == NULL) {
- aprint_error_dev(self, "unable to allocate ring buffer\n");
- return;
- }
+ sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * 2, KM_SLEEP);
sc->sc_rbufend = sc->sc_rbuf + (siotty_rbuf_size * 2);
sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf;
sc->sc_rbavail = siotty_rbuf_size;
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/sgimips/mace/macekbc.c
--- a/sys/arch/sgimips/mace/macekbc.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/sgimips/mace/macekbc.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: macekbc.c,v 1.8 2015/04/04 14:19:00 macallan Exp $ */
+/* $NetBSD: macekbc.c,v 1.9 2019/10/01 18:00:07 chs Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: macekbc.c,v 1.8 2015/04/04 14:19:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: macekbc.c,v 1.9 2019/10/01 18:00:07 chs Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -125,11 +125,7 @@
aprint_normal(": PS2 controller\n");
aprint_naive("\n");
- t = kmem_alloc(sizeof(struct macekbc_internal), KM_NOSLEEP);
- if (t == NULL) {
- aprint_error("%s: not enough memory\n", device_xname(self));
- return;
- }
+ t = kmem_alloc(sizeof(struct macekbc_internal), KM_SLEEP);
t->t_iot = maa->maa_st;
for (slot = 0; slot < PCKBPORT_NSLOTS; slot++)
t->t_present[slot] = 0;
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/sparc/sparc/cpu.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.254 2018/09/03 16:29:27 riastradh Exp $ */
+/* $NetBSD: cpu.c,v 1.255 2019/10/01 18:00:07 chs Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.254 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.255 2019/10/01 18:00:07 chs Exp $");
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
@@ -2095,7 +2095,7 @@
sizeof namebuf);
if (cpu_name && cpu_name[0])
sc->cpu_longname = kmem_strdupsize(cpu_name, NULL,
- KM_NOSLEEP);
+ KM_SLEEP);
}
for (mp = cpu_conf; ; mp++) {
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/sparc64/dev/ldc.c
--- a/sys/arch/sparc64/dev/ldc.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/sparc64/dev/ldc.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldc.c,v 1.4 2018/09/03 16:29:27 riastradh Exp $ */
+/* $NetBSD: ldc.c,v 1.5 2019/10/01 18:00:07 chs Exp $ */
/* $OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis
@@ -529,9 +529,7 @@
int nsegs;
#endif
- lq = kmem_zalloc(sizeof(struct ldc_queue), KM_NOSLEEP);
- if (lq == NULL)
- return NULL;
+ lq = kmem_zalloc(sizeof(struct ldc_queue), KM_SLEEP);
mutex_init(&lq->lq_mtx, MUTEX_DEFAULT, IPL_TTY);
@@ -553,9 +551,7 @@
BUS_DMA_NOWAIT) != 0)
goto unmap;
#else
- va = (vaddr_t)kmem_zalloc(size, KM_NOSLEEP);
- if (va == 0)
- goto free;
+ va = (vaddr_t)kmem_zalloc(size, KM_SLEEP);
#endif
lq->lq_va = (vaddr_t)va;
lq->lq_nentries = nentries;
@@ -567,9 +563,6 @@
bus_dmamem_free(t, &lq->lq_seg, 1);
destroy:
bus_dmamap_destroy(t, lq->lq_map);
-#else
-free:
- kmem_free(lq, sizeof(struct ldc_queue));
#endif
return (NULL);
}
diff -r 23a5ba8ed98e -r d6354ed7969e sys/arch/sparc64/dev/schizo.c
--- a/sys/arch/sparc64/dev/schizo.c Tue Oct 01 17:58:25 2019 +0000
+++ b/sys/arch/sparc64/dev/schizo.c Tue Oct 01 18:00:07 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $ */
+/* $NetBSD: schizo.c,v 1.42 2019/10/01 18:00:07 chs Exp $ */
/* $OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $ */
/*
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.42 2019/10/01 18:00:07 chs Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -180,10 +180,7 @@
SCZ_ECCCTRL_CE_INTEN;
schizo_write(sc, SCZ_ECCCTRL, eccctrl);
- pbm = kmem_zalloc(sizeof(*pbm), KM_NOSLEEP);
- if (pbm == NULL)
- panic("schizo: can't alloc schizo pbm");
-
+ pbm = kmem_zalloc(sizeof(*pbm), KM_SLEEP);
#ifdef DEBUG
sc->sc_pbm = pbm;
#endif
@@ -281,9 +278,7 @@
&_sparc_pci_chipset);
pbm->sp_pc->spc_busmax = busranges[1];
pbm->sp_pc->spc_busnode = kmem_zalloc(sizeof(*pbm->sp_pc->spc_busnode),
- KM_NOSLEEP);
- if (pbm->sp_pc->spc_busnode == NULL)
- panic("schizo: kmem_alloc busnode");
+ KM_SLEEP);
pba.pba_bus = busranges[0];
pba.pba_bridgetag = NULL;
@@ -512,10 +507,7 @@
}
/* give us a nice name.. */
- name = (char *)kmem_alloc(32, KM_NOSLEEP);
- if (name == NULL)
-
- panic("couldn't kmem_alloc iommu name");
+ name = (char *)kmem_alloc(32, KM_SLEEP);
snprintf(name, 32, "%s dvma", device_xname(sc->sc_dev));
iommu_init(name, is, tsbsize, iobase);
Home |
Main Index |
Thread Index |
Old Index