]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.162/mmc-spi-fix-card-detection-during-probe.patch
Linux 4.9.162
[thirdparty/kernel/stable-queue.git] / releases / 4.9.162 / mmc-spi-fix-card-detection-during-probe.patch
1 From c9bd505dbd9d3dc80c496f88eafe70affdcf1ba6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= <j.neuschaefer@gmx.net>
3 Date: Sun, 10 Feb 2019 18:31:07 +0100
4 Subject: mmc: spi: Fix card detection during probe
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
10
11 commit c9bd505dbd9d3dc80c496f88eafe70affdcf1ba6 upstream.
12
13 When using the mmc_spi driver with a card-detect pin, I noticed that the
14 card was not detected immediately after probe, but only after it was
15 unplugged and plugged back in (and the CD IRQ fired).
16
17 The call tree looks something like this:
18
19 mmc_spi_probe
20 mmc_add_host
21 mmc_start_host
22 _mmc_detect_change
23 mmc_schedule_delayed_work(&host->detect, 0)
24 mmc_rescan
25 host->bus_ops->detect(host)
26 mmc_detect
27 _mmc_detect_card_removed
28 host->ops->get_cd(host)
29 mmc_gpio_get_cd -> -ENOSYS (ctx->cd_gpio not set)
30 mmc_gpiod_request_cd
31 ctx->cd_gpio = desc
32
33 To fix this issue, call mmc_detect_change after the card-detect GPIO/IRQ
34 is registered.
35
36 Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
37 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
38 Cc: stable@vger.kernel.org
39 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41
42 ---
43 drivers/mmc/host/mmc_spi.c | 1 +
44 1 file changed, 1 insertion(+)
45
46 --- a/drivers/mmc/host/mmc_spi.c
47 +++ b/drivers/mmc/host/mmc_spi.c
48 @@ -1450,6 +1450,7 @@ static int mmc_spi_probe(struct spi_devi
49 mmc->caps &= ~MMC_CAP_NEEDS_POLL;
50 mmc_gpiod_request_cd_irq(mmc);
51 }
52 + mmc_detect_change(mmc, 0);
53
54 if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) {
55 has_ro = true;