Source-Changes-HG archive

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

[src/trunk]: src/sys - Use IPL_BIO (instead of IPL_SERIAL) for SPI.



details:   https://anonhg.NetBSD.org/src/rev/c2f234bc2a27
branches:  trunk
changeset: 765884:c2f234bc2a27
user:      rmind <rmind%NetBSD.org@localhost>
date:      Wed Jun 08 23:05:48 2011 +0000

description:
- Use IPL_BIO (instead of IPL_SERIAL) for SPI.
- Convert simple_lock/ltsleep to mutex/condvar.

diffstat:

 sys/arch/mips/alchemy/dev/auspi.c |   8 ++++----
 sys/arch/mips/atheros/dev/arspi.c |   8 ++++----
 sys/dev/spi/spi.c                 |  35 +++++++++++++++--------------------
 sys/dev/spi/spivar.h              |   5 +++--
 4 files changed, 26 insertions(+), 30 deletions(-)

diffs (192 lines):

diff -r fc24c831eb4f -r c2f234bc2a27 sys/arch/mips/alchemy/dev/auspi.c
--- a/sys/arch/mips/alchemy/dev/auspi.c Wed Jun 08 22:43:10 2011 +0000
+++ b/sys/arch/mips/alchemy/dev/auspi.c Wed Jun 08 23:05:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auspi.c,v 1.3 2007/02/28 04:21:53 thorpej Exp $ */
+/* $NetBSD: auspi.c,v 1.4 2011/06/08 23:05:48 rmind Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.3 2007/02/28 04:21:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auspi.c,v 1.4 2011/06/08 23:05:48 rmind Exp $");
 
 #include "locators.h"
 
@@ -158,7 +158,7 @@
        PUTREG(sc, AUPSC_SPIMSK, SPIMSK_ALL);
 
        /* enable device interrupts */
-       sc->sc_ih = au_intr_establish(aa->aupsc_irq, 0, IPL_SERIAL, IST_LEVEL,
+       sc->sc_ih = au_intr_establish(aa->aupsc_irq, 0, IPL_BIO, IST_LEVEL,
            auspi_intr, sc);
 
        (void) config_found_ia(&sc->sc_dev, "spibus", &sba, spibus_print);
@@ -428,7 +428,7 @@
        int                     s;
 
        /* make sure we select the right chip */
-       s = splserial();
+       s = splbio();
        spi_transq_enqueue(&sc->sc_q, st);
        if (sc->sc_running == 0) {
                auspi_sched(sc);
diff -r fc24c831eb4f -r c2f234bc2a27 sys/arch/mips/atheros/dev/arspi.c
--- a/sys/arch/mips/atheros/dev/arspi.c Wed Jun 08 22:43:10 2011 +0000
+++ b/sys/arch/mips/atheros/dev/arspi.c Wed Jun 08 23:05:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arspi.c,v 1.5 2007/02/28 04:21:53 thorpej Exp $ */
+/* $NetBSD: arspi.c,v 1.6 2011/06/08 23:05:48 rmind Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.5 2007/02/28 04:21:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arspi.c,v 1.6 2011/06/08 23:05:48 rmind Exp $");
 
 #include "locators.h"
 
@@ -211,7 +211,7 @@
        struct arspi_softc *sc = device_private(self);
        int     s;
 
-       s = splserial();
+       s = splbio();
        sc->sc_interrupts = true;
        splx(s);
 #endif
@@ -270,7 +270,7 @@
                return rv;
        }
 
-       s = splserial();
+       s = splbio();
        spi_transq_enqueue(&sc->sc_transq, st);
        if (sc->sc_transfer == NULL) {
                arspi_sched(sc);
diff -r fc24c831eb4f -r c2f234bc2a27 sys/dev/spi/spi.c
--- a/sys/dev/spi/spi.c Wed Jun 08 22:43:10 2011 +0000
+++ b/sys/dev/spi/spi.c Wed Jun 08 23:05:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spi.c,v 1.4 2010/08/14 20:49:21 jym Exp $ */
+/* $NetBSD: spi.c,v 1.5 2011/06/08 23:05:48 rmind Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.4 2010/08/14 20:49:21 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.5 2011/06/08 23:05:48 rmind Exp $");
 
 #include "locators.h"
 
@@ -50,7 +50,8 @@
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
-#include <sys/proc.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
 #include <sys/errno.h>
 
 #include <dev/spi/spivar.h>
@@ -90,7 +91,7 @@
 static int
 spi_match(device_t parent, cfdata_t cf, void *aux)
 {
-       
+
        return 1;
 }
 
@@ -188,7 +189,7 @@
        if ((sc->sc_mode >= 0) && (sc->sc_mode != mode))
                return EINVAL;
 
-       s = splserial();
+       s = splbio();
        /* pick lowest configured speed */
        if (speed == 0)
                speed = sc->sc_speed;
@@ -210,7 +211,9 @@
 spi_transfer_init(struct spi_transfer *st)
 {
 
-       simple_lock_init(&st->st_lock);
+       mutex_init(&st->st_lock, MUTEX_DEFAULT, IPL_BIO);
+       cv_init(&st->st_cv, "spicv");
+
        st->st_flags = 0;
        st->st_errno = 0;
        st->st_done = NULL;
@@ -267,24 +270,19 @@
 void
 spi_wait(struct spi_transfer *st)
 {
-       int     s;
 
-       s = splserial();
-       simple_lock(&st->st_lock);
+       mutex_enter(&st->st_lock);
        while (!(st->st_flags & SPI_F_DONE)) {
-               ltsleep(st, PWAIT, "spi_wait", 0, &st->st_lock);
+               cv_wait(&st->st_cv, &st->st_lock);
        }
-       simple_unlock(&st->st_lock);
-       splx(s);
+       mutex_exit(&st->st_lock);
 }
 
 void
 spi_done(struct spi_transfer *st, int err)
 {
-       int     s;
 
-       s = splserial();
-       
+       mutex_enter(&st->st_lock);
        if ((st->st_errno = err) != 0) {
                st->st_flags |= SPI_F_ERROR;
        }
@@ -292,12 +290,9 @@
        if (st->st_done != NULL) {
                (*st->st_done)(st);
        } else {
-
-               simple_lock(&st->st_lock);
-               wakeup(st);
-               simple_unlock(&st->st_lock);
+               cv_broadcast(&st->st_cv);
        }
-       splx(s);
+       mutex_exit(&st->st_lock);
 }
 
 /*
diff -r fc24c831eb4f -r c2f234bc2a27 sys/dev/spi/spivar.h
--- a/sys/dev/spi/spivar.h      Wed Jun 08 22:43:10 2011 +0000
+++ b/sys/dev/spi/spivar.h      Wed Jun 08 23:05:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spivar.h,v 1.3 2008/01/08 13:28:22 dogcow Exp $ */
+/* $NetBSD: spivar.h,v 1.4 2011/06/08 23:05:48 rmind Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -109,7 +109,8 @@
        int             st_slave;
        void            *st_private;
        void            (*st_done)(struct spi_transfer *);
-       struct simplelock       st_lock;
+       kmutex_t        st_lock;
+       kcondvar_t      st_cv;
        void            *st_busprivate;
 };
 



Home | Main Index | Thread Index | Old Index