From patchwork Wed Dec 20 14:09:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10125761 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8838960388 for ; Wed, 20 Dec 2017 14:09:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4EB2922F for ; Wed, 20 Dec 2017 14:09:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F7EE29708; Wed, 20 Dec 2017 14:09:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0469E2922F for ; Wed, 20 Dec 2017 14:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755433AbdLTOJg (ORCPT ); Wed, 20 Dec 2017 09:09:36 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:39176 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755393AbdLTOJb (ORCPT ); Wed, 20 Dec 2017 09:09:31 -0500 Received: by mail-lf0-f68.google.com with SMTP id m20so11075587lfi.6 for ; Wed, 20 Dec 2017 06:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G5GSKAuWEjD6UWbPCHeqDqG8NLTEBWOe9Bvlb2CO3yU=; b=gMvQZr2wNAalS4XTBKWMZLSSuXYZ5elA0ARsIns1xQl7FNzDpQCb3fs7sgz6I5p+c6 nvFTarMmBnQWYXxJ6UpVn0ssecx7HwLNxZIcDzIx7DDMd0LCqVxfXNfM55DCAd8k+mJ8 ECNZTWHrH0RBA0KADiS305XfQdQYfclZKKkQU= 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:in-reply-to :references; bh=G5GSKAuWEjD6UWbPCHeqDqG8NLTEBWOe9Bvlb2CO3yU=; b=Wcu1bBVRUu97N6hBT3SMKQW2h3HoDJ2zjlok1ehPYq6VxycYSryrXixIRAzyjMEG69 zGRrH+AmSqDS8HmzW8BEFMR8Uwwtpn/ivyHRgQgN0LdHi9pGAptSKhZeuUhLFIyTbOw4 Xy3wVnWRgdFMWfgelYqC3P2IRW8N702rSocytbeosIZW+Hn5okd+IqTAk0dya3dmhws9 TtwPfhH4sKxZS4376thW1reHs7D81mVB/thLZl+VkM5cb/LGYeZtGdI8KgjR4EOMXeQA 2S1DBvs2h72ABu4nifKvBaVNQWKBnR3635MlbS1YrHP5jpHcSf6pGwf9fMpSU4GZXtug grhA== X-Gm-Message-State: AKGB3mJ/L9rbZFV/B/Z8w9ipABJythhm5KbnSYtuXQCxAVk6cNWXAFz9 JOokGhHVZyFuSBoLTimCpS1x/g== X-Google-Smtp-Source: ACJfBos4srABYkNjHpFj382Nm77W4HN3N4BEYzLXhTPObpSKh63ZiCooJB+uh37HBEO9EnNBLmeMjA== X-Received: by 10.25.25.79 with SMTP id 76mr4210927lfz.93.1513778969434; Wed, 20 Dec 2017 06:09:29 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id f10sm3869505lff.56.2017.12.20.06.09.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Dec 2017 06:09:28 -0800 (PST) From: Ulf Hansson To: Kishon Vijay Abraham I , linux-kernel@vger.kernel.org Cc: "Rafael J . Wysocki" , linux-pm@vger.kernel.org, Yoshihiro Shimoda , Geert Uytterhoeven , linux-renesas-soc@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 1/3] phy: core: Move runtime PM reference counting to the parent device Date: Wed, 20 Dec 2017 15:09:18 +0100 Message-Id: <1513778960-10073-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513778960-10073-1-git-send-email-ulf.hansson@linaro.org> References: <1513778960-10073-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The runtime PM deployment in the phy core is deployed using the phy core device, which is created by the phy core and assigned as a child device of the phy provider device. The behaviour around the runtime PM deployment cause some issues during system suspend, in cases when the phy provider device is put into a low power state via a call to the pm_runtime_force_suspend() helper, as is the case for a Renesas SoC, which has its phy provider device attached to the generic PM domain. In more detail, the problem in this case is that pm_runtime_force_suspend() expects the child device of the provider device, which is the phy core device, to be runtime suspended, else a WARN splat will be printed (correctly) when runtime PM gets re-enabled at system resume. In the current scenario, even if a call to phy_power_off() triggers it to invoke pm_runtime_put() during system suspend, the phy core device doesn't get runtime suspended, because this is prevented in the system suspend phases by the PM core. To solve this problem, let's move the runtime PM deployment from the phy core device to the phy provider device, as this provides the similar behaviour. Changing this makes it redundant to enable runtime PM for the phy core device, so let's avoid doing that. Signed-off-by: Ulf Hansson --- drivers/phy/phy-core.c | 33 +++++++++++++++------------------ include/linux/phy/phy.h | 1 + 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index b4964b0..09588ec 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -153,12 +153,12 @@ int phy_pm_runtime_get(struct phy *phy) { int ret; - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return -ENOTSUPP; - ret = pm_runtime_get(&phy->dev); + ret = pm_runtime_get(phy->dev.parent); if (ret < 0 && ret != -EINPROGRESS) - pm_runtime_put_noidle(&phy->dev); + pm_runtime_put_noidle(phy->dev.parent); return ret; } @@ -168,12 +168,12 @@ int phy_pm_runtime_get_sync(struct phy *phy) { int ret; - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return -ENOTSUPP; - ret = pm_runtime_get_sync(&phy->dev); + ret = pm_runtime_get_sync(phy->dev.parent); if (ret < 0) - pm_runtime_put_sync(&phy->dev); + pm_runtime_put_sync(phy->dev.parent); return ret; } @@ -181,37 +181,37 @@ EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync); int phy_pm_runtime_put(struct phy *phy) { - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return -ENOTSUPP; - return pm_runtime_put(&phy->dev); + return pm_runtime_put(phy->dev.parent); } EXPORT_SYMBOL_GPL(phy_pm_runtime_put); int phy_pm_runtime_put_sync(struct phy *phy) { - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return -ENOTSUPP; - return pm_runtime_put_sync(&phy->dev); + return pm_runtime_put_sync(phy->dev.parent); } EXPORT_SYMBOL_GPL(phy_pm_runtime_put_sync); void phy_pm_runtime_allow(struct phy *phy) { - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return; - pm_runtime_allow(&phy->dev); + pm_runtime_allow(phy->dev.parent); } EXPORT_SYMBOL_GPL(phy_pm_runtime_allow); void phy_pm_runtime_forbid(struct phy *phy) { - if (!pm_runtime_enabled(&phy->dev)) + if (!phy->use_runtime_pm) return; - pm_runtime_forbid(&phy->dev); + pm_runtime_forbid(phy->dev.parent); } EXPORT_SYMBOL_GPL(phy_pm_runtime_forbid); @@ -774,10 +774,7 @@ struct phy *phy_create(struct device *dev, struct device_node *node, if (ret) goto put_dev; - if (pm_runtime_enabled(dev)) { - pm_runtime_enable(&phy->dev); - pm_runtime_no_callbacks(&phy->dev); - } + phy->use_runtime_pm = pm_runtime_enabled(dev); return phy; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 4f8423a..b4298a1 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -83,6 +83,7 @@ struct phy { int power_count; struct phy_attrs attrs; struct regulator *pwr; + bool use_runtime_pm; }; /**