phy: fsl-imx8-mipi-dphy: Hook into runtime pm
Subsystems (2)
v5 cover phy: fsl-imx8-mipi-dphy: Hook into runtime pm
This allows us to shut down the mipi power domain on the imx8. The alternative would be to drop the dphy from the mipi power domain in the SOCs device tree and only have the DSI host controller visible there but since the PD is mostly about the PHY that would defeat it's purpose.
This allows to shut off the power domain when blanking the LCD panel:
pm_genpd_summary before:
domain status slaves
/device runtime status
----------------------------------------------------------------------
mipi on
/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy unsupported
/devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspendedafter:
mipi off-0
/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy suspended
/devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspendedChanges from v1:
- Tweak commit message slightly
Changes from v2:
- As per review comment by Lucas Stach
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Check for pm_runtime_get_sync failure
Changes from v3:
- As per review comment by Liu Ying
https://lore.kernel.org/linux-arm-kernel/[email protected]/
https://lore.kernel.org/linux-arm-kernel/[email protected]/
- Use phy layers runtime pm
- simplify mixel_dphy_remove
Chanes from v4:
- As per review comment by Liu Ying
https://lore.kernel.org/linux-arm-kernel/[email protected]/
- Disable after probe errors
- core: increment device usage count on .configure as well
Guido Günther (2):
phy: core: Use runtime pm during configure too
phy: fsl-imx8-mipi-dphy: Hook into runtime pm
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 13 +++++++++++++ drivers/phy/phy-core.c | 6 ++++++ 2 files changed, 19 insertions(+)
Signature · 1 line
2.30.1
PATCH v5 1/2 phy: core: Use runtime pm during configure too
The phy's configure phase usually needs register access so taking the device out of pm_runtime suspend looks useful.
There's currently two in tree drivers using runtime pm and .configure (qualcomm/phy-qcom-qmp.c, rockchip/phy-rockchip-inno-dsidphy.c) but both don't use the phy layers 'transparent' runtime phy_pm_runtime handling but manage it manually so this will for now only affect the phy-fsl-imx8-mipi-dphy driver.
--- drivers/phy/phy-core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/phy/phy-core.c +6 -0
@@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union phy_configure_opts *opts)if (!phy->ops->configure)return -EOPNOTSUPP ; + ret =phy_pm_runtime_get_sync (phy); +if (ret <0 && ret != -ENOTSUPP ) +return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ +mutex_lock (&phy->mutex); ret = phy->ops->configure (phy, opts);mutex_unlock (&phy->mutex); +phy_pm_runtime_put (phy);return ret; }EXPORT_SYMBOL_GPL (phy_configure);
Signature · 1 line
2.30.1
Re: [PATCH v5 1/2] phy: core: Use runtime pm during configure too
Hi Guido,
Quoted 8 lines · Guido Günther
The phy's configure phase usually needs register access so taking the device out of
pm_runtimesuspend looks useful.There's currently two in tree drivers using runtime pm and .configure (
qualcomm/phy-qcom-qmp.c,rockchip/phy-rockchip-inno-dsidphy.c) but both don't use the phy layers 'transparent' runtimephy_pm_runtimehandling but manage it manually so this will for now only affect the phy-fsl-imx8-mipi-dphy driver.
IIUC, the qualcomm one's runtime PM is managed by the phy core when users enable it using power/control in sysfs(see comment just before pm_runtime_forbid() in that driver).
I'm assuming it's affected and it would be good to test it.
I'm not pretty sure if the rockchip one is affected or not, because I'm assuming the power/control nodes of phy->dev and phy->parent.dev in sysfs are both 'auto' after the driver probes.
Quoted 11 lines
Signed-off-by Guido Günther <[email protected]>--- drivers/phy/phy-core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/phy/phy-core.c +0
-0
drivers/phy/phy-core.c int phy_configure(struct phy *phy, union phy_configure_opts *opts) · line 476
Quoted 7 lines
drivers/phy/phy-core.c +4
-0@@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union phy_configure_opts *opts)if (!phy->ops->configure)return -EOPNOTSUPP ; + ret =phy_pm_runtime_get_sync (phy); +if (ret <0 && ret != -ENOTSUPP ) +return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */
This override is not needed, because 'ret' will be the return value of phy->ops->configure() right below.
Regards,
Liu Ying
Quoted 9 lines
drivers/phy/phy-core.c +2
-0+mutex_lock (&phy->mutex); ret = phy->ops->configure (phy, opts);mutex_unlock (&phy->mutex); +phy_pm_runtime_put (phy);return ret; }EXPORT_SYMBOL_GPL (phy_configure);
Re: [PATCH v5 1/2] phy: core: Use runtime pm during configure too
Hi,
Quoted 12 lines · Liu Ying
Hi Guido,
Quoted 8 lines · Guido Günther
The phy's configure phase usually needs register access so taking the device out of
pm_runtimesuspend looks useful.There's currently two in tree drivers using runtime pm and .configure (
qualcomm/phy-qcom-qmp.c,rockchip/phy-rockchip-inno-dsidphy.c) but both don't use the phy layers 'transparent' runtimephy_pm_runtimehandling but manage it manually so this will for now only affect the phy-fsl-imx8-mipi-dphy driver.
Quoted 4 lines
IIUC, the qualcomm one's runtime PM is managed by the phy core when users enable it using power/control in
sysfs(see comment just before pm_runtime_forbid() in that driver).
I'm assuming it's affected and it would be good to test it.
Ah, right. I'll reword the commit message but i don't have any means to test it.
Quoted 3 lines
I'm not pretty sure if the rockchip one is affected or not, because I'm assuming the power/control nodes of
phy->devandphy->parent.devin sysfs are both 'auto' after the driver probes.
Testing if adding runtime pm for .configure to phy_core breaks anything here would be great too.
I've added Dmitry and Heiko to cc: since they were active in those drivers lately and i sure don't want to break these.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Guido Günther <[email protected]>--- drivers/phy/phy-core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/phy/phy-core.c +0
-0@@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union phy_configure_opts *opts)if (!phy->ops->configure)return -EOPNOTSUPP ;
Quoted 7 lines
drivers/phy/phy-core.c int phy_configure(struct phy *phy, union phy_configure_opts *opts) · line 476
Quoted 4 lines
drivers/phy/phy-core.c +4
-0+ ret =phy_pm_runtime_get_sync (phy); +if (ret <0 && ret != -ENOTSUPP ) +return ret; + ret =0 ;/* Override possible ret == -ENOTSUPP */ This override is not needed, because 'ret' will be the return value of
phy->ops->configure()right below.
I thought being explicit is better here but i'll drop that for the next rev.
Thanks!
-- Guido
Quoted 9 lines
Regards,
Liu YingQuoted 5 lines
drivers/phy/phy-core.c +1
-0+mutex_lock (&phy->mutex); ret = phy->ops->configure (phy, opts);mutex_unlock (&phy->mutex);
Quoted 5 lines
drivers/phy/phy-core.c int phy_configure(struct phy *phy, union phy_configure_opts *opts) · line 485
Quoted 4 lines
drivers/phy/phy-core.c +1
-0+phy_pm_runtime_put (phy);return ret; }EXPORT_SYMBOL_GPL (phy_configure);
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 2/2 phy: fsl-imx8-mipi-dphy: Hook into runtime pm
In reply to Guido GüntherThis allows us to shut down the mipi power domain on the imx8. The alternative would be to drop the dphy from the mipi power domain in the SOCs device tree and only have the DSI host controller visible there but since the PD is mostly about the PHY that would defeat it's purpose.
This allows to shut off the power domain when blanking the LCD panel:
pm_genpd_summary before:
domain status slaves
/device runtime status
----------------------------------------------------------------------
mipi on
/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy unsupported
/devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspendedafter:
mipi off-0
/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy suspended
/devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspended--- drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +13 -0
@@ -14,6 +14,7 @@#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/regmap.h> /* DPHY registers */
@@ -469,20 +470,32 @@ static int mixel_dphy_probe(struct platform_device *pdev)dev_set_drvdata (dev, priv); +pm_runtime_enable (dev); + phy =devm_phy_create (dev, np, &mixel_dphy_phy_ops);if (IS_ERR (phy)) { +pm_runtime_disable (&pdev->dev);dev_err (dev,"Failed to create phy %ld\n" ,PTR_ERR (phy));return PTR_ERR (phy); }phy_set_drvdata (phy, priv); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) +pm_runtime_disable (&pdev->dev);return PTR_ERR_OR_ZERO (phy_provider); } +static int mixel_dphy_remove (struct platform_device *pdev) +{ +pm_runtime_disable (&pdev->dev); +return 0 ; +} +static struct platform_driver mixel_dphy_driver = { .probe = mixel_dphy_probe, + .remove = mixel_dphy_remove, .driver = { .name ="mixel-mipi-dphy" , .of_match_table = mixel_dphy_of_match,
Signature · 1 line
2.30.1
Hi Guido,
Quoted 40 lines · Guido Günther
This allows us to shut down the mipi power domain on the imx8. The alternative would be to drop the dphy from the mipi power domain in the SOCs device tree and only have the DSI host controller visible there but since the PD is mostly about the PHY that would defeat it's purpose.
This allows to shut off the power domain when blanking the LCD panel:
pm_genpd_summarybefore:domain status slaves
/device runtime status
----------------------------------------------------------------------
mipi on/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy unsupported /devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspendedafter:
mipi off-0
/devices/platform/soc@0/soc@0:bus@30800000/30a00300.dphy suspended /devices/platform/soc@0/soc@0:bus@30800000/30a00000.mipi_dsi suspendedSigned-off-by Guido Günther <[email protected]>--- drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +1
-0@@ -14,6 +14,7 @@#include <linux/of_platform.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/regmap.h> /* DPHY registers */
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c static int mixel_dphy_probe(struct platform_device *pdev) · line 477
Quoted 8 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +3
-0@@ -469,20 +470,32 @@ static int mixel_dphy_probe(struct platform_device *pdev)dev_set_drvdata (dev, priv); +pm_runtime_enable (dev); + phy =devm_phy_create (dev, np, &mixel_dphy_phy_ops);if (IS_ERR (phy)) { +pm_runtime_disable (&pdev->dev);
It's fine to just use 'dev'.
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c static int mixel_dphy_probe(struct platform_device *pdev) · line 485
Quoted 8 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +2
-0dev_err (dev,"Failed to create phy %ld\n" ,PTR_ERR (phy));return PTR_ERR (phy); }phy_set_drvdata (phy, priv); phy_provider =devm_of_phy_provider_register (dev, of_phy_simple_xlate); +if (IS_ERR (phy_provider)) +pm_runtime_disable (&pdev->dev);
Ditto.
With the above two addressed:
Quoted 6 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +2
-0return PTR_ERR_OR_ZERO (phy_provider); } +static int mixel_dphy_remove (struct platform_device *pdev) +{
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c static int mixel_dphy_probe(struct platform_device *pdev) · line 501
Quoted 10 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c +5
-0+pm_runtime_disable (&pdev->dev); +return 0 ; +} +static struct platform_driver mixel_dphy_driver = { .probe = mixel_dphy_probe, + .remove = mixel_dphy_remove, .driver = { .name ="mixel-mipi-dphy" , .of_match_table = mixel_dphy_of_match,
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel