Sun Jan 3 17:42:10 2021 UTC ()
malloc(9) -> kmem(9)


(thorpej)
diff -r1.67 -r1.68 src/sys/arch/atari/atari/autoconf.c
diff -r1.16 -r1.17 src/sys/arch/atari/atari/be_bus.c
diff -r1.60 -r1.61 src/sys/arch/atari/atari/bus.c
diff -r1.27 -r1.28 src/sys/arch/atari/atari/intr.c
diff -r1.20 -r1.21 src/sys/arch/atari/atari/le_bus.c
diff -r1.183 -r1.184 src/sys/arch/atari/atari/machdep.c
diff -r1.12 -r1.13 src/sys/arch/atari/atari/mainbus.c
diff -r1.86 -r1.87 src/sys/arch/atari/dev/hdfd.c
diff -r1.79 -r1.80 src/sys/arch/atari/dev/ite.c
diff -r1.34 -r1.35 src/sys/arch/atari/dev/md_root.c
diff -r1.78 -r1.79 src/sys/arch/atari/dev/zs.c
diff -r1.58 -r1.59 src/sys/arch/atari/pci/pci_machdep.c

cvs diff -r1.67 -r1.68 src/sys/arch/atari/atari/autoconf.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/autoconf.c 2019/06/29 16:41:18 1.67
+++ src/sys/arch/atari/atari/autoconf.c 2021/01/03 17:42:10 1.68
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.67 2019/06/29 16:41:18 tsutsui Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.68 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.67 2019/06/29 16:41:18 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.68 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_md.h"
 
@@ -43,7 +43,7 @@
 #include <sys/device.h>
 #include <sys/disklabel.h>
 #include <sys/disk.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <machine/disklabel.h>
 #include <machine/cpu.h>
 #include <atari/atari/device.h>
