linux-stable/drivers/mmc/host
Rajat Jain 7c9f55c5a5 mmc: sdhci-pci: Try "cd" for card-detect lookup before using NULL
commit cdcefe6bd9 upstream.

Problem:

The card detect IRQ does not work with modern BIOS (that want
to use _DSD to provide the card detect GPIO to the driver).

Details:

The mmc core provides the mmc_gpiod_request_cd() API to let host drivers
request the gpio descriptor for the "card detect" pin.
This pin is specified in the ACPI for the SDHC device:

 * Either as a resource using _CRS. This is a method used by legacy BIOS.
   (The driver needs to tell which resource index).

 * Or as a named property ("cd-gpios"/"cd-gpio") in _DSD (which internally
   points to an entry in _CRS). This way, the driver can lookup using a
   string. This is what modern BIOS prefer to use.

This API finally results in a call to the following code:

struct gpio_desc *acpi_find_gpio(..., const char *con_id,...)
{
...
   /* Lookup gpio (using "<con_id>-gpio") in the _DSD */
...
   if (!acpi_can_fallback_to_crs(adev, con_id))
          return ERR_PTR(-ENOENT);
...
   /* Falling back to _CRS is allowed, Lookup gpio in the _CRS */
...
}

Note that this means that if the ACPI has _DSD properties, the kernel
will never use _CRS for the lookup (Because acpi_can_fallback_to_crs()
will always be false for any device hat has _DSD entries).

The SDHCI driver is thus currently broken on a modern BIOS, even if
BIOS provides both _CRS (for index based lookup) and _DSD entries (for
string based lookup). Ironically, none of these will be used for the
lookup currently because:

* Since the con_id is NULL, acpi_find_gpio() does not find a matching
  entry in DSDT. (The _DSDT entry has the property name = "cd-gpios")

* Because ACPI contains DSDT entries, thus acpi_can_fallback_to_crs()
  returns false (because device properties have been populated from
  _DSD), thus the _CRS is never used for the lookup.

Fix:

Try "cd" for lookup in the _DSD before falling back to using NULL so
as to try looking up in the _CRS.

I've tested this patch successfully with both Legacy BIOS (that
provide only _CRS method) as well as modern BIOS (that provide both
_CRS and _DSD). Also the use of "cd" appears to be fairly consistent
across other users of this API (other MMC host controller drivers).

