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: 122468 Delivered-To: patches@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5625345qgn; Wed, 20 Dec 2017 06:09:29 -0800 (PST) X-Received: by 10.25.59.216 with SMTP id d85mr4074343lfl.36.1513778969842; Wed, 20 Dec 2017 06:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513778969; cv=none; d=google.com; s=arc-20160816; b=vhuSQb5kOXLJW9Xnibp15N863nvu9PT1Nexweufnfj2PV8UfsYazPx/IZtvzAfee3q mG3+vz4JJ/Zis+qAgU4vYmtzXM7m0KeFh56I74wo04lwNz8C19wjtdWjvJjMnrtsAP4g Yz7dhRVNT5QXXUwZY4KFeVKJs2PFxwWbu5mx58VRvHL+UlwleU80xK7hMS37OChhw3Mi g8B7VhUxagAnmRRMaVgkAJ3bgyFLAd0paYaHtpv3/oVjbcucAfkh8E8B9kXnZt6M46S0 NCaQ6Ptk6AgAS+Hyzj6K5d3IQ1OgDdC1ymFBXTFCWEMKvkvbhjUrsORk6Es80CBgXrFC kB+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=G5GSKAuWEjD6UWbPCHeqDqG8NLTEBWOe9Bvlb2CO3yU=; b=Tr4dJY1+wOELrTsOvVYyu5F8DciVO6OVjTWZlJ/CswM3JDiFbmvY0F0gsXUJZfTiZ8 JX9cSl/3Fowu9VzJbUgjlpoVU0LGLy4ExHb7Z2I2qaVsBFHRDc/fVesKXK4wpvKgrbi0 mNFxUAWvuiOZjadcNrUsMJkyBOYE8irOu1Sml4a3tkgBDvKpdP2AOR5lfw2XpB8BPjA+ EVbPLQjCQhC/UVhhzXp0HMHQZEIGOv8utq1g5RGJitNRTsjDTNWhiGzNvKX6w4nNk/uz hyx9KoQKxvpoKv2uwsDYAkVBO4ZhFqHNnQYkcqL80UT2DYAkvZsaaSWfamCI6wWifAEa pqfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gMvQZr2w; 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 r75sor23190lff.5.2017.12.20.06.09.29 for (Google Transport Security); Wed, 20 Dec 2017 06:09:29 -0800 (PST) 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=gMvQZr2w; 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: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=KF9drturFqAVOm32pXLGTw5TfjQED3WTHA+kBTy/8R15bdsi33XBlUsm4gn3oxQL2z tbI4GbsBAbHXHCiNFJ+jRlERKQZ/APPYNpVdYopN8xcKnkethGlpJXNgGQBXnBiSbMuX 2OC8DpEL89ZwXWcHD9yPSk+DQZPf3Hm2gvagVSjy/7pfm0zuwhN015s92RMLdvyW3QVX MFlvxmDHZr/i3l7q9pXFiq2Y0T33+aehmLbH2WjVrZOOsc4otUoR8RNb6j3ZB4u8qLvE RLqSmLvlv9Ai2BhFKMHRTfROmK8SlMHt6/qKrpl6fBo6m17AsggBJBp6jf9q/IEOqbbX 3rDw== X-Gm-Message-State: AKGB3mK4EO95JcpOqvlw/NlYQ5JMJwzSItm3t7iiaONg4rUi65IvrEw6 xkuSoZ5G1mwccKb/JlB2dapp6k/b 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) Return-Path: 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> 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(-) -- 2.7.4 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; }; /**