Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic use STAILQ for ccb lists to save some memory, dou...



details:   https://anonhg.NetBSD.org/src/rev/d0296f4b094d
branches:  trunk
changeset: 935957:d0296f4b094d
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Jul 14 11:39:02 2020 +0000

description:
use STAILQ for ccb lists to save some memory, doubly-linked list is not needed

diffstat:

 sys/dev/ic/ciss.c    |  42 +++++++++++++++++++++---------------------
 sys/dev/ic/cissreg.h |   6 +++---
 2 files changed, 24 insertions(+), 24 deletions(-)

diffs (167 lines):

diff -r cece911de089 -r d0296f4b094d sys/dev/ic/ciss.c
--- a/sys/dev/ic/ciss.c Tue Jul 14 10:49:21 2020 +0000
+++ b/sys/dev/ic/ciss.c Tue Jul 14 11:39:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ciss.c,v 1.46 2020/07/14 10:44:34 jdolecek Exp $       */
+/*     $NetBSD: ciss.c,v 1.47 2020/07/14 11:39:02 jdolecek Exp $       */
 /*     $OpenBSD: ciss.c,v 1.68 2013/05/30 16:15:02 deraadt Exp $       */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.46 2020/07/14 10:44:34 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.47 2020/07/14 11:39:02 jdolecek Exp $");
 
 #include "bio.h"
 
@@ -109,8 +109,8 @@
        struct ciss_ccb *ccb;
 
        mutex_enter(&sc->sc_mutex);
-       if ((ccb = TAILQ_LAST(&sc->sc_free_ccb, ciss_queue_head))) {
-               TAILQ_REMOVE(&sc->sc_free_ccb, ccb, ccb_link);
+       if ((ccb = STAILQ_FIRST(&sc->sc_free_ccb))) {
+               STAILQ_REMOVE_HEAD(&sc->sc_free_ccb, ccb_link);
                ccb->ccb_state = CISS_CCB_READY;
        }
        mutex_exit(&sc->sc_mutex);
@@ -124,7 +124,7 @@
 
        ccb->ccb_state = CISS_CCB_FREE;
        mutex_enter(&sc->sc_mutex);
-       TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, ccb_link);
+       STAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, ccb_link);
        mutex_exit(&sc->sc_mutex);
 }
 
@@ -346,7 +346,7 @@
                return -1;
        }
 
-       TAILQ_INIT(&sc->sc_free_ccb);
+       STAILQ_INIT(&sc->sc_free_ccb);
 
        maxfer = sc->maxsg * PAGE_SIZE;
        for (i = 0; total > 0 && i < sc->maxcmd; i++, total -= sc->ccblen) {
@@ -371,7 +371,7 @@
                    &ccb->ccb_dmamap)))
                        break;
 
-               TAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, ccb_link);
+               STAILQ_INSERT_TAIL(&sc->sc_free_ccb, ccb, ccb_link);
        }
 
        if (i < sc->maxcmd) {
@@ -544,7 +544,7 @@
        ccb = (struct ciss_ccb *) ((char *)sc->ccbs + (id >> 2) * sc->ccblen);
        ccb->ccb_cmd.id = htole32(id);
        ccb->ccb_cmd.id_hi = htole32(0);
-       TAILQ_INSERT_TAIL(q, ccb, ccb_link);
+       STAILQ_INSERT_TAIL(q, ccb, ccb_link);
 }
 
 static void
@@ -614,7 +614,7 @@
        ciss_queue_head q;
        struct ciss_ccb *ccb1;
 