@@ -105,8 +105,7 @@
 		md_major = devsw_name2blk("md", NULL, 0);
 		if (md_major >= 0) {
 			for (i = 0; i < RAMD_NDEV; i++) {
-				cf = malloc(sizeof(*cf), M_DEVBUF,
-				    M_ZERO|M_WAITOK);
+				cf = kmem_zalloc(sizeof(*cf), KM_SLEEP);
 				if (cf == NULL)
 					break;	/* XXX */
 				cf->cf_name = md_cd.cd_name;

cvs diff -r1.16 -r1.17 src/sys/arch/atari/atari/be_bus.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/be_bus.c 2019/11/10 21:16:25 1.16
+++ src/sys/arch/atari/atari/be_bus.c 2021/01/03 17:42:10 1.17
@@ -1,4 +1,4 @@
-/*	$NetBSD: be_bus.c,v 1.16 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: be_bus.c,v 1.17 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: be_bus.c,v 1.16 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: be_bus.c,v 1.17 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <machine/cpu.h>
 #include <sys/bus.h>
 
@@ -178,12 +178,12 @@
 
 	/*
 	 * Allow the caller to specify storage space for the tag. This
-	 * is used during console config (when malloc() can't be used).
+	 * is used during console config (when kmem_alloc() can't be used).
 	 */
 	if (storage != NULL)
 		beb_t = storage;
 	else {
-		beb_t = malloc(sizeof(*beb_t), M_TEMP, M_WAITOK);
+		beb_t = kmem_alloc(sizeof(*beb_t), KM_SLEEP);
 	}
 	memset(beb_t, 0, sizeof(*beb_t));
 	

cvs diff -r1.60 -r1.61 src/sys/arch/atari/atari/bus.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/bus.c 2018/03/10 03:44:43 1.60
+++ src/sys/arch/atari/atari/bus.c 2021/01/03 17:42:10 1.61
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus.c,v 1.60 2018/03/10 03:44:43 tsutsui Exp $	*/
+/*	$NetBSD: bus.c,v 1.61 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -33,12 +33,12 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.60 2018/03/10 03:44:43 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.61 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mbuf.h>
 #include <sys/proc.h>
 
@@ -330,6 +330,14 @@
 	return m68k_btop(addr + off);
 }
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+	KASSERT(nsegments > 0); 
+	return sizeof(struct atari_bus_dmamap) +
+	    (sizeof(bus_dma_segment_t) * (nsegments - 1));
+}
+
 /*
  * Common function for DMA map creation.  May be called by bus-specific
  * DMA map creation functions.
@@ -340,7 +348,6 @@
 {
 	struct atari_bus_dmamap *map;
 	void *mapstore;
-	size_t mapsize;
 
 	/*
 	 * Allocate and initialize the DMA map.  The end of the map
@@ -354,13 +361,10 @@
 	 * The bus_dmamap_t includes one bus_dma_segment_t, hence
 	 * the (nsegments - 1).
 	 */
-	mapsize = sizeof(struct atari_bus_dmamap) +
-	    (sizeof(bus_dma_segment_t) * (nsegments - 1));
-	if ((mapstore = malloc(mapsize, M_DMAMAP,
-	    (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+	if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+	    (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
 		return ENOMEM;
 
-	memset(mapstore, 0, mapsize);
 	map = (struct atari_bus_dmamap *)mapstore;
 	map->_dm_size = size;
 	map->_dm_segcnt = nsegments;
@@ -383,7 +387,7 @@
 _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
 {
 
-	free(map, M_DMAMAP);
+	kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
 }
 
 /*

cvs diff -r1.27 -r1.28 src/sys/arch/atari/atari/intr.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/intr.c 2019/11/10 21:16:25 1.27
+++ src/sys/arch/atari/atari/intr.c 2021/01/03 17:42:10 1.28
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.27 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: intr.c,v 1.28 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.27 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.28 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/vmmeter.h>
 #include <sys/queue.h>
 #include <sys/device.h>
@@ -112,8 +112,7 @@
 	u_long		*hard_vec;
 	int		s;
 
-	/* no point in sleeping unless someone can free memory. */
-	ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK);
+	ih = kmem_alloc(sizeof *ih, KM_SLEEP);
 	ih->ih_fun    = ih_fun;
 	ih->ih_arg    = ih_arg;
 	ih->ih_type   = type;
@@ -127,7 +126,7 @@
 	switch (type & (AUTO_VEC|USER_VEC)) {
 	case AUTO_VEC:
 		if (vector < AVEC_MIN || vector > AVEC_MAX) {
-			free(ih, M_DEVBUF);
+			kmem_free(ih, sizeof(*ih));
 			return NULL;
 		}
 		vec_list = &autovec_list[vector-1];
@@ -136,7 +135,7 @@
 		break;
 	case USER_VEC:
 		if (vector < UVEC_MIN || vector > UVEC_MAX) {
-			free(ih, M_DEVBUF);
+			kmem_free(ih, sizeof(*ih));
 			return NULL;
 		}
 		vec_list = &uservec_list[vector];
@@ -145,7 +144,7 @@
 		break;
 	default:
 		printf("%s: bogus vector type\n", __func__);
-		free(ih, M_DEVBUF);
+		kmem_free(ih, sizeof(*ih));
 		return NULL;
 	}
 
@@ -181,7 +180,7 @@
 	 */
 	cur_vec = vec_list->lh_first;
 	if (cur_vec->ih_type & FAST_VEC) {
-		free(ih, M_DEVBUF);
+		kmem_free(ih, sizeof(*ih));
 		printf("intr_establish: vector cannot be shared\n");
 		return NULL;
 	}
@@ -259,7 +258,7 @@
 		*hard_vec = (u_long)intr_glue;
 	splx(s);
 
-	free(ih, M_DEVBUF);
+	kmem_free(ih, sizeof(*ih));
 	return 1;
 }
 

cvs diff -r1.20 -r1.21 src/sys/arch/atari/atari/le_bus.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/le_bus.c 2019/11/10 21:16:25 1.20
+++ src/sys/arch/atari/atari/le_bus.c 2021/01/03 17:42:10 1.21
@@ -1,4 +1,4 @@
-/*	$NetBSD: le_bus.c,v 1.20 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: le_bus.c,v 1.21 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: le_bus.c,v 1.20 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: le_bus.c,v 1.21 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/bswap.h>
 #include <machine/cpu.h>
 #include <sys/bus.h>
@@ -262,12 +262,12 @@
 
 	/*
 	 * Allow the caller to specify storage space for the tag. This
-	 * is used during console config (when malloc() can't be used).
+	 * is used during console config (when kmem_alloc() can't be used).
 	 */
 	if (storage != NULL)
 		leb_t = storage;
 	else {
-		leb_t = malloc(sizeof(*leb_t), M_TEMP, M_WAITOK);
+		leb_t = kmem_alloc(sizeof(*leb_t), KM_SLEEP);
 	}
 	memset(leb_t, 0, sizeof(*leb_t));
 

cvs diff -r1.183 -r1.184 src/sys/arch/atari/atari/machdep.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/machdep.c 2020/06/11 19:20:43 1.183
+++ src/sys/arch/atari/atari/machdep.c 2021/01/03 17:42:10 1.184
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.183 2020/06/11 19:20:43 ad Exp $	*/
+/*	$NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.183 2020/06/11 19:20:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -57,7 +57,7 @@
 #include <sys/conf.h>
 #include <sys/file.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mbuf.h>
 #include <sys/msgbuf.h>
 #include <sys/vnode.h>
@@ -630,7 +630,7 @@
 	splx(s);
 
 	if (si == NULL) {
-		si = malloc(sizeof(*si), M_TEMP, M_NOWAIT);
+		si = kmem_intr_alloc(sizeof(*si), KM_NOSLEEP);
 #ifdef DIAGNOSTIC
 		if (si)
 			++ncbd;		/* count # dynamically allocated */

cvs diff -r1.12 -r1.13 src/sys/arch/atari/atari/mainbus.c (expand / switch to context diff)
--- src/sys/arch/atari/atari/mainbus.c 2019/11/10 21:16:25 1.12
+++ src/sys/arch/atari/atari/mainbus.c 2021/01/03 17:42:10 1.13
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.12 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.13 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.12 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.13 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <machine/cpu.h>
 #include <sys/bus.h>
 
@@ -167,8 +167,7 @@
 {
 	bus_space_tag_t	mb_t;
 
-	/* Not really M_TEMP, is it.. */
-	mb_t = malloc(sizeof(*mb_t), M_TEMP, M_WAITOK|M_ZERO);
+	mb_t = kmem_zalloc(sizeof(*mb_t), KM_SLEEP);
 	mb_t->abs_p_1   = mb_bus_space_peek_1;
 	mb_t->abs_p_2   = mb_bus_space_peek_2;
 	mb_t->abs_p_4   = mb_bus_space_peek_4;
@@ -237,8 +236,7 @@
 mb_free_bus_space_tag(bus_space_tag_t mb_t)
 {
 
-	/* Not really M_TEMP, is it.. */
-	free(mb_t, M_TEMP);
+	kmem_free(mb_t, sizeof(*mb_t));
 }
 
 static int

cvs diff -r1.86 -r1.87 src/sys/arch/atari/dev/hdfd.c (expand / switch to context diff)
--- src/sys/arch/atari/dev/hdfd.c 2019/11/10 21:16:25 1.86
+++ src/sys/arch/atari/dev/hdfd.c 2021/01/03 17:42:10 1.87
@@ -1,4 +1,4 @@
-/*	$NetBSD: hdfd.c,v 1.86 2019/11/10 21:16:25 chs Exp $	*/
+/*	$NetBSD: hdfd.c,v 1.87 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1996 Leo Weppelman
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdfd.c,v 1.86 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdfd.c,v 1.87 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -106,7 +106,7 @@
 #include <sys/disk.h>
 #include <sys/buf.h>
 #include <sys/bufq.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/uio.h>
 #include <sys/syslog.h>
 #include <sys/queue.h>
@@ -1426,8 +1426,7 @@
 			return EINVAL;
 		}
 
-		fd_formb = malloc(sizeof(struct ne7_fd_formb),
-		    M_TEMP, M_WAITOK);
+		fd_formb = kmem_alloc(sizeof(*fd_formb), KM_SLEEP);
 		fd_formb->head = form_cmd->head;
 		fd_formb->cyl = form_cmd->cylinder;
 		fd_formb->transfer_rate = fd->sc_type->rate;
@@ -1451,7 +1450,7 @@
 		}
 		
 		error = fdformat(dev, fd_formb, l->l_proc);
-		free(fd_formb, M_TEMP);
+		kmem_free(fd_formb, sizeof(*fd_formb));
 		return error;
 
 	case FDIOCGETOPTS:		/* get drive options */

cvs diff -r1.79 -r1.80 src/sys/arch/atari/dev/ite.c (expand / switch to context diff)
--- src/sys/arch/atari/dev/ite.c 2019/06/29 16:41:19 1.79
+++ src/sys/arch/atari/dev/ite.c 2021/01/03 17:42:10 1.80
@@ -1,4 +1,4 @@
-/*	$NetBSD: ite.c,v 1.79 2019/06/29 16:41:19 tsutsui Exp $	*/
+/*	$NetBSD: ite.c,v 1.80 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.79 2019/06/29 16:41:19 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.80 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -52,7 +52,7 @@
 #include <sys/kernel.h>
 #include <sys/conf.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/tty.h>
@@ -361,8 +361,8 @@
 		return;
 	if (atari_realconfig) {
 		if (sc->kbdmap && sc->kbdmap != &ascii_kbdmap)
-			free(sc->kbdmap, M_DEVBUF);
-		sc->kbdmap = malloc(sizeof(struct kbdmap), M_DEVBUF, M_WAITOK);
+			kmem_free(sc->kbdmap, sizeof(*sc->kbdmap));
+		sc->kbdmap = kmem_alloc(sizeof(*sc->kbdmap), KM_SLEEP);
 		memcpy(sc->kbdmap, &ascii_kbdmap, sizeof(struct kbdmap));
 	}
 	else
@@ -373,7 +373,7 @@
 	SUBR_INIT(sc);
 	SUBR_CURSOR(sc, DRAW_CURSOR);
 	if (sc->tabs == NULL)
-		sc->tabs = malloc(MAX_TABS * sizeof(u_char),M_DEVBUF,M_WAITOK);
+		sc->tabs = kmem_alloc(MAX_TABS * sizeof(u_char), KM_SLEEP);
 	ite_reset(sc);
 	sc->flags |= ITE_INITED;
 }

cvs diff -r1.34 -r1.35 src/sys/arch/atari/dev/md_root.c (expand / switch to context diff)
--- src/sys/arch/atari/dev/md_root.c 2018/09/03 16:29:24 1.34
+++ src/sys/arch/atari/dev/md_root.c 2021/01/03 17:42:10 1.35
@@ -1,4 +1,4 @@
-/*	$NetBSD: md_root.c,v 1.34 2018/09/03 16:29:24 riastradh Exp $	*/
+/*	$NetBSD: md_root.c,v 1.35 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1996 Leo Weppelman.
@@ -26,12 +26,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md_root.c,v 1.34 2018/09/03 16:29:24 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md_root.c,v 1.35 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/buf.h>
 #include <sys/proc.h>
 #include <sys/device.h>
@@ -129,13 +129,13 @@
 	ri = &rd_info[unit];
 	if (md->md_type != MD_UNCONFIGURED)
 		return;	/* Only configure once */
-	md->md_addr = malloc(ri->ramd_size, M_DEVBUF, M_WAITOK);
+	md->md_addr = kmem_alloc(ri->ramd_size, KM_SLEEP);
 	md->md_size = ri->ramd_size;
 	if (md->md_addr == NULL)
 		return;
 	if (ri->ramd_flag & RAMD_LOAD) {
 		if (loaddisk(md, ri->ramd_dev, curlwp)) {
-			free(md->md_addr, M_DEVBUF);
+			kmem_free(md->md_addr, ri->ramd_size);
 			md->md_addr = NULL;
 			return;
 		}

cvs diff -r1.78 -r1.79 src/sys/arch/atari/dev/zs.c (expand / switch to context diff)
--- src/sys/arch/atari/dev/zs.c 2018/02/08 09:05:17 1.78
+++ src/sys/arch/atari/dev/zs.c 2021/01/03 17:42:10 1.79
@@ -1,4 +1,4 @@
-/*	$NetBSD: zs.c,v 1.78 2018/02/08 09:05:17 dholland Exp $	*/
+/*	$NetBSD: zs.c,v 1.79 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.78 2018/02/08 09:05:17 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.79 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -88,7 +88,7 @@
 #include <sys/conf.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/tty.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
@@ -409,8 +409,8 @@
 		ym2149_ser2(1);
 
 	if (cs->cs_rbuf == NULL) {
-		cs->cs_rbuf = malloc(ZLRB_RING_SIZE * sizeof(int), M_DEVBUF,
-		    M_WAITOK);
+		cs->cs_rbuf = kmem_alloc(ZLRB_RING_SIZE * sizeof(int),
+		    KM_SLEEP);
 	}
 
 	tp = cs->cs_ttyp;

cvs diff -r1.58 -r1.59 src/sys/arch/atari/pci/pci_machdep.c (expand / switch to context diff)
--- src/sys/arch/atari/pci/pci_machdep.c 2019/05/04 08:30:06 1.58
+++ src/sys/arch/atari/pci/pci_machdep.c 2021/01/03 17:42:10 1.59
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.58 2019/05/04 08:30:06 tsutsui Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.59 2021/01/03 17:42:10 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.58 2019/05/04 08:30:06 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.59 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_mbtype.h"
 
@@ -42,7 +42,7 @@
 #include <sys/systm.h>
 #include <sys/errno.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #define _ATARI_BUS_DMA_PRIVATE
 #include <sys/bus.h>
@@ -367,9 +367,8 @@
 		case PCI_CLASS_DISPLAY:
 			if (csr & (PCI_COMMAND_MEM_ENABLE |
 			    PCI_COMMAND_MASTER_ENABLE)) {
-				p = malloc(sizeof(struct pci_memreg),
-				    M_TEMP, M_WAITOK);
-				memset(p, 0, sizeof(struct pci_memreg));
+				p = kmem_zalloc(sizeof(struct pci_memreg),
+				    KM_SLEEP);
 				p->dev = dev;
 				p->csr = csr;
 				p->tag = tag;
@@ -392,9 +391,8 @@
 			if (mask == 0)
 				continue; /* Register unused */
 
-			p = malloc(sizeof(struct pci_memreg),
-			    M_TEMP, M_WAITOK);
-			memset(p, 0, sizeof(struct pci_memreg));
+			p = kmem_zalloc(sizeof(struct pci_memreg),
+			    KM_SLEEP);
 			p->dev = dev;
 			p->csr = csr;
 			p->tag = tag;
@@ -636,14 +634,14 @@
 	while (p != NULL) {
 		q = p;
 		LIST_REMOVE(q, link);
-		free(p, M_WAITOK);
+		kmem_free(p, sizeof(*p));
 		p = LIST_FIRST(&iolist);
 	}
 	p = LIST_FIRST(&memlist);
 	while (p != NULL) {
 		q = p;
 		LIST_REMOVE(q, link);
-		free(p, M_WAITOK);
+		kmem_free(p, sizeof(*p));
 		p = LIST_FIRST(&memlist);
 	}
 }