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

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

diffstat:

 sys/arch/hpcarm/dev/wzero3_kbd.c   |  12 +++++-------
 sys/arch/hpcarm/hpcarm/softintr.c  |  13 +++++++------
 sys/arch/hpcmips/dev/plum.c        |   9 ++++-----
 sys/arch/hpcmips/dev/plumiobus.c   |   8 ++++----
 sys/arch/hpcmips/dev/plumohci.c    |   9 +++++----
 sys/arch/hpcmips/dev/ucbsnd.c      |  15 +++++++--------
 sys/arch/hpcmips/hpcmips/bus_dma.c |  29 ++++++++++++++++++-----------
 sys/arch/hpcmips/tx/tx39icu.c      |  18 +++++++++---------
 sys/arch/hpcmips/tx/txcom.c        |  20 ++++++--------------
 sys/arch/hpcmips/vr/flash_vrip.c   |   8 ++++----
 sys/arch/hpcmips/vr/vr4181giu.c    |   8 ++++----
 sys/arch/hpcmips/vr/vrc4172gpio.c  |  10 +++++-----
 sys/arch/hpcmips/vr/vrgiu.c        |  10 +++++-----
 13 files changed, 83 insertions(+), 86 deletions(-)

diffs (truncated from 625 to 300 lines):

diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcarm/dev/wzero3_kbd.c
--- a/sys/arch/hpcarm/dev/wzero3_kbd.c  Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcarm/dev/wzero3_kbd.c  Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wzero3_kbd.c,v 1.9 2019/11/10 21:16:27 chs Exp $       */
+/*     $NetBSD: wzero3_kbd.c,v 1.10 2020/11/21 21:25:33 thorpej Exp $  */
 
 /*-
  * Copyright (C) 2008, 2009, 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,13 +26,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wzero3_kbd.c,v 1.9 2019/11/10 21:16:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wzero3_kbd.c,v 1.10 2020/11/21 21:25:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/callout.h>
 #include <sys/bus.h>
 
@@ -288,10 +288,8 @@
                return;
        }
 
-       sc->sc_okeystat = malloc(sc->sc_nrow * sc->sc_ncolumn, M_DEVBUF,
-           M_WAITOK | M_ZERO);
-       sc->sc_keystat = malloc(sc->sc_nrow * sc->sc_ncolumn, M_DEVBUF,
-           M_WAITOK | M_ZERO);
+       sc->sc_okeystat = kmem_zalloc(sc->sc_nrow * sc->sc_ncolumn, KM_SLEEP);
+       sc->sc_keystat = kmem_zalloc(sc->sc_nrow * sc->sc_ncolumn, KM_SLEEP);
 
        sc->sc_if.hii_ctx = sc;
        sc->sc_if.hii_establish = wzero3kbd_input_establish;
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcarm/hpcarm/softintr.c
--- a/sys/arch/hpcarm/hpcarm/softintr.c Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcarm/hpcarm/softintr.c Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: softintr.c,v 1.16 2019/11/10 21:16:27 chs Exp $        */
+/*     $NetBSD: softintr.c,v 1.17 2020/11/21 21:25:33 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: softintr.c,v 1.16 2019/11/10 21:16:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: softintr.c,v 1.17 2020/11/21 21:25:33 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/syslog.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/cpu.h>
 #include <arm/cpufunc.h>
@@ -63,7 +63,7 @@
 {
        struct softintr_handler *sh;
 
-       sh = malloc(sizeof(*sh), M_DEVBUF, M_WAITOK);
+       sh = kmem_alloc(sizeof(*sh), KM_SLEEP);
        sh->sh_fun = fun;
        sh->sh_level = ipl_to_spl(level);
        sh->sh_arg = arg;
@@ -85,15 +85,16 @@
                SetCPSR(I32_bit, I32_bit & saved_cpsr);
        } else {
                SetCPSR(I32_bit, I32_bit & saved_cpsr);
-               free(sh, M_DEVBUF);
+               kmem_free(sh, sizeof(*sh));
        }
 }
 
 void
 softintr_free(void *arg)
 {
+       struct softintr_handler *sh = arg;
 
-       free(arg, M_DEVBUF);
+       free(sh, sizeof(*sh));
 }
 
 void
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcmips/dev/plum.c
--- a/sys/arch/hpcmips/dev/plum.c       Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcmips/dev/plum.c       Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plum.c,v 1.17 2019/11/10 21:16:28 chs Exp $ */
+/*     $NetBSD: plum.c,v 1.18 2020/11/21 21:23:48 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plum.c,v 1.17 2019/11/10 21:16:28 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plum.c,v 1.18 2020/11/21 21:23:48 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/bus.h>
 #include <machine/intr.h>
@@ -103,8 +103,7 @@
                printf(": Plum2 #2\n");
                break;
        }
-       sc->sc_pc = malloc(sizeof(struct plum_chipset_tag),
-           M_DEVBUF, M_WAITOK | M_ZERO);
+       sc->sc_pc = kmem_zalloc(sizeof(struct plum_chipset_tag), KM_SLEEP);
        sc->sc_pc->pc_tc = ca->ca_tc;
        
        /* Attach Plum devices */
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcmips/dev/plumiobus.c
--- a/sys/arch/hpcmips/dev/plumiobus.c  Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcmips/dev/plumiobus.c  Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plumiobus.c,v 1.15 2019/11/10 21:16:28 chs Exp $ */
+/*     $NetBSD: plumiobus.c,v 1.16 2020/11/21 21:23:48 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -30,14 +30,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plumiobus.c,v 1.15 2019/11/10 21:16:28 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumiobus.c,v 1.16 2020/11/21 21:23:48 thorpej Exp $");
 
 #define PLUMIOBUSDEBUG
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 
 #include <machine/bus.h>
 #include <machine/intr.h>
@@ -172,7 +172,7 @@
 {
        struct hpcmips_bus_space *hbs;
        
-       hbs = malloc(sizeof(*hbs), M_DEVBUF, M_WAITOK);
+       hbs = kmem_alloc(sizeof(*hbs), KM_SLEEP);
        *hbs = *t;
        hbs->t_base += ofs;
        hbs->t_size = size;
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcmips/dev/plumohci.c
--- a/sys/arch/hpcmips/dev/plumohci.c   Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcmips/dev/plumohci.c   Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plumohci.c,v 1.15 2016/04/23 10:15:29 skrll Exp $ */
+/*     $NetBSD: plumohci.c,v 1.16 2020/11/21 21:23:48 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 UCHIYAMA Yasushi
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plumohci.c,v 1.15 2016/04/23 10:15:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumohci.c,v 1.16 2020/11/21 21:23:48 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,6 +43,7 @@
 #include <sys/device.h>
 #include <sys/proc.h>
 #include <sys/queue.h>
+#include <sys/kmem.h>
 
 /* busdma */
 #include <sys/mbuf.h>
