Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/7ca95b207b88
branches:  trunk
changeset: 949165:7ca95b207b88
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jan 03 17:42:10 2021 +0000

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

diffstat:

 sys/arch/atari/atari/autoconf.c  |   9 ++++-----
 sys/arch/atari/atari/be_bus.c    |  10 +++++-----
 sys/arch/atari/atari/bus.c       |  24 ++++++++++++++----------
 sys/arch/atari/atari/intr.c      |  19 +++++++++----------
 sys/arch/atari/atari/le_bus.c    |  10 +++++-----
 sys/arch/atari/atari/machdep.c   |   8 ++++----
 sys/arch/atari/atari/mainbus.c   |  12 +++++-------
 sys/arch/atari/dev/hdfd.c        |  11 +++++------
 sys/arch/atari/dev/ite.c         |  12 ++++++------
 sys/arch/atari/dev/md_root.c     |  10 +++++-----
 sys/arch/atari/dev/zs.c          |  10 +++++-----
 sys/arch/atari/pci/pci_machdep.c |  20 +++++++++-----------
 12 files changed, 76 insertions(+), 79 deletions(-)

diffs (truncated from 585 to 300 lines):

diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/autoconf.c
--- a/sys/arch/atari/atari/autoconf.c   Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/autoconf.c   Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.67 2019/06/29 16:41:18 tsutsui Exp $    */
+/*     $NetBSD: autoconf.c,v 1.68 2021/01/03 17:42:10 thorpej Exp $    */
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.67 2019/06/29 16:41:18 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.68 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_md.h"
 
@@ -43,7 +43,7 @@
 #include <sys/device.h>
 #include <sys/disklabel.h>
 #include <sys/disk.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <machine/disklabel.h>
 #include <machine/cpu.h>
 #include <atari/atari/device.h>
@@ -105,8 +105,7 @@
                md_major = devsw_name2blk("md", NULL, 0);
                if (md_major >= 0) {
                        for (i = 0; i < RAMD_NDEV; i++) {
-                               cf = malloc(sizeof(*cf), M_DEVBUF,
-                                   M_ZERO|M_WAITOK);
+                               cf = kmem_zalloc(sizeof(*cf), KM_SLEEP);
                                if (cf == NULL)
                                        break;  /* XXX */
                                cf->cf_name = md_cd.cd_name;
diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/be_bus.c
--- a/sys/arch/atari/atari/be_bus.c     Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/be_bus.c     Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: be_bus.c,v 1.16 2019/11/10 21:16:25 chs Exp $  */
+/*     $NetBSD: be_bus.c,v 1.17 2021/01/03 17:42:10 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: be_bus.c,v 1.16 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: be_bus.c,v 1.17 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <machine/cpu.h>
 #include <sys/bus.h>
 
@@ -178,12 +178,12 @@
 
        /*
         * Allow the caller to specify storage space for the tag. This
-        * is used during console config (when malloc() can't be used).
+        * is used during console config (when kmem_alloc() can't be used).
         */
        if (storage != NULL)
                beb_t = storage;
        else {
-               beb_t = malloc(sizeof(*beb_t), M_TEMP, M_WAITOK);
+               beb_t = kmem_alloc(sizeof(*beb_t), KM_SLEEP);
        }
        memset(beb_t, 0, sizeof(*beb_t));
        
diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/bus.c
--- a/sys/arch/atari/atari/bus.c        Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/bus.c        Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.c,v 1.60 2018/03/10 03:44:43 tsutsui Exp $ */
+/*     $NetBSD: bus.c,v 1.61 2021/01/03 17:42:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -33,12 +33,12 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.60 2018/03/10 03:44:43 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.61 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/extent.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mbuf.h>
 #include <sys/proc.h>
 
@@ -330,6 +330,14 @@
        return m68k_btop(addr + off);
 }
 
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+       KASSERT(nsegments > 0); 
+       return sizeof(struct atari_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.
@@ -340,7 +348,6 @@
 {
        struct atari_bus_dmamap *map;
        void *mapstore;
-       size_t mapsize;
 
        /*
         * Allocate and initialize the DMA map.  The end of the map
@@ -354,13 +361,10 @@
         * The bus_dmamap_t includes one bus_dma_segment_t, hence
         * the (nsegments - 1).
         */
-       mapsize = sizeof(struct atari_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 atari_bus_dmamap *)mapstore;
        map->_dm_size = size;
        map->_dm_segcnt = nsegments;
@@ -383,7 +387,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));
 }
 
 /*
diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/intr.c
--- a/sys/arch/atari/atari/intr.c       Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/intr.c       Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.27 2019/11/10 21:16:25 chs Exp $    */
+/*     $NetBSD: intr.c,v 1.28 2021/01/03 17:42:10 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.27 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.28 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/vmmeter.h>
 #include <sys/queue.h>
 #include <sys/device.h>
@@ -112,8 +112,7 @@
        u_long          *hard_vec;
        int             s;
 
-       /* no point in sleeping unless someone can free memory. */
-       ih = malloc(sizeof *ih, M_DEVBUF, M_WAITOK);
+       ih = kmem_alloc(sizeof *ih, KM_SLEEP);
        ih->ih_fun    = ih_fun;
        ih->ih_arg    = ih_arg;
        ih->ih_type   = type;
