From patchwork Tue May 19 15:24:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186945 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3945187ilb; Tue, 19 May 2020 08:24:41 -0700 (PDT) X-Received: by 2002:a2e:2a82:: with SMTP id q124mr14419649ljq.155.1589901881512; Tue, 19 May 2020 08:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589901881; cv=none; d=google.com; s=arc-20160816; b=XTEbaZEGVm9yttr6TmlWezyygRhyDyAY4ltbJa9AFwqqSVtP8mOTmWKpcrfbdezoGJ 0vmC3z8c7jEgZ6Va2CpT9mGxT1XZGAlt/OObctIosv+NOx/Fdnx5S0LevhX/vX1dTNda rUnZsYr8SF3zgaXRoxqGzdRWy756DzT3h0TocFMVG3uw4wG2Aixg8zV/2iGyS7EgBW3k DEIFy+ZI7fJM9fJG/6IT5e/YJzjlWpXYfo+Ry4PC4QKfDalDyfUV4GnA7IfQwIZXbQ4I hEY4XKkhE1sBavTzMUHldArvSjFOJTnl8Tzt31sApvCb44TUuRIdHQLAd4GVKZztbBMj iQrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=kMsv3cAqsxyDutgPEs20bbhBPO7GSajJGggFJHsZRI0=; b=1DenU8q/UBdCqV7J/0mbdWv/LmA9mrT+0UN5zGUJoFFGN7z5zRfh+WeeuqIDnZRJGI xJXNW/jfEZEJe3mB83RXsmzzKvL+yo6mYtlKGpPdVwMxnDjCN7052pg0VR9k9rWAW4/W lcQGP9KTiW3rZVnIJCVYvKq+56kXxoQY/qzhYE3wF6sDTtYiEXdYNtvHxIjfkyVzfvHn /j6Xj2mHgCsINPvBtMDKcD+FyNJsLcKI/c0y02x/EI8yTyw7SEi32evKcFFe+Atzr6G1 FGebE8M0Pd/d5r4kUk1Xj0P/6o4J82+TeIzElnlqxF0jmXWwXTRa2nTin7picbbC5CtN HHPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lGUEhzjL; 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 c10sor2969020lfc.66.2020.05.19.08.24.41 for (Google Transport Security); Tue, 19 May 2020 08:24:41 -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=lGUEhzjL; 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:mime-version :content-transfer-encoding; bh=kMsv3cAqsxyDutgPEs20bbhBPO7GSajJGggFJHsZRI0=; b=lGUEhzjLLdHI8as19cQ2pCWFuK6xvwZguwaW9TS+VtiZ8X4Gi+to4WRDESe4Do8BQ3 WyWk/PO2hThZCGZobHv/KzQwUpSfjTWU/qLOD6816KxNSorN8PqSN8KpnJg7Y01U9H8y i5J5GCcygexpAuA2CySyuHBwTEYZyqLJJoicdam8CXTHEtjEmJ006AGxozkEVvDpnwY4 FLdNW+oSlQ86sexnHXedBhq233CrW5qz3bLTSKLTs+NtwvhyPjUmYzi9YCqrLEJmRVHs VJr1vv6R0qJOB/vh+h7ZTaFf2Iwa1MARc4DF2cwmvNyJQ6fR/1PQ1t60yUkewNzineR6 ZOMg== 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:mime-version :content-transfer-encoding; bh=kMsv3cAqsxyDutgPEs20bbhBPO7GSajJGggFJHsZRI0=; b=emELcZFoj/G+MuVIDK2S8VRX+IrzOpRVasKGS1IDThyPtv9jYmeqrZ+JiKXlZlyJNn 2sXA6/6JstmyBspvggInWCrvlZxvf1uJkfMh/WiZtJKfd1jZz9+80i395UFa2tVL/dRt fCA1O45hY3V23LTCtauy2XegdmD+pPgXC4bfHbvaxvxwVSutVI5p/VV1wdb5URKYtAjH mQSnXWIPrTzBu6yD/EOk7lbsfomgb6ARJ4S4t3oBm2QskdTtdv5ObYV7SWsO4jI287ih 5aXcxb7pN6fR/Wy5eeCWqm1LXDr1ZT0dbdS+MT5jU4r4fi1pDyGPLrNsRT+Uq2q37//N o9Vg== X-Gm-Message-State: AOAM530KVUnFRzbKB6o4/O8h9dYt1T/2psXxuv+UNFW6dSZAQcbE8z6H Ttlq8VtS1gMe5USnVg7soxOHYeP2 X-Google-Smtp-Source: ABdhPJxotfu8oI16gvvkE4fLb6GdKQ4dZhP8pjqzDAWcRYAIgwAiYdOyobAdLV0U61rWkSQud8mvAQ== X-Received: by 2002:a05:6512:3082:: with SMTP id z2mr15811421lfd.32.1589901880766; Tue, 19 May 2020 08:24:40 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id y20sm1144645lji.31.2020.05.19.08.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 08:24:39 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Masahiro Yamada , Wolfram Sang , Geert Uytterhoeven Cc: Ulrich Hecht , Simon Horman , Niklas Soderlund , Geert Uytterhoeven Subject: [PATCH 1/2] mmc: tmio: Further fixup runtime PM management at remove Date: Tue, 19 May 2020 17:24:34 +0200 Message-Id: <20200519152434.6867-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Before calling tmio_mmc_host_probe(), the caller is required to enable clocks for its device, as to make it accessible when reading/writing registers during probe. Therefore, the responsibility to disable these clocks, in the error path of ->probe() and during ->remove(), is better managed outside tmio_mmc_host_remove(). As a matter of fact, callers of tmio_mmc_host_remove() already expects this to be the behaviour. However, there's a problem with tmio_mmc_host_remove() when the Kconfig option, CONFIG_PM, is set. More precisely, tmio_mmc_host_remove() may then disable the clock via runtime PM, which leads to clock enable/disable imbalance problems, when the caller of tmio_mmc_host_remove() also tries to disable the same clocks. To solve the problem, let's make sure tmio_mmc_host_remove() leaves the device with clocks enabled, but also make sure to disable the IRQs, as we normally do at ->runtime_suspend(). Reported-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index f31afd1c2671..ba301fb7656b 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1231,12 +1231,14 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) cancel_work_sync(&host->done); cancel_delayed_work_sync(&host->delayed_reset_work); tmio_mmc_release_dma(host); + tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); - 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); + pm_runtime_dont_use_autosuspend(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); } EXPORT_SYMBOL_GPL(tmio_mmc_host_remove);