summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstsp <stsp@openbsd.org>2019-04-02 07:08:39 +0000
committerstsp <stsp@openbsd.org>2019-04-02 07:08:39 +0000
commitfd406f4d640393a07e2699cbb7600dd2d34d45de (patch)
tree87cc67035b43775d9d664d7de41ba36452ead297
parentsync (diff)
downloadwireguard-openbsd-fd406f4d640393a07e2699cbb7600dd2d34d45de.tar.xz
wireguard-openbsd-fd406f4d640393a07e2699cbb7600dd2d34d45de.zip
Don't detach non-removable devices during resume on "sdhc* at acpi?".
Makes hibernate work with rootfs on built-in emmc storage. Tested on King Jim Portabook. ok deraadt@ kettenis@
-rw-r--r--sys/dev/acpi/sdhc_acpi.c11
-rw-r--r--sys/dev/sdmmc/sdhc.c5
-rw-r--r--sys/dev/sdmmc/sdhcvar.h3
-rw-r--r--sys/dev/sdmmc/sdmmc.c5
-rw-r--r--sys/dev/sdmmc/sdmmcvar.h3
5 files changed, 19 insertions, 8 deletions
diff --git a/sys/dev/acpi/sdhc_acpi.c b/sys/dev/acpi/sdhc_acpi.c
index d6afef333a3..8e21b1d7538 100644
--- a/sys/dev/acpi/sdhc_acpi.c
+++ b/sys/dev/acpi/sdhc_acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhc_acpi.c,v 1.13 2018/07/01 11:37:11 kettenis Exp $ */
+/* $OpenBSD: sdhc_acpi.c,v 1.14 2019/04/02 07:08:39 stsp Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -237,8 +237,13 @@ sdhc_acpi_do_explore(struct aml_node *node, void *arg)
/* Override card detect if we have non-removable devices. */
if (aml_evalinteger(sc->sc_acpi, node, "_RMV", 0, NULL, &rmv))
rmv = 1;
- if (rmv == 0 && sc->sc.sc_card_detect == NULL)
- sc->sc.sc_card_detect = sdhc_acpi_card_detect_nonremovable;
+ if (rmv == 0) {
+ sc->sc.sc_flags |= SDHC_F_NONREMOVABLE;
+ if (sc->sc.sc_card_detect == NULL) {
+ sc->sc.sc_card_detect =
+ sdhc_acpi_card_detect_nonremovable;
+ }
+ }
sdhc_acpi_power_on(sc, node);
diff --git a/sys/dev/sdmmc/sdhc.c b/sys/dev/sdmmc/sdhc.c
index 248878293e3..24f7df07377 100644
--- a/sys/dev/sdmmc/sdhc.c
+++ b/sys/dev/sdmmc/sdhc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhc.c,v 1.61 2018/09/06 10:15:17 patrick Exp $ */
+/* $OpenBSD: sdhc.c,v 1.62 2019/04/02 07:08:40 stsp Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -335,6 +335,9 @@ sdhc_host_found(struct sdhc_softc *sc, bus_space_tag_t iot,
if (ISSET(sc->sc_flags, SDHC_F_NODDR50))
saa.caps &= ~SMC_CAPS_MMC_DDR52;
+ if (ISSET(sc->sc_flags, SDHC_F_NONREMOVABLE))
+ saa.caps |= SMC_CAPS_NONREMOVABLE;
+
hp->sdmmc = config_found(&sc->sc_dev, &saa, NULL);
if (hp->sdmmc == NULL) {
error = 0;
diff --git a/sys/dev/sdmmc/sdhcvar.h b/sys/dev/sdmmc/sdhcvar.h
index 7775015ac97..efa3f5e0bc8 100644
--- a/sys/dev/sdmmc/sdhcvar.h
+++ b/sys/dev/sdmmc/sdhcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdhcvar.h,v 1.11 2018/03/19 21:40:32 kettenis Exp $ */
+/* $OpenBSD: sdhcvar.h,v 1.12 2019/04/02 07:08:40 stsp Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -48,5 +48,6 @@ void sdhc_needs_discover(struct sdhc_softc *);
/* flag values */
#define SDHC_F_NOPWR0 (1 << 0)
#define SDHC_F_NODDR50 (1 << 1)
+#define SDHC_F_NONREMOVABLE (1 << 2)
#endif
diff --git a/sys/dev/sdmmc/sdmmc.c b/sys/dev/sdmmc/sdmmc.c
index 32285bce1cb..9afb62be82a 100644
--- a/sys/dev/sdmmc/sdmmc.c
+++ b/sys/dev/sdmmc/sdmmc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmc.c,v 1.52 2018/12/29 11:37:30 patrick Exp $ */
+/* $OpenBSD: sdmmc.c,v 1.53 2019/04/02 07:08:40 stsp Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -181,7 +181,8 @@ sdmmc_activate(struct device *self, int act)
case DVACT_SUSPEND:
rv = config_activate_children(self, act);
/* If card in slot, cause a detach/re-attach */
- if (ISSET(sc->sc_flags, SMF_CARD_PRESENT))
+ if (ISSET(sc->sc_flags, SMF_CARD_PRESENT) &&
+ !ISSET(sc->sc_caps, SMC_CAPS_NONREMOVABLE))
sc->sc_dying = -1;
break;
case DVACT_RESUME:
diff --git a/sys/dev/sdmmc/sdmmcvar.h b/sys/dev/sdmmc/sdmmcvar.h
index 1cc635e3182..e5f4f385cdd 100644
--- a/sys/dev/sdmmc/sdmmcvar.h
+++ b/sys/dev/sdmmc/sdmmcvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdmmcvar.h,v 1.31 2018/12/29 11:37:30 patrick Exp $ */
+/* $OpenBSD: sdmmcvar.h,v 1.32 2019/04/02 07:08:40 stsp Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
@@ -200,6 +200,7 @@ struct sdmmc_softc {
#define SMC_CAPS_MMC_DDR52 0x2000 /* eMMC DDR52 timing */
#define SMC_CAPS_MMC_HS200 0x4000 /* eMMC HS200 timing */
#define SMC_CAPS_MMC_HS400 0x8000 /* eMMC HS400 timing */
+#define SMC_CAPS_NONREMOVABLE 0x10000 /* non-removable devices */
int sc_function_count; /* number of I/O functions (SDIO) */
struct sdmmc_function *sc_card; /* selected card */