Link: https://lkml.org/lkml/2018/9/25/1113
Signed-off-by: Rajat Jain <rajatja@google.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: f10e4bf663 ("gpio: acpi: Even more tighten up ACPI GPIO lookups")
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-01 09:42:50 +01:00
..
android-goldfish.c mmc: android-goldfish: remove logically dead code in goldfish_mmc_irq() 2017-08-30 14:01:23 +02:00
atmel-mci.c mmc: Convert to using %pOF instead of full_name 2017-08-30 14:01:36 +02:00
au1xmmc.c
bcm2835.c mmc: bcm2835: Don't overwrite max frequency unconditionally 2018-02-22 15:42:26 +01:00
bfin_sdh.c
cavium-octeon.c mmc: cavium-octeon: Convert to use module_platform_driver 2017-08-30 15:03:38 +02:00
cavium-thunderx.c mmc: cavium: Fix use-after-free in of_platform_device_destroy 2017-09-08 15:38:22 +02:00
cavium.c mmc: Delete bounce buffer handling 2017-10-04 10:22:55 +02:00
cavium.h mmc: cavium: Add scatter-gather DMA support 2017-04-24 21:42:10 +02:00
cb710-mmc.c
cb710-mmc.h
davinci_mmc.c mmc: davinci: constify mmc_host_ops structures 2017-08-30 14:01:41 +02:00
dw_mmc-exynos.c mmc: dw_mmc: exynos: fix the suspend/resume issue for exynos5433 2018-03-28 18:24:31 +02:00
dw_mmc-exynos.h
dw_mmc-k3.c mmc: dw_mmc: Fix out-of-bounds access for slot's caps 2018-03-08 22:41:03 -08:00
dw_mmc-pci.c mmc: dw_mmc: Remove the public dw_mmc header file 2017-02-13 13:19:59 +01:00
dw_mmc-pltfm.c mmc: dw_mmc: Remove the public dw_mmc header file 2017-02-13 13:19:59 +01:00
dw_mmc-pltfm.h
dw_mmc-rockchip.c mmc: dw_mmc-rockchip: correct property names in debug 2018-11-04 14:52:44 +01:00
dw_mmc-zx.c mmc: dw_mmc: Fix out-of-bounds access for slot's caps 2018-03-08 22:41:03 -08:00
dw_mmc-zx.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dw_mmc.c mmc: dw_mmc: update actual clock for mmc debugfs 2018-08-03 07:50:37 +02:00
dw_mmc.h mmc: dw_mmc: Fix out-of-bounds access for slot's caps 2018-03-08 22:41:03 -08:00
jz4740_mmc.c mmc: jz4740: Fix race condition in IRQ mask update 2018-04-24 09:36:33 +02:00
Kconfig mmc: host: fix typo after MMC_DEBUG move 2017-09-08 15:38:21 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
meson-gx-mmc.c Revert "mmc: meson-gx: include tx phase in the tuning process" 2018-02-22 15:42:26 +01:00
mmc_spi.c mmc: use new core function mmc_get_dma_dir 2017-04-24 21:41:52 +02:00
mmci.c mmc: mmci: constify amba_id 2017-08-30 15:03:46 +02:00
mmci.h mmc: core/mmci: restore pre/post_req behaviour 2017-02-13 13:20:52 +01:00
mmci_qcom_dml.c scripts/spelling.txt: add "intialization" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
mmci_qcom_dml.h
moxart-mmc.c mmc: moxart: constify mmc_host_ops structures 2017-08-30 14:01:41 +02:00
mtk-sd.c mmc: mediatek: constify mmc_host_ops structures 2017-08-30 14:01:44 +02:00
mvsdio.c mmc: use new core function mmc_get_dma_dir 2017-04-24 21:41:52 +02:00
mvsdio.h
mxcmmc.c mmc: mxcmmc: Handle return value of clk_prepare_enable 2017-08-30 14:01:55 +02:00
mxs-mmc.c mmc: mxs-mmc: Implement CMD23 support 2017-02-13 13:20:27 +01:00
of_mmc_spi.c mmc: of_mmc_spi: fix restricted cast warning of sparse 2017-08-30 14:01:45 +02:00
omap.c mmc: omap: Don't use mmc_card_present() when validating for inserted card 2017-02-13 13:20:23 +01:00
omap_hsmmc.c mmc: omap_hsmmc: fix wakeirq handling on removal 2018-09-26 08:38:06 +02:00
pxamci.c mmc: Delete bounce buffer handling 2017-10-04 10:22:55 +02:00
pxamci.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
renesas_sdhi.h mmc: tmio, renesas-sdhi: add max_{segs, blk_count} to tmio_mmc_data 2017-08-30 14:01:21 +02:00
renesas_sdhi_core.c mmc: renesas_sdhi: Add MODULE_LICENSE 2018-01-17 09:45:23 +01:00
renesas_sdhi_internal_dmac.c mmc: renesas_sdhi_internal_dmac: fix #define RST_RESERVED_BITS 2018-09-09 19:55:53 +02:00
renesas_sdhi_sys_dmac.c mmc: renesas_sdhi: Add r8a7743/5 support 2017-09-01 15:31:01 +02:00
rtsx_pci_sdmmc.c mmc: use empty initializer list to zero-clear structures 2017-02-13 13:19:54 +01:00
rtsx_usb_sdmmc.c mmc: rtsx_usb_sdmmc: make array 'width' static const 2017-08-30 14:01:27 +02:00
s3cmci.c mmc: s3cmci: constify mmc_host_ops structures 2017-08-30 14:01:40 +02:00
s3cmci.h mmc: s3cmci: Register cpufreq notifier only on S3C24xx 2016-07-25 10:34:46 +02:00
sdhci-acpi.c sdhci: acpi: Use new method to get ACPI companion 2017-08-30 14:01:39 +02:00
sdhci-bcm-kona.c mmc: sdhci-bcm-kona: constify sdhci_pltfm_data and sdhci_ops structures 2017-08-30 14:01:52 +02:00
sdhci-brcmstb.c mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume 2017-08-30 15:03:44 +02:00
sdhci-cadence.c mmc: sdhci-pltfm: export sdhci_pltfm_suspend/resume 2017-08-30 15:03:45 +02:00
sdhci-cns3xxx.c mmc: sdhci-pltfm: Drop define for SDHCI_PLTFM_PMOPS 2016-07-29 11:29:04 +02:00
sdhci-dove.c mmc: sdhci-pltfm: Drop define for SDHCI_PLTFM_PMOPS 2016-07-29 11:29:04 +02:00
sdhci-esdhc-imx.c mmc: sdhci-esdhc-imx: allow 1.8V modes without 100/200MHz pinctrl states 2018-07-17 11:39:23 +02:00
sdhci-esdhc.h mmc: sdhci-of-esdhc: support ESDHC_CAPABILITIES_1 accessing 2017-08-30 15:03:36 +02:00
sdhci-iproc.c mmc: sdhci-iproc: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for cygnus 2018-05-30 07:51:48 +02:00
sdhci-msm.c mmc: sdhci-msm: fix issue with power irq 2017-12-10 13:40:40 +01:00
sdhci-of-arasan.c mmc: sdhci-of-arasan: constify sdhci_pltfm_data and sdhci_ops structures 2017-08-30 14:01:53 +02:00
sdhci-of-at91.c mmc: sdhci-of-at91: set clocks and presets after resume from deepest PM 2017-08-30 14:01:31 +02:00
sdhci-of-esdhc.c mmc: sdhci-of-esdhc: set proper dma mask for ls104x chips 2018-09-26 08:38:11 +02:00
sdhci-of-hlwd.c mmc: sdhci-pltfm: Drop define for SDHCI_PLTFM_PMOPS 2016-07-29 11:29:04 +02:00
sdhci-pci-core.c mmc: sdhci-pci: Try "cd" for card-detect lookup before using NULL 2018-12-01 09:42:50 +01:00
sdhci-pci-data.c mmc: sdhci-pci: Use ACPI DSM to get driver strength for some Intel devices 2017-04-24 21:41:28 +02:00
sdhci-pci-o2micro.c mmc: sdhci-pci-o2micro: Add quirk for O2 Micro dev 0x8620 rev 0x01 2018-11-13 11:14:53 -08:00
sdhci-pci-o2micro.h
sdhci-pci.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sdhci-pic32.c mmc: sdhci: constify sdhci_pltfm_data structures 2017-08-30 14:01:51 +02:00
sdhci-pltfm.c mmc: sdhci-pltfm: export sdhci_pltfm_suspend/resume 2017-08-30 15:03:45 +02:00
sdhci-pltfm.h mmc: sdhci-pltfm: export sdhci_pltfm_suspend/resume 2017-08-30 15:03:45 +02:00
sdhci-pxav2.c mmc: sdhci-pxav2: switch to managed clk and sdhci_pltfm_unregister() 2017-08-30 15:03:44 +02:00
sdhci-pxav3.c mmc: sdhci: constify sdhci_pltfm_data structures 2017-08-30 14:01:51 +02:00
sdhci-s3c.c mmc: sdhci-s3c: use generic sdhci_set_bus_width() 2017-08-30 15:03:35 +02:00
sdhci-sirf.c mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume 2017-08-30 15:03:44 +02:00
sdhci-spear.c mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm 2017-04-24 21:41:26 +02:00
sdhci-st.c mmc: sdhci-st: explicitly request exclusive reset control 2017-08-30 14:01:37 +02:00
sdhci-tegra.c mmc: tegra: prevent HS200 on Tegra 3 2018-09-26 08:38:11 +02:00
sdhci-xenon-phy.c mmc: sdhci-xenon: Support HS400 Enhanced Strobe feature 2017-08-30 15:03:43 +02:00
sdhci-xenon.c mmc: sdhci-xenon: wait 5ms after set 1.8V signal enable 2018-03-24 11:01:25 +01:00
sdhci-xenon.h mmc: sdhci-xenon: Fix clock resource by adding an optional bus clock 2017-10-04 10:50:36 +02:00
sdhci.c mmc: sdhci: do not try to use 3.3V signaling if not supported 2018-09-26 08:38:11 +02:00
sdhci.h mmc: sdhci: Implement an SDHCI-specific bounce buffer 2018-02-22 15:42:26 +01:00
sdhci_f_sdh30.c mmc: sdhci-pltfm: Drop define for SDHCI_PLTFM_PMOPS 2016-07-29 11:29:04 +02:00
sdricoh_cs.c mmc: sdricoh_cs: constify mmc_host_ops structures 2017-08-30 14:01:44 +02:00
sh_mmcif.c mmc: sh_mmcif: constify mmc_host_ops structures 2017-08-30 14:01:42 +02:00
sunxi-mmc.c mmc: sunxi: Reset the device at probe time 2017-08-30 15:03:52 +02:00
tifm_sd.c
tmio_mmc.c mmc: tmio: improve checkpatch cleanness 2017-06-20 10:30:50 +02:00
tmio_mmc.h mmc: tmio: no magic values when enabling DMA 2017-08-30 14:01:25 +02:00
tmio_mmc_core.c mmc: tmio: Fix error handling when issuing CMD23 2018-04-24 09:36:33 +02:00
toshsd.c mmc: toshsd: constify mmc_host_ops structures 2017-08-30 14:01:42 +02:00
toshsd.h
usdhi6rol0.c mmc: usdhi6rol0: constify mmc_host_ops structures 2017-08-30 14:01:43 +02:00
ushc.c mmc: ushc: fix NULL-deref at probe 2017-03-16 15:31:27 +01:00
via-sdmmc.c mmc: host: via-sdmmc: constify pci_device_id. 2017-08-30 14:01:35 +02:00
vub300.c mmc: vub300: constify usb_device_id 2017-08-30 14:01:58 +02:00
wbsd.c mmc: wbsd: remove CONFIG_MMC_DEBUG from the driver 2017-08-30 14:01:35 +02:00
wbsd.h
wmt-sdmmc.c mmc: wmt-sdmmc: Handle return value of clk_prepare_enable 2017-08-30 14:01:55 +02:00