mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 00:54:41 +08:00
2836766a9d
Sleep in atomic context happened on Trats2 board after inserting or
removing SD card because mmc_gpio_get_cd() was called under spin lock.
Fix this by moving card detection earlier, before acquiring spin lock.
The mmc_gpio_get_cd() call does not have to be protected by spin lock
because it does not access any sdhci internal data.
The sdhci_do_get_cd() call access host flags (SDHCI_DEVICE_DEAD). After
moving it out side of spin lock it could theoretically race with driver
removal but still there is no actual protection against manual card
eject.
Dmesg after inserting SD card:
[ 41.663414] BUG: sleeping function called from invalid context at drivers/gpio/gpiolib.c:1511
[ 41.670469] in_atomic(): 1, irqs_disabled(): 128, pid: 30, name: kworker/u8:1
[ 41.677580] INFO: lockdep is turned off.
[ 41.681486] irq event stamp: 61972
[ 41.684872] hardirqs last enabled at (61971): [<c0490ee0>] _raw_spin_unlock_irq+0x24/0x5c
[ 41.693118] hardirqs last disabled at (61972): [<c04907ac>] _raw_spin_lock_irq+0x18/0x54
[ 41.701190] softirqs last enabled at (61648): [<c0026fd4>] __do_softirq+0x234/0x2c8
[ 41.708914] softirqs last disabled at (61631): [<c00273a0>] irq_exit+0xd0/0x114
[ 41.716206] Preemption disabled at:[< (null)>] (null)
[ 41.721500]
[ 41.722985] CPU: 3 PID: 30 Comm: kworker/u8:1 Tainted: G W 3.18.0-rc5-next-20141121 #883
[ 41.732111] Workqueue: kmmcd mmc_rescan
[ 41.735945] [<c0014d2c>] (unwind_backtrace) from [<c0011c80>] (show_stack+0x10/0x14)
[ 41.743661] [<c0011c80>] (show_stack) from [<c0489d14>] (dump_stack+0x70/0xbc)
[ 41.750867] [<c0489d14>] (dump_stack) from [<c0228b74>] (gpiod_get_raw_value_cansleep+0x18/0x30)
[ 41.759628] [<c0228b74>] (gpiod_get_raw_value_cansleep) from [<c03646e8>] (mmc_gpio_get_cd+0x38/0x58)
[ 41.768821] [<c03646e8>] (mmc_gpio_get_cd) from [<c036d378>] (sdhci_request+0x50/0x1a4)
[ 41.776808] [<c036d378>] (sdhci_request) from [<c0357934>] (mmc_start_request+0x138/0x268)
[ 41.785051] [<c0357934>] (mmc_start_request) from [<c0357cc8>] (mmc_wait_for_req+0x58/0x1a0)
[ 41.793469] [<c0357cc8>] (mmc_wait_for_req) from [<c0357e68>] (mmc_wait_for_cmd+0x58/0x78)
[ 41.801714] [<c0357e68>] (mmc_wait_for_cmd) from [<c0361c00>] (mmc_io_rw_direct_host+0x98/0x124)
[ 41.810480] [<c0361c00>] (mmc_io_rw_direct_host) from [<c03620f8>] (sdio_reset+0x2c/0x64)
[ 41.818641] [<c03620f8>] (sdio_reset) from [<c035a3d8>] (mmc_rescan+0x254/0x2e4)
[ 41.826028] [<c035a3d8>] (mmc_rescan) from [<c003a0e0>] (process_one_work+0x180/0x3f4)
[ 41.833920] [<c003a0e0>] (process_one_work) from [<c003a3bc>] (worker_thread+0x34/0x4b0)
[ 41.841991] [<c003a3bc>] (worker_thread) from [<c003fed8>] (kthread+0xe4/0x104)
[ 41.849285] [<c003fed8>] (kthread) from [<c000f268>] (ret_from_fork+0x14/0x2c)
[ 42.038276] mmc0: new high speed SDHC card at address 1234
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes:
|
||
---|---|---|
.. | ||
android-goldfish.c | ||
atmel-mci-regs.h | ||
atmel-mci.c | ||
au1xmmc.c | ||
bfin_sdh.c | ||
cb710-mmc.c | ||
cb710-mmc.h | ||
davinci_mmc.c | ||
dw_mmc-exynos.c | ||
dw_mmc-k3.c | ||
dw_mmc-pci.c | ||
dw_mmc-pltfm.c | ||
dw_mmc-pltfm.h | ||
dw_mmc-rockchip.c | ||
dw_mmc.c | ||
dw_mmc.h | ||
jz4740_mmc.c | ||
Kconfig | ||
Makefile | ||
mmc_spi.c | ||
mmci_qcom_dml.c | ||
mmci_qcom_dml.h | ||
mmci.c | ||
mmci.h | ||
moxart-mmc.c | ||
msm_sdcc.c | ||
msm_sdcc.h | ||
mvsdio.c | ||
mvsdio.h | ||
mxcmmc.c | ||
mxs-mmc.c | ||
of_mmc_spi.c | ||
omap_hsmmc.c | ||
omap.c | ||
pxamci.c | ||
pxamci.h | ||
rtsx_pci_sdmmc.c | ||
rtsx_usb_sdmmc.c | ||
s3cmci.c | ||
s3cmci.h | ||
sdhci-acpi.c | ||
sdhci-bcm2835.c | ||
sdhci-bcm-kona.c | ||
sdhci-cns3xxx.c | ||
sdhci-dove.c | ||
sdhci-esdhc-imx.c | ||
sdhci-esdhc.h | ||
sdhci-msm.c | ||
sdhci-of-arasan.c | ||
sdhci-of-esdhc.c | ||
sdhci-of-hlwd.c | ||
sdhci-pci-data.c | ||
sdhci-pci-o2micro.c | ||
sdhci-pci-o2micro.h | ||
sdhci-pci.c | ||
sdhci-pci.h | ||
sdhci-pltfm.c | ||
sdhci-pltfm.h | ||
sdhci-pxav2.c | ||
sdhci-pxav3.c | ||
sdhci-s3c-regs.h | ||
sdhci-s3c.c | ||
sdhci-sirf.c | ||
sdhci-spear.c | ||
sdhci-st.c | ||
sdhci-tegra.c | ||
sdhci.c | ||
sdhci.h | ||
sdricoh_cs.c | ||
sh_mmcif.c | ||
sh_mobile_sdhi.c | ||
sunxi-mmc.c | ||
tifm_sd.c | ||
tmio_mmc_dma.c | ||
tmio_mmc_pio.c | ||
tmio_mmc.c | ||
tmio_mmc.h | ||
toshsd.c | ||
toshsd.h | ||
usdhi6rol0.c | ||
ushc.c | ||
via-sdmmc.c | ||
vub300.c | ||
wbsd.c | ||
wbsd.h | ||
wmt-sdmmc.c |