-       TAILQ_INIT(&q);
+       STAILQ_INIT(&q);
        ms /= 10;
 
        while (ms-- > 0) {
@@ -626,14 +626,14 @@
                        ciss_completed_simple(sc, &q);
                mutex_exit(&sc->sc_mutex);
 
-               while (!TAILQ_EMPTY(&q)) {
-                       ccb1 = TAILQ_FIRST(&q);
-                       TAILQ_REMOVE(&q, ccb1, ccb_link);
+               while (!STAILQ_EMPTY(&q)) {
+                       ccb1 = STAILQ_FIRST(&q);
+                       STAILQ_REMOVE_HEAD(&q, ccb_link);
 
                        KASSERT(ccb1->ccb_state == CISS_CCB_ONQ);
                        ciss_done(ccb1);
                        if (ccb1 == ccb) {
-                               KASSERT(TAILQ_EMPTY(&q));
+                               KASSERT(STAILQ_EMPTY(&q));
                                return 0;
                        }
                }
@@ -1264,9 +1264,9 @@
 {
        struct ciss_ccb *ccb;
 
-       while (!TAILQ_EMPTY(q)) {
-               ccb = TAILQ_FIRST(q);
-               TAILQ_REMOVE(q, ccb, ccb_link);
+       while (!STAILQ_EMPTY(q)) {
+               ccb = STAILQ_FIRST(q);
+               STAILQ_REMOVE_HEAD(q, ccb_link);
 
                if (ccb->ccb_state == CISS_CCB_POLL) {
                        ccb->ccb_state = CISS_CCB_ONQ;
@@ -1291,15 +1291,15 @@
        if (!(bus_space_read_4(sc->sc_iot, sc->sc_ioh, CISS_ISR) & sc->iem))
                return 0;
 
-       TAILQ_INIT(&q);
+       STAILQ_INIT(&q);
        mutex_enter(&sc->sc_mutex);
        ciss_completed_simple(sc, &q);
        mutex_exit(&sc->sc_mutex);
 
-       hit = (!TAILQ_EMPTY(&q));
+       hit = (!STAILQ_EMPTY(&q));
        ciss_completed_process(sc, &q);
 
-       KASSERT(TAILQ_EMPTY(&q));
+       KASSERT(STAILQ_EMPTY(&q));
        CISS_DPRINTF(CISS_D_INTR, ("exit\n"));
 
        return hit;
@@ -1329,14 +1329,14 @@
 
        CISS_DPRINTF(CISS_D_INTR, ("intr "));
 
-       TAILQ_INIT(&q);
+       STAILQ_INIT(&q);
        mutex_enter(&sc->sc_mutex);
        ciss_completed_perf(sc, &q);
        mutex_exit(&sc->sc_mutex);
 
        ciss_completed_process(sc, &q);
 
-       KASSERT(TAILQ_EMPTY(&q));
+       KASSERT(STAILQ_EMPTY(&q));
        CISS_DPRINTF(CISS_D_INTR, ("exit"));
 
        return 1;
diff -r cece911de089 -r d0296f4b094d sys/dev/ic/cissreg.h
--- a/sys/dev/ic/cissreg.h      Tue Jul 14 10:49:21 2020 +0000
+++ b/sys/dev/ic/cissreg.h      Tue Jul 14 11:39:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cissreg.h,v 1.6 2020/07/14 10:37:30 jdolecek Exp $     */
+/*     $NetBSD: cissreg.h,v 1.7 2020/07/14 11:39:02 jdolecek Exp $     */
 /*     $OpenBSD: cissreg.h,v 1.11 2010/06/03 01:02:13 dlg Exp $        */
 
 /*
@@ -516,7 +516,7 @@
 } __packed;
 
 struct ciss_ccb {
-       TAILQ_ENTRY(ciss_ccb)   ccb_link;
+       STAILQ_ENTRY(ciss_ccb)  ccb_link;
        struct ciss_softc       *ccb_sc;
        paddr_t                 ccb_cmdpa;
        enum {
@@ -539,5 +539,5 @@
        struct ciss_cmd         ccb_cmd __aligned(8);   /* followed by sgl */
 };
 
-typedef TAILQ_HEAD(ciss_queue_head, ciss_ccb)     ciss_queue_head;
+typedef STAILQ_HEAD(ciss_queue_head, ciss_ccb)     ciss_queue_head;
 



Home | Main Index | Thread Index | Old Index