Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/dev/spi Pull up following revision(s) (requested by 1...
details: https://anonhg.NetBSD.org/src/rev/ca1271bdf6f2
branches: netbsd-9
changeset: 937215:ca1271bdf6f2
user: martin <martin%NetBSD.org@localhost>
date: Tue Aug 11 19:13:43 2020 +0000
description:
Pull up following revision(s) (requested by 1043):
sys/dev/spi/spivar.h: revision 1.10
sys/arch/arm/broadcom/bcm2835_spi.c: revision 1.7
sys/dev/spi/spi.c: revision 1.15
Use mutex for lwp/interrupt coordination. using splX() simply does not work
on multiprocessor systems.
fixes PR kern/55506
diffstat:
sys/arch/arm/broadcom/bcm2835_spi.c | 17 ++++++++++-------
sys/dev/spi/spi.c | 8 ++++----
sys/dev/spi/spivar.h | 4 ++--
3 files changed, 16 insertions(+), 13 deletions(-)
diffs (136 lines):
diff -r 22cbd61b8b04 -r ca1271bdf6f2 sys/arch/arm/broadcom/bcm2835_spi.c
--- a/sys/arch/arm/broadcom/bcm2835_spi.c Tue Aug 11 19:12:33 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_spi.c Tue Aug 11 19:13:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_spi.c,v 1.5 2017/12/10 21:38:26 skrll Exp $ */
+/* $NetBSD: bcm2835_spi.c,v 1.5.8.1 2020/08/11 19:13:43 martin Exp $ */
/*
* Copyright (c) 2012 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.5 2017/12/10 21:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_spi.c,v 1.5.8.1 2020/08/11 19:13:43 martin Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -53,6 +53,7 @@
bus_space_handle_t sc_ioh;
void *sc_intrh;
struct spi_controller sc_spi;
+ kmutex_t sc_mutex;
SIMPLEQ_HEAD(,spi_transfer) sc_q;
struct spi_transfer *sc_transfer;
struct spi_chunk *sc_wchunk;
@@ -131,6 +132,7 @@
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
sc->sc_spi.sct_cookie = sc;
+ mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_VM);
sc->sc_spi.sct_configure = bcmspi_configure;
sc->sc_spi.sct_transfer = bcmspi_transfer;
sc->sc_spi.sct_nslaves = 3;
@@ -188,14 +190,13 @@
bcmspi_transfer(void *cookie, struct spi_transfer *st)
{
struct bcmspi_softc * const sc = cookie;
- int s;
- s = splbio();
+ mutex_enter(&sc->sc_mutex);
spi_transq_enqueue(&sc->sc_q, st);
if (sc->sc_running == false) {
bcmspi_start(sc);
}
- splx(s);
+ mutex_exit(&sc->sc_mutex);
return 0;
}
@@ -225,13 +226,13 @@
if (!cold)
return;
- int s = splbio();
for (;;) {
+ mutex_exit(&sc->sc_mutex);
bcmspi_intr(sc);
+ mutex_enter(&sc->sc_mutex);
if (ISSET(st->st_flags, SPI_F_DONE))
break;
}
- splx(s);
}
sc->sc_running = false;
@@ -290,6 +291,7 @@
struct spi_transfer *st;
uint32_t cs;
+ mutex_enter(&sc->sc_mutex);
cs = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SPI_CS);
if (ISSET(cs, SPI_CS_DONE)) {
if (sc->sc_wchunk != NULL) {
@@ -313,5 +315,6 @@
}
end:
+ mutex_exit(&sc->sc_mutex);
return ISSET(cs, SPI_CS_DONE|SPI_CS_RXR);
}
diff -r 22cbd61b8b04 -r ca1271bdf6f2 sys/dev/spi/spi.c
--- a/sys/dev/spi/spi.c Tue Aug 11 19:12:33 2020 +0000
+++ b/sys/dev/spi/spi.c Tue Aug 11 19:13:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spi.c,v 1.11 2019/03/09 07:53:12 mlelstv Exp $ */
+/* $NetBSD: spi.c,v 1.11.4.1 2020/08/11 19:13:43 martin 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.11 2019/03/09 07:53:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.11.4.1 2020/08/11 19:13:43 martin Exp $");
#include "locators.h"
@@ -175,7 +175,7 @@
aprint_naive(": SPI bus\n");
aprint_normal(": SPI bus\n");
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_BIO);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
cv_init(&sc->sc_cv, "spictl");
sc->sc_controller = *sba->sba_controller;
@@ -349,7 +349,7 @@
spi_transfer_init(struct spi_transfer *st)
{
- mutex_init(&st->st_lock, MUTEX_DEFAULT, IPL_BIO);
+ mutex_init(&st->st_lock, MUTEX_DEFAULT, IPL_VM);
cv_init(&st->st_cv, "spixfr");
st->st_flags = 0;
diff -r 22cbd61b8b04 -r ca1271bdf6f2 sys/dev/spi/spivar.h
--- a/sys/dev/spi/spivar.h Tue Aug 11 19:12:33 2020 +0000
+++ b/sys/dev/spi/spivar.h Tue Aug 11 19:13:43 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spivar.h,v 1.7 2019/02/23 10:43:25 mlelstv Exp $ */
+/* $NetBSD: spivar.h,v 1.7.4.1 2020/08/11 19:13:43 martin Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -103,7 +103,7 @@
struct spi_transfer {
struct spi_chunk *st_chunks; /* chained bufs */
SIMPLEQ_ENTRY(spi_transfer) st_chain; /* chain of submitted jobs */
- int st_flags;
+ volatile int st_flags;
int st_errno;
int st_slave;
void *st_private;
Home |
Main Index |
Thread Index |
Old Index