Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ieee1394 Revert all previous kmem_ commits. This nee...



details:   https://anonhg.NetBSD.org/src/rev/af46b0aa46e5
branches:  trunk
changeset: 755133:af46b0aa46e5
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 23 18:56:58 2010 +0000

description:
Revert all previous kmem_ commits. This needs to be done in a different way
because we cannot call kmem_ from an interrupt context. I opened PR/43341 for
it.

diffstat:

 sys/dev/ieee1394/firewire.c    |  90 ++++++++++++++++++++++-------------------
 sys/dev/ieee1394/firewirereg.h |   3 +-
 sys/dev/ieee1394/fwdev.c       |  33 +++++++-------
 sys/dev/ieee1394/fwdma.c       |  15 ++----
 sys/dev/ieee1394/fwmem.c       |  12 +++--
 sys/dev/ieee1394/fwohci.c      |  31 +++++++-------
 sys/dev/ieee1394/fwohcivar.h   |   3 +-
 sys/dev/ieee1394/if_fwip.c     |  17 +++----
 sys/dev/ieee1394/sbp.c         |  37 ++++++++--------
 9 files changed, 123 insertions(+), 118 deletions(-)

diffs (truncated from 818 to 300 lines):

diff -r 80dfaec8aa4d -r af46b0aa46e5 sys/dev/ieee1394/firewire.c
--- a/sys/dev/ieee1394/firewire.c       Sun May 23 18:49:14 2010 +0000
+++ b/sys/dev/ieee1394/firewire.c       Sun May 23 18:56:58 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewire.c,v 1.34 2010/05/23 02:24:40 christos Exp $   */
+/*     $NetBSD: firewire.c,v 1.35 2010/05/23 18:56:58 christos 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.34 2010/05/23 02:24:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firewire.c,v 1.35 2010/05/23 18:56:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -48,8 +48,7 @@
 #include <sys/errno.h>
 #include <sys/kernel.h>
 #include <sys/kthread.h>
-#include <sys/kmem.h>
-#include <sys/mutex.h>
+#include <sys/malloc.h>
 #include <sys/queue.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
@@ -218,24 +217,28 @@
        if (fc->nisodma > FWMAXNDMA)
            fc->nisodma = FWMAXNDMA;
 
-       fc->crom_src_buf = kmem_zalloc(sizeof(struct crom_src_buf), KM_NOSLEEP);
+       fc->crom_src_buf =
+           (struct crom_src_buf *)malloc(sizeof(struct crom_src_buf),
+           M_FW, M_NOWAIT | M_ZERO);
        if (fc->crom_src_buf == NULL) {
-               aprint_error_dev(fc->bdev,
-                   "kmem alloc failure crom src buff\n");
+               aprint_error_dev(fc->bdev, "Malloc Failure crom src buff\n");
                return;
        }
        fc->topology_map =
-           kmem_zalloc(sizeof(struct fw_topology_map), KM_NOSLEEP);
+           (struct fw_topology_map *)malloc(sizeof(struct fw_topology_map),
+           M_FW, M_NOWAIT | M_ZERO);
        if (fc->topology_map == NULL) {
                aprint_error_dev(fc->dev, "Malloc Failure topology map\n");
-               kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
+               free(fc->crom_src_buf, M_FW);
                return;
        }
-       fc->speed_map = kmem_zalloc(sizeof(struct fw_speed_map), KM_NOSLEEP);
+       fc->speed_map =
+           (struct fw_speed_map *)malloc(sizeof(struct fw_speed_map),
+           M_FW, M_NOWAIT | M_ZERO);
        if (fc->speed_map == NULL) {
                aprint_error_dev(fc->dev, "Malloc Failure speed map\n");
-               kmem_free(fc->crom_src_buf, sizeof(struct crom_src_buf));
-               kmem_free(fc->topology_map, sizeof(struct fw_topology_map));
+               free(fc->crom_src_buf, M_FW);
+               free(fc->topology_map, M_FW);
                return;
        }
 
@@ -259,7 +262,7 @@
                aprint_error_dev(self, "kthread_create failed\n");
        config_pending_incr();
 
-       devlist = kmem_alloc(sizeof(struct firewire_dev_list), KM_NOSLEEP);
+       devlist = malloc(sizeof(struct firewire_dev_list), M_DEVBUF, M_NOWAIT);
        if (devlist == NULL) {
                aprint_error_dev(self, "device list allocation failed\n");
                return;
@@ -270,7 +273,7 @@
        faa.fwdev = NULL;
        devlist->dev = config_found(sc->dev, &faa, firewire_print);
        if (devlist->dev == NULL)
-               kmem_free(devlist, sizeof(struct firewire_dev_list));
+               free(devlist, M_DEVBUF);
        else
                SLIST_INSERT_HEAD(&sc->devlist, devlist, link);
 
@@ -312,7 +315,7 @@
                if ((err = config_detach(devlist->dev, flags)) != 0)
                        return err;
                SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list, link);
-               kmem_free(devlist, sizeof(struct firewire_dev_list));
+               free(devlist, M_DEVBUF);
        }
 
        callout_stop(&fc->timeout_callout);
@@ -323,11 +326,11 @@
        for (fwdev = STAILQ_FIRST(&fc->devices); fwdev != NULL;
            fwdev = fwdev_next) {
                fwdev_next = STAILQ_NEXT(fwdev, link);
-               kmem_free(fwdev, sizeof(struct fw_device));
+               free(fwdev, 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));
+       free(fc->topology_map, M_FW);
+       free(fc->speed_map, M_FW);
+       free(fc->crom_src_buf, M_FW);
 
        cv_destroy(&fc->fc_cv);
        mutex_destroy(&fc->wait_lock);
@@ -548,6 +551,7 @@
        struct firewire_dev_list *devlist;
        struct firewire_dev_comm *fdc;
        struct crom_src *src;
+       uint32_t *newrom;
 
        if (fc->status == FWBUSMGRELECT)
                callout_stop(&fc->bmr_callout);
@@ -582,13 +586,15 @@
         * Configuration ROM.
         */
 #define FW_MAX_GENERATION      0xF
