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.
This commit is contained in:
David Sidrane 2019-11-11 14:19:22 -08:00 committed by Daniel Agar
parent 11b1573961
commit 11287712f8
4 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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
*

View File

@ -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;
}