]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mmc: rtsx_usb_sdmmc: Re-work runtime PM support
authorUlf Hansson <ulf.hansson@linaro.org>
Fri, 11 Jan 2019 08:30:00 +0000 (09:30 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 14 Jan 2019 09:28:55 +0000 (09:28 +0000)
BugLink: https://bugs.launchpad.net/bugs/1811337
The current implementation uses the runtime PM autosuspend feature with a
default timeout set to 50ms. This really doesn't makes sense, as it's a USB
driven host device, which needs it rtsx USB device (parent device) to be
runtime resumed to provide power to the card.

In practise, using the autosuspend or any async runtime PM suspend method,
means unnecessary delaying the host device and thus the parent, to be
runtime suspended when a card is removed/powered off. For this reasons,
let's simply drop the support for runtime PM autosuspend and tell the mmc
core to use synced runtime PM suspend methods, via setting
MMC_CAP_SYNC_RUNTIME_PM during probe.

Moreover, as the mmc core nowadays deploys runtime PM reference counting of
the mmc host device, convert ->set_ios() to use the more lightweight
pm_runtime_get_noresume() and pm_runtime_put_noidle() APIs.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
(cherry picked from commit f275179f7bdcf08f4c74c2d1d19c4e8269be3454)
Signed-off-by: AceLan Kao <acelan.kao@canonical.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/mmc/host/rtsx_usb_sdmmc.c

index 86ac77bd3e9e8f374024b2b41b1277af02173d78..5ba66396a8ae98cead16e7220817c4b019a5dc82 100644 (file)
@@ -1042,9 +1042,9 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
 
        if (power_mode == MMC_POWER_OFF) {
                err = sd_power_off(host);
 
        if (power_mode == MMC_POWER_OFF) {
                err = sd_power_off(host);
-               pm_runtime_put(sdmmc_dev(host));
+               pm_runtime_put_noidle(sdmmc_dev(host));
        } else {
        } else {
-               pm_runtime_get_sync(sdmmc_dev(host));
+               pm_runtime_get_noresume(sdmmc_dev(host));
                err = sd_power_on(host);
        }
 
                err = sd_power_on(host);
        }
 
@@ -1310,7 +1310,7 @@ static void rtsx_usb_update_led(struct work_struct *work)
 
 out:
        mutex_unlock(&ucr->dev_mutex);
 
 out:
        mutex_unlock(&ucr->dev_mutex);
-       pm_runtime_put(sdmmc_dev(host));
+       pm_runtime_put_sync_suspend(sdmmc_dev(host));
 }
 #endif
 
 }
 #endif
 
@@ -1324,7 +1324,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
        mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
                MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
                MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
        mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
                MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
                MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
-               MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE;
+               MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM;
        mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
                MMC_CAP2_NO_SDIO;
 
        mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
                MMC_CAP2_NO_SDIO;
 
@@ -1367,8 +1367,6 @@ static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
 
        mutex_init(&host->host_mutex);
        rtsx_usb_init_host(host);
 
        mutex_init(&host->host_mutex);
        rtsx_usb_init_host(host);
-       pm_runtime_use_autosuspend(&pdev->dev);
-       pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
        pm_runtime_enable(&pdev->dev);
 
 #ifdef RTSX_USB_USE_LEDS_CLASS
        pm_runtime_enable(&pdev->dev);
 
 #ifdef RTSX_USB_USE_LEDS_CLASS
@@ -1423,7 +1421,6 @@ static int rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev)
 
        mmc_free_host(mmc);
        pm_runtime_disable(&pdev->dev);
 
        mmc_free_host(mmc);
        pm_runtime_disable(&pdev->dev);
-       pm_runtime_dont_use_autosuspend(&pdev->dev);
        platform_set_drvdata(pdev, NULL);
 
        dev_dbg(&(pdev->dev),
        platform_set_drvdata(pdev, NULL);
 
        dev_dbg(&(pdev->dev),