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); From patchwork Tue May 19 15:24:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186946 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp3945380ilb; Tue, 19 May 2020 08:24:52 -0700 (PDT) X-Received: by 2002:a19:c187:: with SMTP id r129mr700611lff.35.1589901892267; Tue, 19 May 2020 08:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589901892; cv=none; d=google.com; s=arc-20160816; b=NS+rt2e9TaqZ8XHKaEdWLn+fsRuP7bCrOl5mF3TrxXUXl9TY3ITVyNlDeh7xT7c7D/ jbboE2AOXWUDW4B4J6RM585iH10X42pAzFzGCOAHFlAt49JeXVXSVyU4A1wXiIWi8aAz Z1YpsF3+sOPmbF47ujz6WGbFL5+KJPTEwN0zaRJ021g3JLGRAt1RDq6r7mQ3CLG1oZ6B dfu/jUBOlGgjlnkypjkZi6Ea9yG/iRMTqf7wHd3Y3RAM5C5RDugaYc49GGZReuUakfx1 UWXPzAr6rDufTse3Fj68jeodw3BG6Xu0BclHCwQddU8m303P9RXdfFgV0OPprZKQfuam LJcA== 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=8qf2J9d+pE8ux/Cchs98T6eJsiSqSCnHXewGGw1uY44=; b=dYq9ROjblunbb1/BAjaDcNj/8xmuEaGB7Yzao86UWEninPkFsrw+I8AkHVunxiARpE XmKAxXfxEXEqOKBWZJfgkxbasGU9o1iwSMW3YF4FkeoPXadQnEPfM6gEoXzMluh12EF1 2Lki/Ht1uJBJDWdoU44WA34zzAH+OpPSP55YbvLa9139smoWfVZxv/diiT5dSFOO4c/J 9OhLsAoBTxOUfDtIFdWxDHT36Nl97O0afRWH2pZFAzEY97sid/VmaTaqsuezsnbUHsrN yINvbMRhCiOVa4S/q43L6D/HCjg9YtkePNHgj3LLNOEnH2yBx2/AEafpUi7Z6jRT2OkF O8Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=anuFNeTM; 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 t65sor936255lff.69.2020.05.19.08.24.52 for (Google Transport Security); Tue, 19 May 2020 08:24:52 -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=anuFNeTM; 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=8qf2J9d+pE8ux/Cchs98T6eJsiSqSCnHXewGGw1uY44=; b=anuFNeTMyDzavdWjY1GTSFbMlaC70QKkcyw+KE8hdosYo4TzXSd/qDzaxalIZs34ko gF5Z5+Y6FJoKFo4ZIO6ShLyLRSL4vxB8DXxx0zfXpNsWusgeOJtzqhVtt3wBbMx8nvYk bxkndfYu5+niXSmiIcGbJfBjoLkK6uWQ0LDMv/y19Rwd6GPBfEqtxEU6/GLhHfJhUYk+ +aYp3NjAW0NC7GPqd1P30rtCDnd3eE2VXJ+pqhqobgzOckFC9nnz8JYmFH+6HV2R3y7h 2OaBonCJeyDr6Rf5MXtgmT2PT5HB3lc44F/suOIQpgAkj05na+lUDXyiQ7wT0N6rSwmx mYqA== 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=8qf2J9d+pE8ux/Cchs98T6eJsiSqSCnHXewGGw1uY44=; b=OiwIWxcWdJAp5peuXu+VsQytTgWXfHsb7qPgFkJ2U9LU7sImvHllpvXwq6bJgrXj/j /RXMFyj4uMr/b/7YWoL8/Md1aQaYSbD63OTYJtxW1oM/yw7sFDT517oAL/y4sUYtC9lZ pZ2NFksChDnRY+0lCqlCwTEHnnEsRrZ2HbwQtypd17pPQS3mE5XG6YDsDhC8YPJnA3lj wH/K5t30o3To9FiEFENBg8vpgax4S/BaGOD3+kOen86S8gRn23gkBmBBZlpNFbwukLgy Pp6W3FVmiFJO3HTZ7QAnuaHdcH3a+INWOw3FILQ1wpEbEkgm3tPOIsqmNQls5Xa+Eb1D mZ/A== X-Gm-Message-State: AOAM531yEFsWi1iB9cHFPCMbaDjgeeTKpTds2HvomFxHLII5siqe6MKy 2/U+bhbYaJ6bEC5AdZHcjdn+FsEExmkwDf5p X-Google-Smtp-Source: ABdhPJyQHZ9eIWlRwy8ZDnTFWK0XQ5gVbcM8LmjoSBxo7r9UZLxgiEJ1+RUdvk6EqoIpKxg+sVkcdQ== X-Received: by 2002:ac2:5473:: with SMTP id e19mr11269026lfn.21.1589901891160; Tue, 19 May 2020 08:24:51 -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 i8sm6234395lfl.72.2020.05.19.08.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 08:24:48 -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 2/2] mmc: tmio: Make sure the PM domain is 'started' while probing Date: Tue, 19 May 2020 17:24:45 +0200 Message-Id: <20200519152445.6922-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 If the tmio device is attached to a genpd (PM domain), that genpd may have ->start|stop() callback assigned to it. To make sure the device is accessible during ->probe(), genpd's ->start() callback must be invoked, which is currently managed by tmio_mmc_host_probe(). However, it's likely that may be too late for some cases, as registers may be read and written way before that point. To fix the behaviour, let's move the call to dev_pm_domain_start() from tmio_mmc_host_probe() into those clients that needs it. From discussions at linux-mmc mailing list, it turned out that it should be sufficient to do this for the SDHI renesas variants, hence the call is move to renesas_sdhi_probe(). Signed-off-by: Ulf Hansson --- drivers/mmc/host/renesas_sdhi_core.c | 3 +++ drivers/mmc/host/tmio_mmc_core.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index ff72b381a6b3..dcba9ad35dd1 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -905,6 +906,8 @@ 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; + dev_pm_domain_start(&pdev->dev); + ret = renesas_sdhi_clk_enable(host); if (ret) goto efree; diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index ba301fb7656b..d7fde57c78c1 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -1192,7 +1191,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) /* See if we also get DMA */ tmio_mmc_request_dma(_host, pdata); - dev_pm_domain_start(&pdev->dev); pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 50);