Module Name: src Committed By: thorpej Date: Sat Nov 21 16:07:18 UTC 2020
Modified Files: src/sys/arch/pmax/pmax: bus_dma.c src/sys/arch/pmax/tc: dt.c Log Message: malloc(9) -> kmem(9) To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/arch/pmax/pmax/bus_dma.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/pmax/tc/dt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/pmax/pmax/bus_dma.c diff -u src/sys/arch/pmax/pmax/bus_dma.c:1.59 src/sys/arch/pmax/pmax/bus_dma.c:1.60 --- src/sys/arch/pmax/pmax/bus_dma.c:1.59 Thu May 18 16:34:56 2017 +++ src/sys/arch/pmax/pmax/bus_dma.c Sat Nov 21 16:07:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.59 2017/05/18 16:34:56 christos Exp $ */ +/* $NetBSD: bus_dma.c,v 1.60 2020/11/21 16:07:18 thorpej Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.59 2017/05/18 16:34:56 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.60 2020/11/21 16:07:18 thorpej Exp $"); #include "opt_cputype.h" @@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v #include <sys/mbuf.h> #include <sys/proc.h> #include <sys/systm.h> +#include <sys/kmem.h> #include <uvm/uvm_extern.h> @@ -87,6 +88,14 @@ pmax_bus_dma_init(void) #endif } +static size_t +_bus_dmamap_mapsize(int const nsegments) +{ + KASSERT(nsegments > 0); + return sizeof(struct pmax_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. @@ -97,7 +106,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ { struct pmax_bus_dmamap *map; void *mapstore; - size_t mapsize; /* * Allocate and initialize the DMA map. The end of the map @@ -111,13 +119,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ * The bus_dmamap_t includes one bus_dma_segment_t, hence * the (nsegments - 1). */ - mapsize = sizeof(struct pmax_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 pmax_bus_dmamap *)mapstore; map->_dm_size = size; map->_dm_segcnt = nsegments; @@ -141,7 +146,7 @@ void _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)); } /* Index: src/sys/arch/pmax/tc/dt.c diff -u src/sys/arch/pmax/tc/dt.c:1.13 src/sys/arch/pmax/tc/dt.c:1.14 --- src/sys/arch/pmax/tc/dt.c:1.13 Sun Nov 10 21:16:31 2019 +++ src/sys/arch/pmax/tc/dt.c Sat Nov 21 16:07:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dt.c,v 1.13 2019/11/10 21:16:31 chs Exp $ */ +/* $NetBSD: dt.c,v 1.14 2020/11/21 16:07:18 thorpej Exp $ */ /*- * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ SOFTWARE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dt.c,v 1.13 2019/11/10 21:16:31 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dt.c,v 1.14 2020/11/21 16:07:18 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -143,7 +143,7 @@ __KERNEL_RCSID(0, "$NetBSD: dt.c,v 1.13 #include <sys/file.h> #include <sys/kernel.h> #include <sys/device.h> -#include <sys/malloc.h> +#include <sys/kmem.h> #include <sys/intr.h> #include <dev/dec/lk201.h> @@ -215,11 +215,11 @@ dt_attach(device_t parent, device_t self dt_cninit(); - msg = malloc(sizeof(*msg) * DT_BUF_CNT, M_DEVBUF, M_WAITOK); + msg = kmem_alloc(sizeof(*msg) * DT_BUF_CNT, KM_SLEEP); sc->sc_sih = softint_establish(SOFTINT_SERIAL, dt_dispatch, sc); if (sc->sc_sih == NULL) { printf("%s: memory exhausted\n", device_xname(self)); - free(msg, M_DEVBUF); + kmem_free(msg, sizeof(*msg) * DT_BUF_CNT); return; }