Module Name: src
Committed By: thorpej
Date: Sat Nov 21 22:37:11 UTC 2020
Modified Files:
src/sys/arch/vax/uba: qv.c qvkbd.c
src/sys/arch/vax/vax: bus_dma.c multicpu.c
src/sys/arch/vax/vsa: lcg.c smg.c spx.c
Log Message:
malloc(9) -> kmem(9)
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/vax/uba/qv.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/vax/uba/qvkbd.c
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/vax/vax/bus_dma.c \
src/sys/arch/vax/vax/multicpu.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/vax/vsa/lcg.c
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/vax/vsa/smg.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/vax/vsa/spx.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/vax/uba/qv.c
diff -u src/sys/arch/vax/uba/qv.c:1.35 src/sys/arch/vax/uba/qv.c:1.36
--- src/sys/arch/vax/uba/qv.c:1.35 Sun Jun 14 01:40:06 2020
+++ src/sys/arch/vax/uba/qv.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: qv.c,v 1.35 2020/06/14 01:40:06 chs Exp $ */
+/* $NetBSD: qv.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $ */
/*
* Copyright (c) 2015 Charles H. Dickman. All rights reserved.
* Derived from smg.c
@@ -31,7 +31,7 @@
/*3456789012345678901234567890123456789012345678901234567890123456789012345678*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: qv.c,v 1.35 2020/06/14 01:40:06 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: qv.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: qv.c,v 1.35
#include <sys/cpu.h>
#include <sys/device.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/extent.h> /***/
#include <sys/time.h>
#include <sys/bus.h>
@@ -900,7 +900,7 @@ qv_alloc_screen(void *v, const struct ws
struct qv_softc *sc = device_private(v);
struct qv_screen *ss;
- ss = malloc(sizeof(struct qv_screen), M_DEVBUF, M_WAITOK|M_ZERO);
+ ss = kmem_zalloc(sizeof(struct qv_screen), KM_SLEEP);
ss->ss_sc = sc;
ss->ss_type = type;
*cookiep = ss;
@@ -916,7 +916,7 @@ void
qv_free_screen(void *v, void *cookie)
{
printf("qv_free_screen: %p\n", cookie);
- free(cookie, M_DEVBUF);
+ kmem_free(cookie, sizeof(struct qv_screen));
}
/*
Index: src/sys/arch/vax/uba/qvkbd.c
diff -u src/sys/arch/vax/uba/qvkbd.c:1.2 src/sys/arch/vax/uba/qvkbd.c:1.3
--- src/sys/arch/vax/uba/qvkbd.c:1.2 Sun Nov 10 21:16:33 2019
+++ src/sys/arch/vax/uba/qvkbd.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: qvkbd.c,v 1.2 2019/11/10 21:16:33 chs Exp $ */
+/* $NetBSD: qvkbd.c,v 1.3 2020/11/21 22:37:11 thorpej Exp $ */
/* Copyright (c) 2015 Charles H. Dickman. All rights reserved.
* Derived from dzkbd.c
@@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$$");
#include <sys/device.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/intr.h>
#include <dev/wscons/wsconsio.h>
@@ -171,8 +171,7 @@ qvkbd_attach(device_t parent, device_t s
if (isconsole) {
qvi = &qvkbd_console_internal;
} else {
- qvi = malloc(sizeof(struct qvkbd_internal),
- M_DEVBUF, M_WAITOK);
+ qvi = kmem_alloc(sizeof(struct qvkbd_internal), KM_SLEEP);
qvi->qvi_ks.attmt.sendchar = qvkbd_sendchar;
qvi->qvi_ks.attmt.cookie = ls;
}
Index: src/sys/arch/vax/vax/bus_dma.c
diff -u src/sys/arch/vax/vax/bus_dma.c:1.35 src/sys/arch/vax/vax/bus_dma.c:1.36
--- src/sys/arch/vax/vax/bus_dma.c:1.35 Fri Apr 27 07:53:07 2018
+++ src/sys/arch/vax/vax/bus_dma.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.35 2018/04/27 07:53:07 maxv Exp $ */
+/* $NetBSD: bus_dma.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.35 2018/04/27 07:53:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v
#include <sys/reboot.h>
#include <sys/conf.h>
#include <sys/file.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/vnode.h>
#include <sys/device.h>
@@ -66,6 +66,15 @@ int _bus_dmamap_load_buffer(bus_dma_tag_
int _bus_dma_inrange(bus_dma_segment_t *, int, bus_addr_t);
int _bus_dmamem_alloc_range(bus_dma_tag_t, bus_size_t, bus_size_t,
bus_size_t, bus_dma_segment_t*, int, int *, int, vaddr_t, vaddr_t);
+
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+ KASSERT(nsegments > 0);
+ return sizeof(struct vax_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.
@@ -77,7 +86,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
{
struct vax_bus_dmamap *map;
void *mapstore;
- size_t mapsize;
#ifdef DEBUG_DMA
printf("dmamap_create: t=%p size=%lx nseg=%x msegsz=%lx boundary=%lx flags=%x\n",
@@ -96,13 +104,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
* The bus_dmamap_t includes one bus_dma_segment_t, hence
* the (nsegments - 1).
*/
- mapsize = sizeof(struct vax_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 vax_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
@@ -135,7 +140,7 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus
if (map->dm_nsegs > 0)
printf("bus_dmamap_destroy() called for map with valid mappings\n");
#endif /* DIAGNOSTIC */
- free(map, M_DEVBUF);
+ kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
}
/*
Index: src/sys/arch/vax/vax/multicpu.c
diff -u src/sys/arch/vax/vax/multicpu.c:1.35 src/sys/arch/vax/vax/multicpu.c:1.36
--- src/sys/arch/vax/vax/multicpu.c:1.35 Sun Nov 10 21:16:33 2019
+++ src/sys/arch/vax/vax/multicpu.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: multicpu.c,v 1.35 2019/11/10 21:16:33 chs Exp $ */
+/* $NetBSD: multicpu.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $ */
/*
* Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
@@ -29,14 +29,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: multicpu.c,v 1.35 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multicpu.c,v 1.36 2020/11/21 22:37:11 thorpej Exp $");
#include "opt_multiprocessor.h"
#include <sys/param.h>
#include <sys/cpu.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/proc.h>
#include <sys/xcall.h>
#include <sys/ipi.h>
@@ -68,7 +68,7 @@ cpu_boot_secondary_processors(void)
while ((q = SIMPLEQ_FIRST(&cpuq))) {
SIMPLEQ_REMOVE_HEAD(&cpuq, cq_q);
(*mp_dep_call->cpu_startslave)(q->cq_ci);
- free(q, M_TEMP);
+ kmem_free(q, sizeof(*q));
}
}
@@ -86,7 +86,7 @@ cpu_slavesetup(device_t self, int slotid
KASSERT(device_private(self) == NULL);
- ci = malloc(sizeof(*ci), M_DEVBUF, M_ZERO|M_WAITOK);
+ ci = kmem_zalloc(sizeof(*ci), KM_SLEEP);
self->dv_private = ci;
ci->ci_dev = self;
ci->ci_slotid = slotid;
@@ -104,7 +104,7 @@ cpu_slavesetup(device_t self, int slotid
ci->ci_istack = istackbase + PAGE_SIZE;
SIMPLEQ_INSERT_TAIL(&cpus, ci, ci_next);
- cq = malloc(sizeof(*cq), M_TEMP, M_WAITOK|M_ZERO);
+ cq = kmem_zalloc(sizeof(*cq), KM_SLEEP);
cq->cq_ci = ci;
cq->cq_dev = ci->ci_dev;
SIMPLEQ_INSERT_TAIL(&cpuq, cq, cq_q);
Index: src/sys/arch/vax/vsa/lcg.c
diff -u src/sys/arch/vax/vsa/lcg.c:1.4 src/sys/arch/vax/vsa/lcg.c:1.5
--- src/sys/arch/vax/vsa/lcg.c:1.4 Wed Jun 6 01:49:08 2018
+++ src/sys/arch/vax/vsa/lcg.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lcg.c,v 1.4 2018/06/06 01:49:08 maya Exp $ */
+/* $NetBSD: lcg.c,v 1.5 2020/11/21 22:37:11 thorpej Exp $ */
/*
* LCG accelerated framebuffer driver
* Copyright (c) 2003, 2004 Blaz Antonic
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.4 2018/06/06 01:49:08 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.5 2020/11/21 22:37:11 thorpej Exp $");
#define LCG_NO_ACCEL
@@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: lcg.c,v 1.4
#include <sys/systm.h>
#include <sys/callout.h>
#include <sys/time.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/systm.h>
@@ -789,7 +789,7 @@ lcg_alloc_screen(void *v, const struct w
int i;
struct lcg_screen *ss;
- *cookiep = malloc(sizeof(struct lcg_screen), M_DEVBUF, M_WAITOK);
+ *cookiep = kmem_alloc(sizeof(struct lcg_screen), KM_SLEEP);
bzero(*cookiep, sizeof(struct lcg_screen));
*curxp = *curyp = 0;
*defattrp = (LCG_BG_COLOR << 4) | LCG_FG_COLOR;
Index: src/sys/arch/vax/vsa/smg.c
diff -u src/sys/arch/vax/vsa/smg.c:1.58 src/sys/arch/vax/vsa/smg.c:1.59
--- src/sys/arch/vax/vsa/smg.c:1.58 Thu Mar 14 23:49:38 2019
+++ src/sys/arch/vax/vsa/smg.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: smg.c,v 1.58 2019/03/14 23:49:38 thorpej Exp $ */
+/* $NetBSD: smg.c,v 1.59 2020/11/21 22:37:11 thorpej Exp $ */
/*
* Copyright (c) 1998 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smg.c,v 1.58 2019/03/14 23:49:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smg.c,v 1.59 2020/11/21 22:37:11 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -34,7 +34,7 @@ __KERNEL_RCSID(0, "$NetBSD: smg.c,v 1.58
#include <sys/cpu.h>
#include <sys/device.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/time.h>
#include <machine/vsbus.h>
@@ -532,7 +532,7 @@ int
smg_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
int *curxp, int *curyp, long *defattrp)
{
- *cookiep = malloc(sizeof(struct smg_screen), M_DEVBUF, M_WAITOK|M_ZERO);
+ *cookiep = kmem_zalloc(sizeof(struct smg_screen), KM_SLEEP);
*curxp = *curyp = *defattrp = 0;
return 0;
}
Index: src/sys/arch/vax/vsa/spx.c
diff -u src/sys/arch/vax/vsa/spx.c:1.9 src/sys/arch/vax/vsa/spx.c:1.10
--- src/sys/arch/vax/vsa/spx.c:1.9 Thu Jul 7 06:55:39 2016
+++ src/sys/arch/vax/vsa/spx.c Sat Nov 21 22:37:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: spx.c,v 1.9 2016/07/07 06:55:39 msaitoh Exp $ */
+/* $NetBSD: spx.c,v 1.10 2020/11/21 22:37:11 thorpej Exp $ */
/*
* SPX/LCSPX/SPXg/SPXgt accelerated framebuffer driver for NetBSD/VAX
* Copyright (c) 2005 Blaz Antonic
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spx.c,v 1.9 2016/07/07 06:55:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spx.c,v 1.10 2020/11/21 22:37:11 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: spx.c,v 1.9
#include <sys/conf.h>
#include <sys/cpu.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/time.h>
#include <machine/vsbus.h>
@@ -1055,7 +1055,7 @@ spx_alloc_screen(void *v, const struct w
int i;
struct spx_screen *ss;
- ss = malloc(sizeof(struct spx_screen), M_DEVBUF, M_WAITOK | M_ZERO);
+ ss = kmem_zalloc(sizeof(struct spx_screen), KM_SLEEP);
*cookiep = ss;
*curxp = *curyp = 0;
@@ -1070,7 +1070,7 @@ spx_alloc_screen(void *v, const struct w
static void
spx_free_screen(void *v, void *cookie)
{
-/* FIXME add something to actually free malloc()ed screen? */
+/* FIXME add something to actually free kmem_zalloc()ed screen? */
}
static int