+       newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO);
        src = &fc->crom_src_buf->src;
-       crom_load(src, fc->new_rom, CROMSIZE);
-       if (memcmp(fc->new_rom, fc->config_rom, CROMSIZE) != 0) {
+       crom_load(src, newrom, CROMSIZE);
+       if (memcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
                if (src->businfo.generation++ > FW_MAX_GENERATION)
                        src->businfo.generation = FW_GENERATION_CHANGEABLE;
-               memcpy(fc->config_rom, fc->new_rom, CROMSIZE);
+               memcpy((void *)fc->config_rom, newrom, CROMSIZE);
        }
+       free(newrom, M_FW);
 }
 
 /* Call once after reboot */
@@ -804,7 +810,7 @@
 {
        struct fw_xfer *xfer;
 
-       xfer = kmem_zalloc(sizeof(struct fw_xfer), KM_NOSLEEP);
+       xfer = malloc(sizeof(struct fw_xfer), type, M_NOWAIT | M_ZERO);
        if (xfer == NULL)
                return xfer;
 
@@ -825,17 +831,17 @@
        xfer->send.pay_len = send_len;
        xfer->recv.pay_len = recv_len;
        if (send_len > 0) {
-               xfer->send.payload = kmem_zalloc(send_len, KM_NOSLEEP);
+               xfer->send.payload = malloc(send_len, type, M_NOWAIT | M_ZERO);
                if (xfer->send.payload == NULL) {
                        fw_xfer_free(xfer);
                        return NULL;
                }
        }
        if (recv_len > 0) {
-               xfer->recv.payload = kmem_alloc(recv_len, KM_NOSLEEP);
+               xfer->recv.payload = malloc(recv_len, type, M_NOWAIT);
                if (xfer->recv.payload == NULL) {
                        if (xfer->send.payload != NULL)
-                               kmem_free(xfer->send.payload, send_len);
+                               free(xfer->send.payload, type);
                        fw_xfer_free(xfer);
                        return NULL;
                }
@@ -906,7 +912,7 @@
        }
        fw_xfer_unload(xfer);
        cv_destroy(&xfer->cv);
-       kmem_free(xfer, sizeof(struct fw_xfer));
+       free(xfer, xfer->malloc);
 }
 
 void
@@ -918,12 +924,14 @@
                return;
        }
        fw_xfer_unload(xfer);
-       if (xfer->send.pay_len > 0)
-               kmem_free(xfer->send.payload, xfer->send.pay_len);
-       if (xfer->recv.pay_len > 0)
-               kmem_free(xfer->recv.payload, xfer->recv.pay_len);
+       if (xfer->send.payload != NULL) {
+               free(xfer->send.payload, xfer->malloc);
+       }
+       if (xfer->recv.payload != NULL) {
+               free(xfer->recv.payload, xfer->malloc);
+       }
        cv_destroy(&xfer->cv);
