[rtems-libbsd commit] rtemsbsd/arasan_sd: Prevent disabled device probe
Joel Sherrill
joel at rtems.org
Fri Sep 16 14:39:36 UTC 2022
Module: rtems-libbsd
Branch: 6-freebsd-12
Commit: 63dae7159f232fde3cc04886e880562e87360cf0
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=63dae7159f232fde3cc04886e880562e87360cf0
Author: Kinsey Moore <kinsey.moore at oarcorp.com>
Date: Thu Sep 15 15:13:39 2022 -0500
rtemsbsd/arasan_sd: Prevent disabled device probe
Probing a SDIO/SDHCI interface that has been disabled by system init via
holding it in reset can cause a CPU hang. This prevents probing of
devices that have been disabled in such a manner on ZynqMP systems.
---
rtemsbsd/sys/dev/sdhci/arasan_sdhci.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
index ccdcb09b..6332260a 100644
--- a/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
+++ b/rtemsbsd/sys/dev/sdhci/arasan_sdhci.c
@@ -246,6 +246,31 @@ arasan_sdhci_attach(device_t dev)
goto fail;
}
+ /*
+ * These devices may be disabled by being held in reset. If this is the
+ * case, a read attempt in its register range will result in a CPU hang.
+ * Detect this situation and avoid probing the device in this situation.
+ */
+#if defined(LIBBSP_AARCH64_XILINX_ZYNQMP_BSP_H)
+ volatile uint32_t *RST_LPD_IOU2_ptr = (uint32_t*)0xFF5E0238;
+ uint32_t RST_LPD_IOU2 = *RST_LPD_IOU2_ptr;
+ uint32_t SDIO0_disabled = RST_LPD_IOU2 & (1 << 5);
+ uint32_t SDIO1_disabled = RST_LPD_IOU2 & (1 << 6);
+ if ( sc->mem_res == 0xFF160000 ) {
+ if ( SDIO0_disabled != 0 ) {
+ device_printf(dev, "SDIO0 disabled\n");
+ err = ENXIO;
+ goto fail;
+ }
+ } else {
+ if ( SDIO1_disabled != 0 ) {
+ device_printf(dev, "SDIO1 disabled\n");
+ err = ENXIO;
+ goto fail;
+ }
+ }
+#endif
+
rid = 0;
sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_ACTIVE);
More information about the vc
mailing list