From patchwork Fri Sep 13 09:40:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11144281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DB0F912 for ; Fri, 13 Sep 2019 09:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC7BA2081B for ; Fri, 13 Sep 2019 09:41:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mdidwElC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387968AbfIMJlB (ORCPT ); Fri, 13 Sep 2019 05:41:01 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35918 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387842AbfIMJlB (ORCPT ); Fri, 13 Sep 2019 05:41:01 -0400 Received: by mail-lf1-f66.google.com with SMTP id x80so21654204lff.3 for ; Fri, 13 Sep 2019 02:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=cnHaKGcMzTZrMV9+DycpQtbjSI9gqCpzF+WM5KDAOYI=; b=mdidwElC8ipcbQxW/mPtNfu0vZY4TgHVrd3CNdL05yVYt9Lu77V+SZgbcEh87oEj7t gkLldHdYEKEK06Fc+cZqP2I5MK7PrKHFf900QCERYDJNbKvModF4UfEzyA9/RkDX0WaI SJHrbh0A/ebWMzJzgdAL/7wS7xRVVjYng9uolBqjzY+4IgDkI+iApBGAKRoU+g7BTgHP oXflWjRSzo7cjca5l98vN4G5cmz8MUZGpy2viBXMqx+fHTLL+NECNr+yfj0nN+yFBwXb TZxJCjC6I7KpNKLSNhb/hcD6L7Vo3PS3c8Yu/ndzVGYexUP+v1YOD+w5D8Dz96F1gL5m 1m0Q== 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=cnHaKGcMzTZrMV9+DycpQtbjSI9gqCpzF+WM5KDAOYI=; b=B7KGS05K87wP4luvUpGCd6DYIiFWxNyG9NUtQFnGJc8DDm7ZzDp6VIIPca+GZ1jRGp ofgOTuE8Bgpj/qDgdvHvrV61kPR3HShb//prpPJ44nh5nZUFHeg4C5QvTpiY8o03cv0q PdAhCVHrw2JRBNrSmJqTgp86l5irD5XuW2nKuk2ty7tZl90+g5Mae55ewLLEmNy4VlDW SgThy8mhdcOSwlIx6WXKzRGhRo5Szgab3lWyUdLoOhwF9w+ckD4IPFzu6qJnYR4PR9WU vCsc9zui2wGrI+qDlQznVzgWFbQDZ2CcxWhDr3ROUsrcDc8YO8Nv2/Fd0VwjYGmuiBVB bgfw== X-Gm-Message-State: APjAAAUxtyaBqchX6vyasvX/5qy87pwM5lXzbT7PmxYzQnKJuPHCAOxU dI8WPDQDsxSSPLyNdPZIiPIWk2CntZo= X-Google-Smtp-Source: APXvYqwEiWp/yNjzuQzjQoTmrkabJNoCTsTHyjiRt4f7PpRE9siDiHU3jHYq2MuhjIpOrvFqdSrDzw== X-Received: by 2002:a19:2207:: with SMTP id i7mr30863016lfi.185.1568367658137; Fri, 13 Sep 2019 02:40:58 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id l9sm6183358ljg.79.2019.09.13.02.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 02:40:57 -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 1/3] Revert "mmc: tmio: move runtime PM enablement to the driver implementations" Date: Fri, 13 Sep 2019 11:40:53 +0200 Message-Id: <20190913094053.20753-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This reverts commit 7ff213193310ef8d0ee5f04f79d791210787ac2c. It turns out that the above commit introduces other problems. For example, calling pm_runtime_set_active() must not be done prior calling pm_runtime_enable() as that makes it fail. This leads to additional problems, such as clock enables being wrongly balanced. Rather than fixing the problem on top, let's start over by doing a revert. Fixes: 7ff213193310 ("mmc: tmio: move runtime PM enablement to the driver implementations") Signed-off-by: Ulf Hansson Tested-by: Wolfram Sang --- drivers/mmc/host/renesas_sdhi_core.c | 6 ------ drivers/mmc/host/tmio_mmc.c | 5 ----- drivers/mmc/host/tmio_mmc_core.c | 11 ++--------- drivers/mmc/host/uniphier-sd.c | 3 --- 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 64d3b5fb7fe5..4a2872f49a60 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -774,8 +774,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; @@ -856,8 +854,6 @@ int renesas_sdhi_probe(struct platform_device *pdev, efree: tmio_mmc_host_free(host); - pm_runtime_disable(&pdev->dev); - return ret; } EXPORT_SYMBOL_GPL(renesas_sdhi_probe); @@ -869,8 +865,6 @@ int renesas_sdhi_remove(struct platform_device *pdev) 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..93e83ad25976 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@ -172,8 +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) goto host_free; @@ -193,7 +191,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); @@ -210,8 +207,6 @@ static int tmio_mmc_remove(struct platform_device *pdev) 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..8b299c1f0069 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1153,15 +1153,6 @@ void tmio_mmc_host_free(struct tmio_mmc_host *host) } EXPORT_SYMBOL_GPL(tmio_mmc_host_free); -/** - * tmio_mmc_host_probe() - Common probe for all implementations - * @_host: Host to probe - * - * Perform tasks common to all implementations probe functions. - * - * The caller should have called pm_runtime_enable() prior to calling - * the common probe function. - */ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) { struct platform_device *pdev = _host->pdev; @@ -1260,6 +1251,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) 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) @@ -1295,6 +1287,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) pm_runtime_dont_use_autosuspend(&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 49aad9a79c18..91a2be41edf6 100644 --- a/drivers/mmc/host/uniphier-sd.c +++ b/drivers/mmc/host/uniphier-sd.c @@ -631,7 +631,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; @@ -653,7 +652,6 @@ static int uniphier_sd_probe(struct platform_device *pdev) free_host: tmio_mmc_host_free(host); - pm_runtime_disable(&pdev->dev); return ret; } @@ -664,7 +662,6 @@ static int uniphier_sd_remove(struct platform_device *pdev) tmio_mmc_host_remove(host); uniphier_sd_clk_disable(host); - pm_runtime_disable(&pdev->dev); return 0; } From patchwork Fri Sep 13 09:41:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11144283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3580B912 for ; Fri, 13 Sep 2019 09:41:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 142A720830 for ; Fri, 13 Sep 2019 09:41:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p/zm/sxh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387842AbfIMJlQ (ORCPT ); Fri, 13 Sep 2019 05:41:16 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40802 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387991AbfIMJlQ (ORCPT ); Fri, 13 Sep 2019 05:41:16 -0400 Received: by mail-lj1-f193.google.com with SMTP id 7so26412823ljw.7 for ; Fri, 13 Sep 2019 02:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=x+Ss15MNzRVyX67MkdlgMEH//XbsQfFeOYqwwe3OaKg=; b=p/zm/sxhH+yLyUYDxLlnKOtmXMLDat12pljG16ezcFFV2KVT9H7TvPLYzzcEKGU2iB Z+dzvPI+7dE3RFBNzp/y7eGYsldxMGXYmuG7IYacFQKsCM1ylejcxJGHxx2OTzbFfnkT BqdQwuGj5/CbTerzQCU6qZvWQBILgMVtCpoDN5XSDon6/bxtY6T7VRbAB7JtI/0NrYI6 Vn9J6utyHjJKTYBt7OlZ0x9CPXDc2P7gu27ihhbaJMBJ1/ZbbFN1neura7JTS7w8z6YL xggY00OLA/9jd0FpdjdpHR0JQJKZMFvVHzv3V7+rfkBuzAfIqSHeHFnQvC5xN7izRC4g jBpQ== 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=x+Ss15MNzRVyX67MkdlgMEH//XbsQfFeOYqwwe3OaKg=; b=dNld6hAOak2Wm7DKfonVtxqWaTMBZUe8my0j5CB2kKDSqjquDyl95xZDUPyM5Zv1k2 H9kdBudef515FaFgkXEpUJtLuVtQFao/BV+lTOyqx0rNy3c5BATs+IZZtV/4QTE068sJ 8ahMEk0k0KxfgPprTDovL0SNJ4kq62g9Gjn7nYEMBzRTt3pKdJAzU7UmotGti4V+k6Jc 8q+amfW4Ez4VExNC/p0d8R48TL/iSxLo2DMQIkqinWN8LcOQYJZNsGMDbk/WugIz1h82 HqsBETIjJwaSRlt7yEVaMUm9k5asddaJTuvdHl3CPIjrRK7u6HtFR/6CFu+Y4v1kBy2S Hr9Q== X-Gm-Message-State: APjAAAVd6bUcfhkfpa9P1mY91d57fcuZ1GFZvhg+2YfjSxf9qRqJhsso k2zqEd4LS/zwAMTE6SRL+ioLom01xdI= X-Google-Smtp-Source: APXvYqzJYGbaNDMizQgqIGnU19xD8dzBy4o+0P+OIYwEEFFswZEvh81y8WZHPl493WfWx8/7DXCddw== X-Received: by 2002:a2e:8e8c:: with SMTP id z12mr28888323ljk.204.1568367672562; Fri, 13 Sep 2019 02:41:12 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id t29sm116607lfb.85.2019.09.13.02.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 02:41:11 -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 , stable@vger.kernel.org Subject: [PATCH 2/3] mmc: tmio: Fixup runtime PM management during probe Date: Fri, 13 Sep 2019 11:41:09 +0200 Message-Id: <20190913094109.21192-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The tmio_mmc_host_probe() calls pm_runtime_set_active() to update the runtime PM status of the device, as to make it reflect the current status of the HW. This works fine for most cases, but unfortunate not for all. Especially, there is a generic problem when the device has a genpd attached and that genpd have the ->start|stop() callbacks assigned. More precisely, if the driver calls pm_runtime_set_active() during ->probe(), genpd does not get to invoke the ->start() callback for it, which means the HW isn't really fully powered on. Furthermore, in the next phase, when the device becomes runtime suspended, genpd will invoke the ->stop() callback for it, potentially leading to usage count imbalance problems, depending on what's implemented behind the callbacks of course. To fix this problem, convert to call pm_runtime_get_sync() from tmio_mmc_host_probe() rather than pm_runtime_set_active(). Additionally, to avoid bumping usage counters and unnecessary re-initializing the HW the first time the tmio driver's ->runtime_resume() callback is called, introduce a state flag to keeping track of this. Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index c5ba13fae399..2f0b092d6dcc 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -163,6 +163,7 @@ struct tmio_mmc_host { unsigned long last_req_ts; struct mutex ios_lock; /* protect set_ios() context */ bool native_hotplug; + bool runtime_synced; bool sdio_irq_enabled; /* Mandatory callback */ diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 8b299c1f0069..32f9679ec42e 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1248,20 +1248,22 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) /* See if we also get DMA */ tmio_mmc_request_dma(_host, pdata); - 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); + pm_runtime_get_sync(&pdev->dev); ret = mmc_add_host(mmc); if (ret) goto remove_host; dev_pm_qos_expose_latency_limit(&pdev->dev, 100); + pm_runtime_put(&pdev->dev); return 0; remove_host: + pm_runtime_put_noidle(&pdev->dev); tmio_mmc_host_remove(_host); return ret; } @@ -1330,6 +1332,11 @@ int tmio_mmc_host_runtime_resume(struct device *dev) { struct tmio_mmc_host *host = dev_get_drvdata(dev); + if (!host->runtime_synced) { + host->runtime_synced = true; + return 0; + } + tmio_mmc_clk_enable(host); tmio_mmc_hw_reset(host->mmc); From patchwork Fri Sep 13 09:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 11144285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1376114E5 for ; Fri, 13 Sep 2019 09:41:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E78A520830 for ; Fri, 13 Sep 2019 09:41:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yZ5hsC3w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388006AbfIMJlZ (ORCPT ); Fri, 13 Sep 2019 05:41:25 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:37295 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388000AbfIMJlZ (ORCPT ); Fri, 13 Sep 2019 05:41:25 -0400 Received: by mail-lf1-f67.google.com with SMTP id w67so21620869lff.4 for ; Fri, 13 Sep 2019 02:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=QS5aLvWZAGl2qy1uqqrDaZesBLdCRvn2tS/IES0IrhM=; b=yZ5hsC3wpKS6si95BrlMuHu1YR8h/0bTMI9DXnxjZWspdHqN1NRmsaGxp+nAxstv92 1fzPPu9jEAL6CNzjvzEjLp3g5hmREbhMnxAnZKOVckJvwdCAu+bJxIyKdlR0Qi6YVo4b 5OLcr7zH3kOTDBXAfUWTiPfaKSQrrO/oIeQuBf8qX8wUaMyVk37vlWX27hoxlGuF/+UY ZAyTx1v2oq1OSd8OlcaHIAtDfN5ElolhZyhFTyFLrygAk9maOIMXSQWY49hELJZBT2Tn Jp6rEBMG+D8e4yy7qTe/q2oOWmRdxz+x5Puswfi2iho4OcCIWM+ZDvDq2hc0/0gOrJiz qung== 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=QS5aLvWZAGl2qy1uqqrDaZesBLdCRvn2tS/IES0IrhM=; b=Bf7V864z3BmyQ6sfN0EjhYf317NNmIL9oQz1zyJprqSqsIiv5hXUffOd3xZYryzrN/ Mk91dPqQyxyFB8lQyojg8Qwja/BLGnr0oI4FjzWpMJ8uK8gECf8IlYyGN8yKtDYaacqb k+wikVe7dWeZwaTfhQ+vnlz8/kY+B7U6/r+qstJy+JfGkLpbadWlAlKqowz/jd+YIp4J B0TVgyKOEtesXUmSVf88GVqCglI/p0mO03FIQuQGjw6YNy74fBWXVbUXfGkkqULHYej8 nl+ZaLRy5s0aYG+NNcMyfZ6jCXiw6KibW1GVUy/DXwaS4yER55YZ9IZIt+mRjUxylZjk ++Ug== X-Gm-Message-State: APjAAAUfzApL6+OCZnunKNGpAp5h/Ihff7qjpMNyiQwNmykSLHFGYrvd DGlNom6vpR3AWP33D1OKEmgLXdXsAO4= X-Google-Smtp-Source: APXvYqyUxASV7kYcJEmZaWXICNtRekMjOPkhAQ78JgYbxBn5y94tN6W9C5mpRNzDqz1V5ckldlf5eg== X-Received: by 2002:ac2:51cd:: with SMTP id u13mr8658216lfm.135.1568367682684; Fri, 13 Sep 2019 02:41:22 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h21sm6198268ljg.34.2019.09.13.02.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2019 02:41:22 -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 , stable@vger.kernel.org Subject: [PATCH 3/3] mmc: tmio: Fixup runtime PM management during remove Date: Fri, 13 Sep 2019 11:41:18 +0200 Message-Id: <20190913094118.21243-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Accessing the device when it may be runtime suspended is a bug, which is the case in tmio_mmc_host_remove(). Let's fix the behaviour. Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index 32f9679ec42e..9b6e1001e77c 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1274,12 +1274,11 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) struct platform_device *pdev = host->pdev; struct mmc_host *mmc = host->mmc; + pm_runtime_get_sync(&pdev->dev); + 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); @@ -1288,6 +1287,8 @@ 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); }