-       kmem_free(xfer, sizeof(struct fw_xfer));
+       free(xfer, xfer->malloc);
 }
 
 void
@@ -1761,7 +1769,8 @@
        mutex_exit(&fc->fc_mtx);
        if (fwdev == NULL) {
                /* new device */
-               fwdev = kmem_zalloc(sizeof(struct fw_device), KM_NOSLEEP);
+               fwdev =
+                   malloc(sizeof(struct fw_device), M_FW, M_NOWAIT | M_ZERO);
                if (fwdev == NULL) {
                        if (firewire_debug)
                                printf("node%d: no memory\n", node);
@@ -1878,7 +1887,7 @@
        char nodes[63];
 
        todo = 0;
-       dfwdev = kmem_alloc(sizeof(struct fw_device), KM_NOSLEEP);
+       dfwdev = malloc(sizeof(*dfwdev), M_TEMP, M_NOWAIT);
        if (dfwdev == NULL)
                return;
        /* setup dummy fwdev */
@@ -1919,7 +1928,7 @@
                }
                todo = todo2;
        }
-       kmem_free(dfwdev, sizeof(struct fw_device));
+       free(dfwdev, M_TEMP);
 }
 
 static void
@@ -1973,8 +1982,8 @@
                mutex_exit(&fc->fc_mtx);
                switch (fwdev->status) {
                case FWDEVNEW:
-                       devlist = kmem_alloc(sizeof(struct firewire_dev_list),
-                           KM_NOSLEEP);
+                       devlist = malloc(sizeof(struct firewire_dev_list),
+                           M_DEVBUF, M_NOWAIT);
                        if (devlist == NULL) {
                                aprint_error_dev(fc->bdev,
                                    "memory allocation failed\n");
@@ -1988,8 +1997,7 @@
                        fwdev->sbp = config_found_sm_loc(sc->dev, "ieee1394if",
                            locs, &fwa, firewire_print, config_stdsubmatch);
                        if (fwdev->sbp == NULL) {
-                               kmem_free(devlist,
-                                   sizeof(struct firewire_dev_list));
+                               free(devlist, M_DEVBUF);
                                break;
                        }
 
@@ -2050,13 +2058,13 @@
 
                        SLIST_REMOVE(&sc->devlist, devlist, firewire_dev_list,
                            link);
-                       kmem_free(devlist, sizeof(struct firewire_dev_list));
+                       free(devlist, M_DEVBUF);
 
                        if (config_detach(fwdev->sbp, DETACH_FORCE) != 0)
                                return;
 
                        STAILQ_REMOVE(&fc->devices, fwdev, fw_device, link);
-                       kmem_free(fwdev, sizeof(struct fw_device));
+                       free(fwdev, M_FW);
                }
        }
 
diff -r 80dfaec8aa4d -r af46b0aa46e5 sys/dev/ieee1394/firewirereg.h
--- a/sys/dev/ieee1394/firewirereg.h    Sun May 23 18:49:14 2010 +0000
+++ b/sys/dev/ieee1394/firewirereg.h    Sun May 23 18:56:58 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: firewirereg.h,v 1.12 2010/05/23 02:24:40 christos Exp $        */
+/*     $NetBSD: firewirereg.h,v 1.13 2010/05/23 18:56:58 christos Exp $        */
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -141,7 +141,6 @@
        uint32_t csr_arc[CSRSIZE/4];
 #define CROMSIZE 0x400
        uint32_t *config_rom;
-       uint32_t *new_rom;
        struct crom_src_buf *crom_src_buf;
        struct crom_src *crom_src;
        struct crom_chunk *crom_root;
diff -r 80dfaec8aa4d -r af46b0aa46e5 sys/dev/ieee1394/fwdev.c
--- a/sys/dev/ieee1394/fwdev.c  Sun May 23 18:49:14 2010 +0000
+++ b/sys/dev/ieee1394/fwdev.c  Sun May 23 18:56:58 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwdev.c,v 1.21 2010/05/14 12:10:07 kiyohara Exp $      */
+/*     $NetBSD: fwdev.c,v 1.22 2010/05/23 18:56:58 christos 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.21 2010/05/14 12:10:07 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwdev.c,v 1.22 2010/05/23 18:56:58 christos 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/kmem.h>
+#include <sys/malloc.h>



Home | Main Index | Thread Index | Old Index