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/efa666192161
branches: trunk
changeset: 957195:efa666192161
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Nov 21 15:52:32 2020 +0000
description:
malloc(9) -> kmem(9)
diffstat:
sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c | 10 +++++-----
sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c | 18 +++++++++---------
sys/arch/evbsh3/evbsh3/bus_dma.c | 23 ++++++++++++++---------
sys/arch/pmax/pmax/bus_dma.c | 23 ++++++++++++++---------
sys/arch/pmax/tc/dt.c | 10 +++++-----
sys/arch/prep/pci/gten.c | 10 +++++-----
sys/arch/prep/pci/pci_machdep.c | 10 +++++-----
sys/arch/prep/pnpbus/pnpbus.c | 22 +++++++++++-----------
sys/arch/prep/prep/mainbus.c | 12 +++++-------
sys/arch/rs6000/mca/mca_machdep.c | 10 +++++-----
sys/arch/rs6000/mca/mcadma_machdep.c | 12 ++++++------
sys/arch/rs6000/rs6000/pic_iocc.c | 8 ++++----
12 files changed, 88 insertions(+), 80 deletions(-)
diffs (truncated from 620 to 300 lines):
diff -r 09119c98a161 -r efa666192161 sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c
--- a/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c Sat Nov 21 15:52:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ap_ms104_sh4_intr.c,v 1.3 2019/11/10 21:16:27 chs Exp $ */
+/* $NetBSD: ap_ms104_sh4_intr.c,v 1.4 2020/11/21 16:21:24 thorpej Exp $ */
/*-
* Copyright (C) 2009 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,12 +26,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ap_ms104_sh4_intr.c,v 1.3 2019/11/10 21:16:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ap_ms104_sh4_intr.c,v 1.4 2020/11/21 16:21:24 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/device.h>
#include <sh3/devreg.h>
@@ -102,7 +102,7 @@
KDASSERT(irq >= 1 && irq <= 14);
- ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
+ ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
s = _cpu_intr_suspend();
@@ -223,7 +223,7 @@
evcnt_detach(&ih->ih_evcnt);
- free((void *)ih, M_DEVBUF);
+ kmem_free((void *)ih, sizeof(*ih));
if (--eih->eih_nih == 0) {
uint8_t reg;
diff -r 09119c98a161 -r efa666192161 sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c
--- a/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c Sat Nov 21 15:52:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shpcmcia.c,v 1.4 2012/10/27 17:17:51 chs Exp $ */
+/* $NetBSD: shpcmcia.c,v 1.5 2020/11/21 16:21:24 thorpej Exp $ */
/*-
* Copyright (C) 2009 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,13 +26,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: shpcmcia.c,v 1.4 2012/10/27 17:17:51 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shpcmcia.c,v 1.5 2020/11/21 16:21:24 thorpej Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/kthread.h>
#include <sys/kernel.h>
#include <sys/callout.h>
@@ -400,9 +400,9 @@
break;
if (pe2->pe_type == SHPCMCIA_EVENT_INSERT) {
SIMPLEQ_REMOVE_HEAD(&h->events, pe_q);
- free(pe1, M_TEMP);
+ kmem_free(pe1, sizeof(*pe1));
SIMPLEQ_REMOVE_HEAD(&h->events, pe_q);
- free(pe2, M_TEMP);
+ kmem_free(pe2, sizeof(*pe2));
}
}
splx(s);
@@ -425,9 +425,9 @@
break;
if (pe2->pe_type == SHPCMCIA_EVENT_REMOVE) {
SIMPLEQ_REMOVE_HEAD(&h->events, pe_q);
- free(pe1, M_TEMP);
+ kmem_free(pe1, sizeof(*pe1));
SIMPLEQ_REMOVE_HEAD(&h->events, pe_q);
- free(pe2, M_TEMP);
+ kmem_free(pe2, sizeof(*pe2));
}
}
splx(s);
@@ -441,7 +441,7 @@
panic("shpcmcia_event_thread: unknown event %d",
pe->pe_type);
}
- free(pe, M_TEMP);
+ kmem_free(pe, sizeof(*pe));
}
h->event_thread = NULL;
@@ -458,7 +458,7 @@
struct shpcmcia_event *pe;
int s;
- pe = malloc(sizeof(*pe), M_TEMP, M_NOWAIT);
+ pe = kmem_intr_alloc(sizeof(*pe), KM_NOSLEEP);
if (pe == NULL)
panic("shpcmcia_queue_event: can't allocate event");
diff -r 09119c98a161 -r efa666192161 sys/arch/evbsh3/evbsh3/bus_dma.c
--- a/sys/arch/evbsh3/evbsh3/bus_dma.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/evbsh3/evbsh3/bus_dma.c Sat Nov 21 15:52:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.4 2015/01/22 03:43:24 nonaka Exp $ */
+/* $NetBSD: bus_dma.c,v 1.5 2020/11/21 16:21:24 thorpej Exp $ */
/*
* Copyright (c) 2005 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,13 +26,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.4 2015/01/22 03:43:24 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.5 2020/11/21 16:21: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/mbuf.h>
#define _EVBSH3_BUS_DMA_PRIVATE
#include <sys/bus.h>
@@ -69,6 +69,14 @@
._dmamem_mmap = _bus_dmamem_mmap,
};
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+ KASSERT(nsegments > 0);
+ return sizeof(struct _bus_dmamap)
+ + (sizeof(bus_dma_segment_t) * (nsegments - 1));
+}
+
/*
* Create a DMA map.
*/
@@ -78,7 +86,6 @@
{
bus_dmamap_t map;
void *mapstore;
- size_t mapsize;
DPRINTF(("%s: t = %p, size = %ld, nsegments = %d, maxsegsz = %ld,"
" boundary = %ld, flags = %x\n",
@@ -94,10 +101,8 @@
* Preservation of ALLOCNOW notifies others that we've
* reserved these resources, and they are not to be freed.
*/
- mapsize = sizeof(struct _bus_dmamap)
- + (sizeof(bus_dma_segment_t) * (nsegments - 1));
- mapstore = malloc(mapsize, M_DMAMAP, M_ZERO
- | ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK));
+ mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+ (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
if (mapstore == NULL)
return ENOMEM;
@@ -126,7 +131,7 @@
DPRINTF(("%s: t = %p, map = %p\n", __func__, t, map));
- free(map, M_DMAMAP);
+ kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
}
static inline int
diff -r 09119c98a161 -r efa666192161 sys/arch/pmax/pmax/bus_dma.c
--- a/sys/arch/pmax/pmax/bus_dma.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/pmax/pmax/bus_dma.c Sat Nov 21 15:52:32 2020 +0000
@@ -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 @@
#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 @@
#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 @@
{
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 @@
* 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 @@
_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 09119c98a161 -r efa666192161 sys/arch/pmax/tc/dt.c
--- a/sys/arch/pmax/tc/dt.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/pmax/tc/dt.c Sat Nov 21 15:52:32 2020 +0000
@@ -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 @@
*/
#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 @@
#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_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;
}
diff -r 09119c98a161 -r efa666192161 sys/arch/prep/pci/gten.c
--- a/sys/arch/prep/pci/gten.c Sat Nov 21 15:48:05 2020 +0000
+++ b/sys/arch/prep/pci/gten.c Sat Nov 21 15:52:32 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gten.c,v 1.21 2019/11/10 21:16:31 chs Exp $ */
+/* $NetBSD: gten.c,v 1.22 2020/11/21 15:59:53 thorpej Exp $ */
Home |
Main Index |
Thread Index |
Old Index