Module Name: src
Committed By: thorpej
Date: Sat Nov 21 16:21:24 UTC 2020
Modified Files:
src/sys/arch/evbsh3/ap_ms104_sh4: ap_ms104_sh4_intr.c shpcmcia.c
src/sys/arch/evbsh3/evbsh3: bus_dma.c
Log Message:
malloc(9) -> kmem(9)
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbsh3/evbsh3/bus_dma.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/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c
diff -u src/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c:1.3 src/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c:1.4
--- src/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c:1.3 Sun Nov 10 21:16:27 2019
+++ src/sys/arch/evbsh3/ap_ms104_sh4/ap_ms104_sh4_intr.c Sat Nov 21 16:21:24 2020
@@ -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 <[email protected]>
@@ -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 @@ extintr_establish(int irq, int trigger,
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 @@ extintr_disestablish(void *cookie)
evcnt_detach(&ih->ih_evcnt);
- free((void *)ih, M_DEVBUF);
+ kmem_free((void *)ih, sizeof(*ih));
if (--eih->eih_nih == 0) {
uint8_t reg;
Index: src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c
diff -u src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c:1.4 src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c:1.5
--- src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c:1.4 Sat Oct 27 17:17:51 2012
+++ src/sys/arch/evbsh3/ap_ms104_sh4/shpcmcia.c Sat Nov 21 16:21:24 2020
@@ -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 <[email protected]>
@@ -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 @@ shpcmcia_event_thread(void *arg)
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 @@ shpcmcia_event_thread(void *arg)
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 @@ shpcmcia_event_thread(void *arg)
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 @@ shpcmcia_queue_event(struct shpcmcia_han
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");
Index: src/sys/arch/evbsh3/evbsh3/bus_dma.c
diff -u src/sys/arch/evbsh3/evbsh3/bus_dma.c:1.4 src/sys/arch/evbsh3/evbsh3/bus_dma.c:1.5
--- src/sys/arch/evbsh3/evbsh3/bus_dma.c:1.4 Thu Jan 22 03:43:24 2015
+++ src/sys/arch/evbsh3/evbsh3/bus_dma.c Sat Nov 21 16:21:24 2020
@@ -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 <[email protected]>
@@ -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 @@ struct _bus_dma_tag evbsh3_bus_dma = {
._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_create(bus_dma_tag_t t, bus_
{
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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_
* 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 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus
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