summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2013-03-28 20:03:20 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2013-03-28 20:03:20 +0000
commit3b41eff1237871026ed211c497d0b0c7897f72f2 (patch)
tree78f6c4de27e9535477821fcb79721be3de4e4acd
parent153c2380c137c1ae7f71d5ff68582a21a1f100a1 (diff)
Prevent a panic during rtsx(4) attachment. If a card is inserted while booting
the interrupt handler can be triggered before sdmmc(4) is attached. In which case the interrupt handler's futile attempt to handle the newly inserted card would crash the kernel. ok miod@
-rw-r--r--sys/dev/ic/rtsx.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/dev/ic/rtsx.c b/sys/dev/ic/rtsx.c
index cf8d3973f6d..cb5b0eca72a 100644
--- a/sys/dev/ic/rtsx.c
+++ b/sys/dev/ic/rtsx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsx.c,v 1.2 2012/12/07 22:18:56 stsp Exp $ */
+/* $OpenBSD: rtsx.c,v 1.3 2013/03/28 20:03:19 stsp Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -215,10 +215,6 @@ rtsx_init(struct rtsx_softc *sc, int attaching)
{
u_int32_t status;
- /* Enable interrupts. */
- WRITE4(sc, RTSX_BIER,
- RTSX_TRANS_OK_INT_EN | RTSX_TRANS_FAIL_INT_EN | RTSX_SD_INT_EN);
-
/* Enable interrupt write-clear (default is read-clear). */
RTSX_CLR(sc, RTSX_NFTS_TX_CTRL, RTSX_INT_READ_CLR);
@@ -226,6 +222,14 @@ rtsx_init(struct rtsx_softc *sc, int attaching)
status = READ4(sc, RTSX_BIPR);
WRITE4(sc, RTSX_BIPR, status);
+ /* Check for cards already inserted at attach time. */
+ if (attaching && (status & RTSX_SD_EXIST))
+ sc->flags |= RTSX_F_CARD_PRESENT;
+
+ /* Enable interrupts. */
+ WRITE4(sc, RTSX_BIER,
+ RTSX_TRANS_OK_INT_EN | RTSX_TRANS_FAIL_INT_EN | RTSX_SD_INT_EN);
+
/* Power on SSC clock. */
RTSX_CLR(sc, RTSX_FPDCTL, RTSX_SSC_POWER_DOWN);
delay(200);
@@ -268,10 +272,6 @@ rtsx_init(struct rtsx_softc *sc, int attaching)
RTSX_WRITE(sc, RTSX_CARD_GPIO, 0x03);
RTSX_WRITE(sc, RTSX_CARD_GPIO_DIR, 0x03);
- /* Check for cards already inserted at attach time. */
- if (attaching && (status & RTSX_SD_EXIST))
- sc->flags |= RTSX_F_CARD_PRESENT;
-
return (0);
}