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/e3bda4bd8c25
branches:  trunk
changeset: 946228:e3bda4bd8c25
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Nov 21 17:48:26 2020 +0000

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

diffstat:

 sys/arch/mvmeppc/mvmeppc/mainbus.c |  12 +++++-------
 sys/arch/news68k/news68k/isr.c     |   8 ++++----
 sys/arch/newsmips/apbus/apbus.c    |  10 +++++-----
 sys/arch/newsmips/apbus/xafb.c     |   9 ++++-----
 sys/arch/newsmips/dev/fb.c         |   9 ++++-----
 sys/arch/newsmips/dev/hb.c         |   8 ++++----
 sys/arch/newsmips/newsmips/bus.c   |  23 ++++++++++++++---------
 sys/arch/next68k/dev/if_xe.c       |   7 ++++---
 sys/arch/next68k/dev/nextdisplay.c |  10 +++++-----
 sys/arch/next68k/dev/nextkbd.c     |  11 +++++------
 sys/arch/next68k/next68k/isr.c     |   8 ++++----
 sys/arch/ofppc/pci/gt_mainbus.c    |  10 +++++-----
 sys/arch/ofppc/pci/ofwpci.c        |   9 ++++-----
 13 files changed, 67 insertions(+), 67 deletions(-)

diffs (truncated from 500 to 300 lines):

diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/mvmeppc/mvmeppc/mainbus.c
--- a/sys/arch/mvmeppc/mvmeppc/mainbus.c        Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/mvmeppc/mvmeppc/mainbus.c        Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.19 2020/07/07 03:38:47 thorpej Exp $     */
+/*     $NetBSD: mainbus.c,v 1.20 2020/11/21 17:57:40 thorpej Exp $     */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,12 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2020/07/07 03:38:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.20 2020/11/21 17:57:40 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/autoconf.h>
 #include <sys/bus.h>
@@ -107,12 +107,10 @@
         * XXX that's not currently possible.
         */
 #if NPCI > 0
-       genppc_pct = malloc(sizeof(struct genppc_pci_chipset), M_DEVBUF,
-           M_WAITOK);
+       genppc_pct = kmem_alloc(sizeof(struct genppc_pci_chipset), KM_SLEEP);
        mvmeppc_pci_get_chipset_tag(genppc_pct);
 
-       pbi = malloc(sizeof(struct genppc_pci_chipset_businfo),
-           M_DEVBUF, M_WAITOK);
+       pbi = kmem_alloc(sizeof(struct genppc_pci_chipset_businfo), KM_SLEEP);
        pbi->pbi_properties = prop_dictionary_create();
        KASSERT(pbi->pbi_properties != NULL);
 
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/news68k/news68k/isr.c
--- a/sys/arch/news68k/news68k/isr.c    Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/news68k/news68k/isr.c    Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isr.c,v 1.22 2019/11/10 21:16:30 chs Exp $     */
+/*     $NetBSD: isr.c,v 1.23 2020/11/21 17:55:38 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -39,11 +39,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.22 2019/11/10 21:16:30 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isr.c,v 1.23 2020/11/21 17:55:38 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/cpu.h>
 #include <sys/intr.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 b347d09de085 -r e3bda4bd8c25 sys/arch/newsmips/apbus/apbus.c
--- a/sys/arch/newsmips/apbus/apbus.c   Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/newsmips/apbus/apbus.c   Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apbus.c,v 1.26 2019/11/10 21:16:31 chs Exp $   */
+/*     $NetBSD: apbus.c,v 1.27 2020/11/21 17:54:47 thorpej Exp $       */
 
 /*-
  * Copyright (C) 1999 SHIMIZU Ryo.  All rights reserved.
@@ -27,13 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.26 2019/11/10 21:16:31 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.27 2020/11/21 17:54:47 thorpej Exp $");
 
 #define __INTR_PRIVATE
 
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/proc.h>
 #include <sys/intr.h>
@@ -230,7 +230,7 @@
 
        ip = &apintr_tab[level];
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
        ih->ih_mask = mask;
        ih->ih_priority = priority;
        ih->ih_func = func;
@@ -501,7 +501,7 @@
 {
        struct newsmips_bus_dma_tag *dmat;
 
-       dmat = malloc(sizeof(*dmat), M_DEVBUF, M_WAITOK);
+       dmat = kmem_alloc(sizeof(*dmat), KM_SLEEP);
        memcpy(dmat, &apbus_dma_tag, sizeof(*dmat));
        dmat->_slotno = apa->apa_slotno;
        dmat->_slotbaset = 0;
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/newsmips/apbus/xafb.c
--- a/sys/arch/newsmips/apbus/xafb.c    Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/newsmips/apbus/xafb.c    Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xafb.c,v 1.18 2016/07/21 19:49:58 christos Exp $       */
+/*     $NetBSD: xafb.c,v 1.19 2020/11/21 17:54:47 thorpej Exp $        */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -29,13 +29,13 @@
 /* "xa" frame buffer driver.  Currently supports 1280x1024x8 only. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xafb.c,v 1.18 2016/07/21 19:49:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xafb.c,v 1.19 2020/11/21 17:54:47 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 
 #include <uvm/uvm_extern.h>
@@ -157,8 +157,7 @@
                ri->ri_flg &= ~RI_NO_AUTO;
                sc->sc_nscreens = 1;
        } else {
-               dc = malloc(sizeof(struct xafb_devconfig), M_DEVBUF,
-                   M_WAITOK|M_ZERO);
+               dc = kmem_zalloc(sizeof(struct xafb_devconfig), KM_SLEEP);
                dc->dc_fbpaddr = (paddr_t)0x10000000;
                dc->dc_fbbase = (void *)MIPS_PHYS_TO_KSEG1(dc->dc_fbpaddr);
                dc->dc_reg = (void *)(apa->apa_hwbase + 0x3000);
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/newsmips/dev/fb.c
--- a/sys/arch/newsmips/dev/fb.c        Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/newsmips/dev/fb.c        Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fb.c,v 1.26 2014/01/31 15:43:06 tsutsui Exp $  */
+/*     $NetBSD: fb.c,v 1.27 2020/11/21 17:54:47 thorpej Exp $  */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,12 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fb.c,v 1.26 2014/01/31 15:43:06 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fb.c,v 1.27 2020/11/21 17:54:47 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/systm.h>
 
 #include <uvm/uvm_extern.h>
