From patchwork Fri May 15 14:04: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: 186828 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp468237ilb; Fri, 15 May 2020 07:04:55 -0700 (PDT) X-Received: by 2002:a2e:b0c8:: with SMTP id g8mr125947ljl.270.1589551495318; Fri, 15 May 2020 07:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589551495; cv=none; d=google.com; s=arc-20160816; b=dDax8r7K54/qyDlwOFu2QPjj/BJfbm50WPHd+a0ytQwQokg+rjlmD9YUUQT8KvRsL5 lPV8YX1nkimCvhfm3ZWFjC9uOke0Qfh7gJYgsMlFIVHtm3aIw87bdJzaurGmfVpu2SK8 1JYN7uQlLVpZIq5zCjz7UVNSbjipMleLkkfZLFRS/PbJWLgojtUmB+tqxrziLE5SDDaT hWYIWmyGeG2YOijW3c110M77OkoV9DmhUl7IS3XfTVsRj1qeai3HelldPfmXHq5S/ezZ 7tt5KxWkTCYpM0YK3Hb+/1GHlmyOuPReaqBWuFNWbneL9vydFgMvhma8yo/eGp0r/JhU mZKg== 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=KqMvS6Pwv6qwK7ezeFo5bAq4FbNQAaDLk8gZGW9T6as=; b=nnerew6IVfSMdMbj1VuuI+joZSfjydHggtcSbpCDOeYU218SVk6tpJKUYtrWTApDK0 QQX74Y6Y2tLgwIADnY44h145T6d+uHrNhU+C7gh7AjQBkFkStyngffRHlGbpQiPitLbl 53j9sxpoPyvB8mk+mh2afH6Xm8/sUc4mhSiNQIrQuR/vR2Prip/Nci2nmXx1SJu2nTSe XGSfAe1dcsAIPh8+fFVt8c1go4ozC233R5NM+/FbFI4+ugxR2plpzOmvwGX/rKNSX2fO egcg/qfBpVTc2TNvrsknn23fIgcOE28hidX5RPdbzXMV8gG/JB+YDksRfPjvaIwMqpEZ GlGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aX8u4ajF; 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 t204sor886165lff.7.2020.05.15.07.04.55 for (Google Transport Security); Fri, 15 May 2020 07:04:55 -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=aX8u4ajF; 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=KqMvS6Pwv6qwK7ezeFo5bAq4FbNQAaDLk8gZGW9T6as=; b=aX8u4ajFiW391041HpRcD7gqgJfPAZ/hJVoyWEEUaZsOnxW/NcXwN+EP9hbJck9lLH WDjTLqSnvRdOScIHXz0y+IBj5FybBPu1wchgIGEn/3IEiKao7HzyrKmf/G4hVoi7NNWb IPeRDmM186Y88s49kG7u0h8mS9W6ca3w4wRNbFKAwUz3ZFb7y9BzuueL9PWOj+XGazv0 tOFcmxK4RueEOop4uFOwyOLHJPLzMKedGWodstvusmZwisrbLg5M/5rtpcy5EnacqsZk CU3TCrmqzDVd6bQzneNAvp/KVozlKkU20ehMcnqfYKerAr/tPgdLCo+d5bojHWfP6EYt kwzA== 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=KqMvS6Pwv6qwK7ezeFo5bAq4FbNQAaDLk8gZGW9T6as=; b=SI03vrSN/rtCDXDLICIS6ZVUqJcn/8Vza6dwyG2sK5pDE6uWxEPDkmqapyojDPeWjW 0p7DyST1h2O/vw6Mvh+vxxOjR/xpbWiVLmfmuN3Vc671V5BXBzMEdCVp8b9UVXpAQvzQ uG/ihlvIuO6DG69oWCjDFHcFPoltPntDzSZt2E05TfBxmJX+T8dO0Ma7YqbDQEu0hz13 Kd4l7PePXam1crev+m3mH5GX50uZbb0AwpWlvg1E/LihzYMGoaej9J+y/gdCIrfifIWl 3ByCRaTVbyZrr9b0FRNDfzf7B8gvGRqUrdnD1Gs1Y1D3WERQlajx+w3M81zdD1ObK1go lHoA== X-Gm-Message-State: AOAM530TZtAMWTejlRvdMlH4L0DNRxMp3ZEhnjz399AoRHaab7qgOLHO LJGT/FYXWaoKRqk2bcgFQvR6//x+ X-Google-Smtp-Source: ABdhPJwD6NGbv8QK0RiAWkvYC0Di8KBIOeOG9AwX2UOFScSP2rYJA8jKEFuP52XOClUvMPOa2FvGJw== X-Received: by 2002:a19:505b:: with SMTP id z27mr2401339lfj.123.1589551494656; Fri, 15 May 2020 07:04:54 -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 q17sm1281448lfa.28.2020.05.15.07.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:04:53 -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/2] mmc: tmio: Further fixup runtime PM management at remove Date: Fri, 15 May 2020 16:04:45 +0200 Message-Id: <20200515140445.15218-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. Reported-by: Geert Uytterhoeven Signed-off-by: Ulf Hansson --- drivers/mmc/host/tmio_mmc_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.1 Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang 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 Fri May 15 14:04:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 186829 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp468411ilb; Fri, 15 May 2020 07:05:04 -0700 (PDT) X-Received: by 2002:ac2:5602:: with SMTP id v2mr2563653lfd.52.1589551503960; Fri, 15 May 2020 07:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589551503; cv=none; d=google.com; s=arc-20160816; b=moXnuySbx56cJdQz9Kmk14hc4fglSlougDZu5DOpTRI2jFfr/3L1p+uWN2Qc/UV+GX dOOoZ2i36NfhI24xpDz4YnZCVUPfpfsAhv3at84sPgnQ51ius1tZka7HvJRU3Uw4HbmB fmv8H+KaJ278Q/qQkAGFTPYC4qS5e7+VmHiOJc+1allIcjNWpPT7Q3Hq69ZhMAG2UIYj pFJjboCsSBQyOhkZ31sMa2nUp41U6FZUQoLcMmMfGGA5Z8Kzgqh/k/YaKoziDXk7Jzng 0H+a1OhLNrGNJLJON35mXUo49zld0ulYndoUNaD7B/xqDBb02sYSk+AGd1VqP+NDdrH5 2kBA== 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=3GzyY6WF9cs2u61XpsJ0RBx3TP+MAWkbmz9R2Rpnmb4=; b=YHgl71DZeyx7IuJgkBqyuSYDxSGHcU5QHtZEwFokX6ciByZKoLpwaGzPnYcLeHlnv8 Je8T/Uc9pOEgbBvULY0e3EemjiRZuXKXC//0iPMV0Mdom5y3/BXPJTNZNYV65Snv+CVI wwXxwB0lN7eHGfYWMxjrewi+0knFrSOGV67yPbWXy95OaCYjfsrjJUQtMx4Xi9Ul9IvY kCoM3T+pQYjDwnF8zWj0qs/j4rvOV/Xn9B1Edl96ErLNGhTbJhFemuHp9PM/1v1D6Cvy OC8H/E7YsCOdLcJvZ8WNQ7C7O4BqojvZoy1GH7TMHlj51lXgmzlqbeC4G4kSbeYN1bRi Es9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUbSTSGb; 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 u11sor885573lff.3.2020.05.15.07.05.03 for (Google Transport Security); Fri, 15 May 2020 07:05:03 -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=IUbSTSGb; 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=3GzyY6WF9cs2u61XpsJ0RBx3TP+MAWkbmz9R2Rpnmb4=; b=IUbSTSGbU5dgDcc68w5rzBkq2MbwX4kc+b4wKOLvVfOmlusCGZupExcjkmQjTs08VH sRAYify3Q1e1HPrYGgwTb+rhpwrOxNthoebR9id41DXMuOR6luKAeVeXTxzozlCtklJ2 TFH1Mxt4Roe+x43VJ1NjeSfrFkd99A3KEG6RrhVRWSQ/OO+xavR8eos5c5B/uzsFc5nJ ZAvbEN0EMS/vFRC5U78OE7//vC13/aYQhluBl7dhmxTeoYR4FJoTmsPgaPQdkra/FK6p IR+VLGBOm87vBLzTbSBagYN2QxkU2Xay/oofi73dlX1BcOsm0KcU7S+W2zzEfyLOps90 lg1Q== 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=3GzyY6WF9cs2u61XpsJ0RBx3TP+MAWkbmz9R2Rpnmb4=; b=j1PyR3u2YpSjeVp4K/cQw5VfwGKm/EOwlT+2+QhH5qQLUoGT5AHPl1s5K4mQdxWyPm YVRQsP/31T3dQN9ICYnqXHQN0OeK5ol3RTxLL6rasmAnR43q8flADMpkcs3ycB0XiJWH qj/oWoXAwcDlPvlY169dVX5w7ctU2ZaFdDA8uX1uhjxFzZiefhT9drLasIuPiaKTv2Sv uxocn5qtnOz6kDFTPSoElZhJJ/l9LGGQ6GBOqZXdPNjVMNeCedlssNf54s6uxcESjUkG 9zNS/CCQA+rIdSat1ezyRq+47mT8Fz/Zu+N+DcAd1hbGsg9XEPxpBnACc1s3gsNC9EC1 ubmg== X-Gm-Message-State: AOAM531cxBeqsXLj5S8PPqIHtidScfFl0LPWWZUxnpij81bze7Ili6OB 3fpzOGuo5k7E5nSFgtdp4AXp4X0p X-Google-Smtp-Source: ABdhPJxYajFmUZMHGZ0pkAdK7BrEi0qf+HcyWTIQjBXReYt07Yt9Nq0E0mP1Z1Rj+z0rel7UpT7u0g== X-Received: by 2002:a19:b8d:: with SMTP id 135mr2517398lfl.145.1589551503534; Fri, 15 May 2020 07:05:03 -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 s27sm1220215ljo.80.2020.05.15.07.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:05:02 -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 2/2] mmc: tmio: Make sure the PM domain is 'started' while probing Date: Fri, 15 May 2020 16:04:59 +0200 Message-Id: <20200515140459.15273-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(). This is very likely to be too late for some cases, as registers may be read and written way before that. To fix this behaviour, let's drop the call to dev_pm_domain_start() from tmio_mmc_host_probe() - and let the tmio clients manage this instead. Signed-off-by: Ulf Hansson --- drivers/mmc/host/renesas_sdhi_core.c | 3 +++ drivers/mmc/host/tmio_mmc.c | 3 +++ drivers/mmc/host/tmio_mmc_core.c | 2 -- drivers/mmc/host/uniphier-sd.c | 3 +++ 4 files changed, 9 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..5d44240d57ec 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 @@ -909,6 +910,8 @@ int renesas_sdhi_probe(struct platform_device *pdev, if (ret) goto efree; + dev_pm_domain_start(&pdev->dev); + ver = sd_ctrl_read16(host, CTL_VERSION); /* GEN2_SDR104 is first known SDHI to use 32bit block count */ if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX) diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index 93e83ad25976..b8f5687e10be 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "tmio_mmc.h" @@ -172,6 +173,8 @@ static int tmio_mmc_probe(struct platform_device *pdev) host->mmc->f_max = pdata->hclk; host->mmc->f_min = pdata->hclk / 512; + dev_pm_domain_start(&pdev->dev); + ret = tmio_mmc_host_probe(host); if (ret) goto host_free; 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); diff --git a/drivers/mmc/host/uniphier-sd.c b/drivers/mmc/host/uniphier-sd.c index f82baf99fd69..0c41dc1cc96c 100644 --- a/drivers/mmc/host/uniphier-sd.c +++ b/drivers/mmc/host/uniphier-sd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "tmio_mmc.h" @@ -624,6 +625,8 @@ static int uniphier_sd_probe(struct platform_device *pdev) if (ret) goto free_host; + dev_pm_domain_start(dev); + uniphier_sd_host_init(host); tmio_data->ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34;