From patchwork Mon Sep 9 10:46:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 173368 Delivered-To: patches@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp4180918ilq; Mon, 9 Sep 2019 03:46:53 -0700 (PDT) X-Received: by 2002:a7b:c7d7:: with SMTP id z23mr18583414wmk.19.1568026013127; Mon, 09 Sep 2019 03:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568026013; cv=none; d=google.com; s=arc-20160816; b=1CtflH5OTZmER4QZBulfGZ/mu1VkuMYyXweDLcwl2vfEHCLaD24SicdvNYo5z7SQOf uZyxcPXK+RFCnLfYdyr00bGBb0FJ7X+WYsPdwoaEs1BvE3AQbFe2zmVeno+oBLdJSUwH T4yCdIa9PmHIiMEaWDnlRyuXsCX4U4HjfwGciyxeYvYYprM4RgM+yDaOJgBWwe1uaJan ppHaf+k1cNmUMLKY5/zlmRe1s8yeMwMP/FZjfZTPaQx6e1RX8ViBHXIbBhR3fyEmipfE MD/HAaPcD8DZFc6uz15lnXy0skNLRtKToq03oi5T91STgsZ9qxjmxN/DaXlHPCQzAoC9 MVyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=e7moCh+jQSw0jwF9Rlsy8SQKxliBxNOLoz695izoqns=; b=J9XbjK+GJYCIGA1tC28iuh/rEeK0uLDgVi10zBN1J3QqY55JJe6cQLzJXNIcmA39Os rIAThcq0P6+DFuzyYzH1a1TQNqk1VRoLGhXSfBT9/+DRbBGkF2OdBJUWV8EPNV1JQjrM sh+dIUywGJK4g4tEYzaPTSjQMRo6KuD1yHYVVhod6UVY84qSAYxoDG7MT41S6XlrGVMk QyDTPmdZcI2YyLXeBQlhXy2eClN/OulBhYOS99lE6kcwENDK8w2GR/r1OEh3Qwoh+Nsp v6cLHp5SaOiVM/9HyYBzRC1pY2mMB4HPkAIcNgv5oerKKsLR2X5UOva/Tyg6QDhNckPP loCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a618mjz3; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p13sor8641419wmb.21.2019.09.09.03.46.52 for (Google Transport Security); Mon, 09 Sep 2019 03:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a618mjz3; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=e7moCh+jQSw0jwF9Rlsy8SQKxliBxNOLoz695izoqns=; b=a618mjz3tppctfX0DICSnWVTgdVsGHGN7Eq7AHhMSKSFFwuXkRnUe70VIAsgLrHahk ElXRQK3hazu+rdS4tstIRYoaEMO6TbcxX0cp9hffeX55WBLnTl1zVgnWtTJi8b3/0RuK tZy393oPrV8QOm8H1WakMMfc4yOWYT3NdAZzTpgT/BangpUbZyNGSOuXcekqoRsP4Eeb 5yJbDcAnbrLudW3Sbxeff/xJ12YG0cZ2KDPr4sb685dSJvKBtxXbFQnOVIDdPs+9mVbo Ztcr80LhCWr4gVWnuiQGokQ7I4Re/RXn2UeVTqSwZcIk1RpDLhOCkS1LLHqfYQGo1JcG svEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=e7moCh+jQSw0jwF9Rlsy8SQKxliBxNOLoz695izoqns=; b=CH479nV5BXzaMtmakx6kHLP0UmDi8HYpBBlfAs6xYvpeYV3v0FuRPYRbvrmjFV/Avo oHYqqwDw+106m24ldv6ukeOQGSVECd3mwOUEQ17+/6lRpRrg6+9+j0Jm2iGMQuY/Bdmc dt+4fg/n8LU+IpN3jGytEElqjMD6/qu3oXEWqbr1VY+V3KhQzzjjzsT92TXSm+hgNdGw jecLq/wHE4zpncIsjGM/njaV+5kN9x2wekY+DNEAUJya5f2qYcsMO3n0WbOzDuN6iwYG OkLahSZGUXyO2Lv6+U4AG3guvY2uSgmTLSUzy7nDYDFahIQCsFzZqhXfyPInwSkhf+tQ 7pqw== X-Gm-Message-State: APjAAAUiq3qv0nfGHxXailZ3cZfQrutwFXNj+neFNGv2Ky/LLpHvkNY0 dAkg/pr/X4siURQCXE8Q2HiYmERJ X-Google-Smtp-Source: APXvYqw5lFA91EojJNkqbGtjzqEv2INthA8qJ3AjPKFocqGmAr0e/CNJHMA66MdDlR0F829s1my1nA== X-Received: by 2002:a1c:5f0b:: with SMTP id t11mr18158808wmb.76.1568026012737; Mon, 09 Sep 2019 03:46:52 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([148.69.85.38]) by smtp.gmail.com with ESMTPSA id n8sm18667415wma.7.2019.09.09.03.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 03:46:52 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Masahiro Yamada , Wolfram Sang Cc: Ulrich Hecht , Simon Horman , Niklas Soderlund , Geert Uytterhoeven Subject: [PATCH] mmc: tmio: Fixup runtime PM management during probe and remove Date: Mon, 9 Sep 2019 12:46:49 +0200 Message-Id: <20190909104649.4960-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 During probe, tmio variant drivers calls pm_runtime_enable() before they call tmio_mmc_host_probe(). This doesn't work as expected, because tmio_mmc_host_probe() calls pm_runtime_set_active(), which fails to set the status to RPM_ACTIVE for the device, when its been enabled for runtime PM. Fix this by calling pm_runtime_enable() from tmio_mmc_host_probe() instead. To avoid the device from being runtime suspended during the probe phase, let's also increase the runtime PM usage count in tmio_mmc_host_probe(). Consequentially, each tmio variant driver can decide themselves when to call pm_runtime_put(), to allow the device to become runtime suspended. Additionally, if the tmio variant driver decided to call pm_runtime_put() during probe, it's is expected that it also calls pm_runtime_get_sync() to restore the usage count, before it calls tmio_mmc_host_remove(). Fixes: 7ff213193310 ("mmc: tmio: move runtime PM enablement to the driver implementations") Signed-off-by: Ulf Hansson --- drivers/mmc/host/renesas_sdhi_core.c | 10 +++------- drivers/mmc/host/tmio_mmc.c | 6 ++---- drivers/mmc/host/tmio_mmc_core.c | 8 +++++--- drivers/mmc/host/uniphier-sd.c | 6 ++---- 4 files changed, 12 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 4c9774dbcfc1..6846c6b688a2 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -777,8 +777,6 @@ int renesas_sdhi_probe(struct platform_device *pdev, /* All SDHI have SDIO status bits which must be 1 */ mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS; - pm_runtime_enable(&pdev->dev); - ret = renesas_sdhi_clk_enable(host); if (ret) goto efree; @@ -845,6 +843,8 @@ int renesas_sdhi_probe(struct platform_device *pdev, goto eirq; } + pm_runtime_put(&pdev->dev); + dev_info(&pdev->dev, "%s base at 0x%08lx max clock rate %u MHz\n", mmc_hostname(host->mmc), (unsigned long) (platform_get_resource(pdev, IORESOURCE_MEM, 0)->start), @@ -858,9 +858,6 @@ int renesas_sdhi_probe(struct platform_device *pdev, renesas_sdhi_clk_disable(host); efree: tmio_mmc_host_free(host); - - pm_runtime_disable(&pdev->dev); - return ret; } EXPORT_SYMBOL_GPL(renesas_sdhi_probe); @@ -869,11 +866,10 @@ int renesas_sdhi_remove(struct platform_device *pdev) { struct tmio_mmc_host *host = platform_get_drvdata(pdev); + pm_runtime_get_sync(&pdev->dev); tmio_mmc_host_remove(host); renesas_sdhi_clk_disable(host); - pm_runtime_disable(&pdev->dev); - return 0; } EXPORT_SYMBOL_GPL(renesas_sdhi_remove); diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index 8539e10784b4..219029a1c420 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@ -172,7 +172,6 @@ static int tmio_mmc_probe(struct platform_device *pdev) host->mmc->f_max = pdata->hclk; host->mmc->f_min = pdata->hclk / 512; - pm_runtime_enable(&pdev->dev); ret = tmio_mmc_host_probe(host); if (ret) @@ -184,6 +183,7 @@ static int tmio_mmc_probe(struct platform_device *pdev) if (ret) goto host_remove; + pm_runtime_put(&pdev->dev); pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc), (unsigned long)host->ctl, irq); @@ -193,7 +193,6 @@ static int tmio_mmc_probe(struct platform_device *pdev) tmio_mmc_host_remove(host); host_free: tmio_mmc_host_free(host); - pm_runtime_disable(&pdev->dev); cell_disable: if (cell->disable) cell->disable(pdev); @@ -206,12 +205,11 @@ static int tmio_mmc_remove(struct platform_device *pdev) const struct mfd_cell *cell = mfd_get_cell(pdev); struct tmio_mmc_host *host = platform_get_drvdata(pdev); + pm_runtime_get_sync(&pdev->dev); tmio_mmc_host_remove(host); if (cell->disable) cell->disable(pdev); - pm_runtime_disable(&pdev->dev); - return 0; } diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 2cb3f951c3e2..ad8f3e902daa 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1257,9 +1257,11 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) /* See if we also get DMA */ tmio_mmc_request_dma(_host, pdata); + pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 50); pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_enable(&pdev->dev); ret = mmc_add_host(mmc); if (ret) @@ -1283,9 +1285,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); - if (!host->native_hotplug) - pm_runtime_get_sync(&pdev->dev); - dev_pm_qos_hide_latency_limit(&pdev->dev); mmc_remove_host(mmc); @@ -1294,7 +1293,10 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) tmio_mmc_release_dma(host); pm_runtime_dont_use_autosuspend(&pdev->dev); + if (host->native_hotplug) + pm_runtime_put_noidle(&pdev->dev); pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); } EXPORT_SYMBOL_GPL(tmio_mmc_host_remove); diff --git a/drivers/mmc/host/uniphier-sd.c b/drivers/mmc/host/uniphier-sd.c index e09336f9166d..8f7bf138408b 100644 --- a/drivers/mmc/host/uniphier-sd.c +++ b/drivers/mmc/host/uniphier-sd.c @@ -629,7 +629,6 @@ static int uniphier_sd_probe(struct platform_device *pdev) host->clk_disable = uniphier_sd_clk_disable; host->set_clock = uniphier_sd_set_clock; - pm_runtime_enable(&pdev->dev); ret = uniphier_sd_clk_enable(host); if (ret) goto free_host; @@ -647,12 +646,11 @@ static int uniphier_sd_probe(struct platform_device *pdev) if (ret) goto free_host; + pm_runtime_put(&pdev->dev); return 0; free_host: tmio_mmc_host_free(host); - pm_runtime_disable(&pdev->dev); - return ret; } @@ -660,9 +658,9 @@ static int uniphier_sd_remove(struct platform_device *pdev) { struct tmio_mmc_host *host = platform_get_drvdata(pdev); + pm_runtime_get_sync(&pdev->dev); tmio_mmc_host_remove(host); uniphier_sd_clk_disable(host); - pm_runtime_disable(&pdev->dev); return 0; }