From 1b313c675c32d2803c41a17c55b92e930ea1c8f8 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 11 Nov 2019 14:19:22 -0800 Subject: [PATCH] fmuk66-v3:Fix hang on SDIO card removal/reinsertion The interrupt driven card detect logic was enabled but the auto mounter was not. That interrupt was calling mmcsd_mediachange. There is a reentrancy issues in the kinetis callback logic. Toplevel calls mmcsd_mediachange calls SDIO_CALLBACKENABLE that calls kinetis_callbackenable that calls kinetis_callback that calls mmcsd_mediachange. --- boards/nxp/fmuk66-v3/nuttx-config/Kconfig | 5 +---- boards/nxp/fmuk66-v3/nuttx-config/nsh/defconfig | 8 +++++++- boards/nxp/fmuk66-v3/src/board_config.h | 2 +- boards/nxp/fmuk66-v3/src/sdhc.c | 9 ++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/boards/nxp/fmuk66-v3/nuttx-config/Kconfig b/boards/nxp/fmuk66-v3/nuttx-config/Kconfig index fd6ef3035f..df8b0f628d 100644 --- a/boards/nxp/fmuk66-v3/nuttx-config/Kconfig +++ b/boards/nxp/fmuk66-v3/nuttx-config/Kconfig @@ -3,7 +3,6 @@ # see misc/tools/kconfig-language.txt. # -if ARCH_BOARD_NXP_FMUK66_V3 config FMUK66_SDHC_AUTOMOUNT bool "SDHC automounter" default n @@ -21,7 +20,7 @@ config FMUK66_SDHC_AUTOMOUNT_BLKDEV config FMUK66_SDHC_AUTOMOUNT_MOUNTPOINT string "SDHC mount point" - default "/mnt/sdcard" + default "/fs/microsd" config FMUK66_SDHC_AUTOMOUNT_DDELAY int "SDHC debounce delay (milliseconds)" @@ -46,5 +45,3 @@ config BOARD_USE_PROBES ---help--- Select to use GPIO FMU-CH1-6 to provide timing signals from selected drivers. - -endif diff --git a/boards/nxp/fmuk66-v3/nuttx-config/nsh/defconfig b/boards/nxp/fmuk66-v3/nuttx-config/nsh/defconfig index 77b708611a..842b2bc5a7 100644 --- a/boards/nxp/fmuk66-v3/nuttx-config/nsh/defconfig +++ b/boards/nxp/fmuk66-v3/nuttx-config/nsh/defconfig @@ -1,3 +1,10 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# # CONFIG_DISABLE_OS_API is not set # CONFIG_MMCSD_HAVE_WRITEPROTECT is not set # CONFIG_MMCSD_SPI is not set @@ -170,7 +177,6 @@ CONFIG_SDCLONE_DISABLE=y CONFIG_SEM_NNESTPRIO=8 CONFIG_SEM_PREALLOCHOLDERS=0 CONFIG_SERIAL_IFLOWCONTROL_WATERMARKS=y -CONFIG_SERIAL_TERMIOS=y CONFIG_SIG_DEFAULT=y CONFIG_SIG_SIGALRM_ACTION=y CONFIG_SIG_SIGUSR1_ACTION=y diff --git a/boards/nxp/fmuk66-v3/src/board_config.h b/boards/nxp/fmuk66-v3/src/board_config.h index b56fc07714..91c53ce98e 100644 --- a/boards/nxp/fmuk66-v3/src/board_config.h +++ b/boards/nxp/fmuk66-v3/src/board_config.h @@ -187,7 +187,7 @@ __BEGIN_DECLS */ #define SD_CAED_P_EN (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTD | PIN6) -#define GPIO_SD_CARDDETECT (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTD | PIN10) +//#define GPIO_SD_CARDDETECT (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTD | PIN10) /* SPI * diff --git a/boards/nxp/fmuk66-v3/src/sdhc.c b/boards/nxp/fmuk66-v3/src/sdhc.c index 1f39b29529..74bc5cbe1d 100644 --- a/boards/nxp/fmuk66-v3/src/sdhc.c +++ b/boards/nxp/fmuk66-v3/src/sdhc.c @@ -99,6 +99,7 @@ static struct fmuk66_sdhc_state_s g_sdhc; * Private Functions ****************************************************************************/ +#if defined(GPIO_SD_CARDDETECT) /**************************************************************************** * Name: fmuk66_mediachange ****************************************************************************/ @@ -143,6 +144,7 @@ static int fmuk66_cdinterrupt(int irq, FAR void *context, FAR void *args) fmuk66_mediachange((struct fmuk66_sdhc_state_s *) args); return OK; } +#endif /**************************************************************************** * Public Functions @@ -164,12 +166,13 @@ int fmuk66_sdhc_initialize(void) VDD_3V3_SD_CARD_EN(true); +#if defined(GPIO_SD_CARDDETECT) kinetis_pinconfig(GPIO_SD_CARDDETECT); /* Attached the card detect interrupt (but don't enable it yet) */ kinetis_pinirqattach(GPIO_SD_CARDDETECT, fmuk66_cdinterrupt, sdhc); - +#endif /* Configure the write protect GPIO -- None */ /* Mount the SDHC-based MMC/SD block driver */ @@ -210,6 +213,7 @@ int fmuk66_sdhc_initialize(void) syslog(LOG_ERR, "Successfully bound SDHC to the MMC/SD driver\n"); +#if defined(GPIO_SD_CARDDETECT) /* Handle the initial card state */ fmuk66_mediachange(sdhc); @@ -217,6 +221,9 @@ int fmuk66_sdhc_initialize(void) /* Enable CD interrupts to handle subsequent media changes */ kinetis_pinirqenable(GPIO_SD_CARDDETECT); +#else + sdhc_mediachange(sdhc->sdhc, true); +#endif return OK; }