@@ -127,7 +126,7 @@
        switch (type & (AUTO_VEC|USER_VEC)) {
        case AUTO_VEC:
                if (vector < AVEC_MIN || vector > AVEC_MAX) {
-                       free(ih, M_DEVBUF);
+                       kmem_free(ih, sizeof(*ih));
                        return NULL;
                }
                vec_list = &autovec_list[vector-1];
@@ -136,7 +135,7 @@
                break;
        case USER_VEC:
                if (vector < UVEC_MIN || vector > UVEC_MAX) {
-                       free(ih, M_DEVBUF);
+                       kmem_free(ih, sizeof(*ih));
                        return NULL;
                }
                vec_list = &uservec_list[vector];
@@ -145,7 +144,7 @@
                break;
        default:
                printf("%s: bogus vector type\n", __func__);
-               free(ih, M_DEVBUF);
+               kmem_free(ih, sizeof(*ih));
                return NULL;
        }
 
@@ -181,7 +180,7 @@
         */
        cur_vec = vec_list->lh_first;
        if (cur_vec->ih_type & FAST_VEC) {
-               free(ih, M_DEVBUF);
+               kmem_free(ih, sizeof(*ih));
                printf("intr_establish: vector cannot be shared\n");
                return NULL;
        }
@@ -259,7 +258,7 @@
                *hard_vec = (u_long)intr_glue;
        splx(s);
 
-       free(ih, M_DEVBUF);
+       kmem_free(ih, sizeof(*ih));
        return 1;
 }
 
diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/le_bus.c
--- a/sys/arch/atari/atari/le_bus.c     Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/le_bus.c     Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: le_bus.c,v 1.20 2019/11/10 21:16:25 chs Exp $  */
+/*     $NetBSD: le_bus.c,v 1.21 2021/01/03 17:42:10 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,12 +30,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: le_bus.c,v 1.20 2019/11/10 21:16:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: le_bus.c,v 1.21 2021/01/03 17:42:10 thorpej Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/bswap.h>
 #include <machine/cpu.h>
 #include <sys/bus.h>
@@ -262,12 +262,12 @@
 
        /*
         * Allow the caller to specify storage space for the tag. This
-        * is used during console config (when malloc() can't be used).
+        * is used during console config (when kmem_alloc() can't be used).
         */
        if (storage != NULL)
                leb_t = storage;
        else {
-               leb_t = malloc(sizeof(*leb_t), M_TEMP, M_WAITOK);
+               leb_t = kmem_alloc(sizeof(*leb_t), KM_SLEEP);
        }
        memset(leb_t, 0, sizeof(*leb_t));
 
diff -r d3e536812870 -r 7ca95b207b88 sys/arch/atari/atari/machdep.c
--- a/sys/arch/atari/atari/machdep.c    Sun Jan 03 17:28:33 2021 +0000
+++ b/sys/arch/atari/atari/machdep.c    Sun Jan 03 17:42:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.183 2020/06/11 19:20:43 ad Exp $ */
+/*     $NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.183 2020/06/11 19:20:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.184 2021/01/03 17:42:10 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -57,7 +57,7 @@
 #include <sys/conf.h>
 #include <sys/file.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mbuf.h>
 #include <sys/msgbuf.h>
 #include <sys/vnode.h>
@@ -630,7 +630,7 @@
        splx(s);
 
        if (si == NULL) {
-               si = malloc(sizeof(*si), M_TEMP, M_NOWAIT);
+               si = kmem_intr_alloc(sizeof(*si), KM_NOSLEEP);
 #ifdef DIAGNOSTIC



Home | Main Index | Thread Index | Old Index