Module Name: src
Committed By: kiyohara
Date: Mon May 10 12:17:33 UTC 2010
Modified Files:
src/sys/dev/ieee1394: firewire.c fwdev.c fwdma.c fwmem.c fwohci.c
if_fwip.c sbp.c
Log Message:
Use kmem(9) instead of malloc(9).
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ieee1394/firewire.c \
src/sys/dev/ieee1394/sbp.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ieee1394/fwdev.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ieee1394/fwdma.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ieee1394/fwmem.c
cvs rdiff -u -r1.125 -r1.126 src/sys/dev/ieee1394/fwohci.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ieee1394/if_fwip.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/dev/ieee1394/firewire.c
diff -u src/sys/dev/ieee1394/firewire.c:1.30 src/sys/dev/ieee1394/firewire.c:1.31
--- src/sys/dev/ieee1394/firewire.c:1.30 Tue Apr 6 10:45:15 2010
+++ src/sys/dev/ieee1394/firewire.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: firewire.c,v 1.30 2010/04/06 10:45:15 reinoud Exp $ */
+/* $NetBSD: firewire.c,v 1.31 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.30 2010/04/06 10:45:15 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.31 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -48,7 +48,7 @@
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -217,28 +217,24 @@
if (fc->nisodma > FWMAXNDMA)
fc->nisodma = FWMAXNDMA;
- fc->crom_src_buf =
- (struct crom_src_buf *)malloc(sizeof(struct crom_src_buf),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->crom_src_buf = kmem_zalloc(sizeof(struct crom_src_buf), KM_NOSLEEP);
if (fc->crom_src_buf == NULL) {
- aprint_error_dev(fc->bdev, "Malloc Failure crom src buff\n");
+ aprint_error_dev(fc->bdev,
+ "kmem alloc failure crom src buff\n");
return;
}
fc->topology_map =
- (struct fw_topology_map *)malloc(sizeof(struct fw_topology_map),
- M_FW, M_NOWAIT | M_ZERO);
+ kmem_zalloc(sizeof(struct fw_topology_map), KM_NOSLEEP);
if (fc->topology_map == NULL) {
aprint_error_dev(fc->dev, "Malloc Failure topology map\n");
- free(fc->crom_src_buf, M_FW);
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
return;
}
- fc->speed_map =
- (struct fw_speed_map *)malloc(sizeof(struct fw_speed_map),
- M_FW, M_NOWAIT | M_ZERO);
+ fc->speed_map = kmem_zalloc(sizeof(struct fw_speed_map), KM_NOSLEEP);
if (fc->speed_map == NULL) {
aprint_error_dev(fc->dev, "Malloc Failure speed map\n");
- free(fc->crom_src_buf, M_FW);
- free(fc->topology_map, M_FW);
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
+ kmem_free(fc->topology_map, sizeof(struct fw_topology_map));
return;
}
@@ -262,7 +258,7 @@
aprint_error_dev(self, "kthread_create failed\n");
config_pending_incr();
- devlist = malloc(sizeof(struct firewire_dev_list), M_DEVBUF, M_NOWAIT);
+ devlist = kmem_alloc(sizeof(struct firewire_dev_list), KM_NOSLEEP);
if (devlist == NULL) {
aprint_error_dev(self, "device list allocation failed\n");
return;
@@ -273,7 +269,7 @@
faa.fwdev = NULL;
devlist->dev = config_found(sc->dev, &faa, firewire_print);
if (devlist->dev == NULL)
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
else
SLIST_INSERT_HEAD(&sc->devlist, devlist, link);
@@ -315,7 +311,7 @@
if ((err = config_detach(devlist->dev, flags)) != 0)
return err;
SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list, link);
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
}
callout_stop(&fc->timeout_callout);
@@ -326,11 +322,11 @@
for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL;
fwdev = fwdev_next) {
fwdev_next = STAILQ_NEXT(fwdev, link);
- free(fwdev, M_FW);
+ kmem_free(fwdev, sizeof(struct fw_device));
}
- free(fc->topology_map, M_FW);
- free(fc->speed_map, M_FW);
- free(fc->crom_src_buf, M_FW);
+ kmem_free(fc->topology_map, sizeof(struct fw_topology_map));
+ kmem_free(fc->speed_map, sizeof(struct fw_speed_map));
+ kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
cv_destroy(&fc->fc_cv);
mutex_destroy(&fc->wait_lock);
@@ -586,7 +582,7 @@
* Configuration ROM.
*/
#define FW_MAX_GENERATION 0xF
- newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
+ newrom = kmem_zalloc(CROMSIZE, KM_NOSLEEP);
src = &fc->crom_src_buf->src;
crom_load(src, newrom, CROMSIZE);
if (memcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
@@ -594,7 +590,7 @@
src->businfo.generation = FW_GENERATION_CHANGEABLE;
memcpy((void *)fc->config_rom, newrom, CROMSIZE);
}
- free(newrom, M_FW);
+ kmem_free(newrom, CROMSIZE);
}
/* Call once after reboot */
@@ -810,7 +806,7 @@
{
struct fw_xfer *xfer;
- xfer = malloc(sizeof(struct fw_xfer), type, M_NOWAIT | M_ZERO);
+ xfer = kmem_zalloc(sizeof(struct fw_xfer), KM_NOSLEEP);
if (xfer == NULL)
return xfer;
@@ -831,17 +827,17 @@
xfer->send.pay_len = send_len;
xfer->recv.pay_len = recv_len;
if (send_len > 0) {
- xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO);
+ xfer->send.payload = kmem_zalloc(send_len, KM_NOSLEEP);
if (xfer->send.payload == NULL) {
fw_xfer_free(xfer);
return NULL;
}
}
if (recv_len > 0) {
- xfer->recv.payload = malloc(recv_len, type, M_NOWAIT);
+ xfer->recv.payload = kmem_alloc(recv_len, KM_NOSLEEP);
if (xfer->recv.payload == NULL) {
if (xfer->send.payload != NULL)
- free(xfer->send.payload, type);
+ kmem_free(xfer->send.payload, send_len);
fw_xfer_free(xfer);
return NULL;
}
@@ -912,7 +908,7 @@
}
fw_xfer_unload(xfer);
cv_destroy(&xfer->cv);
- free(xfer, xfer->malloc);
+ kmem_free(xfer, sizeof(struct fw_xfer));
}
void
@@ -924,14 +920,12 @@
return;
}
fw_xfer_unload(xfer);
- if (xfer->send.payload != NULL) {
- free(xfer->send.payload, xfer->malloc);
- }
- if (xfer->recv.payload != NULL) {
- free(xfer->recv.payload, xfer->malloc);
- }
+ if (xfer->send.payload != NULL)
+ kmem_free(xfer->send.payload, xfer->send.pay_len);
+ if (xfer->recv.payload != NULL)
+ kmem_free(xfer->recv.payload, xfer->recv.pay_len);
cv_destroy(&xfer->cv);
- free(xfer, xfer->malloc);
+ kmem_free(xfer, sizeof(struct fw_xfer));
}
void
@@ -1769,8 +1763,7 @@
mutex_exit(&fc->fc_mtx);
if (fwdev == NULL) {
/* new device */
- fwdev =
- malloc(sizeof(struct fw_device), M_FW, M_NOWAIT | M_ZERO);
+ fwdev = kmem_zalloc(sizeof(struct fw_device), KM_NOSLEEP);
if (fwdev == NULL) {
if (firewire_debug)
printf("node%d: no memory\n", node);
@@ -1887,7 +1880,7 @@
char nodes[63];
todo = 0;
- dfwdev = malloc(sizeof(*dfwdev), M_TEMP, M_NOWAIT);
+ dfwdev = kmem_alloc(sizeof(struct fw_device), KM_NOSLEEP);
if (dfwdev == NULL)
return;
/* setup dummy fwdev */
@@ -1928,7 +1921,7 @@
}
todo = todo2;
}
- free(dfwdev, M_TEMP);
+ kmem_free(dfwdev, sizeof(struct fw_device));
}
static void
@@ -1982,8 +1975,8 @@
mutex_exit(&fc->fc_mtx);
switch (fwdev->status) {
case FWDEVNEW:
- devlist = malloc(sizeof(struct firewire_dev_list),
- M_DEVBUF, M_NOWAIT);
+ devlist = kmem_alloc(sizeof(struct firewire_dev_list),
+ KM_NOSLEEP);
if (devlist == NULL) {
aprint_error_dev(fc->bdev,
"memory allocation failed\n");
@@ -1997,7 +1990,8 @@
fwdev->sbp = config_found_sm_loc(sc->dev, "ieee1394if",
locs, &fwa, firewire_print, config_stdsubmatch);
if (fwdev->sbp == NULL) {
- free(devlist, M_DEVBUF);
+ kmem_free(devlist,
+ sizeof(struct firewire_dev_list));
break;
}
@@ -2058,13 +2052,13 @@
SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list,
link);
- free(devlist, M_DEVBUF);
+ kmem_free(devlist, sizeof(struct firewire_dev_list));
if (config_detach(fwdev->sbp, DETACH_FORCE) != 0)
return;
STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link);
- free(fwdev, M_FW);
+ kmem_free(fwdev, sizeof(struct fw_device));
}
}
Index: src/sys/dev/ieee1394/sbp.c
diff -u src/sys/dev/ieee1394/sbp.c:1.30 src/sys/dev/ieee1394/sbp.c:1.31
--- src/sys/dev/ieee1394/sbp.c:1.30 Thu Apr 29 06:51:26 2010
+++ src/sys/dev/ieee1394/sbp.c Mon May 10 12:17:33 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: sbp.c,v 1.30 2010/04/29 06:51:26 kiyohara Exp $ */
+/* $NetBSD: sbp.c,v 1.31 2010/05/10 12:17:33 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.30 2010/04/29 06:51:26 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbp.c,v 1.31 2010/05/10 12:17:33 kiyohara Exp $");
#include <sys/param.h>
@@ -47,8 +47,8 @@
#include <sys/callout.h>
#include <sys/condvar.h>
#include <sys/kernel.h>
+#include <sys/kmem.h>
#include <sys/kthread.h>
-#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
@@ -708,12 +708,14 @@
/* Reallocate */
if (maxlun != target->num_lun) {
- newluns = (struct sbp_dev **) realloc(target->luns,
- sizeof(struct sbp_dev *) * maxlun,
- M_SBP, M_NOWAIT | M_ZERO);
+ const int sbp_dev_p_sz = sizeof(struct sbp_dev *);
- if (newluns == NULL) {
- aprint_error_dev(sc->sc_fd.dev, "realloc failed\n");
+ newluns = kmem_alloc(sbp_dev_p_sz * maxlun, KM_NOSLEEP);
+ if (newluns != NULL)
+ memcpy(*newluns, target->luns,
+ sizeof(struct sbp_dev *) * target->num_lun);
+ else {
+ aprint_error_dev(sc->sc_fd.dev, "kmem alloc failed\n");
newluns = target->luns;
maxlun = target->num_lun;
}
@@ -722,12 +724,9 @@
* We must zero the extended region for the case
* realloc() doesn't allocate new buffer.
*/
- if (maxlun > target->num_lun) {
- const int sbp_dev_p_sz = sizeof(struct sbp_dev *);
-
+ if (maxlun > target->num_lun)
memset(&newluns[target->num_lun], 0,
sbp_dev_p_sz * (maxlun - target->num_lun));
- }
target->luns = newluns;
target->num_lun = maxlun;
@@ -749,11 +748,10 @@
sdev = target->luns[lun];
if (sdev == NULL) {
- sdev = malloc(sizeof(struct sbp_dev),
- M_SBP, M_NOWAIT | M_ZERO);
+ sdev = kmem_zalloc(sizeof(struct sbp_dev), KM_NOSLEEP);
if (sdev == NULL) {
aprint_error_dev(sc->sc_fd.dev,
- "malloc failed\n");
+ "kmem alloc failed\n");
goto next;
}
target->luns[lun] = sdev;
@@ -787,7 +785,7 @@
fwdma_alloc_setup(sc->sc_fd.dev, sc->sc_dmat, SBP_DMA_SIZE,
&sdev->dma, sizeof(uint32_t), BUS_DMA_NOWAIT);
if (sdev->dma.v_addr == NULL) {
- free(sdev, M_SBP);
+ kmem_free(sdev, sizeof(struct sbp_dev));
target->luns[lun] = NULL;
goto next;
}
@@ -2048,7 +2046,7 @@
for (i = 0; i < SBP_QUEUE_LEN; i++)
bus_dmamap_destroy(sc->sc_dmat, sdev->ocb[i].dmamap);
fwdma_free(sdev->dma.dma_tag, sdev->dma.dma_map, sdev->dma.v_addr);
- free(sdev, M_SBP);
+ kmem_free(sdev, sizeof(struct sbp_dev));
sdev = NULL;
}
@@ -2070,7 +2068,7 @@
fw_xfer_free_buf(xfer);
}
STAILQ_INIT(&target->xferlist);
- free(target->luns, M_SBP);
+ kmem_free(target->luns, sizeof(struct sbp_dev *) * target->num_lun);
target->num_lun = 0;
target->luns = NULL;
target->fwdev = NULL;
@@ -2217,7 +2215,8 @@
/* XXX give up */
sbp_scsipi_detach_target(target);
if (target->luns != NULL)
- free(target->luns, M_SBP);
+ kmem_free(target->luns,
+ sizeof(struct sbp_dev *) * target->num_lun);
target->num_lun = 0;
target->luns = NULL;
target->fwdev = NULL;
Index: src/sys/dev/ieee1394/fwdev.c
diff -u src/sys/dev/ieee1394/fwdev.c:1.19 src/sys/dev/ieee1394/fwdev.c:1.20
--- src/sys/dev/ieee1394/fwdev.c:1.19 Thu Apr 29 06:53:48 2010
+++ src/sys/dev/ieee1394/fwdev.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fwdev.c,v 1.19 2010/04/29 06:53:48 kiyohara Exp $ */
+/* $NetBSD: fwdev.c,v 1.20 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
* Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.19 2010/04/29 06:53:48 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.20 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -46,7 +46,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/poll.h>
#include <sys/proc.h>
@@ -91,7 +91,7 @@
static int fwdev_allocbuf(struct firewire_comm *, struct fw_xferq *,
struct fw_bufspec *);
-static int fwdev_freebuf(struct fw_xferq *);
+static int fwdev_freebuf(struct fw_xferq *, struct fw_bufspec *);
static int fw_read_async(struct fw_drv1 *, struct uio *, int);
static int fw_write_async(struct fw_drv1 *, struct uio *, int);
static void fw_hand(struct fw_xfer *);
@@ -120,7 +120,7 @@
sc->si_drv1 = (void *)-1;
mutex_exit(&sc->fc->fc_mtx);
- sc->si_drv1 = malloc(sizeof(struct fw_drv1), M_FW, M_WAITOK | M_ZERO);
+ sc->si_drv1 = kmem_zalloc(sizeof(struct fw_drv1), KM_SLEEP);
if (sc->si_drv1 == NULL)
return ENOMEM;
@@ -170,7 +170,7 @@
fc->irx_disable(fc, ir->dmach);
}
/* free extbuf */
- fwdev_freebuf(ir);
+ fwdev_freebuf(ir, &d->bufreq.rx);
/* drain receiving buffer */
for (xfer = STAILQ_FIRST(&ir->q); xfer != NULL;
xfer = STAILQ_FIRST(&ir->q)) {
@@ -195,12 +195,12 @@
fc->itx_disable(fc, it->dmach);
}
/* free extbuf */
- fwdev_freebuf(it);
+ fwdev_freebuf(it, &d->bufreq.tx);
it->flag &=
~(FWXFERQ_OPEN | FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK);
d->it = NULL;
}
- free(sc->si_drv1, M_FW);
+ kmem_free(sc->si_drv1, sizeof(struct fw_drv1));
sc->si_drv1 = NULL;
return err;
@@ -577,8 +577,8 @@
err = EINVAL;
break;
}
- fwb = (struct fw_bind *)malloc(sizeof(struct fw_bind),
- M_FW, M_WAITOK);
+ fwb = (struct fw_bind *)kmem_alloc(sizeof(struct fw_bind),
+ KM_SLEEP);
if (fwb == NULL) {
err = ENOMEM;
break;
@@ -635,7 +635,7 @@
break;
}
/* myself */
- ptr = malloc(CROMSIZE, M_FW, M_WAITOK);
+ ptr = kmem_alloc(CROMSIZE, KM_SLEEP);
len = CROMSIZE;
for (i = 0; i < CROMSIZE/4; i++)
((uint32_t *)ptr)[i] = ntohl(fc->config_rom[i]);
@@ -735,8 +735,7 @@
return EBUSY;
q->bulkxfer =
- (struct fw_bulkxfer *)malloc(sizeof(struct fw_bulkxfer) * b->nchunk,
- M_FW, M_WAITOK);
+ kmem_alloc(sizeof(struct fw_bulkxfer) * b->nchunk, KM_SLEEP);
if (q->bulkxfer == NULL)
return ENOMEM;
@@ -745,7 +744,7 @@
b->nchunk * b->npacket, BUS_DMA_WAITOK);
if (q->buf == NULL) {
- free(q->bulkxfer, M_FW);
+ kmem_free(q->bulkxfer, sizeof(struct fw_bulkxfer) * b->nchunk);
q->bulkxfer = NULL;
return ENOMEM;
}
@@ -773,14 +772,14 @@
}
static int
-fwdev_freebuf(struct fw_xferq *q)
+fwdev_freebuf(struct fw_xferq *q, struct fw_bufspec *b)
{
if (q->flag & FWXFERQ_EXTBUF) {
if (q->buf != NULL)
fwdma_free_multiseg(q->buf);
q->buf = NULL;
- free(q->bulkxfer, M_FW);
+ kmem_free(q->bulkxfer, sizeof(struct fw_bulkxfer) * b->nchunk);
q->bulkxfer = NULL;
q->flag &= ~FWXFERQ_EXTBUF;
q->psize = 0;
Index: src/sys/dev/ieee1394/fwdma.c
diff -u src/sys/dev/ieee1394/fwdma.c:1.14 src/sys/dev/ieee1394/fwdma.c:1.15
--- src/sys/dev/ieee1394/fwdma.c:1.14 Thu Apr 29 06:56:00 2010
+++ src/sys/dev/ieee1394/fwdma.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fwdma.c,v 1.14 2010/04/29 06:56:00 kiyohara Exp $ */
+/* $NetBSD: fwdma.c,v 1.15 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwdma.c,v 1.14 2010/04/29 06:56:00 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwdma.c,v 1.15 2010/05/10 12:17:32 kiyohara Exp $");
#if defined(__FreeBSD__)
__FBSDID("$FreeBSD: src/sys/dev/firewire/fwdma.c,v 1.9 2007/06/06 14:31:36 simokawa Exp $");
#endif
@@ -46,7 +46,7 @@
#include <sys/systm.h>
#include <sys/types.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/select.h>
#include <machine/vmparam.h>
@@ -155,9 +155,9 @@
}
size = sizeof(struct fwdma_alloc_multi) +
sizeof(struct fwdma_seg) * nseg;
- am = (struct fwdma_alloc_multi *)malloc(size, M_FW, M_WAITOK | M_ZERO);
+ am = kmem_zalloc(size, KM_SLEEP);
if (am == NULL) {
- aprint_error_dev(fc->dev, "malloc failed\n");
+ aprint_error_dev(fc->dev, "kmem alloc failed\n");
return NULL;
}
am->ssize = ssize;
@@ -184,8 +184,11 @@
fwdma_free_multiseg(struct fwdma_alloc_multi *am)
{
struct fwdma_seg *seg;
+ int nseg;
+ nseg = am->nseg;
for (seg = am->seg; am->nseg--; seg++)
fwdma_free(am->dma_tag, seg->dma_map, seg->v_addr);
- free(am, M_FW);
+ kmem_free(am,
+ sizeof(struct fwdma_alloc_multi) + sizeof(struct fwdma_seg) * nseg);
}
Index: src/sys/dev/ieee1394/fwmem.c
diff -u src/sys/dev/ieee1394/fwmem.c:1.12 src/sys/dev/ieee1394/fwmem.c:1.13
--- src/sys/dev/ieee1394/fwmem.c:1.12 Mon Mar 29 03:05:27 2010
+++ src/sys/dev/ieee1394/fwmem.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fwmem.c,v 1.12 2010/03/29 03:05:27 kiyohara Exp $ */
+/* $NetBSD: fwmem.c,v 1.13 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2002-2003
* Hidetoshi Shimokawa. All rights reserved.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwmem.c,v 1.12 2010/03/29 03:05:27 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwmem.c,v 1.13 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -44,7 +44,7 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/sysctl.h>
#include <dev/ieee1394/firewire.h>
@@ -185,9 +185,7 @@
fms = (struct fwmem_softc *)sc->si_drv1;
fms->refcount++;
} else {
- sc->si_drv1 = (void *)-1;
- sc->si_drv1 = malloc(sizeof(struct fwmem_softc),
- M_FWMEM, M_WAITOK);
+ sc->si_drv1 = kmem_alloc(sizeof(struct fwmem_softc), KM_SLEEP);
if (sc->si_drv1 == NULL)
return ENOMEM;
fms = (struct fwmem_softc *)sc->si_drv1;
@@ -225,7 +223,7 @@
STAILQ_REMOVE_HEAD(&fms->xferlist, link);
fw_xfer_free(xfer);
}
- free(sc->si_drv1, M_FW);
+ kmem_free(sc->si_drv1, sizeof(struct fwmem_softc));
sc->si_drv1 = NULL;
}
Index: src/sys/dev/ieee1394/fwohci.c
diff -u src/sys/dev/ieee1394/fwohci.c:1.125 src/sys/dev/ieee1394/fwohci.c:1.126
--- src/sys/dev/ieee1394/fwohci.c:1.125 Thu Apr 29 06:53:13 2010
+++ src/sys/dev/ieee1394/fwohci.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: fwohci.c,v 1.125 2010/04/29 06:53:13 kiyohara Exp $ */
+/* $NetBSD: fwohci.c,v 1.126 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2003 Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
*
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.125 2010/04/29 06:53:13 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.126 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -46,7 +46,7 @@
#include <sys/errno.h>
#include <sys/conf.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/reboot.h>
@@ -1703,10 +1703,10 @@
db_tr->buf = NULL;
}
}
- dbch->ndb = 0;
db_tr = STAILQ_FIRST(&dbch->db_trq);
fwdma_free_multiseg(dbch->am);
- free(db_tr, M_FW);
+ kmem_free(db_tr, sizeof(struct fwohcidb_tr) * dbch->ndb);
+ dbch->ndb = 0;
STAILQ_INIT(&dbch->db_trq);
dbch->flags &= ~FWOHCI_DBCH_INIT;
seldestroy(&dbch->xferq.rsel);
@@ -1726,9 +1726,9 @@
/* allocate DB entries and attach one to each DMA channels */
/* DB entry must start at 16 bytes bounary. */
STAILQ_INIT(&dbch->db_trq);
- db_tr = (struct fwohcidb_tr *)malloc(db_tr_sz, M_FW, M_WAITOK | M_ZERO);
+ db_tr = kmem_zalloc(db_tr_sz, KM_SLEEP);
if (db_tr == NULL) {
- aprint_error_dev(fc->dev, "malloc(1) failed\n");
+ aprint_error_dev(fc->dev, "kmem alloc failed\n");
return;
}
@@ -1743,7 +1743,7 @@
#endif
if (dbch->am == NULL) {
aprint_error_dev(fc->dev, "fwdma_malloc_multiseg failed\n");
- free(db_tr, M_FW);
+ kmem_free(db_tr, sizeof(struct fwohcidb_tr) * dbch->ndb);
return;
}
/* Attach DB to DMA ch. */
@@ -2140,9 +2140,9 @@
return;
}
plen -= 4; /* chop control info */
- buf = (uint32_t *)malloc(OHCI_SIDSIZE, M_FW, M_NOWAIT);
+ buf = kmem_alloc(OHCI_SIDSIZE, KM_NOSLEEP);
if (buf == NULL) {
- aprint_error_dev(fc->dev, "malloc failed\n");
+ aprint_error_dev(fc->dev, "kmem alloc failed\n");
return;
}
for (i = 0; i < plen / 4; i++)
@@ -2156,7 +2156,7 @@
fw_drain_txq(fc);
#endif
fw_sidrcv(fc, buf, plen);
- free(buf, M_FW);
+ kmem_free(buf, OHCI_SIDSIZE);
}
static void
Index: src/sys/dev/ieee1394/if_fwip.c
diff -u src/sys/dev/ieee1394/if_fwip.c:1.22 src/sys/dev/ieee1394/if_fwip.c:1.23
--- src/sys/dev/ieee1394/if_fwip.c:1.22 Mon Mar 29 03:05:28 2010
+++ src/sys/dev/ieee1394/if_fwip.c Mon May 10 12:17:32 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: if_fwip.c,v 1.22 2010/03/29 03:05:28 kiyohara Exp $ */
+/* $NetBSD: if_fwip.c,v 1.23 2010/05/10 12:17:32 kiyohara Exp $ */
/*-
* Copyright (c) 2004
* Doug Rabson
@@ -38,13 +38,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.22 2010/03/29 03:05:28 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.23 2010/05/10 12:17:32 kiyohara Exp $");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/device.h>
#include <sys/errno.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/sysctl.h>
@@ -344,6 +344,8 @@
fc = sc->sc_fd.fc;
if (sc->sc_dma_ch < 0) {
+ const size_t size = sizeof(struct fw_bulkxfer) * rx_queue_len;
+
sc->sc_dma_ch = fw_open_isodma(fc, /* tx */0);
if (sc->sc_dma_ch < 0)
return ENXIO;
@@ -360,11 +362,9 @@
xferq->psize = MCLBYTES;
xferq->queued = 0;
xferq->buf = NULL;
- xferq->bulkxfer = (struct fw_bulkxfer *) malloc(
- sizeof(struct fw_bulkxfer) * xferq->bnchunk,
- M_FWIP, M_WAITOK);
+ xferq->bulkxfer = kmem_alloc(size, KM_SLEEP);
if (xferq->bulkxfer == NULL) {
- aprint_error_ifnet(ifp, "if_fwip: malloc failed\n");
+ aprint_error_ifnet(ifp, "if_fwip: kmem alloc failed\n");
return ENOMEM;
}
STAILQ_INIT(&xferq->stvalid);
@@ -455,7 +455,8 @@
for (i = 0; i < xferq->bnchunk; i++)
m_freem(xferq->bulkxfer[i].mbuf);
- free(xferq->bulkxfer, M_FWIP);
+ kmem_free(xferq->bulkxfer,
+ sizeof(struct fw_bulkxfer) * xferq->bnchunk);
fw_bindremove(fc, &sc->sc_fwb);
for (xfer = STAILQ_FIRST(&sc->sc_fwb.xferlist); xfer != NULL;