@@ -146,8 +146,7 @@
                ri->ri_flg &= ~RI_NO_AUTO;
                sc->sc_nscreens = 1;
        } else {
-               dc = malloc(sizeof(struct fb_devconfig), M_DEVBUF,
-                   M_WAITOK|M_ZERO);
+               dc = kmem_zalloc(sizeof(struct fb_devconfig), KM_SLEEP);
 
                dc->dc_fbbase = NWB253_VRAM;
                fb_common_init(dc);
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/newsmips/dev/hb.c
--- a/sys/arch/newsmips/dev/hb.c        Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/newsmips/dev/hb.c        Sat Nov 21 17:48:26 2020 +0000
@@ -1,13 +1,13 @@
-/*     $NetBSD: hb.c,v 1.20 2019/11/10 21:16:31 chs Exp $      */
+/*     $NetBSD: hb.c,v 1.21 2020/11/21 17:54:47 thorpej Exp $  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hb.c,v 1.20 2019/11/10 21:16:31 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hb.c,v 1.21 2020/11/21 17:54:47 thorpej Exp $");
 
 #define __INTR_PRIVATE
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/intr.h>
 
 #include <machine/autoconf.h>
@@ -99,7 +99,7 @@
 
        ip = &hbintr_tab[level];
 
-       ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
        ih->ih_func = func;
        ih->ih_arg = arg;
        ih->ih_level = level;
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/newsmips/newsmips/bus.c
--- a/sys/arch/newsmips/newsmips/bus.c  Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/newsmips/newsmips/bus.c  Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.c,v 1.33 2015/06/11 08:22:09 matt Exp $    */
+/*     $NetBSD: bus.c,v 1.34 2020/11/21 17:54:48 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,13 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.33 2015/06/11 08:22:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.34 2020/11/21 17:54:48 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>
 
@@ -132,6 +132,14 @@
        return 0;
 }
 
+static size_t 
+_bus_dmamap_mapsize(int const nsegments)
+{ 
+       KASSERT(nsegments > 0); 
+       return sizeof(struct newsmips_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.
@@ -142,7 +150,6 @@
 {
        struct newsmips_bus_dmamap *map;
        void *mapstore;
-       size_t mapsize;
 
        /*
         * Allocate and initialize the DMA map.  The end of the map
@@ -156,10 +163,8 @@
         * The bus_dmamap_t includes one bus_dma_segment_t, hence
         * the (nsegments - 1).
         */
-       mapsize = sizeof(struct newsmips_bus_dmamap) +
-           (sizeof(bus_dma_segment_t) * (nsegments - 1));
-       if ((mapstore = malloc(mapsize, M_DMAMAP,
-           ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)|M_ZERO)) == NULL)
+       if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+           (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
                return ENOMEM;
 
        map = (struct newsmips_bus_dmamap *)mapstore;
@@ -185,7 +190,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));
 }
 
 extern paddr_t kvtophys(vaddr_t);              /* XXX */
diff -r b347d09de085 -r e3bda4bd8c25 sys/arch/next68k/dev/if_xe.c
--- a/sys/arch/next68k/dev/if_xe.c      Sat Nov 21 17:46:08 2020 +0000
+++ b/sys/arch/next68k/dev/if_xe.c      Sat Nov 21 17:48:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_xe.c,v 1.26 2019/11/10 21:16:31 chs Exp $   */
+/*     $NetBSD: if_xe.c,v 1.27 2020/11/21 17:49:20 thorpej Exp $       */
 /*
  * Copyright (c) 1998 Darrin B. Jewell
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xe.c,v 1.26 2019/11/10 21:16:31 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xe.c,v 1.27 2020/11/21 17:49:20 thorpej Exp $");
 
 #include "opt_inet.h"
 



Home | Main Index | Thread Index | Old Index