Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/vax malloc(9) -> kmem(9)



details:   https://anonhg.NetBSD.org/src/rev/dbb77ce5eab0
branches:  trunk
changeset: 946262:dbb77ce5eab0
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Nov 21 22:37:11 2020 +0000

description:
malloc(9) -> kmem(9)

diffstat:

 sys/arch/vax/uba/qv.c       |  10 +++++-----
 sys/arch/vax/uba/qvkbd.c    |   7 +++----
 sys/arch/vax/vax/bus_dma.c  |  25 +++++++++++++++----------
 sys/arch/vax/vax/multicpu.c |  12 ++++++------
 sys/arch/vax/vsa/lcg.c      |   8 ++++----
 sys/arch/vax/vsa/smg.c      |   8 ++++----
 sys/arch/vax/vsa/spx.c      |  10 +++++-----
 7 files changed, 42 insertions(+), 38 deletions(-)

diffs (truncated from 319 to 300 lines):

diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/uba/qv.c
--- a/sys/arch/vax/uba/qv.c     Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/uba/qv.c     Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #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 @@
         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 @@
 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));
 }
 
 /*
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/uba/qvkbd.c
--- a/sys/arch/vax/uba/qvkbd.c  Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/uba/qvkbd.c  Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #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 @@
        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;
        }
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/vax/bus_dma.c
--- a/sys/arch/vax/vax/bus_dma.c        Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/vax/bus_dma.c        Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #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_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 @@
 {
        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 @@
         * 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 @@
        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));
 }
 
 /*
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/vax/multicpu.c
--- a/sys/arch/vax/vax/multicpu.c       Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/vax/multicpu.c       Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
        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 @@
 
        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 @@
        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);
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/vsa/lcg.c
--- a/sys/arch/vax/vsa/lcg.c    Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/vsa/lcg.c    Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #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 @@
        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;
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/vsa/smg.c
--- a/sys/arch/vax/vsa/smg.c    Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/vsa/smg.c    Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #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 @@
 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;
 }
diff -r f22d75f21d45 -r dbb77ce5eab0 sys/arch/vax/vsa/spx.c
--- a/sys/arch/vax/vsa/spx.c    Sat Nov 21 22:00:34 2020 +0000
+++ b/sys/arch/vax/vsa/spx.c    Sat Nov 21 22:37:11 2020 +0000
@@ -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 @@
 #include <sys/conf.h>
 #include <sys/cpu.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/time.h>
 



Home | Main Index | Thread Index | Old Index