Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Change sdhc_detach so that it detaches all host cont...
details: https://anonhg.NetBSD.org/src/rev/055440f5eda4
branches: trunk
changeset: 783430:055440f5eda4
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Thu Dec 20 14:37:00 2012 +0000
description:
Change sdhc_detach so that it detaches all host controllers at once.
This should make multiple slot controllers, for example those with
a controller on more than one PCI/CardBus BAR, detach with fewer bugs.
Tested with as-of-yet-uncommited sdhc_pci changes on a single-host
ExpressCard JMicron JMB38[89].
diffstat:
sys/dev/cardbus/sdhc_cardbus.c | 6 ++--
sys/dev/sdmmc/sdhc.c | 48 ++++++++++++++++++++++++++++++-----------
sys/dev/sdmmc/sdhcvar.h | 4 +-
3 files changed, 40 insertions(+), 18 deletions(-)
diffs (131 lines):
diff -r 597aecec6b92 -r 055440f5eda4 sys/dev/cardbus/sdhc_cardbus.c
--- a/sys/dev/cardbus/sdhc_cardbus.c Thu Dec 20 14:24:11 2012 +0000
+++ b/sys/dev/cardbus/sdhc_cardbus.c Thu Dec 20 14:37:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdhc_cardbus.c,v 1.4 2012/02/02 22:49:17 nonaka Exp $ */
+/* $NetBSD: sdhc_cardbus.c,v 1.5 2012/12/20 14:37:00 jakllsch Exp $ */
/*
* Copyright (c) 2010 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc_cardbus.c,v 1.4 2012/02/02 22:49:17 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_cardbus.c,v 1.5 2012/12/20 14:37:00 jakllsch Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -191,7 +191,7 @@
struct cardbus_devfunc *ct = sc->sc_ct;
int rv;
- rv = sdhc_detach((device_t)sc->sc.sc_host[0], flags);
+ rv = sdhc_detach(&sc->sc, flags);
if (rv)
return rv;
if (sc->sc_ih != NULL) {
diff -r 597aecec6b92 -r 055440f5eda4 sys/dev/sdmmc/sdhc.c
--- a/sys/dev/sdmmc/sdhc.c Thu Dec 20 14:24:11 2012 +0000
+++ b/sys/dev/sdmmc/sdhc.c Thu Dec 20 14:37:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdhc.c,v 1.35 2012/12/13 06:43:37 riastradh Exp $ */
+/* $NetBSD: sdhc.c,v 1.36 2012/12/20 14:37:00 jakllsch Exp $ */
/* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */
/*
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.35 2012/12/13 06:43:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.36 2012/12/20 14:37:00 jakllsch Exp $");
#ifdef _KERNEL_OPT
#include "opt_sdmmc.h"
@@ -62,6 +62,7 @@
bus_space_tag_t iot; /* host register set tag */
bus_space_handle_t ioh; /* host register set handle */
+ bus_size_t ios; /* host register space size */
bus_dma_tag_t dmat; /* host DMA tag */
device_t sdmmc; /* generic SD/MMC device */
@@ -257,6 +258,7 @@
hp->sc = sc;
hp->iot = iot;
hp->ioh = ioh;
+ hp->ios = iosize;
hp->dmat = sc->sc_dmat;
mutex_init(&hp->host_mtx, MUTEX_DEFAULT, IPL_SDMMC);
@@ -430,20 +432,40 @@
}
int
-sdhc_detach(device_t dev, int flags)
+sdhc_detach(struct sdhc_softc *sc, int flags)
{
- struct sdhc_host *hp = (struct sdhc_host *)dev;
- struct sdhc_softc *sc = hp->sc;
+ struct sdhc_host *hp;
int rv = 0;
- if (hp->sdmmc)
- rv = config_detach(hp->sdmmc, flags);
-
- cv_destroy(&hp->intr_cv);
- mutex_destroy(&hp->intr_mtx);
- mutex_destroy(&hp->host_mtx);
- free(hp, M_DEVBUF);
- sc->sc_host[--sc->sc_nhosts] = NULL;
+ for (size_t n = 0; n < sc->sc_nhosts; n++) {
+ hp = sc->sc_host[n];
+ if (hp == NULL)
+ continue;
+ if (hp->sdmmc != NULL) {
+ rv = config_detach(hp->sdmmc, flags);
+ if (rv)
+ break;
+ hp->sdmmc = NULL;
+ }
+ /* disable interrupts */
+ if ((flags & DETACH_FORCE) == 0) {
+ if (ISSET(hp->sc->sc_flags, SDHC_FLAG_32BIT_ACCESS)) {
+ HWRITE4(hp, SDHC_NINTR_SIGNAL_EN, 0);
+ } else {
+ HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, 0);
+ }
+ sdhc_soft_reset(hp, SDHC_RESET_ALL);
+ }
+ cv_destroy(&hp->intr_cv);
+ mutex_destroy(&hp->intr_mtx);
+ mutex_destroy(&hp->host_mtx);
+ if (hp->ios > 0) {
+ bus_space_unmap(hp->iot, hp->ioh, hp->ios);
+ hp->ios = 0;
+ }
+ free(hp, M_DEVBUF);
+ sc->sc_host[n] = NULL;
+ }
return rv;
}
diff -r 597aecec6b92 -r 055440f5eda4 sys/dev/sdmmc/sdhcvar.h
--- a/sys/dev/sdmmc/sdhcvar.h Thu Dec 20 14:24:11 2012 +0000
+++ b/sys/dev/sdmmc/sdhcvar.h Thu Dec 20 14:37:00 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdhcvar.h,v 1.11 2012/12/13 06:43:37 riastradh Exp $ */
+/* $NetBSD: sdhcvar.h,v 1.12 2012/12/20 14:37:00 jakllsch Exp $ */
/* $OpenBSD: sdhcvar.h,v 1.3 2007/09/06 08:01:01 jsg Exp $ */
/*
@@ -63,7 +63,7 @@
int sdhc_host_found(struct sdhc_softc *, bus_space_tag_t,
bus_space_handle_t, bus_size_t);
int sdhc_intr(void *);
-int sdhc_detach(device_t, int);
+int sdhc_detach(struct sdhc_softc *, int);
bool sdhc_suspend(device_t, const pmf_qual_t *);
bool sdhc_resume(device_t, const pmf_qual_t *);
bool sdhc_shutdown(device_t, int);
Home |
Main Index |
Thread Index |
Old Index