malloc(9) -> kmem(9)
This commit is contained in:
parent
9e26d3f35b
commit
33d87a86d4
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: adm5120_intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $ */
|
/* $NetBSD: adm5120_intr.c,v 1.9 2021/01/04 18:11:26 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
|
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
|
||||||
@ -67,14 +67,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: adm5120_intr.c,v 1.8 2019/11/10 21:16:29 chs Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: adm5120_intr.c,v 1.9 2021/01/04 18:11:26 thorpej Exp $");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include "opt_ddb.h"
|
||||||
#define __INTR_PRIVATE
|
#define __INTR_PRIVATE
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/intr.h>
|
#include <sys/intr.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/kmem.h>
|
||||||
|
|
||||||
#include <mips/locore.h>
|
#include <mips/locore.h>
|
||||||
#include <mips/adm5120/include/adm5120reg.h>
|
#include <mips/adm5120/include/adm5120reg.h>
|
||||||
@ -191,7 +191,7 @@ adm5120_intr_establish(int irq, int priority, int (*func)(void *), void *arg)
|
|||||||
if (irq < 0 || irq >= NIRQS)
|
if (irq < 0 || irq >= NIRQS)
|
||||||
panic("adm5120_intr_establish: bogus IRQ %d", irq);
|
panic("adm5120_intr_establish: bogus IRQ %d", irq);
|
||||||
|
|
||||||
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
|
ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
|
||||||
ih->ih_func = func;
|
ih->ih_func = func;
|
||||||
ih->ih_arg = arg;
|
ih->ih_arg = arg;
|
||||||
ih->ih_irq = irq;
|
ih->ih_irq = irq;
|
||||||
@ -259,7 +259,7 @@ adm5120_intr_disestablish(void *cookie)
|
|||||||
|
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
free(ih, M_DEVBUF);
|
kmem_free(ih, sizeof(*ih));
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
evbmips_iointr(int ipl, uint32_t ipending, struct clockframe *cf)
|
evbmips_iointr(int ipl, uint32_t ipending, struct clockframe *cf)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: bus_dma.c,v 1.42 2020/07/16 13:32:05 simonb Exp $ */
|
/* $NetBSD: bus_dma.c,v 1.43 2021/01/04 18:09:01 thorpej Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc.
|
* Copyright (c) 1997, 1998, 2001, 2020 The NetBSD Foundation, Inc.
|
||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||||
|
|
||||||
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.42 2020/07/16 13:32:05 simonb Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.43 2021/01/04 18:09:01 thorpej Exp $");
|
||||||
|
|
||||||
#define _MIPS_BUS_DMA_PRIVATE
|
#define _MIPS_BUS_DMA_PRIVATE
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.42 2020/07/16 13:32:05 simonb Exp $");
|
|||||||
#include <sys/device.h>
|
#include <sys/device.h>
|
||||||
#include <sys/evcnt.h>
|
#include <sys/evcnt.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/kmem.h>
|
||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -285,6 +285,22 @@ _bus_dma_load_bouncebuf(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
|||||||
}
|
}
|
||||||
#endif /* _MIPS_NEED_BUS_DMA_BOUNCE */
|
#endif /* _MIPS_NEED_BUS_DMA_BOUNCE */
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
_bus_dmamap_mapsize(int const nsegments)
|
||||||
|
{
|
||||||
|
KASSERT(nsegments > 0);
|
||||||
|
return sizeof(struct mips_bus_dmamap) +
|
||||||
|
(sizeof(bus_dma_segment_t) * (nsegments - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
_bus_dmamap_cookiesize(int const nsegments)
|
||||||
|
{
|
||||||
|
KASSERT(nsegments > 0);
|
||||||
|
return sizeof(struct mips_bus_dma_cookie) +
|
||||||
|
(sizeof(bus_dma_segment_t) * nsegments);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Common function for DMA map creation. May be called by bus-specific
|
* Common function for DMA map creation. May be called by bus-specific
|
||||||
* DMA map creation functions.
|
* DMA map creation functions.
|
||||||
@ -295,9 +311,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
|||||||
{
|
{
|
||||||
struct mips_bus_dmamap *map;
|
struct mips_bus_dmamap *map;
|
||||||
void *mapstore;
|
void *mapstore;
|
||||||
size_t mapsize;
|
const int allocflags =
|
||||||
const int mallocflags = M_ZERO |
|
((flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP);
|
||||||
((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
@ -313,9 +328,8 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
|||||||
* The bus_dmamap_t includes one bus_dma_segment_t, hence
|
* The bus_dmamap_t includes one bus_dma_segment_t, hence
|
||||||
* the (nsegments - 1).
|
* the (nsegments - 1).
|
||||||
*/
|
*/
|
||||||
mapsize = sizeof(struct mips_bus_dmamap) +
|
if ((mapstore = kmem_zalloc(_bus_dmamap_mapsize(nsegments),
|
||||||
(sizeof(bus_dma_segment_t) * (nsegments - 1));
|
allocflags)) == NULL)
|
||||||
if ((mapstore = malloc(mapsize, M_DMAMAP, mallocflags)) == NULL)
|
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
map = mapstore;
|
map = mapstore;
|
||||||
@ -336,7 +350,6 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
|||||||
struct mips_bus_dma_cookie *cookie;
|
struct mips_bus_dma_cookie *cookie;
|
||||||
int cookieflags;
|
int cookieflags;
|
||||||
void *cookiestore;
|
void *cookiestore;
|
||||||
size_t cookiesize;
|
|
||||||
|
|
||||||
if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh)
|
if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh)
|
||||||
map->_dm_bounce_thresh = 0;
|
map->_dm_bounce_thresh = 0;
|
||||||
@ -356,13 +369,11 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cookiesize = sizeof(struct mips_bus_dma_cookie) +
|
|
||||||
(sizeof(bus_dma_segment_t) * map->_dm_segcnt);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate our cookie.
|
* Allocate our cookie.
|
||||||
*/
|
*/
|
||||||
if ((cookiestore = malloc(cookiesize, M_DMAMAP, mallocflags)) == NULL) {
|
if ((cookiestore = kmem_zalloc(_bus_dmamap_cookiesize(nsegments),
|
||||||
|
allocflags)) == NULL) {
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -403,13 +414,13 @@ _bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
|
|||||||
if (cookie->id_flags & _BUS_DMA_HAS_BOUNCE)
|
if (cookie->id_flags & _BUS_DMA_HAS_BOUNCE)
|
||||||
_bus_dma_free_bouncebuf(t, map);
|
_bus_dma_free_bouncebuf(t, map);
|
||||||
STAT_INCR(bounced_destroys);
|
STAT_INCR(bounced_destroys);
|
||||||
free(cookie, M_DMAMAP);
|
kmem_free(cookie, _bus_dmamap_cookiesize(map->_dm_segcnt));
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
STAT_INCR(destroys);
|
STAT_INCR(destroys);
|
||||||
if (map->dm_nsegs > 0)
|
if (map->dm_nsegs > 0)
|
||||||
STAT_INCR(unloads);
|
STAT_INCR(unloads);
|
||||||
free(map, M_DMAMAP);
|
kmem_free(map, _bus_dmamap_mapsize(map->_dm_segcnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1325,8 +1336,8 @@ _bus_dmatag_subregion(bus_dma_tag_t tag, bus_addr_t min_addr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*newtag = malloc(sizeof(struct mips_bus_dma_tag), M_DMAMAP,
|
if ((*newtag = kmem_alloc(sizeof(struct mips_bus_dma_tag),
|
||||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
|
(flags & BUS_DMA_NOWAIT) ? KM_NOSLEEP : KM_SLEEP)) == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
**newtag = *tag;
|
**newtag = *tag;
|
||||||
@ -1354,7 +1365,7 @@ _bus_dmatag_destroy(bus_dma_tag_t tag)
|
|||||||
case 0:
|
case 0:
|
||||||
break; /* not allocated with malloc */
|
break; /* not allocated with malloc */
|
||||||
case 1:
|
case 1:
|
||||||
free(tag, M_DMAMAP); /* last reference to tag */
|
kmem_free(tag, sizeof(*tag)); /* last reference to tag */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
(tag->_tag_needs_free)--; /* one less reference */
|
(tag->_tag_needs_free)--; /* one less reference */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ralink_intr.c,v 1.6 2019/11/10 21:16:30 chs Exp $ */
|
/* $NetBSD: ralink_intr.c,v 1.7 2021/01/04 18:14:38 thorpej Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2011 CradlePoint Technology, Inc.
|
* Copyright (c) 2011 CradlePoint Technology, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -29,14 +29,14 @@
|
|||||||
#define __INTR_PRIVATE
|
#define __INTR_PRIVATE
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: ralink_intr.c,v 1.6 2019/11/10 21:16:30 chs Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: ralink_intr.c,v 1.7 2021/01/04 18:14:38 thorpej Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
#include <sys/device.h>
|
#include <sys/device.h>
|
||||||
#include <sys/intr.h>
|
#include <sys/intr.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/kmem.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
|
||||||
#include <mips/locore.h>
|
#include <mips/locore.h>
|
||||||
@ -267,7 +267,7 @@ ra_intr_establish(int intr, int (*func)(void *), void *arg, int priority)
|
|||||||
{
|
{
|
||||||
struct evbmips_intrhand *ih;
|
struct evbmips_intrhand *ih;
|
||||||
|
|
||||||
ih = malloc(sizeof(*ih), M_DEVBUF, M_WAITOK);
|
ih = kmem_alloc(sizeof(*ih), KM_SLEEP);
|
||||||
ih->ih_func = func;
|
ih->ih_func = func;
|
||||||
ih->ih_arg = arg;
|
ih->ih_arg = arg;
|
||||||
ih->ih_irq = intr;
|
ih->ih_irq = intr;
|
||||||
@ -310,7 +310,7 @@ ra_intr_disestablish(void *arg)
|
|||||||
|
|
||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
free(ih, M_DEVBUF);
|
kmem_free(ih, sizeof(*ih));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user