Module Name: src
Committed By: thorpej
Date: Sat Nov 21 21:01:16 UTC 2020
Modified Files:
src/sys/arch/hppa/dev: apic.c
src/sys/arch/hppa/hppa: mainbus.c
Log Message:
malloc(9) -> kmem(9)
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hppa/dev/apic.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/hppa/mainbus.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/hppa/dev/apic.c
diff -u src/sys/arch/hppa/dev/apic.c:1.3 src/sys/arch/hppa/dev/apic.c:1.4
--- src/sys/arch/hppa/dev/apic.c:1.3 Sun Nov 10 21:16:28 2019
+++ src/sys/arch/hppa/dev/apic.c Sat Nov 21 21:01:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: apic.c,v 1.3 2019/11/10 21:16:28 chs Exp $ */
+/* $NetBSD: apic.c,v 1.4 2020/11/21 21:01:16 thorpej Exp $ */
/* $OpenBSD: apic.c,v 1.14 2011/05/01 21:59:39 kettenis Exp $ */
@@ -22,7 +22,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <machine/autoconf.h>
#include <machine/pdc.h>
@@ -109,8 +109,7 @@ apic_attach(struct elroy_softc *sc)
aprint_normal(" APIC ver %x, %d pins",
data & APIC_VERSION_MASK, sc->sc_nints);
- sc->sc_irq = malloc(sc->sc_nints * sizeof(int), M_DEVBUF,
- M_WAITOK | M_ZERO);
+ sc->sc_irq = kmem_zalloc(sc->sc_nints * sizeof(int), KM_SLEEP);
apic_get_int_tbl(sc);
@@ -171,8 +170,8 @@ apic_intr_establish(void *v, pci_intr_ha
if (irq <= 0 || irq > 31)
return NULL;
- aiv = malloc(sizeof(struct apic_iv), M_DEVBUF, M_WAITOK);
- cnt = malloc(sizeof(struct evcnt), M_DEVBUF, M_WAITOK);
+ aiv = kmem_alloc(sizeof(struct apic_iv), KM_SLEEP);
+ cnt = kmem_alloc(sizeof(struct evcnt), KM_SLEEP);
aiv->sc = sc;
aiv->ih = ih;
aiv->handler = handler;
@@ -184,8 +183,8 @@ apic_intr_establish(void *v, pci_intr_ha
if (biv == NULL) {
iv = hppa_intr_establish(pri, apic_intr, aiv, &ci->ci_ir, irq);
if (iv == NULL) {
- free(aiv, M_DEVBUF);
- free(cnt, M_DEVBUF);
+ kmem_free(aiv, sizeof(*aiv));
+ kmem_free(cnt, sizeof(*cnt));
return NULL;
}
@@ -267,7 +266,7 @@ apic_get_int_tbl(struct elroy_softc *sc)
size = nentries * sizeof(struct pdc_pat_pci_rt);
sc->sc_int_tbl_sz = nentries;
- sc->sc_int_tbl = malloc(size, M_DEVBUF, M_WAITOK);
+ sc->sc_int_tbl = kmem_alloc(size, KM_SLEEP);
pdcproc_pci_gettable(nentries, size, sc->sc_int_tbl);
}
Index: src/sys/arch/hppa/hppa/mainbus.c
diff -u src/sys/arch/hppa/hppa/mainbus.c:1.5 src/sys/arch/hppa/hppa/mainbus.c:1.6
--- src/sys/arch/hppa/hppa/mainbus.c:1.5 Fri Oct 16 17:50:44 2020
+++ src/sys/arch/hppa/hppa/mainbus.c Sat Nov 21 21:01:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.5 2020/10/16 17:50:44 macallan Exp $ */
+/* $NetBSD: mainbus.c,v 1.6 2020/11/21 21:01:16 thorpej Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.5 2020/10/16 17:50:44 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.6 2020/11/21 21:01:16 thorpej Exp $");
#include "locators.h"
#include "power.h"
@@ -71,6 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v
#include <sys/extent.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
+#include <sys/kmem.h>
#include <uvm/uvm_page.h>
#include <uvm/uvm.h>
@@ -729,6 +730,14 @@ const struct hppa_bus_space_tag hppa_bus
mbus_cp_1, mbus_cp_2, mbus_cp_4, mbus_cp_8
};
+static size_t
+_bus_dmamap_mapsize(int const nsegments)
+{
+ KASSERT(nsegments > 0);
+ return sizeof(struct hppa_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.
@@ -738,7 +747,6 @@ mbus_dmamap_create(void *v, bus_size_t s
bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
{
struct hppa_bus_dmamap *map;
- size_t mapsize;
/*
* Allocate and initialize the DMA map. The end of the map is a
@@ -752,14 +760,11 @@ mbus_dmamap_create(void *v, bus_size_t s
* The bus_dmamap_t includes one bus_dma_segment_t, hence the
* (nsegments - 1).
*/
- mapsize = sizeof(struct hppa_bus_dmamap) +
- (sizeof(bus_dma_segment_t) * (nsegments - 1));
- map = malloc(mapsize, M_DMAMAP,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
+ map = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
+ (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
if (!map)
return ENOMEM;
- memset(map, 0, mapsize);
map->_dm_size = size;
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
@@ -786,7 +791,7 @@ mbus_dmamap_destroy(void *v, bus_dmamap_
if (map->dm_mapsize != 0)
mbus_dmamap_unload(v, map);
- free(map, M_DMAMAP);
+ kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
}
/*
@@ -1067,8 +1072,8 @@ mbus_dmamem_alloc(void *v, bus_size_t si
low = 0;
high = ((flags & BUS_DMA_24BIT) ? (1 << 24) : 0) - 1;
- if ((mlist = malloc(sizeof(*mlist), M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+ if ((mlist = kmem_alloc(sizeof(*mlist),
+ (flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
return ENOMEM;
/*
@@ -1083,7 +1088,7 @@ mbus_dmamem_alloc(void *v, bus_size_t si
DPRINTF(("%s: uvm_pglistalloc(%lx, %lx, %lx, 0, 0, %p, %d, %0x)"
" failed", __func__, size, low, high, mlist, nsegs,
(flags & BUS_DMA_NOWAIT) == 0));
- free(mlist, M_DEVBUF);
+ kmem_free(mlist, sizeof(*mlist));
return error;
}
@@ -1095,7 +1100,7 @@ mbus_dmamem_alloc(void *v, bus_size_t si
if (pa != pa_next) {
if (++seg >= nsegs) {
uvm_pglistfree(mlist);
- free(mlist, M_DEVBUF);
+ kmem_free(mlist, sizeof(*mlist));
return ENOMEM;
}
segs[seg].ds_addr = pa;
@@ -1136,7 +1141,7 @@ mbus_dmamem_free(void *v, bus_dma_segmen
return;
uvm_pglistfree(mlist);
- free(mlist, M_DEVBUF);
+ kmem_free(mlist, sizeof(*mlist));
}
/*