Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/91efebe97201
branches:  trunk
changeset: 957988:91efebe97201
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Dec 19 21:38:30 2020 +0000

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

diffstat:

 sys/arch/luna68k/luna68k/isr.c |   8 ++++----
 sys/arch/m68k/m68k/bus_dma.c   |  24 ++++++++++++++----------
 2 files changed, 18 insertions(+), 14 deletions(-)

diffs (109 lines):

diff -r 997e060042de -r 91efebe97201 sys/arch/luna68k/luna68k/isr.c
--- a/sys/arch/luna68k/luna68k/isr.c    Sat Dec 19 21:27:52 2020 +0000
+++ b/sys/arch/luna68k/luna68k/isr.c    Sat Dec 19 21:38:30 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isr.c,v 1.23 2019/11/10 21:16:29 chs Exp $     */
+/*     $NetBSD: isr.c,v 1.24 2020/12/19 21:38:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.23 2019/11/10 21:16:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.24 2020/12/19 21:38:30 thorpej Exp $");
 
 /*
  * Link and dispatch interrupts.
@@ -39,7 +39,7 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/vmmeter.h>
 #include <sys/cpu.h>
 
@@ -82,7 +82,7 @@
        if ((ipl < 0) || (ipl >= NISRAUTOVEC))
                panic("isrlink_autovec: bad ipl %d", ipl);
 
-       newisr = malloc(sizeof(struct isr_autovec), M_DEVBUF, M_WAITOK);
+       newisr = kmem_alloc(sizeof(*newisr), KM_SLEEP);
        newisr->isr_func = func;
        newisr->isr_arg = arg;
        newisr->isr_ipl = ipl;
diff -r 997e060042de -r 91efebe97201 sys/arch/m68k/m68k/bus_dma.c
--- a/sys/arch/m68k/m68k/bus_dma.c      Sat Dec 19 21:27:52 2020 +0000
+++ b/sys/arch/m68k/m68k/bus_dma.c      Sat Dec 19 21:38:30 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $ */
+/* $NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 thorpej Exp $ */
 
 /*
  * This file was taken from from alpha/common/bus_dma.c
@@ -41,13 +41,13 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.35 2013/10/25 09:46:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.36 2020/12/19 21:39:24 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/mbuf.h>
 
@@ -63,6 +63,14 @@
            bus_dmamap_t, void *, bus_size_t, struct vmspace *, int,
            paddr_t *, int *, int);
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+       KASSERT(nsegments > 0);
+       return sizeof(struct m68k_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.
@@ -73,7 +81,6 @@
 {
        struct m68k_bus_dmamap *map;
        void *mapstore;
-       size_t mapsize;
 
        /*
         * Allocate and initialize the DMA map.  The end of the map
@@ -87,13 +94,10 @@
         * The bus_dmamap_t includes one bus_dma_segment_t, hence
         * the (nsegments - 1).
         */
-       mapsize = sizeof(struct m68k_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 m68k_bus_dmamap *)mapstore;
        map->_dm_size = size;
        map->_dm_segcnt = nsegments;
@@ -119,7 +123,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));
 }
 
 /*



Home | Main Index | Thread Index | Old Index