@@ -247,7 +248,7 @@
 
        pmap_extract(pmap_kernel(), (vaddr_t)caddr, &paddr);
 
-       ps = malloc(sizeof(struct plumohci_shm), M_DEVBUF, M_NOWAIT);
+       ps = kmem_intr_alloc(sizeof(struct plumohci_shm), KM_NOSLEEP);
        if (ps == 0)
                return 1;
 
@@ -276,7 +277,7 @@
                if (ps->ps_paddr == segs[0].ds_addr) {
                        bus_space_free(sc->sc.iot, ps->ps_bsh, ps->ps_size);
                        LIST_REMOVE(ps, ps_link);
-                       free(ps, M_DEVBUF);
+                       kmem_intr_free(ps, sizeof(*ps));
 
                        return;
                }
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcmips/dev/ucbsnd.c
--- a/sys/arch/hpcmips/dev/ucbsnd.c     Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcmips/dev/ucbsnd.c     Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucbsnd.c,v 1.25 2016/12/17 03:46:52 riastradh Exp $ */
+/*     $NetBSD: ucbsnd.c,v 1.26 2020/11/21 21:23:48 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -37,14 +37,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucbsnd.c,v 1.25 2016/12/17 03:46:52 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucbsnd.c,v 1.26 2020/11/21 21:23:48 thorpej Exp $");
 
 #include "opt_use_poll.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/device.h>
 #include <sys/proc.h>
 #include <sys/endian.h>
@@ -658,7 +658,7 @@
        rb->rb_blksize = blksize;
        rb->rb_maxblks = maxblk;
 #if notyet
-       rb->rb_buf = (u_int32_t)malloc(rb->rb_bufsize, M_DEVBUF, M_WAITOK);
+       rb->rb_buf = (u_int32_t)kmem_alloc(rb->rb_bufsize, KM_SLEEP);
 #else
        rb->rb_buf = (u_int32_t)dmabuf_static;
 #endif
@@ -668,8 +668,7 @@
        }
        memset((char*)rb->rb_buf, 0, rb->rb_bufsize);
 #if notyet
-       rb->rb_bufcnt = malloc(rb->rb_maxblks * sizeof(size_t), M_DEVBUF,
-           M_WAITOK);
+       rb->rb_bufcnt = kmem_alloc(rb->rb_maxblks * sizeof(size_t), KM_SLEEP);
 #else
        rb->rb_bufcnt = dmabufcnt_static;
 #endif
@@ -688,8 +687,8 @@
 ringbuf_deallocate(struct ring_buf *rb)
 {
 #if notyet
-       free((void*)rb->rb_buf, M_DEVBUF);
-       free(rb->rb_bufcnt, M_DEVBUF);
+       kmem_free((void*)rb->rb_buf, rb->rb_bufsize);
+       kmem_free(rb->rb_bufcnt, rb->rb_maxblks * sizeof(size_t));
 #endif
 }
 
diff -r c7426b6a0afb -r e6631bfacda6 sys/arch/hpcmips/hpcmips/bus_dma.c
--- a/sys/arch/hpcmips/hpcmips/bus_dma.c        Sat Nov 21 21:07:38 2020 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_dma.c        Sat Nov 21 21:23:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.39 2015/06/11 08:22:09 matt Exp $        */
+/*     $NetBSD: bus_dma.c,v 1.40 2020/11/21 21:23:48 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -31,12 +31,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.39 2015/06/11 08:22:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.40 2020/11/21 21:23:48 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/proc.h>
+#include <sys/kmem.h>
 
 #include <uvm/uvm_extern.h>
 #include <mips/cache.h>
@@ -77,6 +78,15 @@
        NULL,
 };
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{ 
+       KASSERT(nsegments > 0);
+       return sizeof(struct bus_dmamap_hpcmips) +
+           sizeof(struct bus_dma_segment_hpcmips) * (nsegments - 1) +
+           sizeof(bus_dma_segment_t) * nsegments;
+}
+
 /*
  * Common function for DMA map creation.  May be called by bus-specific
  * DMA map creation functions.
@@ -87,7 +97,6 @@



Home | Main Index | Thread Index | Old Index